Remove redundant setting resets in after blocks

Settings are stored in the database, and so any changes to the settings
done during the tests are automatically rolled back between one test and
the next one.

There were also a few places where we weren't using an `after` block but
changing the setting at the end of the test.
This commit is contained in:
Javi Martín
2019-06-20 01:27:50 +02:00
parent 9182c833c0
commit da121ebc53
39 changed files with 0 additions and 215 deletions

View File

@@ -7,10 +7,6 @@ describe RemotelyTranslatable do
Setting["feature.remote_translations"] = true
end
after do
Setting["feature.remote_translations"] = nil
end
describe "#detect_remote_translations" do
describe "Should detect remote_translations" do

View File

@@ -31,10 +31,6 @@ describe DebatesController do
end
describe "Vote with too many anonymous votes" do
after do
Setting["max_ratio_anon_votes_on_debates"] = 50
end
it "allows vote if user is allowed" do
Setting["max_ratio_anon_votes_on_debates"] = 100
debate = create(:debate)

View File

@@ -13,22 +13,12 @@ describe InstallationController, type: :request do
let(:seeds_feature_settings) { Setting.where("key LIKE 'feature.%'") }
before do
@current_feature_settings = seeds_feature_settings.pluck(:key, :value).to_h
seeds_feature_settings.destroy_all
test_feature_settings.each do |feature_name, feature_value|
Setting["feature.#{feature_name}"] = feature_value
end
end
after do
test_feature_settings.each_key do |feature_name|
Setting.find_by(key: "feature.#{feature_name}").destroy
end
@current_feature_settings.each do |feature_name, feature_value|
Setting[feature_name] = feature_value
end
end
specify "with query string inside query params" do
get "/consul.json"

View File

@@ -183,12 +183,6 @@ describe "Account" do
Setting["feature.user.recommendations_on_proposals"] = true
end
after do
Setting["feature.user.recommendations"] = nil
Setting["feature.user.recommendations_on_debates"] = nil
Setting["feature.user.recommendations_on_proposals"] = nil
end
scenario "are enabled by default" do
visit account_path

View File

@@ -20,10 +20,6 @@ describe "Admin budget groups" do
Setting["process.budgets"] = nil
end
after do
Setting["process.budgets"] = true
end
scenario "Disabled with a feature flag" do
expect do
visit admin_budget_groups_path(budget)

View File

@@ -21,10 +21,6 @@ describe "Admin budget headings" do
Setting["process.budgets"] = nil
end
after do
Setting["process.budgets"] = true
end
scenario "Disabled with a feature flag" do
expect do
visit admin_budget_group_headings_path(budget, group)

View File

@@ -28,10 +28,6 @@ describe "Admin budget investments" do
Setting["process.budgets"] = nil
end
after do
Setting["process.budgets"] = true
end
scenario "Disabled with a feature flag" do
expect { visit admin_budgets_path }.to raise_exception(FeatureFlags::FeatureDisabled)
end

View File

@@ -8,8 +8,6 @@ describe "Admin debates" do
login_as(admin.user)
expect { visit admin_hidden_debates_path }.to raise_exception(FeatureFlags::FeatureDisabled)
Setting["process.debates"] = true
end
before do

View File

@@ -287,7 +287,6 @@ describe "Admin collaborative legislation" do
let!(:process) { create(:legislation_process) }
before { Setting["feature.translation_interface"] = true }
after { Setting["feature.translation_interface"] = nil }
scenario "Cant manage translations on homepage form" do
visit edit_admin_legislation_process_homepage_path(process)

View File

@@ -138,10 +138,6 @@ describe "Admin settings" do
Setting["feature.remote_census"] = true
end
after do
Setting["feature.remote_census"] = nil
end
scenario "Should not be able when remote census feature deactivated" do
Setting["feature.remote_census"] = nil
admin = create(:administrator).user
@@ -178,10 +174,6 @@ describe "Admin settings" do
Setting["feature.remote_census"] = true
end
after do
Setting["feature.remote_census"] = nil
end
scenario "On #tab-remote-census-configuration", :js do
remote_census_setting = create(:setting, key: "remote_census.general.whatever")
admin = create(:administrator).user
@@ -221,10 +213,6 @@ describe "Admin settings" do
Setting["feature.map"] = true
end
after do
Setting["feature.map"] = nil
end
scenario "On #tab-map-configuration", :js do
map_setting = Setting.create(key: "map.whatever")
admin = create(:administrator).user

View File

