require 'rails_helper' feature 'Spending proposals' do let(:author) { create(:user, :level_two) } scenario 'Index' do visit spending_proposals_path expect(page).to_not have_link('Create spending proposal', href: new_spending_proposal_path) expect(page).to have_link('verify your account') login_as(author) visit spending_proposals_path expect(page).to have_link('Create spending proposal', href: new_spending_proposal_path) expect(page).to_not have_link('verify your account') end scenario 'Create' do login_as(author) visit new_spending_proposal_path fill_in 'spending_proposal_title', with: 'Build a skyscraper' fill_in 'spending_proposal_description', with: 'I want to live in a high tower over the clouds' fill_in 'spending_proposal_external_url', with: 'http://http://skyscraperpage.com/' fill_in 'spending_proposal_captcha', with: correct_captcha_text select 'All city', from: 'spending_proposal_geozone_id' check 'spending_proposal_terms_of_service' click_button 'Create' expect(page).to have_content 'Spending proposal created successfully' end scenario 'Captcha is required for proposal creation' do login_as(author) visit new_spending_proposal_path fill_in 'spending_proposal_title', with: 'Build a skyscraper' fill_in 'spending_proposal_description', with: 'I want to live in a high tower over the clouds' fill_in 'spending_proposal_external_url', with: 'http://http://skyscraperpage.com/' fill_in 'spending_proposal_captcha', with: 'wrongText' check 'spending_proposal_terms_of_service' click_button 'Create' expect(page).to_not have_content 'Spending proposal created successfully' expect(page).to have_content '1 error' fill_in 'spending_proposal_captcha', with: correct_captcha_text click_button 'Create' expect(page).to have_content 'Spending proposal created successfully' end scenario 'Errors on create' do login_as(author) visit new_spending_proposal_path click_button 'Create' expect(page).to have_content error_message end end