* Initial automatic cleanup with rubocop * Fix syntax error introduced by rubocop * Cleanup seeds file * Cleanup lib folder * Exclude bin folder because it contains auto generated files * Make Rubocop a little bit more chatty * Block length should not include comments in the count * Cleanup config folder * Cleanup specs * Updated Rubocop version and generated a todo file * Fix broken ArticlesApi spec * Fix tests * Restored rubocop pre-commit hook
29 lines
1.3 KiB
Ruby
29 lines
1.3 KiB
Ruby
require "rails_helper"
|
|
|
|
RSpec.describe "AdditionalContentBoxes", type: :request do
|
|
let(:tag) { create(:tag) }
|
|
let(:user) { create(:user) }
|
|
let(:regular_article) { create(:article, user: user, tags: [tag.name]) }
|
|
|
|
describe "GET /additional_content_boxes" do
|
|
it "returns an article if there is a published/featured one" do
|
|
suggestion = create(:article, published: true, featured: true)
|
|
get "/additional_content_boxes?article_id=#{regular_article.id}"
|
|
expect(response.body).to include CGI.escapeHTML(suggestion.title)
|
|
end
|
|
|
|
it "returns no article if not published/featured" do
|
|
suggestion = create(:article)
|
|
get "/additional_content_boxes?article_id=#{regular_article.id}"
|
|
expect(response.body).not_to include CGI.escapeHTML(suggestion.title)
|
|
end
|
|
|
|
it "returns boosted article if available" do
|
|
organization = create(:organization)
|
|
create(:article, published: true, featured: true)
|
|
boosted_sugg = create(:article, tags: [tag.name], featured: true, boosted_additional_articles: true, organization_id: organization.id) # rubocop:disable Metrics/LineLength
|
|
get "/additional_content_boxes?article_id=#{regular_article.id}"
|
|
expect(response.body).to include CGI.escapeHTML(boosted_sugg.title)
|
|
end
|
|
end
|
|
end
|