58 lines
1.8 KiB
Ruby
58 lines
1.8 KiB
Ruby
require 'rails_helper'
|
|
|
|
feature 'Spending proposals' do
|
|
|
|
scenario 'Index' do
|
|
visit spending_proposals_path
|
|
|
|
expect(page).to have_link('Create spending proposal', href: new_spending_proposal_path)
|
|
end
|
|
|
|
scenario 'Create' do
|
|
author = create(:user)
|
|
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
|
|
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(create(:user))
|
|
|
|
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
|
|
author = create(:user)
|
|
login_as(author)
|
|
|
|
visit new_spending_proposal_path
|
|
click_button 'Create'
|
|
expect(page).to have_content error_message
|
|
end
|
|
|
|
end
|