From 26f2f2fea62f1c114708026ac2dc9d89ae5f082f Mon Sep 17 00:00:00 2001 From: Angel Perez Date: Thu, 15 Mar 2018 13:04:11 -0400 Subject: [PATCH] Refactor test to avoid interaction with non-visible element --- .../budget_investments_valuation_spec.rb | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/spec/features/comments/budget_investments_valuation_spec.rb b/spec/features/comments/budget_investments_valuation_spec.rb index f2888845c..746edc18e 100644 --- a/spec/features/comments/budget_investments_valuation_spec.rb +++ b/spec/features/comments/budget_investments_valuation_spec.rb @@ -162,20 +162,10 @@ feature 'Internal valuation comments on Budget::Investments' do end context 'Valuation comment creation' do - scenario 'Normal users cannot create valuation comments altering public comments form', :js do - logout - login_as(user) - visit budget_investment_path(investment.budget, investment) - - fill_in "comment-body-budget_investment_#{investment.id}", with: 'HACKERMAN IS HERE' - find(:xpath, "//input[@id='comment_valuation']", visible: false).set('true') - click_button 'Publish comment' - - visit budget_investment_path(investment.budget, investment) - expect(page).not_to have_content('HACKERMAN IS HERE') - - visit valuation_budget_budget_investment_path(budget, investment) - expect(page).not_to have_content('HACKERMAN IS HERE') + scenario 'Normal users cannot create valuation comments altering public comments form' do + comment = build(:comment, body: 'HACKERMAN IS HERE', valuation: true, author: user) + expect(comment).not_to be_valid + expect(comment.errors.size).to eq(1) end scenario 'Create comment', :js do