adds responsible name to proposals
This commit is contained in:
@@ -7,6 +7,17 @@ FactoryGirl.define do
|
||||
terms_of_service '1'
|
||||
confirmed_at { Time.now }
|
||||
|
||||
trait :level_two do
|
||||
residence_verified_at Time.now
|
||||
confirmed_phone "611111111"
|
||||
document_number "12345678Z"
|
||||
end
|
||||
|
||||
trait :level_three do
|
||||
verified_at Time.now
|
||||
document_number "12345678Z"
|
||||
end
|
||||
|
||||
trait :hidden do
|
||||
hidden_at Time.now
|
||||
end
|
||||
@@ -106,6 +117,7 @@ FactoryGirl.define do
|
||||
description 'Proposal description'
|
||||
question 'Proposal question'
|
||||
external_url 'http://external_documention.es'
|
||||
responsible_name 'John Snow'
|
||||
terms_of_service '1'
|
||||
association :author, factory: :user
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@ feature 'Proposals' do
|
||||
fill_in 'proposal_question', with: '¿Would you like to give assistance to war refugees?'
|
||||
fill_in 'proposal_description', with: 'This is very important because...'
|
||||
fill_in 'proposal_external_url', with: 'http://rescue.org/refugees'
|
||||
fill_in 'proposal_responsible_name', with: 'Isabel Garcia'
|
||||
fill_in 'proposal_captcha', with: correct_captcha_text
|
||||
check 'proposal_terms_of_service'
|
||||
|
||||
@@ -75,6 +76,45 @@ feature 'Proposals' do
|
||||
expect(page).to have_content I18n.l(Proposal.last.created_at.to_date)
|
||||
end
|
||||
|
||||
scenario 'Responsible name is stored for anonymous users' do
|
||||
author = create(:user)
|
||||
login_as(author)
|
||||
|
||||
visit new_proposal_path
|
||||
fill_in 'proposal_title', with: 'Help refugees'
|
||||
fill_in 'proposal_question', with: '¿Would you like to give assistance to war refugees?'
|
||||
fill_in 'proposal_description', with: 'This is very important because...'
|
||||
fill_in 'proposal_external_url', with: 'http://rescue.org/refugees'
|
||||
fill_in 'proposal_responsible_name', with: 'Isabel Garcia'
|
||||
fill_in 'proposal_captcha', with: correct_captcha_text
|
||||
fill_in 'proposal_responsible_name', with: 'Isabel Garcia'
|
||||
check 'proposal_terms_of_service'
|
||||
|
||||
click_button 'Start a proposal'
|
||||
|
||||
expect(page).to have_content 'Proposal was successfully created.'
|
||||
expect(Proposal.last.responsible_name).to eq('Isabel Garcia')
|
||||
end
|
||||
|
||||
scenario 'Responsible name field is not shown for verified users' do
|
||||
author = create(:user, :level_two)
|
||||
login_as(author)
|
||||
|
||||
visit new_proposal_path
|
||||
expect(page).to_not have_selector('#proposal_responsible_name')
|
||||
|
||||
fill_in 'proposal_title', with: 'Help refugees'
|
||||
fill_in 'proposal_question', with: '¿Would you like to give assistance to war refugees?'
|
||||
fill_in 'proposal_description', with: 'This is very important because...'
|
||||
fill_in 'proposal_external_url', with: 'http://rescue.org/refugees'
|
||||
fill_in 'proposal_captcha', with: correct_captcha_text
|
||||
check 'proposal_terms_of_service'
|
||||
|
||||
click_button 'Start a proposal'
|
||||
|
||||
expect(page).to have_content 'Proposal was successfully created.'
|
||||
end
|
||||
|
||||
scenario 'Captcha is required for proposal creation' do
|
||||
login_as(create(:user))
|
||||
|
||||
@@ -83,6 +123,7 @@ feature 'Proposals' do
|
||||
fill_in 'proposal_question', with: '¿Would you like to give assistance to war refugees?'
|
||||
fill_in 'proposal_description', with: 'Very important issue...'
|
||||
fill_in 'proposal_external_url', with: 'http://rescue.org/refugees'
|
||||
fill_in 'proposal_responsible_name', with: 'Isabel Garcia'
|
||||
fill_in 'proposal_captcha', with: "wrongText!"
|
||||
check 'proposal_terms_of_service'
|
||||
|
||||
@@ -107,6 +148,7 @@ feature 'Proposals' do
|
||||
fill_in 'proposal_question', with: '¿Would you like to give assistance to war refugees?'
|
||||
fill_in 'proposal_description', with: 'Very important issue...'
|
||||
fill_in 'proposal_external_url', with: 'http://rescue.org/refugees'
|
||||
fill_in 'proposal_responsible_name', with: 'Isabel Garcia'
|
||||
fill_in 'proposal_captcha', with: correct_captcha_text
|
||||
check 'proposal_terms_of_service'
|
||||
|
||||
@@ -138,6 +180,7 @@ feature 'Proposals' do
|
||||
fill_in 'proposal_question', with: '¿Would you like to give assistance to war refugees?'
|
||||
fill_in 'proposal_description', with: '<p>This is <script>alert("an attack");</script></p>'
|
||||
fill_in 'proposal_external_url', with: 'http://rescue.org/refugees'
|
||||
fill_in 'proposal_responsible_name', with: 'Isabel Garcia'
|
||||
fill_in 'proposal_captcha', with: correct_captcha_text
|
||||
check 'proposal_terms_of_service'
|
||||
|
||||
@@ -158,6 +201,7 @@ feature 'Proposals' do
|
||||
fill_in 'proposal_title', with: 'Testing auto link'
|
||||
fill_in 'proposal_question', with: 'Should I stay or should I go?'
|
||||
fill_in 'proposal_description', with: '<p>This is a link www.example.org</p>'
|
||||
fill_in 'proposal_responsible_name', with: 'Isabel Garcia'
|
||||
fill_in 'proposal_captcha', with: correct_captcha_text
|
||||
check 'proposal_terms_of_service'
|
||||
|
||||
@@ -176,6 +220,7 @@ feature 'Proposals' do
|
||||
fill_in 'proposal_title', with: 'Testing auto link'
|
||||
fill_in 'proposal_question', with: 'Should I stay or should I go?'
|
||||
fill_in 'proposal_description', with: "<script>alert('hey')</script> <a href=\"javascript:alert('surprise!')\">click me<a/> http://example.org"
|
||||
fill_in 'proposal_responsible_name', with: 'Isabel Garcia'
|
||||
fill_in 'proposal_captcha', with: correct_captcha_text
|
||||
check 'proposal_terms_of_service'
|
||||
|
||||
@@ -212,6 +257,7 @@ feature 'Proposals' do
|
||||
fill_in 'proposal_question', with: '¿Would you like to give assistance to war refugees?'
|
||||
fill_in_ckeditor 'proposal_description', with: 'A description with enough characters'
|
||||
fill_in 'proposal_external_url', with: 'http://rescue.org/refugees'
|
||||
fill_in 'proposal_responsible_name', with: 'Isabel Garcia'
|
||||
fill_in 'proposal_captcha', with: correct_captcha_text
|
||||
check 'proposal_terms_of_service'
|
||||
|
||||
@@ -234,6 +280,7 @@ feature 'Proposals' do
|
||||
fill_in 'proposal_question', with: '¿Would you like to give assistance to war refugees?'
|
||||
fill_in 'proposal_description', with: 'A description suitable for this test'
|
||||
fill_in 'proposal_external_url', with: 'http://rescue.org/refugees'
|
||||
fill_in 'proposal_responsible_name', with: 'Isabel Garcia'
|
||||
fill_in 'proposal_captcha', with: correct_captcha_text
|
||||
check 'proposal_terms_of_service'
|
||||
|
||||
@@ -284,6 +331,7 @@ feature 'Proposals' do
|
||||
fill_in 'proposal_question', with: '¿Would you like to give assistance to war refugees?'
|
||||
fill_in 'proposal_description', with: "Let's do something to end child poverty"
|
||||
fill_in 'proposal_external_url', with: 'http://rescue.org/refugees'
|
||||
fill_in 'proposal_responsible_name', with: 'Isabel Garcia'
|
||||
fill_in 'proposal_captcha', with: correct_captcha_text
|
||||
|
||||
click_button "Save changes"
|
||||
|
||||
@@ -12,13 +12,13 @@ describe Proposal do
|
||||
expect(proposal).to_not be_valid
|
||||
end
|
||||
|
||||
it "should not be valid without a question" do
|
||||
proposal.question = nil
|
||||
it "should not be valid without a title" do
|
||||
proposal.title = nil
|
||||
expect(proposal).to_not be_valid
|
||||
end
|
||||
|
||||
it "should not be valid without a title" do
|
||||
proposal.title = nil
|
||||
it "should not be valid without a question" do
|
||||
proposal.question = nil
|
||||
expect(proposal).to_not be_valid
|
||||
end
|
||||
|
||||
@@ -35,6 +35,31 @@ describe Proposal do
|
||||
end
|
||||
end
|
||||
|
||||
describe "#responsible" do
|
||||
it "should be mandatory" do
|
||||
proposal.responsible_name = nil
|
||||
expect(proposal).to_not be_valid
|
||||
end
|
||||
|
||||
it "should be the document_number if level two user" do
|
||||
author = create(:user, :level_two, document_number: "12345678Z")
|
||||
proposal.author = author
|
||||
proposal.responsible_name = nil
|
||||
|
||||
expect(proposal).to be_valid
|
||||
proposal.responsible_name = "12345678Z"
|
||||
end
|
||||
|
||||
it "should be the document_number if level two user" do
|
||||
author = create(:user, :level_three, document_number: "12345678Z")
|
||||
proposal.author = author
|
||||
proposal.responsible_name = nil
|
||||
|
||||
expect(proposal).to be_valid
|
||||
proposal.responsible_name = "12345678Z"
|
||||
end
|
||||
end
|
||||
|
||||
it "should sanitize the tag list" do
|
||||
proposal.tag_list = "user_id=1"
|
||||
proposal.valid?
|
||||
|
||||
Reference in New Issue
Block a user