Merge branch 'master' into polling-views-plus
This commit is contained in:
@@ -50,7 +50,7 @@ feature 'Official positions' do
|
||||
@proposal1 = create(:proposal, author: @user1)
|
||||
@proposal2 = create(:proposal, author: @user2)
|
||||
|
||||
featured_proposals = 3.times { create(:proposal) }
|
||||
create_featured_proposals
|
||||
end
|
||||
|
||||
scenario "Index" do
|
||||
|
||||
57
spec/features/proposal_ballots_spec.rb
Normal file
57
spec/features/proposal_ballots_spec.rb
Normal file
@@ -0,0 +1,57 @@
|
||||
# coding: utf-8
|
||||
require 'rails_helper'
|
||||
|
||||
feature 'Proposal ballots' do
|
||||
|
||||
scenario 'Banner shows in proposal index' do
|
||||
create_featured_proposals
|
||||
|
||||
visit proposals_path
|
||||
expect(page).to_not have_css("#next-voting")
|
||||
expect(page).to have_css("#featured-proposals")
|
||||
|
||||
create_successfull_proposals
|
||||
|
||||
visit proposals_path
|
||||
|
||||
expect(page).to have_css("#next-voting")
|
||||
expect(page).to_not have_css("#featured-proposals")
|
||||
end
|
||||
|
||||
scenario 'Successfull proposals do not show support buttons in index' do
|
||||
successfull_proposals = create_successfull_proposals
|
||||
|
||||
visit proposals_path
|
||||
|
||||
successfull_proposals.each do |proposal|
|
||||
within("#proposal_#{proposal.id}_votes") do
|
||||
expect(page).to_not have_css(".supports")
|
||||
expect(page).to have_content "This proposal has reached the required supports"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Successfull proposals do not show support buttons in show' do
|
||||
successfull_proposals = create_successfull_proposals
|
||||
|
||||
successfull_proposals.each do |proposal|
|
||||
visit proposal_path(proposal)
|
||||
within("#proposal_#{proposal.id}_votes") do
|
||||
expect(page).to_not have_css(".supports")
|
||||
expect(page).to have_content "This proposal has reached the required supports"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Successfull proposals are listed in the proposal ballots index' do
|
||||
successfull_proposals = create_successfull_proposals
|
||||
|
||||
visit proposal_ballots_path
|
||||
|
||||
successfull_proposals.each do |proposal|
|
||||
expect(page).to have_content(proposal.title)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -3,48 +3,50 @@ require 'rails_helper'
|
||||
|
||||
feature 'Proposals' do
|
||||
|
||||
scenario 'Index' do
|
||||
featured_proposals = create_featured_proposals
|
||||
proposals = [create(:proposal), create(:proposal), create(:proposal)]
|
||||
context 'Index' do
|
||||
scenario 'Lists featured and regular proposals' do
|
||||
featured_proposals = create_featured_proposals
|
||||
proposals = [create(:proposal), create(:proposal), create(:proposal)]
|
||||
|
||||
visit proposals_path
|
||||
visit proposals_path
|
||||
|
||||
expect(page).to have_selector('#proposals .proposal-featured', count: 3)
|
||||
featured_proposals.each do |featured_proposal|
|
||||
within('#featured-proposals') do
|
||||
expect(page).to have_content featured_proposal.title
|
||||
expect(page).to have_css("a[href='#{proposal_path(featured_proposal)}']")
|
||||
expect(page).to have_selector('#proposals .proposal-featured', count: 3)
|
||||
featured_proposals.each do |featured_proposal|
|
||||
within('#featured-proposals') do
|
||||
expect(page).to have_content featured_proposal.title
|
||||
expect(page).to have_css("a[href='#{proposal_path(featured_proposal)}']")
|
||||
end
|
||||
end
|
||||
|
||||
expect(page).to have_selector('#proposals .proposal', count: 3)
|
||||
proposals.each do |proposal|
|
||||
within('#proposals') do
|
||||
expect(page).to have_content proposal.title
|
||||
expect(page).to have_css("a[href='#{proposal_path(proposal)}']", text: proposal.title)
|
||||
expect(page).to have_css("a[href='#{proposal_path(proposal)}']", text: proposal.summary)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
expect(page).to have_selector('#proposals .proposal', count: 3)
|
||||
proposals.each do |proposal|
|
||||
within('#proposals') do
|
||||
expect(page).to have_content proposal.title
|
||||
expect(page).to have_css("a[href='#{proposal_path(proposal)}']", text: proposal.title)
|
||||
expect(page).to have_css("a[href='#{proposal_path(proposal)}']", text: proposal.summary)
|
||||
scenario 'Pagination' do
|
||||
per_page = Kaminari.config.default_per_page
|
||||
(per_page + 5).times { create(:proposal) }
|
||||
|
||||
visit proposals_path
|
||||
|
||||
expect(page).to have_selector('#proposals .proposal', count: per_page)
|
||||
|
||||
within("ul.pagination") do
|
||||
expect(page).to have_content("1")
|
||||
expect(page).to have_content("2")
|
||||
expect(page).to_not have_content("3")
|
||||
click_link "Next", exact: false
|
||||
end
|
||||
|
||||
expect(page).to have_selector('#proposals .proposal', count: 2)
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Paginated Index' do
|
||||
per_page = Kaminari.config.default_per_page
|
||||
(per_page + 5).times { create(:proposal) }
|
||||
|
||||
visit proposals_path
|
||||
|
||||
expect(page).to have_selector('#proposals .proposal', count: per_page)
|
||||
|
||||
within("ul.pagination") do
|
||||
expect(page).to have_content("1")
|
||||
expect(page).to have_content("2")
|
||||
expect(page).to_not have_content("3")
|
||||
click_link "Next", exact: false
|
||||
end
|
||||
|
||||
expect(page).to have_selector('#proposals .proposal', count: 2)
|
||||
end
|
||||
|
||||
scenario 'Show' do
|
||||
proposal = create(:proposal)
|
||||
|
||||
@@ -676,6 +678,110 @@ feature 'Proposals' do
|
||||
end
|
||||
end
|
||||
|
||||
feature 'Archived proposals' do
|
||||
|
||||
scenario 'show on archived tab' do
|
||||
create_featured_proposals
|
||||
archived_proposals = create_archived_proposals
|
||||
|
||||
visit proposals_path
|
||||
click_link 'Archived'
|
||||
|
||||
within("#proposals-list") do
|
||||
archived_proposals.each do |proposal|
|
||||
expect(page).to have_content(proposal.title)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'do not show in other index tabs' do
|
||||
create_featured_proposals
|
||||
archived_proposal = create(:proposal, :archived)
|
||||
|
||||
visit proposals_path
|
||||
|
||||
within("#proposals-list") do
|
||||
expect(page).to_not have_content archived_proposal.title
|
||||
end
|
||||
|
||||
orders = %w{hot_score confidence_score created_at relevance}
|
||||
orders.each do |order|
|
||||
visit proposals_path(order: order)
|
||||
|
||||
within("#proposals-list") do
|
||||
expect(page).to_not have_content archived_proposal.title
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'do not show support buttons in index' do
|
||||
create_featured_proposals
|
||||
archived_proposals = create_archived_proposals
|
||||
|
||||
visit proposals_path(order: 'archival_date')
|
||||
|
||||
within("#proposals-list") do
|
||||
archived_proposals.each do |proposal|
|
||||
within("#proposal_#{proposal.id}_votes") do
|
||||
expect(page).to_not have_css(".supports")
|
||||
expect(page).to have_content "This proposal has been archived and can't collect supports"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'do not show support buttons in show' do
|
||||
archived_proposal = create(:proposal, :archived)
|
||||
|
||||
visit proposal_path(archived_proposal)
|
||||
expect(page).to_not have_css(".supports")
|
||||
expect(page).to have_content "This proposal has been archived and can't collect supports"
|
||||
end
|
||||
|
||||
scenario 'do not show in featured proposals section' do
|
||||
featured_proposal = create(:proposal, :with_confidence_score, cached_votes_up: 100)
|
||||
archived_proposal = create(:proposal, :archived, :with_confidence_score, cached_votes_up: 10000)
|
||||
|
||||
visit proposals_path
|
||||
|
||||
within("#featured-proposals") do
|
||||
expect(page).to have_content(featured_proposal.title)
|
||||
expect(page).to_not have_content(archived_proposal.title)
|
||||
end
|
||||
within("#proposals-list") do
|
||||
expect(page).to_not have_content(featured_proposal.title)
|
||||
expect(page).to_not have_content(archived_proposal.title)
|
||||
end
|
||||
|
||||
click_link "Archived"
|
||||
|
||||
within("#featured-proposals") do
|
||||
expect(page).to have_content(featured_proposal.title)
|
||||
expect(page).to_not have_content(archived_proposal.title)
|
||||
end
|
||||
within("#proposals-list") do
|
||||
expect(page).to_not have_content(featured_proposal.title)
|
||||
expect(page).to have_content(archived_proposal.title)
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Order by votes" do
|
||||
create(:proposal, :archived, title: "Least voted").update_column(:confidence_score, 10)
|
||||
create(:proposal, :archived, title: "Most voted").update_column(:confidence_score, 50)
|
||||
create(:proposal, :archived, title: "Some votes").update_column(:confidence_score, 25)
|
||||
|
||||
visit proposals_path
|
||||
click_link 'Archived'
|
||||
|
||||
within("#proposals-list") do
|
||||
expect(all(".proposal")[0].text).to match "Most voted"
|
||||
expect(all(".proposal")[1].text).to match "Some votes"
|
||||
expect(all(".proposal")[2].text).to match "Least voted"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context "Search" do
|
||||
|
||||
context "Basic search" do
|
||||
|
||||
@@ -285,4 +285,59 @@ feature 'Users' do
|
||||
|
||||
expect(page).to have_content "Your password has been changed successfully."
|
||||
end
|
||||
|
||||
scenario 'Sign in, admin with password expired' do
|
||||
user = create(:user, password_changed_at: Time.now - 1.year)
|
||||
admin = create(:administrator, user: user)
|
||||
|
||||
login_as(admin.user)
|
||||
visit root_path
|
||||
|
||||
expect(page).to have_content "Your password is expired"
|
||||
|
||||
fill_in 'user_current_password', with: 'judgmentday'
|
||||
fill_in 'user_password', with: '123456789'
|
||||
fill_in 'user_password_confirmation', with: '123456789'
|
||||
|
||||
click_button 'Change your password'
|
||||
|
||||
expect(page).to have_content "Password successfully updated"
|
||||
end
|
||||
|
||||
scenario 'Sign in, admin without password expired' do
|
||||
user = create(:user, password_changed_at: Time.now - 360.days)
|
||||
admin = create(:administrator, user: user)
|
||||
|
||||
login_as(admin.user)
|
||||
visit root_path
|
||||
|
||||
expect(page).to_not have_content "Your password is expired"
|
||||
end
|
||||
|
||||
scenario 'Sign in, user with password expired' do
|
||||
user = create(:user, password_changed_at: Time.now - 1.year)
|
||||
|
||||
login_as(user)
|
||||
visit root_path
|
||||
|
||||
expect(page).to_not have_content "Your password is expired"
|
||||
end
|
||||
|
||||
scenario 'Admin with password expired trying to use same password' do
|
||||
user = create(:user, password_changed_at: Time.now - 1.year, password: '123456789')
|
||||
admin = create(:administrator, user: user)
|
||||
|
||||
login_as(admin.user)
|
||||
visit root_path
|
||||
|
||||
expect(page).to have_content "Your password is expired"
|
||||
|
||||
fill_in 'user_current_password', with: 'judgmentday'
|
||||
fill_in 'user_password', with: '123456789'
|
||||
fill_in 'user_password_confirmation', with: '123456789'
|
||||
click_button 'Change your password'
|
||||
|
||||
expect(page).to have_content "must be different than the current password."
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user