Skip to content

Commit

Permalink
Do not create article meta description for password-protected articles
Browse files Browse the repository at this point in the history
  • Loading branch information
mvz committed May 14, 2022
1 parent 84e67ac commit 1a78f16
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
5 changes: 4 additions & 1 deletion publify_core/app/controllers/articles_controller.rb
Expand Up @@ -166,7 +166,10 @@ def show_article
format.html do
@comment = Comment.new
@page_title = this_blog.article_title_template.to_title(@article, this_blog, params)
@description = this_blog.article_desc_template.to_title(@article, this_blog, params)
if @article.password.blank?
@description = this_blog.article_desc_template.
to_title(@article, this_blog, params)
end

@keywords = @article.tags.map(&:name).join(", ")
render "articles/#{@article.post_type}"
Expand Down
19 changes: 19 additions & 0 deletions publify_core/spec/controllers/articles_controller_spec.rb
Expand Up @@ -483,6 +483,25 @@
to raise_error ActiveRecord::RecordNotFound
end
end

context "when the article is password protected" do
render_views

let!(:blog) { create(:blog, permalink_format: "/%title%.html") }
let!(:article) do
create(:article, title: "Secretive", body: "protected foobar", password: "password")
end

it "shows a password form for the article" do
get :redirect, params: { from: "secretive.html" }
expect(response.body).to have_selector('input[id="article_password"]', count: 1)
end

it "does not include the article body anywhere" do
get :redirect, params: { from: "secretive.html" }
expect(response.body).not_to include article.body
end
end
end

describe "#check_password" do
Expand Down
12 changes: 10 additions & 2 deletions spec/controllers/articles_controller_spec.rb
Expand Up @@ -99,12 +99,20 @@
end

context "when the article is password protected" do
let(:article) { create(:article, password: "password") }
let(:article) do
create(:article, title: "Secretive", body: "protected foobar",
password: "password")
end

it "article alone should be password protected" do
it "shows a password form for the article" do
get :redirect, params: { from: from_param }
expect(response.body).to have_selector('input[id="article_password"]', count: 1)
end

it "does not include the article body anywhere" do
get :redirect, params: { from: from_param }
expect(response.body).not_to include article.body
end
end
end

Expand Down

0 comments on commit 1a78f16

Please sign in to comment.