diff --git a/.travis.yml b/.travis.yml index 7d5f6169a..8836964a6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,7 @@ before_script: - "for i in config/*.example; do cp \"$i\" \"${i/.example}\"; done" - bundle exec rake db:setup script: + - "bundle exec rake assets:precompile RAILS_ENV=test" - "bundle exec rake knapsack:rspec" env: global: diff --git a/spec/features/admin/budget_investments_spec.rb b/spec/features/admin/budget_investments_spec.rb index 925f105b0..7252e2660 100644 --- a/spec/features/admin/budget_investments_spec.rb +++ b/spec/features/admin/budget_investments_spec.rb @@ -390,13 +390,10 @@ feature 'Admin budget investments' do budget_investment2 = create(:budget_investment) - visit admin_budget_budget_investment_path(budget_investment2.budget, budget_investment2) - click_link 'Edit classification' + visit edit_admin_budget_budget_investment_path(budget_investment2.budget, budget_investment2) find('.js-add-tag-link', text: 'Education').click - fill_in 'budget_investment_title', with: 'Updated title' - click_button 'Update' expect(page).to have_content 'Investment project updated succesfully.' diff --git a/spec/features/admin/legislation/questions_spec.rb b/spec/features/admin/legislation/questions_spec.rb index 44698a25c..ffbca09b1 100644 --- a/spec/features/admin/legislation/questions_spec.rb +++ b/spec/features/admin/legislation/questions_spec.rb @@ -9,8 +9,15 @@ feature 'Admin legislation questions' do context "Feature flag" do - scenario 'Disabled with a feature flag' do + background do Setting['feature.legislation'] = nil + end + + after do + Setting['feature.legislation'] = true + end + + scenario 'Disabled with a feature flag' do process = create(:legislation_process) expect{ visit admin_legislation_process_questions_path(process) }.to raise_exception(FeatureFlags::FeatureDisabled) end diff --git a/spec/features/legacy_legislation_spec.rb b/spec/features/legacy_legislation_spec.rb deleted file mode 100644 index 8ccc7fcb0..000000000 --- a/spec/features/legacy_legislation_spec.rb +++ /dev/null @@ -1,99 +0,0 @@ -require 'rails_helper' - -feature 'Legacy Legislation' do - - scenario 'Show' do - legacy_legislation = create(:legacy_legislation, title: 'Change the world', body: 'To achieve this...') - - visit legacy_legislation_path(legacy_legislation) - - expect(page).to have_content 'Change the world' - expect(page).to have_content 'To achieve this...' - end - - context 'Annotations', :js do - - let(:user) { create(:user) } - background { login_as user } - - scenario 'Create' do - legacy_legislation = create(:legacy_legislation) - - visit legacy_legislation_path(legacy_legislation) - - page.find(:css, "#legacy_legislation_body").double_click - page.find(:css, ".annotator-adder button").click - fill_in 'annotator-field-0', with: 'this is my annotation' - page.find(:css, ".annotator-controls a[href='#save']").click - - expect(page).to have_css ".annotator-hl" - first(:css, ".annotator-hl").click - expect(page).to have_content "this is my annotation" - - visit legacy_legislation_path(legacy_legislation) - - expect(page).to have_css ".annotator-hl" - first(:css, ".annotator-hl").click - expect(page).to have_content "this is my annotation" - end - - scenario 'Update' do - legacy_legislation = create(:legacy_legislation) - annotation = create(:annotation, legacy_legislation: legacy_legislation, user: user, text: "my annotation") - - visit legacy_legislation_path(legacy_legislation) - - expect(page).to have_css ".annotator-hl" - page.find(:css, ".annotator-hl").click - page.find(:css, ".annotator-edit").click - - fill_in 'annotator-field-0', with: 'edited annotation' - page.find(:css, ".annotator-controls a[href='#save']").click - - expect(page).to_not have_css('span', text: 'my annotation') - - page.find(:css, ".annotator-hl").click - expect(page).to have_content "edited annotation" - - visit legacy_legislation_path(legacy_legislation) - - page.find(:css, ".annotator-hl").click - expect(page).to have_content "edited annotation" - end - - scenario 'Destroy' do - legacy_legislation = create(:legacy_legislation) - annotation = create(:annotation, legacy_legislation: legacy_legislation, user: user) - - visit legacy_legislation_path(legacy_legislation) - - expect(page).to have_css ".annotator-hl" - - page.find(:css, ".annotator-hl").click - page.find(:css, ".annotator-delete").click - - expect(page).to_not have_css ".annotator-hl" - end - - scenario 'Search' do - legacy_legislation = create(:legacy_legislation) - annotation1 = create(:annotation, legacy_legislation: legacy_legislation, text: "my annotation", - ranges: [{"start" => "/div[1]", "startOffset" => 5, "end" => "/div[1]", "endOffset" => 10}]) - annotation2 = create(:annotation, legacy_legislation: legacy_legislation, text: "my other annotation", - ranges: [{"start" => "/div[1]", "startOffset" => 12, "end" => "/div[1]", "endOffset" => 19}]) - - visit legacy_legislation_path(legacy_legislation) - - expect(page).to have_css ".annotator-hl" - first(:css, ".annotator-hl").click - expect(page).to have_content "my annotation" - - all(".annotator-hl")[1].click - expect(page).to have_content "my other annotation" - end - - end - -end - -## Notes logged in and not logged in users diff --git a/spec/features/votes_spec.rb b/spec/features/votes_spec.rb index 73a255415..093599368 100644 --- a/spec/features/votes_spec.rb +++ b/spec/features/votes_spec.rb @@ -303,7 +303,7 @@ feature 'Votes' do debate = create(:debate) comment = create(:comment, commentable: debate) - visit comment_path(debate) + visit comment_path(comment) within("#comment_#{comment.id}") do find("div.votes").hover expect_message_you_need_to_sign_in_to_vote_comments diff --git a/spec/models/geozone_spec.rb b/spec/models/geozone_spec.rb index 1a7bf6b09..0eeb331b7 100644 --- a/spec/models/geozone_spec.rb +++ b/spec/models/geozone_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe Geozone, type: :model do +describe Geozone do let(:geozone) { build(:geozone) } it "should be valid" do @@ -13,6 +13,8 @@ RSpec.describe Geozone, type: :model do end describe "#safe_to_destroy?" do + let(:geozone) { create(:geozone) } + it "is true when not linked to other models" do expect(geozone.safe_to_destroy?).to be_truthy end diff --git a/spec/shared/features/nested_documentable.rb b/spec/shared/features/nested_documentable.rb index 253deacda..906b2d38f 100644 --- a/spec/shared/features/nested_documentable.rb +++ b/spec/shared/features/nested_documentable.rb @@ -248,7 +248,7 @@ def attach_new_file(documentable_factory_name, index, path) end def fill_new_valid_proposal - fill_in :proposal_title, with: "Proposal title" + fill_in :proposal_title, with: "Proposal title #{rand(9999)}" fill_in :proposal_summary, with: "Proposal summary" fill_in :proposal_question, with: "Proposal question?" check :proposal_terms_of_service