adds setting allow_images to specs

This commit is contained in:
decabeza
2017-12-06 20:59:34 +01:00
parent cbaf1ae6c1
commit 1d6877b797
3 changed files with 26 additions and 2 deletions

View File

@@ -9,6 +9,14 @@ feature 'Budget Investments' do
let(:group) { create(:budget_group, name: "Health", budget: budget) } let(:group) { create(:budget_group, name: "Health", budget: budget) }
let!(:heading) { create(:budget_heading, name: "More hospitals", group: group) } let!(:heading) { create(:budget_heading, name: "More hospitals", group: group) }
before do
Setting['feature.allow_images'] = true
end
after do
Setting['feature.allow_images'] = nil
end
scenario 'Index' do scenario 'Index' do
investments = [create(:budget_investment, heading: heading), investments = [create(:budget_investment, heading: heading),
create(:budget_investment, heading: heading), create(:budget_investment, heading: heading),
@@ -37,7 +45,7 @@ feature 'Budget Investments' do
visit budget_investments_path(budget, heading_id: heading.id) visit budget_investments_path(budget, heading_id: heading.id)
within("#budget_investment_#{investment.id}") do within("#budget_investment_#{investment.id}") do
expect(page).to have_css("div.no-image") expect(page).to_not have_css("div.with-image")
end end
within("#budget_investment_#{investment_with_image.id}") do within("#budget_investment_#{investment_with_image.id}") do
expect(page).to have_css("img[alt='#{investment_with_image.image.title}']") expect(page).to have_css("img[alt='#{investment_with_image.image.title}']")

View File

@@ -4,6 +4,15 @@ require 'rails_helper'
feature 'Proposals' do feature 'Proposals' do
context 'Index' do context 'Index' do
before do
Setting['feature.allow_images'] = true
end
after do
Setting['feature.allow_images'] = nil
end
scenario 'Lists featured and regular proposals' do scenario 'Lists featured and regular proposals' do
featured_proposals = create_featured_proposals featured_proposals = create_featured_proposals
proposals = [create(:proposal), create(:proposal), create(:proposal)] proposals = [create(:proposal), create(:proposal), create(:proposal)]
@@ -55,7 +64,7 @@ feature 'Proposals' do
visit proposals_path(proposal) visit proposals_path(proposal)
within("#proposal_#{proposal.id}") do within("#proposal_#{proposal.id}") do
expect(page).to have_css("div.no-image") expect(page).to_not have_css("div.with-image")
end end
within("#proposal_#{proposal_with_image.id}") do within("#proposal_#{proposal_with_image.id}") do
expect(page).to have_css("img[alt='#{proposal_with_image.image.title}']") expect(page).to have_css("img[alt='#{proposal_with_image.image.title}']")

View File

@@ -9,6 +9,9 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p
let!(:imageable) { create(imageable_factory_name) } let!(:imageable) { create(imageable_factory_name) }
before do before do
Setting['feature.allow_images'] = true
imageable_path_arguments&.each do |argument_name, path_to_value| imageable_path_arguments&.each do |argument_name, path_to_value|
arguments.merge!("#{argument_name}": imageable.send(path_to_value)) arguments.merge!("#{argument_name}": imageable.send(path_to_value))
end end
@@ -16,6 +19,10 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p
imageable.update(author: user) if imageable.respond_to?(:author) imageable.update(author: user) if imageable.respond_to?(:author)
end end
after do
Setting['feature.allow_images'] = nil
end
describe "at #{path}" do describe "at #{path}" do
scenario "Should show new image link when imageable has not an associated image defined" do scenario "Should show new image link when imageable has not an associated image defined" do