@@ -89,12 +89,6 @@ describe "Signature sheets" do
Setting["remote_census.response.valid"] = access_user_data
end
after do
Setting["feature.remote_census"] = nil
Setting["remote_census.request.date_of_birth"] = nil
Setting["remote_census.request.postal_code"] = nil
end
scenario "Proposal" do
proposal = create(:proposal)
visit new_admin_signature_sheet_path

View File

@@ -17,10 +17,6 @@ describe "Budget Investments" do
Setting["feature.allow_images"] = true
end
after do
Setting["feature.allow_images"] = nil
end
context "Concerns" do
it_behaves_like "notifiable in-app", Budget::Investment
it_behaves_like "relationable", Budget::Investment
@@ -1107,8 +1103,6 @@ describe "Budget Investments" do
investment = create(:budget_investment, heading: heading)
visit budget_investment_path(budget, id: investment.id)
expect(page).to have_content "Access the community"
Setting["feature.community"] = false
end
scenario "Can not access the community" do

View File

@@ -340,8 +340,6 @@ describe "Commenting topics from proposals" do
page.find("#flag-expand-comment-#{comment.id}").click
expect(page).to have_selector("#flag-comment-#{comment.id}")
end
Setting["feature.community"] = nil
end
scenario "Erasing a comment's author" do
@@ -893,8 +891,6 @@ describe "Commenting topics from budget investments" do
page.find("#flag-expand-comment-#{comment.id}").click
expect(page).to have_selector("#flag-comment-#{comment.id}")
end
Setting["feature.community"] = nil
end
scenario "Erasing a comment's author" do

View File

@@ -6,10 +6,6 @@ describe "Communities" do
Setting["feature.community"] = true
end
after do
Setting["feature.community"] = nil
end
context "Show" do
scenario "Should display default content" do

View File

@@ -460,11 +460,6 @@ describe "Debates" do
Setting["feature.user.recommendations_on_debates"] = true
end
after do
Setting["feature.user.recommendations"] = nil
Setting["feature.user.recommendations_on_debates"] = nil
end
scenario "can't be sorted if there's no logged user" do
visit debates_path
expect(page).not_to have_selector("a", text: "recommendations")
@@ -1005,9 +1000,6 @@ describe "Debates" do
expect(page).not_to have_content "Do not display with same tag"
expect(page).not_to have_content "Do not display"
end
Setting["feature.user.recommendations"] = nil
Setting["feature.user.recommendations_on_debates"] = nil
end
scenario "After a search do not show featured debates" do

View File

@@ -32,10 +32,6 @@ describe "Home" do
login_as(user)
end
after do
Setting["feature.user.recommendations"] = nil
end
scenario "Display recommended section when feature flag recommended is active" do
debate = create(:debate, tag_list: "Sport")
visit root_path

View File

@@ -73,12 +73,6 @@ describe "DocumentVerifications" do
Setting["remote_census.response.valid"] = access_user_data
end
after do
Setting["feature.remote_census"] = nil
Setting["remote_census.request.date_of_birth"] = nil
Setting["remote_census.request.postal_code"] = nil
end
scenario "Verifying a user which does not exist and is not in the census shows an error" do
expect_any_instance_of(Verification::Management::Document).to receive(:in_census?).

View File

@@ -98,10 +98,6 @@ describe "Moderation" do
Setting["org_name"] = "OrgName"
end
after do
Setting["org_name"] = "CONSUL"
end
scenario "Contains correct elements" do
create(:moderator, user: user)
login_as(user)

View File

@@ -127,12 +127,6 @@ describe "Residence", :with_frozen_time do
visit officing_root_path
end
after do
Setting["feature.remote_census"] = nil
Setting["remote_census.request.date_of_birth"] = nil
Setting["remote_census.request.postal_code"] = nil
end
describe "Display form fields according to the remote census configuration" do
scenario "by default (without custom census) not display date_of_birth and postal_code" do

View File

@@ -381,10 +381,6 @@ describe "Proposal Notifications" do
Setting[:proposal_notification_minimum_interval_in_days] = 0
end
after do
Setting[:proposal_notification_minimum_interval_in_days] = 3
end
scenario "for the same proposal", :js do
author = create(:user)
user = create(:user)

View File

