Merge pull request #1888 from consul/flaky-specs

Fixes some flaky specs
This commit is contained in:
BertoCQ
2017-09-19 16:43:41 +02:00
committed by GitHub
7 changed files with 15 additions and 107 deletions

View File

@@ -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:

View File

@@ -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.'

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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