Merge pull request #1085 from consul/retire-proposals

Retire proposals
This commit is contained in:
Juanjo Bazán
2016-04-25 18:00:34 +02:00
20 changed files with 375 additions and 38 deletions

View File

@@ -88,27 +88,27 @@ feature 'Proposals' do
end
context "Embedded video" do
scenario "Show YouTube video" do
scenario "Show YouTube video" do
proposal = create(:proposal, video_url: "http://www.youtube.com/watch?v=a7UFm6ErMPU")
visit proposal_path(proposal)
expect(page).to have_selector("div[id='js-embedded-video']")
expect(page.html).to include 'https://www.youtube.com/embed/a7UFm6ErMPU'
end
scenario "Show Vimeo video" do
scenario "Show Vimeo video" do
proposal = create(:proposal, video_url: "https://vimeo.com/7232823" )
visit proposal_path(proposal)
expect(page).to have_selector("div[id='js-embedded-video']")
expect(page.html).to include 'https://player.vimeo.com/video/7232823'
end
scenario "Dont show video" do
scenario "Dont show video" do
proposal = create(:proposal, video_url: nil)
visit proposal_path(proposal)
expect(page).to_not have_selector("div[id='js-embedded-video']")
end
end
end
end
scenario 'Social Media Cards' do
proposal = create(:proposal)
@@ -375,7 +375,7 @@ feature 'Proposals' do
end
end
context "Geozones" do
context 'Geozones' do
scenario "Default whole city" do
author = create(:user)
@@ -430,6 +430,100 @@ feature 'Proposals' do
end
context 'Retired proposals' do
scenario 'Retire' do
proposal = create(:proposal)
login_as(proposal.author)
visit user_path(proposal.author)
within("#proposal_#{proposal.id}") do
click_link 'Retire'
end
expect(current_path).to eq(retire_form_proposal_path(proposal))
select 'Duplicated', from: 'proposal_retired_reason'
fill_in 'proposal_retired_explanation', with: 'There are three other better proposals with the same subject'
click_button "Retire proposal"
expect(page).to have_content "Proposal retired"
visit proposal_path(proposal)
expect(page).to have_content proposal.title
expect(page).to have_content 'Proposal retired by the author'
expect(page).to have_content 'Duplicated'
expect(page).to have_content 'There are three other better proposals with the same subject'
end
scenario 'Fields are mandatory' do
proposal = create(:proposal)
login_as(proposal.author)
visit retire_form_proposal_path(proposal)
click_button 'Retire proposal'
expect(page).to_not have_content 'Proposal retired'
expect(page).to have_content "can't be blank", count: 2
end
scenario 'Index do not list retired proposals by default' do
create_featured_proposals
not_retired = create(:proposal)
retired = create(:proposal, retired_at: Time.now)
visit proposals_path
expect(page).to have_selector('#proposals .proposal', count: 1)
within('#proposals') do
expect(page).to have_content not_retired.title
expect(page).to_not have_content retired.title
end
end
scenario 'Index has a link to retired proposals list' do
create_featured_proposals
not_retired = create(:proposal)
retired = create(:proposal, retired_at: Time.now)
visit proposals_path
expect(page).to_not have_content retired.title
click_link 'Proposals retired by the author'
expect(page).to have_content retired.title
expect(page).to_not have_content not_retired.title
end
scenario 'Retired proposals index interface elements' do
visit proposals_path(retired: 'all')
expect(page).to_not have_content 'Advanced search'
expect(page).to_not have_content 'Categories'
expect(page).to_not have_content 'Districts'
end
scenario 'Retired proposals index has links to filter by retired_reason' do
unfeasible = create(:proposal, retired_at: Time.now, retired_reason: 'unfeasible')
duplicated = create(:proposal, retired_at: Time.now, retired_reason: 'duplicated')
visit proposals_path(retired: 'all')
expect(page).to have_content unfeasible.title
expect(page).to have_content duplicated.title
expect(page).to have_link 'Duplicated'
expect(page).to have_link 'Underway'
expect(page).to have_link 'Unfeasible'
expect(page).to have_link 'Done'
expect(page).to have_link 'Other'
click_link 'Unfeasible'
expect(page).to have_content unfeasible.title
expect(page).to_not have_content duplicated.title
end
end
scenario 'Update should not be posible if logged user is not the author' do
proposal = create(:proposal)
expect(proposal).to be_editable