@@ -43,10 +43,6 @@ describe "Proposals" do
Setting["featured_proposals_number"] = 3
end
after do
Setting["feature.allow_images"] = nil
end
scenario "Lists featured and regular proposals" do
featured_proposals = create_featured_proposals
proposals = [create(:proposal), create(:proposal), create(:proposal)]
@@ -632,7 +628,6 @@ describe "Proposals" do
context "Special interface translation behaviour" do
before { Setting["feature.translation_interface"] = true }
after { Setting["feature.translation_interface"] = nil }
scenario "Cant manage translations" do
proposal = create(:proposal)
@@ -776,11 +771,6 @@ describe "Proposals" do
Setting["feature.user.recommendations_on_proposals"] = true
end
after do
Setting["feature.user.recommendations"] = nil
Setting["feature.user.recommendations_on_proposals"] = nil
end
scenario "can't be sorted if there's no logged user" do
visit proposals_path
expect(page).not_to have_selector("a", text: "recommendations")
@@ -1544,9 +1534,6 @@ describe "Proposals" do
expect(page).not_to have_content "Do not display with same tag"
expect(page).not_to have_content "Do not display"
end
Setting["feature.user.recommendations"] = nil
Setting["feature.user.recommendations_for_proposals"] = nil
end
scenario "After a search do not show featured proposals" do
@@ -1959,10 +1946,6 @@ describe "Successful proposals" do
Setting["feature.user.skip_verification"] = "true"
end
after do
Setting["feature.user.skip_verification"] = nil
end
scenario "Create" do
author = create(:user)
login_as(author)

View File

@@ -23,16 +23,6 @@ describe "Social media meta tags" do
Setting["org_name"] = org_name
end
after do
Setting["meta_keywords"] = nil
Setting["meta_title"] = nil
Setting["meta_description"] = nil
Setting["twitter_handle"] = nil
Setting["url"] = "http://example.com"
Setting["facebook_handle"] = nil
Setting["org_name"] = "CONSUL"
end
scenario "Social media meta tags partial render settings content" do
visit root_path

View File

@@ -117,8 +117,6 @@ describe "Welcome screen" do
4.times do |i|
expect(page).to have_css "li:nth-child(#{i + 1})"
end
Setting["feature.user.skip_verification"] = nil
end
end

View File

@@ -17,10 +17,6 @@ describe SignatureSheetsHelper do
Setting["feature.remote_census"] = true
end
after do
Setting["feature.remote_census"] = nil
end
it "returns text help when date_of_birth and postal_code are not required" do
text_help_1 = "To verify a user, your application needs: Document number"
text_help_2 = "Required fields for each user must be separated by commas and each user must be separated by semicolons."

View File

@@ -12,10 +12,6 @@ describe "Dashboards Rake" do
ActionMailer::Base.deliveries.clear
end
after do
Setting["dashboard.emails"] = nil
end
let :run_rake_task do
Rake::Task["dashboards:send_notifications"].reenable
Rake.application.invoke_task "dashboards:send_notifications"

View File

@@ -13,10 +13,6 @@ describe Dashboard::Mailer do
Setting["dashboard.emails"] = true
end
after do
Setting["dashboard.emails"] = nil
end
describe "#forward" do
let!(:proposal) { create(:proposal) }

View File

@@ -77,7 +77,6 @@ describe Debate do
let(:debate) { create(:debate) }
before { Setting["max_votes_for_debate_edit"] = 3 }
after { Setting["max_votes_for_debate_edit"] = 1000 }
it "is true if debate has no votes yet" do
expect(debate.total_votes).to eq(0)
@@ -101,7 +100,6 @@ describe Debate do
let(:debate) { create(:debate) }
before { Setting["max_votes_for_debate_edit"] = 1 }
after { Setting["max_votes_for_debate_edit"] = 1000 }
it "is true if user is the author and debate is editable" do
expect(debate.editable_by?(debate.author)).to be true

View File

@@ -54,12 +54,6 @@ describe Officing::Residence do
Setting["remote_census.response.valid"] = access_user_data
end
after do
Setting["feature.remote_census"] = nil
Setting["remote_census.request.date_of_birth"] = nil
Setting["remote_census.request.postal_code"] = nil
end
it "is valid" do
expect(custom_residence).to be_valid
end

View File

