Cleanup Settings values modified after specs are run
This commit is contained in:
@@ -22,6 +22,10 @@ describe DebatesController do
|
||||
end
|
||||
|
||||
describe "Vote with too many anonymous votes" do
|
||||
after do
|
||||
Setting['max_ratio_anon_votes_on_debates'] = 50
|
||||
end
|
||||
|
||||
it 'should allow vote if user is allowed' do
|
||||
Setting["max_ratio_anon_votes_on_debates"] = 100
|
||||
debate = create(:debate)
|
||||
|
||||
@@ -11,8 +11,15 @@ feature 'Admin budget investments' do
|
||||
|
||||
context "Feature flag" do
|
||||
|
||||
scenario 'Disabled with a feature flag' do
|
||||
background do
|
||||
Setting['feature.budgets'] = nil
|
||||
end
|
||||
|
||||
after do
|
||||
Setting['feature.budgets'] = true
|
||||
end
|
||||
|
||||
scenario 'Disabled with a feature flag' do
|
||||
expect{ visit admin_budgets_path }.to raise_exception(FeatureFlags::FeatureDisabled)
|
||||
end
|
||||
|
||||
|
||||
@@ -9,8 +9,15 @@ feature 'Admin budgets' do
|
||||
|
||||
context 'Feature flag' do
|
||||
|
||||
scenario 'Disabled with a feature flag' do
|
||||
background do
|
||||
Setting['feature.budgets'] = nil
|
||||
end
|
||||
|
||||
after do
|
||||
Setting['feature.budgets'] = true
|
||||
end
|
||||
|
||||
scenario 'Disabled with a feature flag' do
|
||||
expect{ visit admin_budgets_path }.to raise_exception(FeatureFlags::FeatureDisabled)
|
||||
end
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@ feature 'Admin debates' do
|
||||
login_as(admin.user)
|
||||
|
||||
expect{ visit admin_debates_path }.to raise_exception(FeatureFlags::FeatureDisabled)
|
||||
|
||||
Setting['feature.debates'] = true
|
||||
end
|
||||
|
||||
background do
|
||||
@@ -91,4 +93,4 @@ feature 'Admin debates' do
|
||||
expect(current_url).to include('page=2')
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,11 +3,17 @@ require 'rails_helper'
|
||||
feature 'Admin feature flags' do
|
||||
|
||||
background do
|
||||
Setting["feature.spending_proposals"] = true
|
||||
Setting['feature.spending_proposals'] = true
|
||||
Setting['feature.spending_proposal_features.voting_allowed'] = true
|
||||
login_as(create(:administrator).user)
|
||||
end
|
||||
|
||||
after do
|
||||
Setting['feature.spending_proposals'] = nil
|
||||
Setting['feature.spending_proposal_features.voting_allowed'] = nil
|
||||
end
|
||||
|
||||
|
||||
scenario 'Enabled features are listed on menu' do
|
||||
visit admin_root_path
|
||||
|
||||
@@ -65,4 +71,4 @@ feature 'Admin feature flags' do
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -9,6 +9,11 @@ feature 'Admin spending proposals' do
|
||||
login_as(admin.user)
|
||||
end
|
||||
|
||||
after do
|
||||
Setting['feature.spending_proposals'] = nil
|
||||
Setting['feature.spending_proposal_features.voting_allowed'] = nil
|
||||
end
|
||||
|
||||
context "Feature flag" do
|
||||
|
||||
scenario 'Disabled with a feature flag' do
|
||||
@@ -671,4 +676,4 @@ feature 'Admin spending proposals' do
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -74,6 +74,8 @@ feature 'Admin' do
|
||||
expect(page).to have_link('Moderation')
|
||||
expect(page).to have_link('Valuation')
|
||||
expect(page).to have_link('Management')
|
||||
|
||||
Setting['feature.spending_proposals'] = nil
|
||||
end
|
||||
|
||||
scenario 'Admin dashboard' do
|
||||
|
||||
@@ -6,6 +6,7 @@ feature 'Debates' do
|
||||
scenario 'Disabled with a feature flag' do
|
||||
Setting['feature.debates'] = nil
|
||||
expect{ visit debates_path }.to raise_exception(FeatureFlags::FeatureDisabled)
|
||||
Setting['feature.debates'] = true
|
||||
end
|
||||
|
||||
scenario 'Index' do
|
||||
|
||||
@@ -148,6 +148,8 @@ feature 'Emails' do
|
||||
expect(email).to have_body_text(spending_proposal.title)
|
||||
expect(email).to have_body_text(spending_proposal.code)
|
||||
expect(email).to have_body_text(spending_proposal.feasible_explanation)
|
||||
|
||||
Setting["feature.spending_proposals"] = nil
|
||||
end
|
||||
|
||||
context "Direct Message" do
|
||||
|
||||
@@ -3,11 +3,16 @@ require 'rails_helper'
|
||||
feature 'Spending Proposals' do
|
||||
|
||||
background do
|
||||
Setting["feature.spending_proposals"] = true
|
||||
Setting['feature.spending_proposals'] = true
|
||||
Setting['feature.spending_proposal_features.voting_allowed'] = true
|
||||
login_as_manager
|
||||
end
|
||||
|
||||
after do
|
||||
Setting['feature.spending_proposals'] = nil
|
||||
Setting['feature.spending_proposal_features.voting_allowed'] = nil
|
||||
end
|
||||
|
||||
context "Create" do
|
||||
|
||||
scenario 'Creating spending proposals on behalf of someone' do
|
||||
|
||||
@@ -8,6 +8,8 @@ feature 'Moderate debates' do
|
||||
login_as(moderator.user)
|
||||
|
||||
expect{ visit moderation_debates_path }.to raise_exception(FeatureFlags::FeatureDisabled)
|
||||
|
||||
Setting['feature.debates'] = true
|
||||
end
|
||||
|
||||
scenario 'Hide', :js do
|
||||
|
||||
@@ -78,6 +78,10 @@ feature 'Official positions' do
|
||||
@spending_proposal2 = create(:spending_proposal, author: @user2)
|
||||
end
|
||||
|
||||
after do
|
||||
Setting["feature.spending_proposals"] = nil
|
||||
end
|
||||
|
||||
scenario "Index" do
|
||||
visit spending_proposals_path
|
||||
|
||||
@@ -95,4 +99,4 @@ feature 'Official positions' do
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -536,6 +536,7 @@ feature 'Proposals' do
|
||||
expect(current_path).not_to eq(edit_proposal_path(proposal))
|
||||
expect(current_path).to eq(proposals_path)
|
||||
expect(page).to have_content 'You do not have permission'
|
||||
Setting["max_votes_for_proposal_edit"] = 1000
|
||||
end
|
||||
|
||||
scenario 'Update should be posible for the author of an editable proposal' do
|
||||
|
||||
@@ -5,10 +5,15 @@ feature 'Spending proposals' do
|
||||
let(:author) { create(:user, :level_two, username: 'Isabel') }
|
||||
|
||||
background do
|
||||
Setting["feature.spending_proposals"] = true
|
||||
Setting['feature.spending_proposals'] = true
|
||||
Setting['feature.spending_proposal_features.voting_allowed'] = true
|
||||
end
|
||||
|
||||
after do
|
||||
Setting['feature.spending_proposals'] = nil
|
||||
Setting['feature.spending_proposal_features.voting_allowed'] = nil
|
||||
end
|
||||
|
||||
scenario 'Index' do
|
||||
spending_proposals = [create(:spending_proposal), create(:spending_proposal), create(:spending_proposal, feasible: true)]
|
||||
unfeasible_spending_proposal = create(:spending_proposal, feasible: false)
|
||||
|
||||
@@ -252,6 +252,9 @@ feature 'Users' do
|
||||
Setting['feature.budgets'] = nil
|
||||
visit user_path(user)
|
||||
expect(page).to have_content('4 Comments')
|
||||
|
||||
Setting['feature.debates'] = true
|
||||
Setting['feature.budgets'] = true
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@ feature 'Valuation budget investments' do
|
||||
scenario 'Disabled with a feature flag' do
|
||||
Setting['feature.budgets'] = nil
|
||||
expect{ visit valuation_budget_budget_investments_path(create(:budget)) }.to raise_exception(FeatureFlags::FeatureDisabled)
|
||||
|
||||
Setting['feature.budgets'] = true
|
||||
end
|
||||
|
||||
scenario 'Display link to valuation section' do
|
||||
|
||||
@@ -10,6 +10,8 @@ feature 'Valuation budgets' do
|
||||
scenario 'Disabled with a feature flag' do
|
||||
Setting['feature.budgets'] = nil
|
||||
expect{ visit valuation_budgets_path }.to raise_exception(FeatureFlags::FeatureDisabled)
|
||||
|
||||
Setting['feature.budgets'] = true
|
||||
end
|
||||
|
||||
context 'Index' do
|
||||
|
||||
@@ -3,12 +3,17 @@ require 'rails_helper'
|
||||
feature 'Valuation spending proposals' do
|
||||
|
||||
background do
|
||||
Setting["feature.spending_proposals"] = true
|
||||
Setting['feature.spending_proposals'] = true
|
||||
Setting['feature.spending_proposal_features.voting_allowed'] = true
|
||||
@valuator = create(:valuator, user: create(:user, username: 'Rachel', email: 'rachel@valuators.org'))
|
||||
login_as(@valuator.user)
|
||||
end
|
||||
|
||||
after do
|
||||
Setting['feature.spending_proposals'] = nil
|
||||
Setting['feature.spending_proposal_features.voting_allowed'] = nil
|
||||
end
|
||||
|
||||
scenario 'Disabled with a feature flag' do
|
||||
Setting['feature.spending_proposals'] = nil
|
||||
expect{ visit valuation_spending_proposals_path }.to raise_exception(FeatureFlags::FeatureDisabled)
|
||||
|
||||
@@ -4,10 +4,15 @@ feature 'Valuation' do
|
||||
let(:user) { create(:user) }
|
||||
|
||||
background do
|
||||
Setting["feature.spending_proposals"] = true
|
||||
Setting['feature.spending_proposals'] = true
|
||||
Setting['feature.spending_proposal_features.voting_allowed'] = true
|
||||
end
|
||||
|
||||
after do
|
||||
Setting['feature.spending_proposals'] = nil
|
||||
Setting['feature.spending_proposal_features.voting_allowed'] = nil
|
||||
end
|
||||
|
||||
scenario 'Access as regular user is not authorized' do
|
||||
login_as(user)
|
||||
visit root_path
|
||||
|
||||
@@ -364,11 +364,16 @@ feature 'Votes' do
|
||||
|
||||
feature 'Spending Proposals' do
|
||||
background do
|
||||
Setting["feature.spending_proposals"] = true
|
||||
Setting['feature.spending_proposals'] = true
|
||||
Setting['feature.spending_proposal_features.voting_allowed'] = true
|
||||
login_as(@manuela)
|
||||
end
|
||||
|
||||
after do
|
||||
Setting['feature.spending_proposals'] = nil
|
||||
Setting['feature.spending_proposal_features.voting_allowed'] = nil
|
||||
end
|
||||
|
||||
feature 'Index' do
|
||||
scenario "Index shows user votes on proposals" do
|
||||
spending_proposal1 = create(:spending_proposal)
|
||||
|
||||
@@ -84,6 +84,7 @@ describe Debate do
|
||||
describe "#editable?" do
|
||||
let(:debate) { create(:debate) }
|
||||
before(:each) { Setting["max_votes_for_debate_edit"] = 3 }
|
||||
after(:each) { Setting["max_votes_for_debate_edit"] = 1000 }
|
||||
|
||||
it "should be true if debate has no votes yet" do
|
||||
expect(debate.total_votes).to eq(0)
|
||||
@@ -106,6 +107,7 @@ describe Debate do
|
||||
describe "#editable_by?" do
|
||||
let(:debate) { create(:debate) }
|
||||
before(:each) { Setting["max_votes_for_debate_edit"] = 1 }
|
||||
after(:each) { Setting["max_votes_for_debate_edit"] = 1000 }
|
||||
|
||||
it "should be true if user is the author and debate is editable" do
|
||||
expect(debate.editable_by?(debate.author)).to be true
|
||||
|
||||
@@ -138,11 +138,14 @@ describe Proposal do
|
||||
Setting["proposal_code_prefix"] = "TEST"
|
||||
proposal = create(:proposal)
|
||||
expect(proposal.code).to eq "TEST-#{proposal.created_at.strftime('%Y-%m')}-#{proposal.id}"
|
||||
|
||||
Setting["proposal_code_prefix"] = "MAD"
|
||||
end
|
||||
|
||||
describe "#editable?" do
|
||||
let(:proposal) { create(:proposal) }
|
||||
before(:each) {Setting["max_votes_for_proposal_edit"] = 5}
|
||||
after(:each) {Setting["max_votes_for_proposal_edit"] = 1000}
|
||||
|
||||
it "should be true if proposal has no votes yet" do
|
||||
expect(proposal.total_votes).to eq(0)
|
||||
|
||||
@@ -290,11 +290,16 @@ describe SpendingProposal do
|
||||
let(:city_sp) { create(:spending_proposal) }
|
||||
let(:district_sp) { create(:spending_proposal, geozone: district) }
|
||||
|
||||
before(:each) do
|
||||
before do
|
||||
Setting["feature.spending_proposals"] = true
|
||||
Setting['feature.spending_proposal_features.voting_allowed'] = true
|
||||
end
|
||||
|
||||
after do
|
||||
Setting["feature.spending_proposals"] = nil
|
||||
Setting['feature.spending_proposal_features.voting_allowed'] = nil
|
||||
end
|
||||
|
||||
describe '#reason_for_not_being_votable_by' do
|
||||
it "rejects not logged in users" do
|
||||
expect(city_sp.reason_for_not_being_votable_by(nil)).to eq(:not_logged_in)
|
||||
@@ -327,6 +332,8 @@ describe SpendingProposal do
|
||||
Setting["feature.spending_proposal_features.voting_allowed"] = true
|
||||
expect(city_sp.reason_for_not_being_votable_by(user)).to be_nil
|
||||
expect(district_sp.reason_for_not_being_votable_by(user)).to be_nil
|
||||
|
||||
Setting["feature.spending_proposal_features.voting_allowed"] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -348,9 +355,17 @@ describe SpendingProposal do
|
||||
end
|
||||
|
||||
describe "total votes" do
|
||||
it "takes into account physical votes in addition to web votes" do
|
||||
before do
|
||||
Setting["feature.spending_proposals"] = true
|
||||
Setting['feature.spending_proposal_features.voting_allowed'] = true
|
||||
end
|
||||
|
||||
after do
|
||||
Setting["feature.spending_proposals"] = nil
|
||||
Setting['feature.spending_proposal_features.voting_allowed'] = nil
|
||||
end
|
||||
|
||||
it "takes into account physical votes in addition to web votes" do
|
||||
|
||||
sp = create(:spending_proposal)
|
||||
sp.register_vote(create(:user, :level_two), true)
|
||||
|
||||
Reference in New Issue
Block a user