From 16fceecadbe80ab0ef846b62a12dc7bfff10b8c5 Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Mon, 7 Feb 2022 23:13:44 +0100 Subject: [PATCH] Fix setting the article password from the Admin The password field was present in the form, but not accepted by the controller. This change adds password to the list of accepted fields. --- .../app/controllers/admin/content_controller.rb | 1 + .../controllers/admin/content_controller_spec.rb | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/publify_core/app/controllers/admin/content_controller.rb b/publify_core/app/controllers/admin/content_controller.rb index 5ebd608498..b86f381f49 100644 --- a/publify_core/app/controllers/admin/content_controller.rb +++ b/publify_core/app/controllers/admin/content_controller.rb @@ -180,6 +180,7 @@ def update_params :body_and_extended, :draft, :extended, + :password, :permalink, :published_at, :text_filter_name, diff --git a/publify_core/spec/controllers/admin/content_controller_spec.rb b/publify_core/spec/controllers/admin/content_controller_spec.rb index dd56999d78..9507186d98 100644 --- a/publify_core/spec/controllers/admin/content_controller_spec.rb +++ b/publify_core/spec/controllers/admin/content_controller_spec.rb @@ -160,6 +160,12 @@ def base_article(options = {}) assert_equal 2, new_article.tags.size end + it "creates an article with a password" do + post :create, params: { "article" => base_article(password: "foobar") } + new_article = Article.last + expect(new_article.password).to eq("foobar") + end + it "creates an article with a unique Tag instance named lang:FR" do post :create, params: { "article" => base_article(keywords: "lang:FR") } new_article = Article.last @@ -392,6 +398,15 @@ def base_article(options = {}) expect(article.extended).to eq("barbaz") end + it "allows updating password" do + put :update, params: { "id" => article.id, "article" => { + "password" => "foobar", + } } + assert_response :redirect + article.reload + expect(article.password).to eq("foobar") + end + context "when a published article has drafts" do let(:original_published_at) { 2.days.ago.to_date } let!(:original) { create(:article, published_at: original_published_at) }