@@ -178,7 +178,6 @@ describe Proposal do
let(:proposal) { create(:proposal) }
before { Setting["max_votes_for_proposal_edit"] = 5 }
after { Setting["max_votes_for_proposal_edit"] = 1000 }
it "is true if proposal has no votes yet" do
expect(proposal.total_votes).to eq(0)
@@ -1083,10 +1082,6 @@ describe Proposal do
ActionMailer::Base.deliveries.clear
end
after do
Setting["dashboard.emails"] = nil
end
it "send notification after create when there are new actived actions" do
create(:dashboard_action, :proposed_action, :active, day_offset: 0, published_proposal: false)
create(:dashboard_action, :resource, :active, day_offset: 0, published_proposal: false)
@@ -1114,10 +1109,6 @@ describe Proposal do
ActionMailer::Base.deliveries.clear
end
after do
Setting["dashboard.emails"] = nil
end
it "send notification after published when there are new actived actions" do
create(:dashboard_action, :proposed_action, :active, day_offset: 0, published_proposal: true)
create(:dashboard_action, :resource, :active, day_offset: 0, published_proposal: true)

View File

@@ -82,10 +82,6 @@ describe SignatureSheet do
Setting["feature.remote_census"] = true
end
after do
Setting["feature.remote_census"] = nil
end
it "creates signatures for each group with document_number" do
required_fields_to_verify = "123A; 456B"
signature_sheet = create(:signature_sheet, required_fields_to_verify: required_fields_to_verify)

View File

@@ -41,12 +41,6 @@ describe Signature do
Setting["remote_census.request.postal_code"] = "some.value"
end
after do
Setting["feature.remote_census"] = nil
Setting["remote_census.request.date_of_birth"] = nil
Setting["remote_census.request.postal_code"] = nil
end
it "is valid" do
expect(signature).to be_valid
end
@@ -255,12 +249,6 @@ describe Signature do
Setting["remote_census.response.valid"] = access_user_data
end
after do
Setting["feature.remote_census"] = nil
Setting["remote_census.request.date_of_birth"] = nil
Setting["remote_census.request.postal_code"] = nil
end
it "calls assign_vote_to_user" do
signature = create(:signature, document_number: "12345678Z",
date_of_birth: "31/12/1980",

View File

@@ -43,12 +43,6 @@ describe Verification::Management::Document do
Setting["remote_census.response.valid"] = access_user_data
end
after do
Setting["feature.remote_census"] = nil
Setting["remote_census.request.date_of_birth"] = nil
Setting["remote_census.request.postal_code"] = nil
end
it "is valid" do
expect(verification_document).to be_valid
end

View File

@@ -22,10 +22,6 @@ describe "Retrieves number of supports for the successful proposal" do
sign_in(proposal.author)
end
after do
Setting["proposals.successful_proposal_id"] = @successful_proposal_id
end
it "returns the number of supports grouped by day" do
get proposal_dashboard_successful_supports_path(proposal, format: :json)

View File

@@ -71,10 +71,6 @@ shared_examples "documentable" do |documentable_factory_name, documentable_path,
Setting["feature.allow_attached_documents"] = true
end
after do
Setting["feature.allow_attached_documents"] = false
end
scenario "Documents list should be available" do
login_as(user)
visit send(documentable_path, arguments)
@@ -98,10 +94,6 @@ shared_examples "documentable" do |documentable_factory_name, documentable_path,
Setting["feature.allow_attached_documents"] = false
end
after do
Setting["feature.allow_attached_documents"] = true
end
scenario "Documents list should not be available" do
login_as(create(:user))
visit send(documentable_path, arguments)

View File

@@ -297,10 +297,6 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na
Setting["feature.allow_attached_documents"] = false
end
after do
Setting["feature.allow_attached_documents"] = true
end
scenario "Add new document button should not be available" do
login_as user_to_login
visit send(path, arguments)

View File

@@ -19,10 +19,6 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p
imageable.update(author: user) if imageable.respond_to?(:author)
end
after do
Setting["feature.allow_images"] = nil
end
describe "at #{path}" do
scenario "Should show new image link when imageable has not an associated image defined" do

View File

@@ -12,10 +12,6 @@ shared_examples "remotely_translatable" do |factory_name, path_name, path_argume
Setting["feature.remote_translations"] = true
end
after do
Setting["feature.remote_translations"] = false
end
context "Button to request remote translation" do
scenario "should not be present when current locale translation exists", :js do

View File

@@ -8,10 +8,6 @@ shared_examples "map validations" do
Setting["feature.map"] = true
end
after do
Setting["feature.map"] = nil
end
it "is valid with a map location" do
mappable.map_location = build(:map_location)
mappable.skip_map = nil

View File

@@ -187,10 +187,6 @@ shared_examples_for "verifiable" do
Setting["feature.user.skip_verification"] = "true"
end
after do
Setting["feature.user.skip_verification"] = nil
end
describe "#residence_verified?" do
it "is true if skipped" do
expect(user.residence_verified?).to eq(true)