Remove instance variables in RSpec
Instance variables might lead to hard-to-detect issues, since using a nonexistent instance variable will return `nil` instead of raising an error.
This commit is contained in:
@@ -57,9 +57,6 @@ Rails/SaveBang:
|
||||
Rails/SkipsModelValidations:
|
||||
Enabled: true
|
||||
|
||||
RSpec/InstanceVariable:
|
||||
Enabled: true
|
||||
|
||||
Security/Eval:
|
||||
Enabled: true
|
||||
|
||||
|
||||
@@ -199,6 +199,9 @@ RSpec/Focus:
|
||||
RSpec/HookArgument:
|
||||
Enabled: true
|
||||
|
||||
RSpec/InstanceVariable:
|
||||
Enabled: true
|
||||
|
||||
RSpec/LetBeforeExamples:
|
||||
Enabled: true
|
||||
|
||||
|
||||
@@ -3,17 +3,20 @@ require "rails_helper"
|
||||
describe RemoteTranslationsController do
|
||||
|
||||
describe "POST create", :delay_jobs do
|
||||
let(:debate) { create(:debate) }
|
||||
let(:debate) { create(:debate) }
|
||||
|
||||
let(:remote_translations_params) do
|
||||
[{ remote_translatable_id: debate.id.to_s,
|
||||
remote_translatable_type: debate.class.to_s,
|
||||
locale: :es }].to_json
|
||||
end
|
||||
|
||||
before do
|
||||
@remote_translations_params = [{ remote_translatable_id: debate.id.to_s,
|
||||
remote_translatable_type: debate.class.to_s,
|
||||
locale: :es }].to_json
|
||||
request.env["HTTP_REFERER"] = "any_path"
|
||||
end
|
||||
|
||||
it "create correctly remote translation" do
|
||||
post :create, params: { remote_translations: @remote_translations_params }
|
||||
post :create, params: { remote_translations: remote_translations_params }
|
||||
|
||||
expect(RemoteTranslation.count).to eq(1)
|
||||
end
|
||||
@@ -21,7 +24,7 @@ describe RemoteTranslationsController do
|
||||
it "create remote translation when same remote translation with error_message is enqueued" do
|
||||
create(:remote_translation, remote_translatable: debate, locale: :es, error_message: "Has errors")
|
||||
|
||||
post :create, params: { remote_translations: @remote_translations_params }
|
||||
post :create, params: { remote_translations: remote_translations_params }
|
||||
|
||||
expect(RemoteTranslation.count).to eq(2)
|
||||
end
|
||||
@@ -29,13 +32,13 @@ describe RemoteTranslationsController do
|
||||
it "not create remote translation when same remote translation is enqueued" do
|
||||
create(:remote_translation, remote_translatable: debate, locale: :es)
|
||||
|
||||
post :create, params: { remote_translations: @remote_translations_params }
|
||||
post :create, params: { remote_translations: remote_translations_params }
|
||||
|
||||
expect(RemoteTranslation.count).to eq(1)
|
||||
end
|
||||
|
||||
it "redirect_to request referer after create" do
|
||||
post :create, params: { remote_translations: @remote_translations_params }
|
||||
post :create, params: { remote_translations: remote_translations_params }
|
||||
|
||||
expect(subject).to redirect_to("any_path")
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@ require "rails_helper"
|
||||
|
||||
describe Users::ConfirmationsController do
|
||||
before do
|
||||
@request.env["devise.mapping"] = Devise.mappings[:user]
|
||||
request.env["devise.mapping"] = Devise.mappings[:user]
|
||||
end
|
||||
|
||||
describe "GET show" do
|
||||
|
||||
@@ -5,7 +5,7 @@ describe Users::RegistrationsController do
|
||||
describe "POST check_username" do
|
||||
|
||||
before do
|
||||
@request.env["devise.mapping"] = Devise.mappings[:user]
|
||||
request.env["devise.mapping"] = Devise.mappings[:user]
|
||||
end
|
||||
|
||||
context "when username is available" do
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe "Account" do
|
||||
let(:user) { create(:user, username: "Manuela Colau") }
|
||||
|
||||
before do
|
||||
@user = create(:user, username: "Manuela Colau")
|
||||
login_as(@user)
|
||||
login_as(user)
|
||||
end
|
||||
|
||||
scenario "Show" do
|
||||
@@ -19,7 +19,7 @@ describe "Account" do
|
||||
end
|
||||
|
||||
scenario "Show organization" do
|
||||
create(:organization, user: @user, name: "Manuela Corp")
|
||||
create(:organization, user: user, name: "Manuela Corp")
|
||||
|
||||
visit account_path
|
||||
|
||||
@@ -85,7 +85,7 @@ describe "Account" do
|
||||
end
|
||||
|
||||
scenario "Edit Organization" do
|
||||
create(:organization, user: @user, name: "Manuela Corp")
|
||||
create(:organization, user: user, name: "Manuela Corp")
|
||||
visit account_path
|
||||
|
||||
fill_in "account_organization_attributes_name", with: "Google"
|
||||
@@ -170,7 +170,7 @@ describe "Account" do
|
||||
|
||||
expect(page).to have_content "Goodbye! Your account has been cancelled. We hope to see you again soon."
|
||||
|
||||
login_through_form_as(@user)
|
||||
login_through_form_as(user)
|
||||
|
||||
expect(page).to have_content "Invalid Email or username or password"
|
||||
end
|
||||
@@ -203,10 +203,10 @@ describe "Account" do
|
||||
expect(find("#account_recommended_debates")).not_to be_checked
|
||||
expect(find("#account_recommended_proposals")).not_to be_checked
|
||||
|
||||
@user.reload
|
||||
user.reload
|
||||
|
||||
expect(@user.recommended_debates).to be(false)
|
||||
expect(@user.recommended_proposals).to be(false)
|
||||
expect(user.recommended_debates).to be(false)
|
||||
expect(user.recommended_proposals).to be(false)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe "Admin activity" do
|
||||
let(:admin) { create(:administrator) }
|
||||
|
||||
before do
|
||||
@admin = create(:administrator)
|
||||
login_as(@admin.user)
|
||||
login_as(admin.user)
|
||||
end
|
||||
|
||||
context "Proposals" do
|
||||
@@ -23,7 +23,7 @@ describe "Admin activity" do
|
||||
within("#activity_#{Activity.last.id}") do
|
||||
expect(page).to have_content(proposal.title)
|
||||
expect(page).to have_content("Hidden")
|
||||
expect(page).to have_content(@admin.user.username)
|
||||
expect(page).to have_content(admin.user.username)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -65,7 +65,7 @@ describe "Admin activity" do
|
||||
within("#activity_#{Activity.last.id}") do
|
||||
expect(page).to have_content(proposal.title)
|
||||
expect(page).to have_content("Restored")
|
||||
expect(page).to have_content(@admin.user.username)
|
||||
expect(page).to have_content(admin.user.username)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -86,7 +86,7 @@ describe "Admin activity" do
|
||||
within("#activity_#{Activity.last.id}") do
|
||||
expect(page).to have_content(debate.title)
|
||||
expect(page).to have_content("Hidden")
|
||||
expect(page).to have_content(@admin.user.username)
|
||||
expect(page).to have_content(admin.user.username)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -128,7 +128,7 @@ describe "Admin activity" do
|
||||
within("#activity_#{Activity.last.id}") do
|
||||
expect(page).to have_content(debate.title)
|
||||
expect(page).to have_content("Restored")
|
||||
expect(page).to have_content(@admin.user.username)
|
||||
expect(page).to have_content(admin.user.username)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -150,7 +150,7 @@ describe "Admin activity" do
|
||||
within("#activity_#{Activity.last.id}") do
|
||||
expect(page).to have_content(comment.body)
|
||||
expect(page).to have_content("Hidden")
|
||||
expect(page).to have_content(@admin.user.username)
|
||||
expect(page).to have_content(admin.user.username)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -192,7 +192,7 @@ describe "Admin activity" do
|
||||
within("#activity_#{Activity.last.id}") do
|
||||
expect(page).to have_content(comment.body)
|
||||
expect(page).to have_content("Restored")
|
||||
expect(page).to have_content(@admin.user.username)
|
||||
expect(page).to have_content(admin.user.username)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -215,7 +215,7 @@ describe "Admin activity" do
|
||||
expect(page).to have_content("Blocked")
|
||||
expect(page).to have_content(proposal.author.username)
|
||||
expect(page).to have_content(proposal.author.email)
|
||||
expect(page).to have_content(@admin.user.username)
|
||||
expect(page).to have_content(admin.user.username)
|
||||
expect(page).not_to have_content(proposal.title)
|
||||
end
|
||||
end
|
||||
@@ -234,7 +234,7 @@ describe "Admin activity" do
|
||||
within("#activity_#{Activity.last.id}") do
|
||||
expect(page).to have_content(user.username)
|
||||
expect(page).to have_content(user.email)
|
||||
expect(page).to have_content(@admin.user.username)
|
||||
expect(page).to have_content(admin.user.username)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -331,7 +331,7 @@ describe "Admin activity" do
|
||||
expect(page).to have_content(user.username)
|
||||
expect(page).to have_content(user.email)
|
||||
expect(page).to have_content("Restored")
|
||||
expect(page).to have_content(@admin.user.username)
|
||||
expect(page).to have_content(admin.user.username)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -342,14 +342,14 @@ describe "Admin activity" do
|
||||
proposal_notification = create(:proposal_notification, proposal: proposal,
|
||||
title: "Proposal A Title",
|
||||
body: "Proposal A Notification Body")
|
||||
proposal_notification.moderate_system_email(@admin.user)
|
||||
proposal_notification.moderate_system_email(admin.user)
|
||||
|
||||
visit admin_activity_path
|
||||
|
||||
within("#activity_#{Activity.last.id}") do
|
||||
expect(page).to have_content(proposal_notification.title)
|
||||
expect(page).to have_content("Hidden")
|
||||
expect(page).to have_content(@admin.user.username)
|
||||
expect(page).to have_content(admin.user.username)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -12,8 +12,7 @@ describe "Admin budget investments" do
|
||||
"admin_budget_budget_investment_path"
|
||||
|
||||
before do
|
||||
@admin = create(:administrator)
|
||||
login_as(@admin.user)
|
||||
login_as(create(:administrator).user)
|
||||
end
|
||||
|
||||
context "Feature flag" do
|
||||
|
||||
@@ -7,10 +7,8 @@ describe "Admin change log" do
|
||||
end
|
||||
|
||||
context "Investments Participatory Budgets" do
|
||||
|
||||
before do
|
||||
@admin = create(:administrator)
|
||||
login_as(@admin.user)
|
||||
login_as(create(:administrator).user)
|
||||
end
|
||||
|
||||
scenario "No changes" do
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe "Admin managers" do
|
||||
let!(:user) { create(:user) }
|
||||
let!(:manager) { create(:manager) }
|
||||
|
||||
before do
|
||||
@admin = create(:administrator)
|
||||
@user = create(:user)
|
||||
@manager = create(:manager)
|
||||
login_as(@admin.user)
|
||||
login_as(create(:administrator).user)
|
||||
visit admin_managers_path
|
||||
end
|
||||
|
||||
scenario "Index" do
|
||||
expect(page).to have_content @manager.name
|
||||
expect(page).to have_content @manager.email
|
||||
expect(page).not_to have_content @user.name
|
||||
expect(page).to have_content manager.name
|
||||
expect(page).to have_content manager.email
|
||||
expect(page).not_to have_content user.name
|
||||
end
|
||||
|
||||
scenario "Create Manager", :js do
|
||||
fill_in "name_or_email", with: @user.email
|
||||
fill_in "name_or_email", with: user.email
|
||||
click_button "Search"
|
||||
|
||||
expect(page).to have_content @user.name
|
||||
expect(page).to have_content user.name
|
||||
click_link "Add"
|
||||
within("#managers") do
|
||||
expect(page).to have_content @user.name
|
||||
expect(page).to have_content user.name
|
||||
end
|
||||
end
|
||||
|
||||
@@ -30,55 +30,55 @@ describe "Admin managers" do
|
||||
click_link "Delete"
|
||||
|
||||
within("#managers") do
|
||||
expect(page).not_to have_content @manager.name
|
||||
expect(page).not_to have_content manager.name
|
||||
end
|
||||
end
|
||||
|
||||
context "Search" do
|
||||
let(:user) { create(:user, username: "Taylor Swift", email: "taylor@swift.com") }
|
||||
let(:user2) { create(:user, username: "Stephanie Corneliussen", email: "steph@mrrobot.com") }
|
||||
let!(:manager1) { create(:manager, user: user) }
|
||||
let!(:manager2) { create(:manager, user: user2) }
|
||||
|
||||
before do
|
||||
user = create(:user, username: "Taylor Swift", email: "taylor@swift.com")
|
||||
user2 = create(:user, username: "Stephanie Corneliussen", email: "steph@mrrobot.com")
|
||||
@manager1 = create(:manager, user: user)
|
||||
@manager2 = create(:manager, user: user2)
|
||||
visit admin_managers_path
|
||||
end
|
||||
|
||||
scenario "returns no results if search term is empty" do
|
||||
expect(page).to have_content(@manager1.name)
|
||||
expect(page).to have_content(@manager2.name)
|
||||
expect(page).to have_content(manager1.name)
|
||||
expect(page).to have_content(manager2.name)
|
||||
|
||||
fill_in "name_or_email", with: " "
|
||||
click_button "Search"
|
||||
|
||||
expect(page).to have_content("Managers: User search")
|
||||
expect(page).to have_content("No results found")
|
||||
expect(page).not_to have_content(@manager1.name)
|
||||
expect(page).not_to have_content(@manager2.name)
|
||||
expect(page).not_to have_content(manager1.name)
|
||||
expect(page).not_to have_content(manager2.name)
|
||||
end
|
||||
|
||||
scenario "search by name" do
|
||||
expect(page).to have_content(@manager1.name)
|
||||
expect(page).to have_content(@manager2.name)
|
||||
expect(page).to have_content(manager1.name)
|
||||
expect(page).to have_content(manager2.name)
|
||||
|
||||
fill_in "name_or_email", with: "Taylor"
|
||||
click_button "Search"
|
||||
|
||||
expect(page).to have_content("Managers: User search")
|
||||
expect(page).to have_content(@manager1.name)
|
||||
expect(page).not_to have_content(@manager2.name)
|
||||
expect(page).to have_content(manager1.name)
|
||||
expect(page).not_to have_content(manager2.name)
|
||||
end
|
||||
|
||||
scenario "search by email" do
|
||||
expect(page).to have_content(@manager1.email)
|
||||
expect(page).to have_content(@manager2.email)
|
||||
expect(page).to have_content(manager1.email)
|
||||
expect(page).to have_content(manager2.email)
|
||||
|
||||
fill_in "name_or_email", with: @manager2.email
|
||||
fill_in "name_or_email", with: manager2.email
|
||||
click_button "Search"
|
||||
|
||||
expect(page).to have_content("Managers: User search")
|
||||
expect(page).to have_content(@manager2.email)
|
||||
expect(page).not_to have_content(@manager1.email)
|
||||
expect(page).to have_content(manager2.email)
|
||||
expect(page).not_to have_content(manager1.email)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe "Admin moderators" do
|
||||
let!(:user) { create(:user, username: "Jose Luis Balbin") }
|
||||
let!(:moderator) { create(:moderator) }
|
||||
|
||||
before do
|
||||
@admin = create(:administrator)
|
||||
@user = create(:user, username: "Jose Luis Balbin")
|
||||
@moderator = create(:moderator)
|
||||
login_as(@admin.user)
|
||||
login_as(create(:administrator).user)
|
||||
visit admin_moderators_path
|
||||
end
|
||||
|
||||
scenario "Index" do
|
||||
expect(page).to have_content @moderator.name
|
||||
expect(page).to have_content @moderator.email
|
||||
expect(page).not_to have_content @user.name
|
||||
expect(page).to have_content moderator.name
|
||||
expect(page).to have_content moderator.email
|
||||
expect(page).not_to have_content user.name
|
||||
end
|
||||
|
||||
scenario "Create Moderator", :js do
|
||||
fill_in "name_or_email", with: @user.email
|
||||
fill_in "name_or_email", with: user.email
|
||||
click_button "Search"
|
||||
|
||||
expect(page).to have_content @user.name
|
||||
expect(page).to have_content user.name
|
||||
click_link "Add"
|
||||
within("#moderators") do
|
||||
expect(page).to have_content @user.name
|
||||
expect(page).to have_content user.name
|
||||
end
|
||||
end
|
||||
|
||||
@@ -30,55 +30,55 @@ describe "Admin moderators" do
|
||||
click_link "Delete"
|
||||
|
||||
within("#moderators") do
|
||||
expect(page).not_to have_content @moderator.name
|
||||
expect(page).not_to have_content moderator.name
|
||||
end
|
||||
end
|
||||
|
||||
context "Search" do
|
||||
let(:user) { create(:user, username: "Elizabeth Bathory", email: "elizabeth@bathory.com") }
|
||||
let(:user2) { create(:user, username: "Ada Lovelace", email: "ada@lovelace.com") }
|
||||
let!(:moderator1) { create(:moderator, user: user) }
|
||||
let!(:moderator2) { create(:moderator, user: user2) }
|
||||
|
||||
before do
|
||||
user = create(:user, username: "Elizabeth Bathory", email: "elizabeth@bathory.com")
|
||||
user2 = create(:user, username: "Ada Lovelace", email: "ada@lovelace.com")
|
||||
@moderator1 = create(:moderator, user: user)
|
||||
@moderator2 = create(:moderator, user: user2)
|
||||
visit admin_moderators_path
|
||||
end
|
||||
|
||||
scenario "returns no results if search term is empty" do
|
||||
expect(page).to have_content(@moderator1.name)
|
||||
expect(page).to have_content(@moderator2.name)
|
||||
expect(page).to have_content(moderator1.name)
|
||||
expect(page).to have_content(moderator2.name)
|
||||
|
||||
fill_in "name_or_email", with: " "
|
||||
click_button "Search"
|
||||
|
||||
expect(page).to have_content("Moderators: User search")
|
||||
expect(page).to have_content("No results found")
|
||||
expect(page).not_to have_content(@moderator1.name)
|
||||
expect(page).not_to have_content(@moderator2.name)
|
||||
expect(page).not_to have_content(moderator1.name)
|
||||
expect(page).not_to have_content(moderator2.name)
|
||||
end
|
||||
|
||||
scenario "search by name" do
|
||||
expect(page).to have_content(@moderator1.name)
|
||||
expect(page).to have_content(@moderator2.name)
|
||||
expect(page).to have_content(moderator1.name)
|
||||
expect(page).to have_content(moderator2.name)
|
||||
|
||||
fill_in "name_or_email", with: "Eliz"
|
||||
click_button "Search"
|
||||
|
||||
expect(page).to have_content("Moderators: User search")
|
||||
expect(page).to have_content(@moderator1.name)
|
||||
expect(page).not_to have_content(@moderator2.name)
|
||||
expect(page).to have_content(moderator1.name)
|
||||
expect(page).not_to have_content(moderator2.name)
|
||||
end
|
||||
|
||||
scenario "search by email" do
|
||||
expect(page).to have_content(@moderator1.email)
|
||||
expect(page).to have_content(@moderator2.email)
|
||||
expect(page).to have_content(moderator1.email)
|
||||
expect(page).to have_content(moderator2.email)
|
||||
|
||||
fill_in "name_or_email", with: @moderator2.email
|
||||
fill_in "name_or_email", with: moderator2.email
|
||||
click_button "Search"
|
||||
|
||||
expect(page).to have_content("Moderators: User search")
|
||||
expect(page).to have_content(@moderator2.email)
|
||||
expect(page).not_to have_content(@moderator1.email)
|
||||
expect(page).to have_content(moderator2.email)
|
||||
expect(page).not_to have_content(moderator1.email)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,32 +1,31 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe "Admin officials" do
|
||||
let!(:citizen) { create(:user, username: "Citizen Kane") }
|
||||
let!(:official) { create(:user, official_position: "Mayor", official_level: 5) }
|
||||
|
||||
before do
|
||||
@citizen = create(:user, username: "Citizen Kane")
|
||||
@official = create(:user, official_position: "Mayor", official_level: 5)
|
||||
@admin = create(:administrator)
|
||||
login_as(@admin.user)
|
||||
login_as(create(:administrator).user)
|
||||
end
|
||||
|
||||
scenario "Index" do
|
||||
visit admin_officials_path
|
||||
|
||||
expect(page).to have_content @official.name
|
||||
expect(page).not_to have_content @citizen.name
|
||||
expect(page).to have_content @official.official_position
|
||||
expect(page).to have_content @official.official_level
|
||||
expect(page).to have_content official.name
|
||||
expect(page).not_to have_content citizen.name
|
||||
expect(page).to have_content official.official_position
|
||||
expect(page).to have_content official.official_level
|
||||
end
|
||||
|
||||
scenario "Edit an official" do
|
||||
visit admin_officials_path
|
||||
click_link @official.name
|
||||
click_link official.name
|
||||
|
||||
expect(page).to have_current_path(edit_admin_official_path(@official))
|
||||
expect(page).to have_current_path(edit_admin_official_path(official))
|
||||
|
||||
expect(page).not_to have_content @citizen.name
|
||||
expect(page).to have_content @official.name
|
||||
expect(page).to have_content @official.email
|
||||
expect(page).not_to have_content citizen.name
|
||||
expect(page).to have_content official.name
|
||||
expect(page).to have_content official.email
|
||||
|
||||
fill_in "user_official_position", with: "School Teacher"
|
||||
select "3", from: "user_official_level", exact: false
|
||||
@@ -36,20 +35,20 @@ describe "Admin officials" do
|
||||
|
||||
visit admin_officials_path
|
||||
|
||||
expect(page).to have_content @official.name
|
||||
expect(page).to have_content official.name
|
||||
expect(page).to have_content "School Teacher"
|
||||
expect(page).to have_content "3"
|
||||
end
|
||||
|
||||
scenario "Create an official" do
|
||||
visit admin_officials_path
|
||||
fill_in "name_or_email", with: @citizen.email
|
||||
fill_in "name_or_email", with: citizen.email
|
||||
click_button "Search"
|
||||
|
||||
expect(page).to have_current_path(search_admin_officials_path, ignore_query: true)
|
||||
expect(page).not_to have_content @official.name
|
||||
expect(page).not_to have_content official.name
|
||||
|
||||
click_link @citizen.name
|
||||
click_link citizen.name
|
||||
|
||||
fill_in "user_official_position", with: "Hospital manager"
|
||||
select "4", from: "user_official_level", exact: false
|
||||
@@ -59,20 +58,20 @@ describe "Admin officials" do
|
||||
|
||||
visit admin_officials_path
|
||||
|
||||
expect(page).to have_content @official.name
|
||||
expect(page).to have_content @citizen.name
|
||||
expect(page).to have_content official.name
|
||||
expect(page).to have_content citizen.name
|
||||
expect(page).to have_content "Hospital manager"
|
||||
expect(page).to have_content "4"
|
||||
end
|
||||
|
||||
scenario "Destroy" do
|
||||
visit edit_admin_official_path(@official)
|
||||
visit edit_admin_official_path(official)
|
||||
|
||||
click_link 'Remove "Official" status'
|
||||
|
||||
expect(page).to have_content "Details saved: the user is no longer an official"
|
||||
expect(page).to have_current_path(admin_officials_path, ignore_query: true)
|
||||
expect(page).not_to have_content @citizen.name
|
||||
expect(page).not_to have_content @official.name
|
||||
expect(page).not_to have_content citizen.name
|
||||
expect(page).not_to have_content official.name
|
||||
end
|
||||
end
|
||||
|
||||
@@ -27,10 +27,10 @@ describe "Admin::Organizations" do
|
||||
end
|
||||
|
||||
context "Search" do
|
||||
let(:user) { create(:user, email: "marley@humanrights.com", phone_number: "6764440002") }
|
||||
|
||||
before do
|
||||
@user = create(:user, email: "marley@humanrights.com", phone_number: "6764440002")
|
||||
create(:organization, user: @user, name: "Get up, Stand up")
|
||||
create(:organization, user: user, name: "Get up, Stand up")
|
||||
end
|
||||
|
||||
scenario "returns no results if search term is empty" do
|
||||
@@ -62,7 +62,7 @@ describe "Admin::Organizations" do
|
||||
visit search_admin_organizations_path
|
||||
expect(page).not_to have_content("Get up, Stand up")
|
||||
|
||||
fill_in "term", with: @user.email
|
||||
fill_in "term", with: user.email
|
||||
click_button "Search"
|
||||
|
||||
within("#search-results") do
|
||||
@@ -74,7 +74,7 @@ describe "Admin::Organizations" do
|
||||
visit search_admin_organizations_path
|
||||
expect(page).not_to have_content("Get up, Stand up")
|
||||
|
||||
fill_in "term", with: @user.phone_number
|
||||
fill_in "term", with: user.phone_number
|
||||
click_button "Search"
|
||||
|
||||
within("#search-results") do
|
||||
|
||||
@@ -1,29 +1,28 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe "Admin poll officers" do
|
||||
let!(:user) { create(:user, username: "Pedro Jose Garcia") }
|
||||
let!(:officer) { create(:poll_officer) }
|
||||
|
||||
before do
|
||||
@admin = create(:administrator)
|
||||
@user = create(:user, username: "Pedro Jose Garcia")
|
||||
@officer = create(:poll_officer)
|
||||
login_as(@admin.user)
|
||||
login_as(create(:administrator).user)
|
||||
visit admin_officers_path
|
||||
end
|
||||
|
||||
scenario "Index" do
|
||||
expect(page).to have_content @officer.name
|
||||
expect(page).to have_content @officer.email
|
||||
expect(page).not_to have_content @user.name
|
||||
expect(page).to have_content officer.name
|
||||
expect(page).to have_content officer.email
|
||||
expect(page).not_to have_content user.name
|
||||
end
|
||||
|
||||
scenario "Create", :js do
|
||||
fill_in "email", with: @user.email
|
||||
fill_in "email", with: user.email
|
||||
click_button "Search"
|
||||
|
||||
expect(page).to have_content @user.name
|
||||
expect(page).to have_content user.name
|
||||
click_link "Add"
|
||||
within("#officers") do
|
||||
expect(page).to have_content @user.name
|
||||
expect(page).to have_content user.name
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -100,21 +100,19 @@ describe "Stats" do
|
||||
describe "Budget investments" do
|
||||
|
||||
context "Supporting phase" do
|
||||
before do
|
||||
@budget = create(:budget)
|
||||
@group_all_city = create(:budget_group, budget: @budget)
|
||||
@heading_all_city = create(:budget_heading, group: @group_all_city)
|
||||
end
|
||||
let(:budget) { create(:budget) }
|
||||
let(:group_all_city) { create(:budget_group, budget: budget) }
|
||||
let!(:heading_all_city) { create(:budget_heading, group: group_all_city) }
|
||||
|
||||
scenario "Number of supports in investment projects" do
|
||||
group_2 = create(:budget_group, budget: @budget)
|
||||
group_2 = create(:budget_group, budget: budget)
|
||||
|
||||
create(:budget_investment, heading: create(:budget_heading, group: group_2), voters: [create(:user)])
|
||||
create(:budget_investment, heading: @heading_all_city, voters: [create(:user), create(:user)])
|
||||
create(:budget_investment, heading: heading_all_city, voters: [create(:user), create(:user)])
|
||||
|
||||
visit admin_stats_path
|
||||
click_link "Participatory Budgets"
|
||||
within("#budget_#{@budget.id}") do
|
||||
within("#budget_#{budget.id}") do
|
||||
click_link "Supporting phase"
|
||||
end
|
||||
|
||||
@@ -122,9 +120,9 @@ describe "Stats" do
|
||||
end
|
||||
|
||||
scenario "Number of users that have supported an investment project" do
|
||||
group_2 = create(:budget_group, budget: @budget)
|
||||
group_2 = create(:budget_group, budget: budget)
|
||||
investment1 = create(:budget_investment, heading: create(:budget_heading, group: group_2))
|
||||
investment2 = create(:budget_investment, heading: @heading_all_city)
|
||||
investment2 = create(:budget_investment, heading: heading_all_city)
|
||||
|
||||
create(:user, :level_two, votables: [investment1, investment2])
|
||||
create(:user, :level_two, votables: [investment1])
|
||||
@@ -132,7 +130,7 @@ describe "Stats" do
|
||||
|
||||
visit admin_stats_path
|
||||
click_link "Participatory Budgets"
|
||||
within("#budget_#{@budget.id}") do
|
||||
within("#budget_#{budget.id}") do
|
||||
click_link "Supporting phase"
|
||||
end
|
||||
|
||||
@@ -179,35 +177,33 @@ describe "Stats" do
|
||||
visit admin_stats_path
|
||||
click_link "Participatory Budgets"
|
||||
|
||||
within("#budget_#{@budget.id}") do
|
||||
within("#budget_#{budget.id}") do
|
||||
expect(page).not_to have_link "Final voting"
|
||||
end
|
||||
end
|
||||
|
||||
scenario "show message when accessing final voting stats" do
|
||||
visit budget_balloting_admin_stats_path(budget_id: @budget.id)
|
||||
visit budget_balloting_admin_stats_path(budget_id: budget.id)
|
||||
|
||||
expect(page).to have_content "There isn't any data to show before the balloting phase."
|
||||
end
|
||||
end
|
||||
|
||||
context "Balloting phase" do
|
||||
before do
|
||||
@budget = create(:budget, :balloting)
|
||||
@group = create(:budget_group, budget: @budget)
|
||||
@heading = create(:budget_heading, group: @group)
|
||||
@investment = create(:budget_investment, :feasible, :selected, heading: @heading)
|
||||
end
|
||||
let(:budget) { create(:budget, :balloting) }
|
||||
let(:group) { create(:budget_group, budget: budget) }
|
||||
let(:heading) { create(:budget_heading, group: group) }
|
||||
let!(:investment) { create(:budget_investment, :feasible, :selected, heading: heading) }
|
||||
|
||||
scenario "Number of votes in investment projects" do
|
||||
investment_2 = create(:budget_investment, :feasible, :selected, budget: @budget)
|
||||
investment_2 = create(:budget_investment, :feasible, :selected, budget: budget)
|
||||
|
||||
create(:user, ballot_lines: [@investment, investment_2])
|
||||
create(:user, ballot_lines: [investment, investment_2])
|
||||
create(:user, ballot_lines: [investment_2])
|
||||
|
||||
visit admin_stats_path
|
||||
click_link "Participatory Budgets"
|
||||
within("#budget_#{@budget.id}") do
|
||||
within("#budget_#{budget.id}") do
|
||||
click_link "Final voting"
|
||||
end
|
||||
|
||||
@@ -215,13 +211,13 @@ describe "Stats" do
|
||||
end
|
||||
|
||||
scenario "Number of users that have voted a investment project" do
|
||||
create(:user, ballot_lines: [@investment])
|
||||
create(:user, ballot_lines: [@investment])
|
||||
create(:user, ballot_lines: [investment])
|
||||
create(:user, ballot_lines: [investment])
|
||||
create(:user)
|
||||
|
||||
visit admin_stats_path
|
||||
click_link "Participatory Budgets"
|
||||
within("#budget_#{@budget.id}") do
|
||||
within("#budget_#{budget.id}") do
|
||||
click_link "Final voting"
|
||||
end
|
||||
|
||||
|
||||
@@ -1,33 +1,34 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe "Admin users" do
|
||||
let(:admin) { create(:administrator) }
|
||||
let!(:user) { create(:user, username: "Jose Luis Balbin") }
|
||||
|
||||
before do
|
||||
@admin = create(:administrator)
|
||||
@user = create(:user, username: "Jose Luis Balbin")
|
||||
login_as(@admin.user)
|
||||
login_as(admin.user)
|
||||
visit admin_users_path
|
||||
end
|
||||
|
||||
scenario "Index" do
|
||||
expect(page).to have_link @user.name
|
||||
expect(page).to have_content @user.email
|
||||
expect(page).to have_content @admin.name
|
||||
expect(page).to have_content @admin.email
|
||||
expect(page).to have_link user.name
|
||||
expect(page).to have_content user.email
|
||||
expect(page).to have_content admin.name
|
||||
expect(page).to have_content admin.email
|
||||
end
|
||||
|
||||
scenario "The username links to their public profile" do
|
||||
click_link @user.name
|
||||
click_link user.name
|
||||
|
||||
expect(page).to have_current_path(user_path(@user))
|
||||
expect(page).to have_current_path(user_path(user))
|
||||
end
|
||||
|
||||
scenario "Search" do
|
||||
fill_in :search, with: "Luis"
|
||||
click_button "Search"
|
||||
|
||||
expect(page).to have_content @user.name
|
||||
expect(page).to have_content @user.email
|
||||
expect(page).not_to have_content @admin.name
|
||||
expect(page).not_to have_content @admin.email
|
||||
expect(page).to have_content user.name
|
||||
expect(page).to have_content user.email
|
||||
expect(page).not_to have_content admin.name
|
||||
expect(page).not_to have_content admin.email
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,42 +1,40 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe "Email campaigns" do
|
||||
let(:campaign1) { create(:campaign) }
|
||||
let(:campaign2) { create(:campaign) }
|
||||
|
||||
before do
|
||||
@campaign1 = create(:campaign)
|
||||
@campaign2 = create(:campaign)
|
||||
|
||||
admin = create(:administrator)
|
||||
login_as(admin.user)
|
||||
login_as(create(:administrator).user)
|
||||
end
|
||||
|
||||
scenario "Track email templates" do
|
||||
3.times { visit root_url(track_id: @campaign1.track_id) }
|
||||
5.times { visit root_url(track_id: @campaign2.track_id) }
|
||||
3.times { visit root_url(track_id: campaign1.track_id) }
|
||||
5.times { visit root_url(track_id: campaign2.track_id) }
|
||||
|
||||
visit admin_stats_path
|
||||
click_link @campaign1.name
|
||||
click_link campaign1.name
|
||||
|
||||
expect(page).to have_content "#{@campaign1.name} (3)"
|
||||
expect(page).to have_content "#{campaign1.name} (3)"
|
||||
|
||||
click_link "Go back"
|
||||
click_link @campaign2.name
|
||||
click_link campaign2.name
|
||||
|
||||
expect(page).to have_content "#{@campaign2.name} (5)"
|
||||
expect(page).to have_content "#{campaign2.name} (5)"
|
||||
end
|
||||
|
||||
scenario "Do not track erroneous track_ids" do
|
||||
visit root_url(track_id: @campaign1.track_id)
|
||||
visit root_url(track_id: campaign1.track_id)
|
||||
visit root_url(track_id: "999")
|
||||
|
||||
visit admin_stats_path
|
||||
click_link @campaign1.name
|
||||
click_link campaign1.name
|
||||
|
||||
expect(page).to have_content "#{@campaign1.name} (1)"
|
||||
expect(page).to have_content "#{campaign1.name} (1)"
|
||||
|
||||
click_link "Go back"
|
||||
|
||||
expect(page).not_to have_content @campaign2.name.to_s
|
||||
expect(page).not_to have_content campaign2.name.to_s
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -500,24 +500,24 @@ describe "Commenting Budget::Investments" do
|
||||
end
|
||||
|
||||
describe "Voting comments" do
|
||||
let(:verified) { create(:user, verified_at: Time.current) }
|
||||
let(:unverified) { create(:user) }
|
||||
let(:budget) { create(:budget) }
|
||||
let(:investment) { create(:budget_investment, budget: budget) }
|
||||
let!(:comment) { create(:comment, commentable: investment) }
|
||||
|
||||
before do
|
||||
@manuela = create(:user, verified_at: Time.current)
|
||||
@pablo = create(:user)
|
||||
@investment = create(:budget_investment)
|
||||
@comment = create(:comment, commentable: @investment)
|
||||
@budget = @investment.budget
|
||||
|
||||
login_as(@manuela)
|
||||
login_as(verified)
|
||||
end
|
||||
|
||||
scenario "Show" do
|
||||
create(:vote, voter: @manuela, votable: @comment, vote_flag: true)
|
||||
create(:vote, voter: @pablo, votable: @comment, vote_flag: false)
|
||||
create(:vote, voter: verified, votable: comment, vote_flag: true)
|
||||
create(:vote, voter: unverified, votable: comment, vote_flag: false)
|
||||
|
||||
visit budget_investment_path(@budget, @budget, @investment)
|
||||
visit budget_investment_path(budget, investment)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
within("#comment_#{comment.id}_votes") do
|
||||
within(".in_favor") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
@@ -531,9 +531,9 @@ describe "Commenting Budget::Investments" do
|
||||
end
|
||||
|
||||
scenario "Create", :js do
|
||||
visit budget_investment_path(@budget, @investment)
|
||||
visit budget_investment_path(budget, investment)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
within("#comment_#{comment.id}_votes") do
|
||||
find(".in_favor a").click
|
||||
|
||||
within(".in_favor") do
|
||||
@@ -549,9 +549,9 @@ describe "Commenting Budget::Investments" do
|
||||
end
|
||||
|
||||
scenario "Update", :js do
|
||||
visit budget_investment_path(@budget, @investment)
|
||||
visit budget_investment_path(budget, investment)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
within("#comment_#{comment.id}_votes") do
|
||||
find(".in_favor a").click
|
||||
|
||||
within(".in_favor") do
|
||||
@@ -573,9 +573,9 @@ describe "Commenting Budget::Investments" do
|
||||
end
|
||||
|
||||
scenario "Trying to vote multiple times", :js do
|
||||
visit budget_investment_path(@budget, @investment)
|
||||
visit budget_investment_path(budget, investment)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
within("#comment_#{comment.id}_votes") do
|
||||
find(".in_favor a").click
|
||||
find(".in_favor a").click
|
||||
|
||||
|
||||
@@ -445,22 +445,22 @@ describe "Commenting debates" do
|
||||
end
|
||||
|
||||
describe "Voting comments" do
|
||||
before do
|
||||
@manuela = create(:user, verified_at: Time.current)
|
||||
@pablo = create(:user)
|
||||
@debate = create(:debate)
|
||||
@comment = create(:comment, commentable: @debate)
|
||||
let(:verified) { create(:user, verified_at: Time.current) }
|
||||
let(:unverified) { create(:user) }
|
||||
let(:debate) { create(:debate) }
|
||||
let!(:comment) { create(:comment, commentable: debate) }
|
||||
|
||||
login_as(@manuela)
|
||||
before do
|
||||
login_as(verified)
|
||||
end
|
||||
|
||||
scenario "Show" do
|
||||
create(:vote, voter: @manuela, votable: @comment, vote_flag: true)
|
||||
create(:vote, voter: @pablo, votable: @comment, vote_flag: false)
|
||||
create(:vote, voter: verified, votable: comment, vote_flag: true)
|
||||
create(:vote, voter: unverified, votable: comment, vote_flag: false)
|
||||
|
||||
visit debate_path(@debate)
|
||||
visit debate_path(debate)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
within("#comment_#{comment.id}_votes") do
|
||||
within(".in_favor") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
@@ -474,9 +474,9 @@ describe "Commenting debates" do
|
||||
end
|
||||
|
||||
scenario "Create", :js do
|
||||
visit debate_path(@debate)
|
||||
visit debate_path(debate)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
within("#comment_#{comment.id}_votes") do
|
||||
find(".in_favor a").click
|
||||
|
||||
within(".in_favor") do
|
||||
@@ -492,9 +492,9 @@ describe "Commenting debates" do
|
||||
end
|
||||
|
||||
scenario "Update", :js do
|
||||
visit debate_path(@debate)
|
||||
visit debate_path(debate)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
within("#comment_#{comment.id}_votes") do
|
||||
find(".in_favor a").click
|
||||
|
||||
within(".in_favor") do
|
||||
@@ -516,9 +516,9 @@ describe "Commenting debates" do
|
||||
end
|
||||
|
||||
scenario "Trying to vote multiple times", :js do
|
||||
visit debate_path(@debate)
|
||||
visit debate_path(debate)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
within("#comment_#{comment.id}_votes") do
|
||||
find(".in_favor a").click
|
||||
within(".in_favor") do
|
||||
expect(page).to have_content "1"
|
||||
|
||||
@@ -517,24 +517,24 @@ describe "Commenting legislation questions" do
|
||||
end
|
||||
|
||||
describe "Voting comments" do
|
||||
before do
|
||||
@manuela = create(:user, verified_at: Time.current)
|
||||
@pablo = create(:user)
|
||||
@legislation_annotation = create(:legislation_annotation)
|
||||
@comment = create(:comment, commentable: @legislation_annotation)
|
||||
let(:verified) { create(:user, verified_at: Time.current) }
|
||||
let(:unverified) { create(:user) }
|
||||
let(:annotation) { create(:legislation_annotation) }
|
||||
let!(:comment) { create(:comment, commentable: annotation) }
|
||||
|
||||
login_as(@manuela)
|
||||
before do
|
||||
login_as(verified)
|
||||
end
|
||||
|
||||
scenario "Show" do
|
||||
create(:vote, voter: @manuela, votable: @comment, vote_flag: true)
|
||||
create(:vote, voter: @pablo, votable: @comment, vote_flag: false)
|
||||
create(:vote, voter: verified, votable: comment, vote_flag: true)
|
||||
create(:vote, voter: unverified, votable: comment, vote_flag: false)
|
||||
|
||||
visit legislation_process_draft_version_annotation_path(@legislation_annotation.draft_version.process,
|
||||
@legislation_annotation.draft_version,
|
||||
@legislation_annotation)
|
||||
visit legislation_process_draft_version_annotation_path(annotation.draft_version.process,
|
||||
annotation.draft_version,
|
||||
annotation)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
within("#comment_#{comment.id}_votes") do
|
||||
within(".in_favor") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
@@ -548,11 +548,11 @@ describe "Commenting legislation questions" do
|
||||
end
|
||||
|
||||
scenario "Create", :js do
|
||||
visit legislation_process_draft_version_annotation_path(@legislation_annotation.draft_version.process,
|
||||
@legislation_annotation.draft_version,
|
||||
@legislation_annotation)
|
||||
visit legislation_process_draft_version_annotation_path(annotation.draft_version.process,
|
||||
annotation.draft_version,
|
||||
annotation)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
within("#comment_#{comment.id}_votes") do
|
||||
find(".in_favor a").click
|
||||
|
||||
within(".in_favor") do
|
||||
@@ -568,11 +568,11 @@ describe "Commenting legislation questions" do
|
||||
end
|
||||
|
||||
scenario "Update", :js do
|
||||
visit legislation_process_draft_version_annotation_path(@legislation_annotation.draft_version.process,
|
||||
@legislation_annotation.draft_version,
|
||||
@legislation_annotation)
|
||||
visit legislation_process_draft_version_annotation_path(annotation.draft_version.process,
|
||||
annotation.draft_version,
|
||||
annotation)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
within("#comment_#{comment.id}_votes") do
|
||||
find(".in_favor a").click
|
||||
|
||||
within(".in_favor") do
|
||||
@@ -594,11 +594,11 @@ describe "Commenting legislation questions" do
|
||||
end
|
||||
|
||||
scenario "Trying to vote multiple times", :js do
|
||||
visit legislation_process_draft_version_annotation_path(@legislation_annotation.draft_version.process,
|
||||
@legislation_annotation.draft_version,
|
||||
@legislation_annotation)
|
||||
visit legislation_process_draft_version_annotation_path(annotation.draft_version.process,
|
||||
annotation.draft_version,
|
||||
annotation)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
within("#comment_#{comment.id}_votes") do
|
||||
find(".in_favor a").click
|
||||
within(".in_favor") do
|
||||
expect(page).to have_content "1"
|
||||
|
||||
@@ -468,22 +468,23 @@ describe "Commenting legislation questions" do
|
||||
end
|
||||
|
||||
describe "Voting comments" do
|
||||
before do
|
||||
@manuela = create(:user, verified_at: Time.current)
|
||||
@pablo = create(:user)
|
||||
@legislation_question = create(:legislation_question)
|
||||
@comment = create(:comment, commentable: @legislation_question)
|
||||
let(:verified) { create(:user, verified_at: Time.current) }
|
||||
let(:unverified) { create(:user) }
|
||||
let(:question) { create(:legislation_question) }
|
||||
let!(:comment) { create(:comment, commentable: question) }
|
||||
|
||||
login_as(@manuela)
|
||||
before do
|
||||
|
||||
login_as(verified)
|
||||
end
|
||||
|
||||
scenario "Show" do
|
||||
create(:vote, voter: @manuela, votable: @comment, vote_flag: true)
|
||||
create(:vote, voter: @pablo, votable: @comment, vote_flag: false)
|
||||
create(:vote, voter: verified, votable: comment, vote_flag: true)
|
||||
create(:vote, voter: unverified, votable: comment, vote_flag: false)
|
||||
|
||||
visit legislation_process_question_path(@legislation_question.process, @legislation_question)
|
||||
visit legislation_process_question_path(question.process, question)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
within("#comment_#{comment.id}_votes") do
|
||||
within(".in_favor") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
@@ -497,9 +498,9 @@ describe "Commenting legislation questions" do
|
||||
end
|
||||
|
||||
scenario "Create", :js do
|
||||
visit legislation_process_question_path(@legislation_question.process, @legislation_question)
|
||||
visit legislation_process_question_path(question.process, question)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
within("#comment_#{comment.id}_votes") do
|
||||
find(".in_favor a").click
|
||||
|
||||
within(".in_favor") do
|
||||
@@ -515,9 +516,9 @@ describe "Commenting legislation questions" do
|
||||
end
|
||||
|
||||
scenario "Update", :js do
|
||||
visit legislation_process_question_path(@legislation_question.process, @legislation_question)
|
||||
visit legislation_process_question_path(question.process, question)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
within("#comment_#{comment.id}_votes") do
|
||||
find(".in_favor a").click
|
||||
|
||||
within(".in_favor") do
|
||||
@@ -539,9 +540,9 @@ describe "Commenting legislation questions" do
|
||||
end
|
||||
|
||||
scenario "Trying to vote multiple times", :js do
|
||||
visit legislation_process_question_path(@legislation_question.process, @legislation_question)
|
||||
visit legislation_process_question_path(question.process, question)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
within("#comment_#{comment.id}_votes") do
|
||||
find(".in_favor a").click
|
||||
within(".in_favor") do
|
||||
expect(page).to have_content "1"
|
||||
|
||||
@@ -453,23 +453,22 @@ describe "Commenting polls" do
|
||||
end
|
||||
|
||||
describe "Voting comments" do
|
||||
let(:verified) { create(:user, verified_at: Time.current) }
|
||||
let(:unverified) { create(:user) }
|
||||
let(:poll) { create(:poll) }
|
||||
let!(:comment) { create(:comment, commentable: poll) }
|
||||
|
||||
before do
|
||||
@manuela = create(:user, verified_at: Time.current)
|
||||
@pablo = create(:user)
|
||||
@poll = create(:poll)
|
||||
@comment = create(:comment, commentable: @poll)
|
||||
|
||||
login_as(@manuela)
|
||||
login_as(verified)
|
||||
end
|
||||
|
||||
scenario "Show" do
|
||||
create(:vote, voter: @manuela, votable: @comment, vote_flag: true)
|
||||
create(:vote, voter: @pablo, votable: @comment, vote_flag: false)
|
||||
create(:vote, voter: verified, votable: comment, vote_flag: true)
|
||||
create(:vote, voter: unverified, votable: comment, vote_flag: false)
|
||||
|
||||
visit poll_path(@poll)
|
||||
visit poll_path(poll)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
within("#comment_#{comment.id}_votes") do
|
||||
within(".in_favor") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
@@ -483,9 +482,9 @@ describe "Commenting polls" do
|
||||
end
|
||||
|
||||
scenario "Create", :js do
|
||||
visit poll_path(@poll)
|
||||
visit poll_path(poll)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
within("#comment_#{comment.id}_votes") do
|
||||
find(".in_favor a").click
|
||||
|
||||
within(".in_favor") do
|
||||
@@ -501,9 +500,9 @@ describe "Commenting polls" do
|
||||
end
|
||||
|
||||
scenario "Update", :js do
|
||||
visit poll_path(@poll)
|
||||
visit poll_path(poll)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
within("#comment_#{comment.id}_votes") do
|
||||
find(".in_favor a").click
|
||||
|
||||
within(".in_favor") do
|
||||
@@ -525,9 +524,9 @@ describe "Commenting polls" do
|
||||
end
|
||||
|
||||
scenario "Trying to vote multiple times", :js do
|
||||
visit poll_path(@poll)
|
||||
visit poll_path(poll)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
within("#comment_#{comment.id}_votes") do
|
||||
find(".in_favor a").click
|
||||
find(".in_favor a").click
|
||||
|
||||
|
||||
@@ -432,22 +432,22 @@ describe "Commenting proposals" do
|
||||
end
|
||||
|
||||
describe "Voting comments" do
|
||||
before do
|
||||
@manuela = create(:user, verified_at: Time.current)
|
||||
@pablo = create(:user)
|
||||
@proposal = create(:proposal)
|
||||
@comment = create(:comment, commentable: @proposal)
|
||||
let(:verified) { create(:user, verified_at: Time.current) }
|
||||
let(:unverified) { create(:user) }
|
||||
let(:proposal) { create(:proposal) }
|
||||
let!(:comment) { create(:comment, commentable: proposal) }
|
||||
|
||||
login_as(@manuela)
|
||||
before do
|
||||
login_as(verified)
|
||||
end
|
||||
|
||||
scenario "Show" do
|
||||
create(:vote, voter: @manuela, votable: @comment, vote_flag: true)
|
||||
create(:vote, voter: @pablo, votable: @comment, vote_flag: false)
|
||||
create(:vote, voter: verified, votable: comment, vote_flag: true)
|
||||
create(:vote, voter: unverified, votable: comment, vote_flag: false)
|
||||
|
||||
visit proposal_path(@proposal)
|
||||
visit proposal_path(proposal)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
within("#comment_#{comment.id}_votes") do
|
||||
within(".in_favor") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
@@ -461,9 +461,9 @@ describe "Commenting proposals" do
|
||||
end
|
||||
|
||||
scenario "Create", :js do
|
||||
visit proposal_path(@proposal)
|
||||
visit proposal_path(proposal)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
within("#comment_#{comment.id}_votes") do
|
||||
find(".in_favor a").click
|
||||
|
||||
within(".in_favor") do
|
||||
@@ -479,9 +479,9 @@ describe "Commenting proposals" do
|
||||
end
|
||||
|
||||
scenario "Update", :js do
|
||||
visit proposal_path(@proposal)
|
||||
visit proposal_path(proposal)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
within("#comment_#{comment.id}_votes") do
|
||||
find(".in_favor a").click
|
||||
|
||||
within(".in_favor") do
|
||||
@@ -503,9 +503,9 @@ describe "Commenting proposals" do
|
||||
end
|
||||
|
||||
scenario "Trying to vote multiple times", :js do
|
||||
visit proposal_path(@proposal)
|
||||
visit proposal_path(proposal)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
within("#comment_#{comment.id}_votes") do
|
||||
find(".in_favor a").click
|
||||
find(".in_favor a").click
|
||||
|
||||
|
||||
@@ -481,23 +481,23 @@ describe "Commenting topics from proposals" do
|
||||
end
|
||||
|
||||
describe "Voting comments" do
|
||||
before do
|
||||
@manuela = create(:user, verified_at: Time.current)
|
||||
@pablo = create(:user)
|
||||
@proposal = create(:proposal)
|
||||
@topic = create(:topic, community: @proposal.community)
|
||||
@comment = create(:comment, commentable: @topic)
|
||||
let(:verified) { create(:user, verified_at: Time.current) }
|
||||
let(:unverified) { create(:user) }
|
||||
let(:proposal) { create(:proposal) }
|
||||
let(:topic) { create(:topic, community: proposal.community) }
|
||||
let!(:comment) { create(:comment, commentable: topic) }
|
||||
|
||||
login_as(@manuela)
|
||||
before do
|
||||
login_as(verified)
|
||||
end
|
||||
|
||||
scenario "Show" do
|
||||
create(:vote, voter: @manuela, votable: @comment, vote_flag: true)
|
||||
create(:vote, voter: @pablo, votable: @comment, vote_flag: false)
|
||||
create(:vote, voter: verified, votable: comment, vote_flag: true)
|
||||
create(:vote, voter: unverified, votable: comment, vote_flag: false)
|
||||
|
||||
visit community_topic_path(@proposal.community, @topic)
|
||||
visit community_topic_path(proposal.community, topic)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
within("#comment_#{comment.id}_votes") do
|
||||
within(".in_favor") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
@@ -511,9 +511,9 @@ describe "Commenting topics from proposals" do
|
||||
end
|
||||
|
||||
scenario "Create", :js do
|
||||
visit community_topic_path(@proposal.community, @topic)
|
||||
visit community_topic_path(proposal.community, topic)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
within("#comment_#{comment.id}_votes") do
|
||||
find(".in_favor a").click
|
||||
|
||||
within(".in_favor") do
|
||||
@@ -529,9 +529,9 @@ describe "Commenting topics from proposals" do
|
||||
end
|
||||
|
||||
scenario "Update", :js do
|
||||
visit community_topic_path(@proposal.community, @topic)
|
||||
visit community_topic_path(proposal.community, topic)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
within("#comment_#{comment.id}_votes") do
|
||||
find(".in_favor a").click
|
||||
|
||||
within(".in_favor") do
|
||||
@@ -553,9 +553,9 @@ describe "Commenting topics from proposals" do
|
||||
end
|
||||
|
||||
scenario "Trying to vote multiple times", :js do
|
||||
visit community_topic_path(@proposal.community, @topic)
|
||||
visit community_topic_path(proposal.community, topic)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
within("#comment_#{comment.id}_votes") do
|
||||
find(".in_favor a").click
|
||||
find(".in_favor a").click
|
||||
|
||||
@@ -1032,23 +1032,23 @@ describe "Commenting topics from budget investments" do
|
||||
end
|
||||
|
||||
describe "Voting comments" do
|
||||
before do
|
||||
@manuela = create(:user, verified_at: Time.current)
|
||||
@pablo = create(:user)
|
||||
@investment = create(:budget_investment)
|
||||
@topic = create(:topic, community: @investment.community)
|
||||
@comment = create(:comment, commentable: @topic)
|
||||
let(:verified) { create(:user, verified_at: Time.current) }
|
||||
let(:unverified) { create(:user) }
|
||||
let(:investment) { create(:budget_investment) }
|
||||
let(:topic) { create(:topic, community: investment.community) }
|
||||
let!(:comment) { create(:comment, commentable: topic) }
|
||||
|
||||
login_as(@manuela)
|
||||
before do
|
||||
login_as(verified)
|
||||
end
|
||||
|
||||
scenario "Show" do
|
||||
create(:vote, voter: @manuela, votable: @comment, vote_flag: true)
|
||||
create(:vote, voter: @pablo, votable: @comment, vote_flag: false)
|
||||
create(:vote, voter: verified, votable: comment, vote_flag: true)
|
||||
create(:vote, voter: unverified, votable: comment, vote_flag: false)
|
||||
|
||||
visit community_topic_path(@investment.community, @topic)
|
||||
visit community_topic_path(investment.community, topic)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
within("#comment_#{comment.id}_votes") do
|
||||
within(".in_favor") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
@@ -1062,9 +1062,9 @@ describe "Commenting topics from budget investments" do
|
||||
end
|
||||
|
||||
scenario "Create", :js do
|
||||
visit community_topic_path(@investment.community, @topic)
|
||||
visit community_topic_path(investment.community, topic)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
within("#comment_#{comment.id}_votes") do
|
||||
find(".in_favor a").click
|
||||
|
||||
within(".in_favor") do
|
||||
@@ -1080,9 +1080,9 @@ describe "Commenting topics from budget investments" do
|
||||
end
|
||||
|
||||
scenario "Update", :js do
|
||||
visit community_topic_path(@investment.community, @topic)
|
||||
visit community_topic_path(investment.community, topic)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
within("#comment_#{comment.id}_votes") do
|
||||
find(".in_favor a").click
|
||||
|
||||
within(".in_favor") do
|
||||
@@ -1104,9 +1104,9 @@ describe "Commenting topics from budget investments" do
|
||||
end
|
||||
|
||||
scenario "Trying to vote multiple times", :js do
|
||||
visit community_topic_path(@investment.community, @topic)
|
||||
visit community_topic_path(investment.community, topic)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
within("#comment_#{comment.id}_votes") do
|
||||
find(".in_favor a").click
|
||||
find(".in_favor a").click
|
||||
|
||||
|
||||
@@ -299,12 +299,13 @@ describe "Legislation Draft Versions" do
|
||||
before do
|
||||
create(:legislation_annotation, draft_version: draft_version, text: "my annotation", quote: "ipsum",
|
||||
ranges: [{ "start" => "/p[1]", "startOffset" => 6, "end" => "/p[1]", "endOffset" => 11 }])
|
||||
@annotation = create(:legislation_annotation, draft_version: draft_version, text: "my other annotation", quote: "audiam",
|
||||
ranges: [{ "start" => "/p[3]", "startOffset" => 6, "end" => "/p[3]", "endOffset" => 11 }])
|
||||
end
|
||||
|
||||
scenario "See one annotation with replies for a draft version" do
|
||||
visit legislation_process_draft_version_annotation_path(draft_version.process, draft_version, @annotation)
|
||||
annotation = create(:legislation_annotation, draft_version: draft_version, text: "my other annotation", quote: "audiam",
|
||||
ranges: [{ "start" => "/p[3]", "startOffset" => 6, "end" => "/p[3]", "endOffset" => 11 }])
|
||||
|
||||
visit legislation_process_draft_version_annotation_path(draft_version.process, draft_version, annotation)
|
||||
|
||||
expect(page).not_to have_content "ipsum"
|
||||
expect(page).not_to have_content "my annotation"
|
||||
|
||||
@@ -2,15 +2,20 @@ require "rails_helper"
|
||||
|
||||
describe "Legislation" do
|
||||
context "process debate page" do
|
||||
let(:process) do
|
||||
create(:legislation_process,
|
||||
debate_start_date: Date.current - 3.days,
|
||||
debate_end_date: Date.current + 2.days)
|
||||
end
|
||||
|
||||
before do
|
||||
@process = create(:legislation_process, debate_start_date: Date.current - 3.days, debate_end_date: Date.current + 2.days)
|
||||
create(:legislation_question, process: @process, title: "Question 1")
|
||||
create(:legislation_question, process: @process, title: "Question 2")
|
||||
create(:legislation_question, process: @process, title: "Question 3")
|
||||
create(:legislation_question, process: process, title: "Question 1")
|
||||
create(:legislation_question, process: process, title: "Question 2")
|
||||
create(:legislation_question, process: process, title: "Question 3")
|
||||
end
|
||||
|
||||
scenario "shows question list" do
|
||||
visit legislation_process_path(@process)
|
||||
visit legislation_process_path(process)
|
||||
|
||||
expect(page).to have_content("Participate in the debate")
|
||||
|
||||
@@ -35,14 +40,14 @@ describe "Legislation" do
|
||||
end
|
||||
|
||||
scenario "shows question page" do
|
||||
visit legislation_process_question_path(@process, @process.questions.first)
|
||||
visit legislation_process_question_path(process, process.questions.first)
|
||||
|
||||
expect(page).to have_content("Question 1")
|
||||
expect(page).to have_content("Open answers (0)")
|
||||
end
|
||||
|
||||
scenario "shows next question link in question page" do
|
||||
visit legislation_process_question_path(@process, @process.questions.first)
|
||||
visit legislation_process_question_path(process, process.questions.first)
|
||||
|
||||
expect(page).to have_content("Question 1")
|
||||
expect(page).to have_content("Next question")
|
||||
@@ -59,7 +64,7 @@ describe "Legislation" do
|
||||
end
|
||||
|
||||
scenario "answer question" do
|
||||
question = @process.questions.first
|
||||
question = process.questions.first
|
||||
create(:legislation_question_option, question: question, value: "Yes")
|
||||
create(:legislation_question_option, question: question, value: "No")
|
||||
option = create(:legislation_question_option, question: question, value: "I don't know")
|
||||
@@ -67,7 +72,7 @@ describe "Legislation" do
|
||||
|
||||
login_as(user)
|
||||
|
||||
visit legislation_process_question_path(@process, question)
|
||||
visit legislation_process_question_path(process, question)
|
||||
|
||||
expect(page).to have_selector(:radio_button, "Yes")
|
||||
expect(page).to have_selector(:radio_button, "No")
|
||||
@@ -89,8 +94,8 @@ describe "Legislation" do
|
||||
end
|
||||
|
||||
scenario "cannot answer question when phase not open" do
|
||||
@process.update_attribute(:debate_end_date, Date.current - 1.day)
|
||||
question = @process.questions.first
|
||||
process.update_attribute(:debate_end_date, Date.current - 1.day)
|
||||
question = process.questions.first
|
||||
create(:legislation_question_option, question: question, value: "Yes")
|
||||
create(:legislation_question_option, question: question, value: "No")
|
||||
create(:legislation_question_option, question: question, value: "I don't know")
|
||||
@@ -98,7 +103,7 @@ describe "Legislation" do
|
||||
|
||||
login_as(user)
|
||||
|
||||
visit legislation_process_question_path(@process, question)
|
||||
visit legislation_process_question_path(process, question)
|
||||
|
||||
expect(page).to have_selector(:radio_button, "Yes", disabled: true)
|
||||
expect(page).to have_selector(:radio_button, "No", disabled: true)
|
||||
|
||||
@@ -17,37 +17,33 @@ describe "Legislation" do
|
||||
end
|
||||
|
||||
context "process empty" do
|
||||
before do
|
||||
@process = create(:legislation_process, :empty, end_date: Date.current - 1.day)
|
||||
end
|
||||
let(:process) { create(:legislation_process, :empty, end_date: Date.current - 1.day) }
|
||||
|
||||
scenario "warning empty" do
|
||||
visit resume_legislation_process_path(@process)
|
||||
visit resume_legislation_process_path(process)
|
||||
expect(page).to have_content("The process have no phases.")
|
||||
end
|
||||
end
|
||||
|
||||
context "phases empty" do
|
||||
before do
|
||||
@process = create(:legislation_process, end_date: Date.current - 1.day)
|
||||
end
|
||||
let(:process) { create(:legislation_process, end_date: Date.current - 1.day) }
|
||||
|
||||
scenario "debates empty" do
|
||||
visit resume_legislation_process_path(@process)
|
||||
visit resume_legislation_process_path(process)
|
||||
expect(page).to have_content("Debates phase")
|
||||
expect(page).to have_content("No debates")
|
||||
expect(page).to have_content("There aren't any questions")
|
||||
end
|
||||
|
||||
scenario "proposals empty" do
|
||||
visit resume_legislation_process_path(@process)
|
||||
visit resume_legislation_process_path(process)
|
||||
expect(page).to have_content("Proposal phase")
|
||||
expect(page).to have_content("No proposals")
|
||||
expect(page).to have_content("There are no proposals")
|
||||
end
|
||||
|
||||
scenario "text comments empty" do
|
||||
visit resume_legislation_process_path(@process)
|
||||
visit resume_legislation_process_path(process)
|
||||
expect(page).to have_content("Text comment phase")
|
||||
expect(page).to have_content("No comments")
|
||||
expect(page).to have_content("There are no text comments")
|
||||
@@ -55,31 +51,29 @@ describe "Legislation" do
|
||||
end
|
||||
|
||||
context "process empty" do
|
||||
before do
|
||||
@process = create(:legislation_process, :empty, end_date: Date.current - 1.day)
|
||||
end
|
||||
let(:process) { create(:legislation_process, :empty, end_date: Date.current - 1.day) }
|
||||
|
||||
scenario "warning empty" do
|
||||
visit resume_legislation_process_path(@process)
|
||||
visit resume_legislation_process_path(process)
|
||||
expect(page).to have_content("The process have no phases.")
|
||||
end
|
||||
end
|
||||
|
||||
context "only debates exist" do
|
||||
let(:process) { create(:legislation_process, end_date: Date.current - 1.day) }
|
||||
|
||||
before do
|
||||
user = create(:user, :level_two)
|
||||
@process = create(:legislation_process, end_date: Date.current - 1.day)
|
||||
|
||||
@debate = create(:legislation_question, process: @process, title: "Question 1")
|
||||
@debate = create(:legislation_question, process: process, title: "Question 1")
|
||||
create(:comment, user: user, commentable: @debate, body: "Answer 1")
|
||||
create(:comment, user: user, commentable: @debate, body: "Answer 2")
|
||||
@debate = create(:legislation_question, process: @process, title: "Question 2")
|
||||
@debate = create(:legislation_question, process: process, title: "Question 2")
|
||||
create(:comment, user: user, commentable: @debate, body: "Answer 3")
|
||||
create(:comment, user: user, commentable: @debate, body: "Answer 4")
|
||||
end
|
||||
|
||||
scenario "show debates list" do
|
||||
visit resume_legislation_process_path(@process)
|
||||
visit resume_legislation_process_path(process)
|
||||
expect(page).to have_content("Debates phase")
|
||||
expect(page).to have_content("2 debates")
|
||||
|
||||
@@ -97,7 +91,7 @@ describe "Legislation" do
|
||||
expect(page).not_to have_content("Answer 3")
|
||||
expect(page).not_to have_content("Answer 4")
|
||||
|
||||
visit resume_legislation_process_path(@process)
|
||||
visit resume_legislation_process_path(process)
|
||||
click_link "Question 2"
|
||||
expect(page).to have_content("Question 2")
|
||||
expect(page).not_to have_content("Answer 1")
|
||||
@@ -108,14 +102,14 @@ describe "Legislation" do
|
||||
end
|
||||
|
||||
scenario "proposals empty" do
|
||||
visit resume_legislation_process_path(@process)
|
||||
visit resume_legislation_process_path(process)
|
||||
expect(page).to have_content("Proposal phase")
|
||||
expect(page).to have_content("No proposals")
|
||||
expect(page).to have_content("There are no proposals")
|
||||
end
|
||||
|
||||
scenario "text comments empty" do
|
||||
visit resume_legislation_process_path(@process)
|
||||
visit resume_legislation_process_path(process)
|
||||
expect(page).to have_content("Text comment phase")
|
||||
expect(page).to have_content("No comments")
|
||||
expect(page).to have_content("There are no text comments")
|
||||
@@ -123,27 +117,28 @@ describe "Legislation" do
|
||||
end
|
||||
|
||||
context "only proposals exist" do
|
||||
let(:process) { create(:legislation_process, end_date: Date.current - 1.day) }
|
||||
|
||||
before do
|
||||
@process = create(:legislation_process, end_date: Date.current - 1.day)
|
||||
create(:legislation_proposal, legislation_process_id: @process.id,
|
||||
create(:legislation_proposal, legislation_process_id: process.id,
|
||||
title: "Legislation proposal 1", selected: true)
|
||||
create(:legislation_proposal, legislation_process_id: @process.id,
|
||||
create(:legislation_proposal, legislation_process_id: process.id,
|
||||
title: "Legislation proposal 2", selected: false)
|
||||
create(:legislation_proposal, legislation_process_id: @process.id,
|
||||
create(:legislation_proposal, legislation_process_id: process.id,
|
||||
title: "Legislation proposal 3", selected: true)
|
||||
create(:legislation_proposal, legislation_process_id: @process.id,
|
||||
create(:legislation_proposal, legislation_process_id: process.id,
|
||||
title: "Legislation proposal 4", selected: false)
|
||||
end
|
||||
|
||||
scenario "debates empty" do
|
||||
visit resume_legislation_process_path(@process)
|
||||
visit resume_legislation_process_path(process)
|
||||
expect(page).to have_content("Debates phase")
|
||||
expect(page).to have_content("No debates")
|
||||
expect(page).to have_content("There aren't any questions")
|
||||
end
|
||||
|
||||
scenario "proposals empty" do
|
||||
visit resume_legislation_process_path(@process)
|
||||
visit resume_legislation_process_path(process)
|
||||
expect(page).to have_content("Proposal phase")
|
||||
expect(page).to have_content("2 proposals")
|
||||
|
||||
@@ -155,14 +150,14 @@ describe "Legislation" do
|
||||
click_link "Legislation proposal 1"
|
||||
expect(page).to have_content("Legislation proposal 1")
|
||||
|
||||
visit resume_legislation_process_path(@process)
|
||||
visit resume_legislation_process_path(process)
|
||||
click_link "Legislation proposal 3"
|
||||
expect(page).to have_content("Legislation proposal 3")
|
||||
|
||||
end
|
||||
|
||||
scenario "text comments empty" do
|
||||
visit resume_legislation_process_path(@process)
|
||||
visit resume_legislation_process_path(process)
|
||||
expect(page).to have_content("Text comment phase")
|
||||
expect(page).to have_content("No comments")
|
||||
expect(page).to have_content("There are no text comments")
|
||||
@@ -170,13 +165,14 @@ describe "Legislation" do
|
||||
end
|
||||
|
||||
context "only text comments exist" do
|
||||
let(:process) { create(:legislation_process, end_date: Date.current - 1.day) }
|
||||
|
||||
before do
|
||||
user = create(:user, :level_two)
|
||||
@process = create(:legislation_process, end_date: Date.current - 1.day)
|
||||
draft_version_1 = create(:legislation_draft_version, process: @process,
|
||||
draft_version_1 = create(:legislation_draft_version, process: process,
|
||||
title: "Version 1", body: "Body of the first version",
|
||||
status: "published")
|
||||
draft_version_2 = create(:legislation_draft_version, process: @process,
|
||||
draft_version_2 = create(:legislation_draft_version, process: process,
|
||||
title: "Version 2", body: "Body of the second version and that's it all of it",
|
||||
status: "published")
|
||||
annotation0 = create(:legislation_annotation,
|
||||
@@ -196,21 +192,21 @@ describe "Legislation" do
|
||||
end
|
||||
|
||||
scenario "debates empty" do
|
||||
visit resume_legislation_process_path(@process)
|
||||
visit resume_legislation_process_path(process)
|
||||
expect(page).to have_content("Debates phase")
|
||||
expect(page).to have_content("No debates")
|
||||
expect(page).to have_content("There aren't any questions")
|
||||
end
|
||||
|
||||
scenario "proposals empty" do
|
||||
visit resume_legislation_process_path(@process)
|
||||
visit resume_legislation_process_path(process)
|
||||
expect(page).to have_content("Proposal phase")
|
||||
expect(page).to have_content("No proposals")
|
||||
expect(page).to have_content("There are no proposals")
|
||||
end
|
||||
|
||||
scenario "text comments empty" do
|
||||
visit resume_legislation_process_path(@process)
|
||||
visit resume_legislation_process_path(process)
|
||||
expect(page).to have_content("Text comment phase (version Version 2")
|
||||
expect(page).to have_content("5 comments")
|
||||
expect(page).not_to have_content("Comment 0")
|
||||
@@ -223,7 +219,7 @@ describe "Legislation" do
|
||||
end
|
||||
|
||||
# scenario "excel download" do
|
||||
# visit resume_legislation_process_path(@process)
|
||||
# visit resume_legislation_process_path(process)
|
||||
# click_link "Download"
|
||||
# page.response_headers['Content-Type'].should eq "application/xlsx"
|
||||
# end
|
||||
@@ -234,9 +230,9 @@ describe "Legislation" do
|
||||
before do
|
||||
user = create(:user, :level_two)
|
||||
@process = create(:legislation_process, end_date: Date.current - 1.day)
|
||||
@debate = create(:legislation_question, process: @process, title: "Question 1")
|
||||
create(:comment, user: user, commentable: @debate, body: "Answer 1")
|
||||
create(:comment, user: user, commentable: @debate, body: "Answer 2")
|
||||
debate = create(:legislation_question, process: @process, title: "Question 1")
|
||||
create(:comment, user: user, commentable: debate, body: "Answer 1")
|
||||
create(:comment, user: user, commentable: debate, body: "Answer 2")
|
||||
end
|
||||
|
||||
it "download execl file test" do
|
||||
|
||||
@@ -2,24 +2,21 @@ require "rails_helper"
|
||||
|
||||
describe "Moderate budget investments" do
|
||||
|
||||
let(:budget) { create(:budget) }
|
||||
let(:heading) { create(:budget_heading, budget: budget, price: 666666) }
|
||||
|
||||
before do
|
||||
@mod = create(:moderator)
|
||||
@investment = create(:budget_investment, heading: heading, author: create(:user))
|
||||
end
|
||||
let(:budget) { create(:budget) }
|
||||
let(:heading) { create(:budget_heading, budget: budget, price: 666666) }
|
||||
let(:mod) { create(:moderator) }
|
||||
let!(:investment) { create(:budget_investment, heading: heading, author: create(:user)) }
|
||||
|
||||
scenario "Disabled with a feature flag" do
|
||||
Setting["process.budgets"] = nil
|
||||
login_as(@mod.user)
|
||||
login_as(mod.user)
|
||||
|
||||
expect { visit moderation_budget_investments_path }.to raise_exception(FeatureFlags::FeatureDisabled)
|
||||
end
|
||||
|
||||
scenario "Hiding an investment", :js do
|
||||
login_as(@mod.user)
|
||||
visit budget_investment_path(budget, @investment)
|
||||
login_as(mod.user)
|
||||
visit budget_investment_path(budget, investment)
|
||||
|
||||
accept_confirm { click_link "Hide" }
|
||||
|
||||
@@ -27,12 +24,12 @@ describe "Moderate budget investments" do
|
||||
|
||||
visit budget_investments_path(budget.id, heading_id: heading.id)
|
||||
|
||||
expect(page).not_to have_content(@investment.title)
|
||||
expect(page).not_to have_content(investment.title)
|
||||
end
|
||||
|
||||
scenario "Hiding an investment's author", :js do
|
||||
login_as(@mod.user)
|
||||
visit budget_investment_path(budget, @investment)
|
||||
login_as(mod.user)
|
||||
visit budget_investment_path(budget, investment)
|
||||
|
||||
accept_confirm { click_link "Hide author" }
|
||||
|
||||
@@ -40,16 +37,16 @@ describe "Moderate budget investments" do
|
||||
|
||||
visit budget_investments_path(budget.id, heading_id: heading.id)
|
||||
|
||||
expect(page).not_to have_content(@investment.title)
|
||||
expect(page).not_to have_content(investment.title)
|
||||
end
|
||||
|
||||
scenario "Can not hide own investment" do
|
||||
@investment.update(author: @mod.user)
|
||||
login_as(@mod.user)
|
||||
investment.update(author: mod.user)
|
||||
login_as(mod.user)
|
||||
|
||||
visit budget_investment_path(budget, @investment)
|
||||
visit budget_investment_path(budget, investment)
|
||||
|
||||
within "#budget_investment_#{@investment.id}" do
|
||||
within "#budget_investment_#{investment.id}" do
|
||||
expect(page).not_to have_link("Hide")
|
||||
expect(page).not_to have_link("Hide author")
|
||||
end
|
||||
@@ -58,7 +55,7 @@ describe "Moderate budget investments" do
|
||||
describe "/moderation/ screen" do
|
||||
|
||||
before do
|
||||
login_as(@mod.user)
|
||||
login_as(mod.user)
|
||||
end
|
||||
|
||||
describe "moderate in bulk" do
|
||||
@@ -71,40 +68,40 @@ describe "Moderate budget investments" do
|
||||
click_link "All"
|
||||
end
|
||||
|
||||
within("#investment_#{@investment.id}") do
|
||||
check "budget_investment_#{@investment.id}_check"
|
||||
within("#investment_#{investment.id}") do
|
||||
check "budget_investment_#{investment.id}_check"
|
||||
end
|
||||
|
||||
expect(page).not_to have_css("investment#{@investment.id}")
|
||||
expect(page).not_to have_css("investment#{investment.id}")
|
||||
end
|
||||
|
||||
scenario "Hide the investment" do
|
||||
click_button "Hide budget investments"
|
||||
expect(page).not_to have_css("investment_#{@investment.id}")
|
||||
expect(page).not_to have_css("investment_#{investment.id}")
|
||||
|
||||
@investment.reload
|
||||
investment.reload
|
||||
|
||||
expect(@investment.author).not_to be_hidden
|
||||
expect(investment.author).not_to be_hidden
|
||||
end
|
||||
|
||||
scenario "Block the author" do
|
||||
click_button "Block authors"
|
||||
expect(page).not_to have_css("investment_#{@investment.id}")
|
||||
expect(page).not_to have_css("investment_#{investment.id}")
|
||||
|
||||
@investment.reload
|
||||
investment.reload
|
||||
|
||||
expect(@investment.author).to be_hidden
|
||||
expect(investment.author).to be_hidden
|
||||
end
|
||||
|
||||
scenario "Ignore the investment" do
|
||||
click_button "Mark as viewed"
|
||||
expect(page).not_to have_css("investment_#{@investment.id}")
|
||||
expect(page).not_to have_css("investment_#{investment.id}")
|
||||
|
||||
@investment.reload
|
||||
investment.reload
|
||||
|
||||
expect(@investment).to be_ignored_flag
|
||||
expect(@investment).not_to be_hidden
|
||||
expect(@investment.author).not_to be_hidden
|
||||
expect(investment).to be_ignored_flag
|
||||
expect(investment).not_to be_hidden
|
||||
expect(investment.author).not_to be_hidden
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -72,40 +72,41 @@ describe "Moderate comments" do
|
||||
|
||||
describe "moderate in bulk" do
|
||||
describe "When a comment has been selected for moderation" do
|
||||
let!(:comment) { create(:comment) }
|
||||
|
||||
before do
|
||||
@comment = create(:comment)
|
||||
visit moderation_comments_path
|
||||
within(".menu.simple") do
|
||||
click_link "All"
|
||||
end
|
||||
|
||||
within("#comment_#{@comment.id}") do
|
||||
check "comment_#{@comment.id}_check"
|
||||
within("#comment_#{comment.id}") do
|
||||
check "comment_#{comment.id}_check"
|
||||
end
|
||||
|
||||
expect(page).not_to have_css("comment_#{@comment.id}")
|
||||
expect(page).not_to have_css("comment_#{comment.id}")
|
||||
end
|
||||
|
||||
scenario "Hide the comment" do
|
||||
click_on "Hide comments"
|
||||
expect(page).not_to have_css("comment_#{@comment.id}")
|
||||
expect(@comment.reload).to be_hidden
|
||||
expect(@comment.user).not_to be_hidden
|
||||
expect(page).not_to have_css("comment_#{comment.id}")
|
||||
expect(comment.reload).to be_hidden
|
||||
expect(comment.user).not_to be_hidden
|
||||
end
|
||||
|
||||
scenario "Block the user" do
|
||||
click_on "Block authors"
|
||||
expect(page).not_to have_css("comment_#{@comment.id}")
|
||||
expect(@comment.reload).to be_hidden
|
||||
expect(@comment.user).to be_hidden
|
||||
expect(page).not_to have_css("comment_#{comment.id}")
|
||||
expect(comment.reload).to be_hidden
|
||||
expect(comment.user).to be_hidden
|
||||
end
|
||||
|
||||
scenario "Ignore the comment" do
|
||||
click_on "Mark as viewed"
|
||||
expect(page).not_to have_css("comment_#{@comment.id}")
|
||||
expect(@comment.reload).to be_ignored_flag
|
||||
expect(@comment.reload).not_to be_hidden
|
||||
expect(@comment.user).not_to be_hidden
|
||||
expect(page).not_to have_css("comment_#{comment.id}")
|
||||
expect(comment.reload).to be_ignored_flag
|
||||
expect(comment.reload).not_to be_hidden
|
||||
expect(comment.user).not_to be_hidden
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -53,40 +53,41 @@ describe "Moderate debates" do
|
||||
|
||||
describe "moderate in bulk" do
|
||||
describe "When a debate has been selected for moderation" do
|
||||
let!(:debate) { create(:debate) }
|
||||
|
||||
before do
|
||||
@debate = create(:debate)
|
||||
visit moderation_debates_path
|
||||
within(".menu.simple") do
|
||||
click_link "All"
|
||||
end
|
||||
|
||||
within("#debate_#{@debate.id}") do
|
||||
check "debate_#{@debate.id}_check"
|
||||
within("#debate_#{debate.id}") do
|
||||
check "debate_#{debate.id}_check"
|
||||
end
|
||||
|
||||
expect(page).not_to have_css("debate_#{@debate.id}")
|
||||
expect(page).not_to have_css("debate_#{debate.id}")
|
||||
end
|
||||
|
||||
scenario "Hide the debate" do
|
||||
click_on "Hide debates"
|
||||
expect(page).not_to have_css("debate_#{@debate.id}")
|
||||
expect(@debate.reload).to be_hidden
|
||||
expect(@debate.author).not_to be_hidden
|
||||
expect(page).not_to have_css("debate_#{debate.id}")
|
||||
expect(debate.reload).to be_hidden
|
||||
expect(debate.author).not_to be_hidden
|
||||
end
|
||||
|
||||
scenario "Block the author" do
|
||||
click_on "Block authors"
|
||||
expect(page).not_to have_css("debate_#{@debate.id}")
|
||||
expect(@debate.reload).to be_hidden
|
||||
expect(@debate.author).to be_hidden
|
||||
expect(page).not_to have_css("debate_#{debate.id}")
|
||||
expect(debate.reload).to be_hidden
|
||||
expect(debate.author).to be_hidden
|
||||
end
|
||||
|
||||
scenario "Ignore the debate" do
|
||||
click_on "Mark as viewed"
|
||||
expect(page).not_to have_css("debate_#{@debate.id}")
|
||||
expect(@debate.reload).to be_ignored_flag
|
||||
expect(@debate.reload).not_to be_hidden
|
||||
expect(@debate.author).not_to be_hidden
|
||||
expect(page).not_to have_css("debate_#{debate.id}")
|
||||
expect(debate.reload).to be_ignored_flag
|
||||
expect(debate.reload).not_to be_hidden
|
||||
expect(debate.author).not_to be_hidden
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -48,41 +48,41 @@ describe "Moderate proposal notifications" do
|
||||
|
||||
describe "moderate in bulk" do
|
||||
describe "When a proposal has been selected for moderation" do
|
||||
let!(:proposal_notification) { create(:proposal_notification, created_at: Date.current - 4.days) }
|
||||
|
||||
before do
|
||||
proposal = create(:proposal)
|
||||
@proposal_notification = create(:proposal_notification, proposal: proposal, created_at: Date.current - 4.days)
|
||||
visit moderation_proposal_notifications_path
|
||||
within(".menu.simple") do
|
||||
click_link "All"
|
||||
end
|
||||
|
||||
within("#proposal_notification_#{@proposal_notification.id}") do
|
||||
check "proposal_notification_#{@proposal_notification.id}_check"
|
||||
within("#proposal_notification_#{proposal_notification.id}") do
|
||||
check "proposal_notification_#{proposal_notification.id}_check"
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Hide the proposal" do
|
||||
click_on "Hide proposals"
|
||||
expect(page).not_to have_css("#proposal_notification_#{@proposal_notification.id}")
|
||||
expect(@proposal_notification.reload).to be_hidden
|
||||
expect(@proposal_notification.author).not_to be_hidden
|
||||
expect(page).not_to have_css("#proposal_notification_#{proposal_notification.id}")
|
||||
expect(proposal_notification.reload).to be_hidden
|
||||
expect(proposal_notification.author).not_to be_hidden
|
||||
end
|
||||
|
||||
scenario "Block the author" do
|
||||
author = create(:user)
|
||||
@proposal_notification.update(author: author)
|
||||
proposal_notification.update(author: author)
|
||||
click_on "Block authors"
|
||||
expect(page).not_to have_css("#proposal_notification_#{@proposal_notification.id}")
|
||||
expect(@proposal_notification.reload).to be_hidden
|
||||
expect(page).not_to have_css("#proposal_notification_#{proposal_notification.id}")
|
||||
expect(proposal_notification.reload).to be_hidden
|
||||
expect(author.reload).to be_hidden
|
||||
end
|
||||
|
||||
scenario "Ignore the proposal" do
|
||||
click_button "Mark as viewed"
|
||||
|
||||
expect(@proposal_notification.reload).to be_ignored
|
||||
expect(@proposal_notification.reload).not_to be_hidden
|
||||
expect(@proposal_notification.author).not_to be_hidden
|
||||
expect(proposal_notification.reload).to be_ignored
|
||||
expect(proposal_notification.reload).not_to be_hidden
|
||||
expect(proposal_notification.author).not_to be_hidden
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -51,41 +51,42 @@ describe "Moderate proposals" do
|
||||
end
|
||||
|
||||
describe "moderate in bulk" do
|
||||
let!(:proposal) { create(:proposal) }
|
||||
|
||||
describe "When a proposal has been selected for moderation" do
|
||||
before do
|
||||
@proposal = create(:proposal)
|
||||
visit moderation_proposals_path
|
||||
within(".menu.simple") do
|
||||
click_link "All"
|
||||
end
|
||||
|
||||
within("#proposal_#{@proposal.id}") do
|
||||
check "proposal_#{@proposal.id}_check"
|
||||
within("#proposal_#{proposal.id}") do
|
||||
check "proposal_#{proposal.id}_check"
|
||||
end
|
||||
|
||||
expect(page).not_to have_css("proposal_#{@proposal.id}")
|
||||
expect(page).not_to have_css("proposal_#{proposal.id}")
|
||||
end
|
||||
|
||||
scenario "Hide the proposal" do
|
||||
click_on "Hide proposals"
|
||||
expect(page).not_to have_css("proposal_#{@proposal.id}")
|
||||
expect(@proposal.reload).to be_hidden
|
||||
expect(@proposal.author).not_to be_hidden
|
||||
expect(page).not_to have_css("proposal_#{proposal.id}")
|
||||
expect(proposal.reload).to be_hidden
|
||||
expect(proposal.author).not_to be_hidden
|
||||
end
|
||||
|
||||
scenario "Block the author" do
|
||||
click_on "Block authors"
|
||||
expect(page).not_to have_css("proposal_#{@proposal.id}")
|
||||
expect(@proposal.reload).to be_hidden
|
||||
expect(@proposal.author).to be_hidden
|
||||
expect(page).not_to have_css("proposal_#{proposal.id}")
|
||||
expect(proposal.reload).to be_hidden
|
||||
expect(proposal.author).to be_hidden
|
||||
end
|
||||
|
||||
scenario "Ignore the proposal" do
|
||||
click_button "Mark as viewed"
|
||||
expect(page).not_to have_css("proposal_#{@proposal.id}")
|
||||
expect(@proposal.reload).to be_ignored_flag
|
||||
expect(@proposal.reload).not_to be_hidden
|
||||
expect(@proposal.author).not_to be_hidden
|
||||
expect(page).not_to have_css("proposal_#{proposal.id}")
|
||||
expect(proposal.reload).to be_ignored_flag
|
||||
expect(proposal.reload).not_to be_hidden
|
||||
expect(proposal.author).not_to be_hidden
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -3,16 +3,13 @@ require "rails_helper"
|
||||
describe "Official positions" do
|
||||
|
||||
context "Badge" do
|
||||
|
||||
before do
|
||||
@user1 = create(:user, official_level: 1, official_position: "Employee", official_position_badge: true)
|
||||
@user2 = create(:user, official_level: 0, official_position: "")
|
||||
end
|
||||
let(:user1) { create(:user, official_level: 1, official_position: "Employee", official_position_badge: true) }
|
||||
let(:user2) { create(:user, official_level: 0, official_position: "") }
|
||||
|
||||
scenario "Comments" do
|
||||
proposal = create(:proposal)
|
||||
comment1 = create(:comment, commentable: proposal, user: @user1)
|
||||
comment2 = create(:comment, commentable: proposal, user: @user2)
|
||||
comment1 = create(:comment, commentable: proposal, user: user1)
|
||||
comment2 = create(:comment, commentable: proposal, user: user2)
|
||||
|
||||
visit proposal_path(proposal)
|
||||
|
||||
@@ -21,49 +18,43 @@ describe "Official positions" do
|
||||
end
|
||||
|
||||
context "Debates" do
|
||||
|
||||
before do
|
||||
@debate1 = create(:debate, author: @user1)
|
||||
@debate2 = create(:debate, author: @user2)
|
||||
end
|
||||
let!(:debate1) { create(:debate, author: user1) }
|
||||
let!(:debate2) { create(:debate, author: user2) }
|
||||
|
||||
scenario "Index" do
|
||||
visit debates_path
|
||||
|
||||
expect_badge_for("debate", @debate1)
|
||||
expect_no_badge_for("debate", @debate2)
|
||||
expect_badge_for("debate", debate1)
|
||||
expect_no_badge_for("debate", debate2)
|
||||
end
|
||||
|
||||
scenario "Show" do
|
||||
visit debate_path(@debate1)
|
||||
expect_badge_for("debate", @debate1)
|
||||
visit debate_path(debate1)
|
||||
expect_badge_for("debate", debate1)
|
||||
|
||||
visit debate_path(@debate2)
|
||||
expect_no_badge_for("debate", @debate2)
|
||||
visit debate_path(debate2)
|
||||
expect_no_badge_for("debate", debate2)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context "Proposals" do
|
||||
|
||||
before do
|
||||
@proposal1 = create(:proposal, author: @user1)
|
||||
@proposal2 = create(:proposal, author: @user2)
|
||||
end
|
||||
let!(:proposal1) { create(:proposal, author: user1) }
|
||||
let!(:proposal2) { create(:proposal, author: user2) }
|
||||
|
||||
scenario "Index" do
|
||||
visit proposals_path
|
||||
|
||||
expect_badge_for("proposal", @proposal1)
|
||||
expect_no_badge_for("proposal", @proposal2)
|
||||
expect_badge_for("proposal", proposal1)
|
||||
expect_no_badge_for("proposal", proposal2)
|
||||
end
|
||||
|
||||
scenario "Show" do
|
||||
visit proposal_path(@proposal1)
|
||||
expect_badge_for("proposal", @proposal1)
|
||||
visit proposal_path(proposal1)
|
||||
expect_badge_for("proposal", proposal1)
|
||||
|
||||
visit proposal_path(@proposal2)
|
||||
expect_no_badge_for("proposal", @proposal2)
|
||||
visit proposal_path(proposal2)
|
||||
expect_no_badge_for("proposal", proposal2)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -4,15 +4,16 @@ describe "Officing Results", :with_frozen_time do
|
||||
let(:poll) { create(:poll, ends_at: 1.day.ago) }
|
||||
let(:booth) { create(:poll_booth, polls: [poll]) }
|
||||
let(:poll_officer) { create(:poll_officer) }
|
||||
let(:question_1) { create(:poll_question, poll: poll) }
|
||||
let(:question_2) { create(:poll_question, poll: poll) }
|
||||
|
||||
before do
|
||||
create(:poll_shift, :recount_scrutiny_task, officer: poll_officer, booth: booth, date: Date.current)
|
||||
@question_1 = create(:poll_question, poll: poll)
|
||||
create(:poll_question_answer, title: "Yes", question: @question_1, given_order: 1)
|
||||
create(:poll_question_answer, title: "No", question: @question_1, given_order: 2)
|
||||
@question_2 = create(:poll_question, poll: poll)
|
||||
create(:poll_question_answer, title: "Today", question: @question_2, given_order: 1)
|
||||
create(:poll_question_answer, title: "Tomorrow", question: @question_2, given_order: 2)
|
||||
create(:poll_question_answer, title: "Yes", question: question_1, given_order: 1)
|
||||
create(:poll_question_answer, title: "No", question: question_1, given_order: 2)
|
||||
|
||||
create(:poll_question_answer, title: "Today", question: question_2, given_order: 1)
|
||||
create(:poll_question_answer, title: "Tomorrow", question: question_2, given_order: 2)
|
||||
|
||||
login_as(poll_officer.user)
|
||||
set_officing_booth(booth)
|
||||
@@ -57,11 +58,11 @@ describe "Officing Results", :with_frozen_time do
|
||||
|
||||
select booth.name, from: "officer_assignment_id"
|
||||
|
||||
fill_in "questions[#{@question_1.id}][0]", with: "100"
|
||||
fill_in "questions[#{@question_1.id}][1]", with: "200"
|
||||
fill_in "questions[#{question_1.id}][0]", with: "100"
|
||||
fill_in "questions[#{question_1.id}][1]", with: "200"
|
||||
|
||||
fill_in "questions[#{@question_2.id}][0]", with: "333"
|
||||
fill_in "questions[#{@question_2.id}][1]", with: "444"
|
||||
fill_in "questions[#{question_2.id}][0]", with: "333"
|
||||
fill_in "questions[#{question_2.id}][1]", with: "444"
|
||||
|
||||
fill_in "whites", with: "66"
|
||||
fill_in "nulls", with: "77"
|
||||
@@ -82,22 +83,22 @@ describe "Officing Results", :with_frozen_time do
|
||||
officer_assignment: poll_officer.officer_assignments.first,
|
||||
booth_assignment: poll_officer.officer_assignments.first.booth_assignment,
|
||||
date: Date.current,
|
||||
question: @question_1,
|
||||
answer: @question_1.question_answers.first.title,
|
||||
question: question_1,
|
||||
answer: question_1.question_answers.first.title,
|
||||
author: poll_officer.user,
|
||||
amount: 7777)
|
||||
|
||||
visit officing_poll_results_path(poll, date: I18n.l(partial_result.date), booth_assignment_id: partial_result.booth_assignment_id)
|
||||
|
||||
within("#question_#{@question_1.id}_0_result") { expect(page).to have_content("7777") }
|
||||
within("#question_#{question_1.id}_0_result") { expect(page).to have_content("7777") }
|
||||
|
||||
visit new_officing_poll_result_path(poll)
|
||||
|
||||
booth_name = partial_result.booth_assignment.booth.name
|
||||
select booth_name, from: "officer_assignment_id"
|
||||
|
||||
fill_in "questions[#{@question_1.id}][0]", with: "5555"
|
||||
fill_in "questions[#{@question_1.id}][1]", with: "200"
|
||||
fill_in "questions[#{question_1.id}][0]", with: "5555"
|
||||
fill_in "questions[#{question_1.id}][1]", with: "200"
|
||||
fill_in "whites", with: "6"
|
||||
fill_in "nulls", with: "7"
|
||||
fill_in "total", with: "8"
|
||||
@@ -114,8 +115,8 @@ describe "Officing Results", :with_frozen_time do
|
||||
within("#white_results") { expect(page).to have_content("6") }
|
||||
within("#null_results") { expect(page).to have_content("7") }
|
||||
within("#total_results") { expect(page).to have_content("8") }
|
||||
within("#question_#{@question_1.id}_0_result") { expect(page).to have_content("5555") }
|
||||
within("#question_#{@question_1.id}_1_result") { expect(page).to have_content("200") }
|
||||
within("#question_#{question_1.id}_0_result") { expect(page).to have_content("5555") }
|
||||
within("#question_#{question_1.id}_1_result") { expect(page).to have_content("200") }
|
||||
end
|
||||
|
||||
scenario "Index lists all questions and answers" do
|
||||
@@ -123,7 +124,7 @@ describe "Officing Results", :with_frozen_time do
|
||||
officer_assignment: poll_officer.officer_assignments.first,
|
||||
booth_assignment: poll_officer.officer_assignments.first.booth_assignment,
|
||||
date: poll.ends_at,
|
||||
question: @question_1,
|
||||
question: question_1,
|
||||
amount: 33)
|
||||
|
||||
create(:poll_recount,
|
||||
@@ -141,14 +142,14 @@ describe "Officing Results", :with_frozen_time do
|
||||
expect(page).to have_content(I18n.l(poll.ends_at.to_date, format: :long))
|
||||
expect(page).to have_content(poll_officer.officer_assignments.first.booth_assignment.booth.name)
|
||||
|
||||
expect(page).to have_content(@question_1.title)
|
||||
@question_1.question_answers.each_with_index do |answer, i|
|
||||
within("#question_#{@question_1.id}_#{i}_result") { expect(page).to have_content(answer.title) }
|
||||
expect(page).to have_content(question_1.title)
|
||||
question_1.question_answers.each_with_index do |answer, i|
|
||||
within("#question_#{question_1.id}_#{i}_result") { expect(page).to have_content(answer.title) }
|
||||
end
|
||||
|
||||
expect(page).to have_content(@question_2.title)
|
||||
@question_2.question_answers.each_with_index do |answer, i|
|
||||
within("#question_#{@question_2.id}_#{i}_result") { expect(page).to have_content(answer.title) }
|
||||
expect(page).to have_content(question_2.title)
|
||||
question_2.question_answers.each_with_index do |answer, i|
|
||||
within("#question_#{question_2.id}_#{i}_result") { expect(page).to have_content(answer.title) }
|
||||
end
|
||||
|
||||
within("#white_results") { expect(page).to have_content("21") }
|
||||
|
||||
@@ -3,9 +3,9 @@ require "rails_helper"
|
||||
describe "Tracking budgets" do
|
||||
|
||||
before do
|
||||
@tracker = create(:tracker, user: create(:user, username: "Rachel",
|
||||
tracker = create(:tracker, user: create(:user, username: "Rachel",
|
||||
email: "rachel@trackers.org"))
|
||||
login_as(@tracker.user)
|
||||
login_as(tracker.user)
|
||||
end
|
||||
|
||||
scenario "Disabled with a feature flag" do
|
||||
|
||||
@@ -3,15 +3,15 @@ require "rails_helper"
|
||||
describe "Users" do
|
||||
|
||||
describe "Show (public page)" do
|
||||
let(:user) { create(:user) }
|
||||
|
||||
before do
|
||||
@user = create(:user)
|
||||
1.times { create(:debate, author: @user) }
|
||||
2.times { create(:proposal, author: @user) }
|
||||
3.times { create(:budget_investment, author: @user) }
|
||||
4.times { create(:comment, user: @user) }
|
||||
1.times { create(:debate, author: user) }
|
||||
2.times { create(:proposal, author: user) }
|
||||
3.times { create(:budget_investment, author: user) }
|
||||
4.times { create(:comment, user: user) }
|
||||
|
||||
visit user_path(@user)
|
||||
visit user_path(user)
|
||||
end
|
||||
|
||||
scenario "shows user public activity" do
|
||||
@@ -22,7 +22,7 @@ describe "Users" do
|
||||
end
|
||||
|
||||
scenario "shows only items where user has activity" do
|
||||
@user.proposals.destroy_all
|
||||
user.proposals.destroy_all
|
||||
|
||||
expect(page).not_to have_content("0 Proposals")
|
||||
expect(page).to have_content("1 Debate")
|
||||
@@ -31,41 +31,41 @@ describe "Users" do
|
||||
end
|
||||
|
||||
scenario "default filter is proposals" do
|
||||
@user.proposals.each do |proposal|
|
||||
user.proposals.each do |proposal|
|
||||
expect(page).to have_content(proposal.title)
|
||||
end
|
||||
|
||||
@user.debates.each do |debate|
|
||||
user.debates.each do |debate|
|
||||
expect(page).not_to have_content(debate.title)
|
||||
end
|
||||
|
||||
@user.comments.each do |comment|
|
||||
user.comments.each do |comment|
|
||||
expect(page).not_to have_content(comment.body)
|
||||
end
|
||||
end
|
||||
|
||||
scenario "shows debates by default if user has no proposals" do
|
||||
@user.proposals.destroy_all
|
||||
visit user_path(@user)
|
||||
user.proposals.destroy_all
|
||||
visit user_path(user)
|
||||
|
||||
expect(page).to have_content(@user.debates.first.title)
|
||||
expect(page).to have_content(user.debates.first.title)
|
||||
end
|
||||
|
||||
scenario "shows investments by default if user has no proposals nor debates" do
|
||||
@user.proposals.destroy_all
|
||||
@user.debates.destroy_all
|
||||
visit user_path(@user)
|
||||
user.proposals.destroy_all
|
||||
user.debates.destroy_all
|
||||
visit user_path(user)
|
||||
|
||||
expect(page).to have_content(@user.budget_investments.first.title)
|
||||
expect(page).to have_content(user.budget_investments.first.title)
|
||||
end
|
||||
|
||||
scenario "shows comments by default if user has no proposals nor debates nor investments" do
|
||||
@user.proposals.destroy_all
|
||||
@user.debates.destroy_all
|
||||
@user.budget_investments.destroy_all
|
||||
visit user_path(@user)
|
||||
user.proposals.destroy_all
|
||||
user.debates.destroy_all
|
||||
user.budget_investments.destroy_all
|
||||
visit user_path(user)
|
||||
|
||||
@user.comments.each do |comment|
|
||||
user.comments.each do |comment|
|
||||
expect(page).to have_content(comment.body)
|
||||
end
|
||||
end
|
||||
@@ -73,43 +73,43 @@ describe "Users" do
|
||||
scenario "filters" do
|
||||
click_link "1 Debate"
|
||||
|
||||
@user.debates.each do |debate|
|
||||
user.debates.each do |debate|
|
||||
expect(page).to have_content(debate.title)
|
||||
end
|
||||
|
||||
@user.proposals.each do |proposal|
|
||||
user.proposals.each do |proposal|
|
||||
expect(page).not_to have_content(proposal.title)
|
||||
end
|
||||
|
||||
@user.comments.each do |comment|
|
||||
user.comments.each do |comment|
|
||||
expect(page).not_to have_content(comment.body)
|
||||
end
|
||||
|
||||
click_link "4 Comments"
|
||||
|
||||
@user.comments.each do |comment|
|
||||
user.comments.each do |comment|
|
||||
expect(page).to have_content(comment.body)
|
||||
end
|
||||
|
||||
@user.proposals.each do |proposal|
|
||||
user.proposals.each do |proposal|
|
||||
expect(page).not_to have_content(proposal.title)
|
||||
end
|
||||
|
||||
@user.debates.each do |debate|
|
||||
user.debates.each do |debate|
|
||||
expect(page).not_to have_content(debate.title)
|
||||
end
|
||||
|
||||
click_link "2 Proposals"
|
||||
|
||||
@user.proposals.each do |proposal|
|
||||
user.proposals.each do |proposal|
|
||||
expect(page).to have_content(proposal.title)
|
||||
end
|
||||
|
||||
@user.comments.each do |comment|
|
||||
user.comments.each do |comment|
|
||||
expect(page).not_to have_content(comment.body)
|
||||
end
|
||||
|
||||
@user.debates.each do |debate|
|
||||
user.debates.each do |debate|
|
||||
expect(page).not_to have_content(debate.title)
|
||||
end
|
||||
end
|
||||
@@ -138,19 +138,17 @@ describe "Users" do
|
||||
end
|
||||
|
||||
describe "Public activity" do
|
||||
before do
|
||||
@user = create(:user)
|
||||
end
|
||||
let(:user) { create(:user) }
|
||||
|
||||
scenario "visible by default" do
|
||||
visit user_path(@user)
|
||||
visit user_path(user)
|
||||
|
||||
expect(page).to have_content(@user.username)
|
||||
expect(page).to have_content(user.username)
|
||||
expect(page).not_to have_content("activity list private")
|
||||
end
|
||||
|
||||
scenario "user can hide public page" do
|
||||
login_as(@user)
|
||||
login_as(user)
|
||||
visit account_path
|
||||
|
||||
uncheck "account_public_activity"
|
||||
@@ -158,23 +156,23 @@ describe "Users" do
|
||||
|
||||
logout
|
||||
|
||||
visit user_path(@user)
|
||||
visit user_path(user)
|
||||
expect(page).to have_content("activity list private")
|
||||
end
|
||||
|
||||
scenario "is always visible for the owner" do
|
||||
login_as(@user)
|
||||
login_as(user)
|
||||
visit account_path
|
||||
|
||||
uncheck "account_public_activity"
|
||||
click_button "Save changes"
|
||||
|
||||
visit user_path(@user)
|
||||
visit user_path(user)
|
||||
expect(page).not_to have_content("activity list private")
|
||||
end
|
||||
|
||||
scenario "is always visible for admins" do
|
||||
login_as(@user)
|
||||
login_as(user)
|
||||
visit account_path
|
||||
|
||||
uncheck "account_public_activity"
|
||||
@@ -183,12 +181,12 @@ describe "Users" do
|
||||
logout
|
||||
|
||||
login_as(create(:administrator).user)
|
||||
visit user_path(@user)
|
||||
visit user_path(user)
|
||||
expect(page).not_to have_content("activity list private")
|
||||
end
|
||||
|
||||
scenario "is always visible for moderators" do
|
||||
login_as(@user)
|
||||
login_as(user)
|
||||
visit account_path
|
||||
|
||||
uncheck "account_public_activity"
|
||||
@@ -197,51 +195,46 @@ describe "Users" do
|
||||
logout
|
||||
|
||||
login_as(create(:moderator).user)
|
||||
visit user_path(@user)
|
||||
visit user_path(user)
|
||||
expect(page).not_to have_content("activity list private")
|
||||
end
|
||||
|
||||
describe "User email" do
|
||||
|
||||
before do
|
||||
@user = create(:user)
|
||||
end
|
||||
let(:user) { create(:user) }
|
||||
|
||||
scenario "is not shown if no user logged in" do
|
||||
visit user_path(@user)
|
||||
expect(page).not_to have_content(@user.email)
|
||||
visit user_path(user)
|
||||
expect(page).not_to have_content(user.email)
|
||||
end
|
||||
|
||||
scenario "is not shown if logged in user is a regular user" do
|
||||
login_as(create(:user))
|
||||
visit user_path(@user)
|
||||
expect(page).not_to have_content(@user.email)
|
||||
visit user_path(user)
|
||||
expect(page).not_to have_content(user.email)
|
||||
end
|
||||
|
||||
scenario "is not shown if logged in user is moderator" do
|
||||
login_as(create(:moderator).user)
|
||||
visit user_path(@user)
|
||||
expect(page).not_to have_content(@user.email)
|
||||
visit user_path(user)
|
||||
expect(page).not_to have_content(user.email)
|
||||
end
|
||||
|
||||
scenario "is shown if logged in user is admin" do
|
||||
login_as(create(:administrator).user)
|
||||
visit user_path(@user)
|
||||
expect(page).to have_content(@user.email)
|
||||
visit user_path(user)
|
||||
expect(page).to have_content(user.email)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
describe "Public interests" do
|
||||
before do
|
||||
@user = create(:user)
|
||||
end
|
||||
let(:user) { create(:user) }
|
||||
|
||||
scenario "Display interests" do
|
||||
create(:proposal, tag_list: "Sport", followers: [@user])
|
||||
create(:proposal, tag_list: "Sport", followers: [user])
|
||||
|
||||
login_as(@user)
|
||||
login_as(user)
|
||||
visit account_path
|
||||
|
||||
check "account_public_interests"
|
||||
@@ -249,15 +242,15 @@ describe "Users" do
|
||||
|
||||
logout
|
||||
|
||||
visit user_path(@user)
|
||||
visit user_path(user)
|
||||
expect(page).to have_content("Sport")
|
||||
end
|
||||
|
||||
scenario "Not display interests when proposal has been destroyed" do
|
||||
proposal = create(:proposal, tag_list: "Sport", followers: [@user])
|
||||
proposal = create(:proposal, tag_list: "Sport", followers: [user])
|
||||
proposal.destroy
|
||||
|
||||
login_as(@user)
|
||||
login_as(user)
|
||||
visit account_path
|
||||
|
||||
check "account_public_interests"
|
||||
@@ -265,21 +258,21 @@ describe "Users" do
|
||||
|
||||
logout
|
||||
|
||||
visit user_path(@user)
|
||||
visit user_path(user)
|
||||
expect(page).not_to have_content("Sport")
|
||||
end
|
||||
|
||||
scenario "No visible by default" do
|
||||
visit user_path(@user)
|
||||
visit user_path(user)
|
||||
|
||||
expect(page).to have_content(@user.username)
|
||||
expect(page).to have_content(user.username)
|
||||
expect(page).not_to have_css("#public_interests")
|
||||
end
|
||||
|
||||
scenario "User can display public page" do
|
||||
create(:proposal, tag_list: "Sport", followers: [@user])
|
||||
create(:proposal, tag_list: "Sport", followers: [user])
|
||||
|
||||
login_as(@user)
|
||||
login_as(user)
|
||||
visit account_path
|
||||
|
||||
check "account_public_interests"
|
||||
@@ -287,28 +280,28 @@ describe "Users" do
|
||||
|
||||
logout
|
||||
|
||||
visit user_path(@user, filter: "follows", page: "1")
|
||||
visit user_path(user, filter: "follows", page: "1")
|
||||
|
||||
expect(page).to have_css("#public_interests")
|
||||
end
|
||||
|
||||
scenario "Is always visible for the owner" do
|
||||
create(:proposal, tag_list: "Sport", followers: [@user])
|
||||
create(:proposal, tag_list: "Sport", followers: [user])
|
||||
|
||||
login_as(@user)
|
||||
login_as(user)
|
||||
visit account_path
|
||||
|
||||
uncheck "account_public_interests"
|
||||
click_button "Save changes"
|
||||
|
||||
visit user_path(@user, filter: "follows", page: "1")
|
||||
visit user_path(user, filter: "follows", page: "1")
|
||||
expect(page).to have_css("#public_interests")
|
||||
end
|
||||
|
||||
scenario "Is always visible for admins" do
|
||||
create(:proposal, tag_list: "Sport", followers: [@user])
|
||||
create(:proposal, tag_list: "Sport", followers: [user])
|
||||
|
||||
login_as(@user)
|
||||
login_as(user)
|
||||
visit account_path
|
||||
|
||||
uncheck "account_public_interests"
|
||||
@@ -317,14 +310,14 @@ describe "Users" do
|
||||
logout
|
||||
|
||||
login_as(create(:administrator).user)
|
||||
visit user_path(@user, filter: "follows", page: "1")
|
||||
visit user_path(user, filter: "follows", page: "1")
|
||||
expect(page).to have_css("#public_interests")
|
||||
end
|
||||
|
||||
scenario "Is always visible for moderators" do
|
||||
create(:proposal, tag_list: "Sport", followers: [@user])
|
||||
create(:proposal, tag_list: "Sport", followers: [user])
|
||||
|
||||
login_as(@user)
|
||||
login_as(user)
|
||||
visit account_path
|
||||
|
||||
uncheck "account_public_interests"
|
||||
@@ -333,25 +326,25 @@ describe "Users" do
|
||||
logout
|
||||
|
||||
login_as(create(:moderator).user)
|
||||
visit user_path(@user, filter: "follows", page: "1")
|
||||
visit user_path(user, filter: "follows", page: "1")
|
||||
expect(page).to have_css("#public_interests")
|
||||
end
|
||||
|
||||
scenario "Should display generic interests title" do
|
||||
create(:proposal, tag_list: "Sport", followers: [@user])
|
||||
create(:proposal, tag_list: "Sport", followers: [user])
|
||||
|
||||
@user.update(public_interests: true)
|
||||
visit user_path(@user, filter: "follows", page: "1")
|
||||
user.update(public_interests: true)
|
||||
visit user_path(user, filter: "follows", page: "1")
|
||||
|
||||
expect(page).to have_content("Tags of elements this user follows")
|
||||
end
|
||||
|
||||
scenario "Should display custom interests title when user is visiting own user page" do
|
||||
create(:proposal, tag_list: "Sport", followers: [@user])
|
||||
create(:proposal, tag_list: "Sport", followers: [user])
|
||||
|
||||
@user.update(public_interests: true)
|
||||
login_as(@user)
|
||||
visit user_path(@user, filter: "follows", page: "1")
|
||||
user.update(public_interests: true)
|
||||
login_as(user)
|
||||
visit user_path(user, filter: "follows", page: "1")
|
||||
|
||||
expect(page).to have_content("Tags of elements you follow")
|
||||
end
|
||||
@@ -411,30 +404,27 @@ describe "Users" do
|
||||
end
|
||||
|
||||
describe "Following (public page)" do
|
||||
|
||||
before do
|
||||
@user = create(:user)
|
||||
end
|
||||
let(:user) { create(:user) }
|
||||
|
||||
scenario "Do not display follows' tab when user is not following any followables" do
|
||||
visit user_path(@user)
|
||||
visit user_path(user)
|
||||
|
||||
expect(page).not_to have_content("0 Following")
|
||||
end
|
||||
|
||||
scenario "Active following tab by default when follows filters selected", :js do
|
||||
create(:proposal, author: @user, followers: [@user])
|
||||
create(:proposal, author: user, followers: [user])
|
||||
|
||||
visit user_path(@user, filter: "follows")
|
||||
visit user_path(user, filter: "follows")
|
||||
|
||||
expect(page).to have_selector(".activity li.is-active", text: "1 Following")
|
||||
end
|
||||
|
||||
scenario "Gracefully handle followables that have been hidden" do
|
||||
create(:proposal, followers: [@user])
|
||||
create(:proposal, followers: [@user]) { |proposal| proposal.hide }
|
||||
create(:proposal, followers: [user])
|
||||
create(:proposal, followers: [user]) { |proposal| proposal.hide }
|
||||
|
||||
visit user_path(@user)
|
||||
visit user_path(user)
|
||||
|
||||
expect(page).to have_content("1 Following")
|
||||
end
|
||||
@@ -442,43 +432,43 @@ describe "Users" do
|
||||
describe "Proposals" do
|
||||
|
||||
scenario "Display following tab when user is following one proposal at least" do
|
||||
create(:proposal, followers: [@user])
|
||||
create(:proposal, followers: [user])
|
||||
|
||||
visit user_path(@user)
|
||||
visit user_path(user)
|
||||
|
||||
expect(page).to have_content("1 Following")
|
||||
end
|
||||
|
||||
scenario "Display proposal tab when user is following one proposal at least" do
|
||||
create(:proposal, followers: [@user])
|
||||
create(:proposal, followers: [user])
|
||||
|
||||
visit user_path(@user, filter: "follows")
|
||||
visit user_path(user, filter: "follows")
|
||||
|
||||
expect(page).to have_link("Citizen proposals", href: "#citizen_proposals")
|
||||
end
|
||||
|
||||
scenario "Do not display proposals' tab when user is not following any proposal" do
|
||||
visit user_path(@user, filter: "follows")
|
||||
visit user_path(user, filter: "follows")
|
||||
|
||||
expect(page).not_to have_link("Citizen proposals", href: "#citizen_proposals")
|
||||
end
|
||||
|
||||
scenario "Display proposals with link to proposal" do
|
||||
proposal = create(:proposal, author: @user, followers: [@user])
|
||||
proposal = create(:proposal, author: user, followers: [user])
|
||||
|
||||
login_as @user
|
||||
login_as user
|
||||
|
||||
visit user_path(@user, filter: "follows")
|
||||
visit user_path(user, filter: "follows")
|
||||
click_link "Citizen proposals"
|
||||
|
||||
expect(page).to have_content proposal.title
|
||||
end
|
||||
|
||||
scenario "Retired proposals do not have a link to the dashboard", js: true do
|
||||
proposal = create(:proposal, :retired, author: @user)
|
||||
login_as @user
|
||||
proposal = create(:proposal, :retired, author: user)
|
||||
login_as user
|
||||
|
||||
visit user_path(@user)
|
||||
visit user_path(user)
|
||||
|
||||
expect(page).to have_content proposal.title
|
||||
expect(page).not_to have_link "Dashboard"
|
||||
@@ -486,10 +476,10 @@ describe "Users" do
|
||||
end
|
||||
|
||||
scenario "Published proposals have a link to the dashboard" do
|
||||
proposal = create(:proposal, :published, author: @user)
|
||||
login_as @user
|
||||
proposal = create(:proposal, :published, author: user)
|
||||
login_as user
|
||||
|
||||
visit user_path(@user)
|
||||
visit user_path(user)
|
||||
|
||||
expect(page).to have_content proposal.title
|
||||
expect(page).to have_link "Dashboard"
|
||||
@@ -499,23 +489,23 @@ describe "Users" do
|
||||
describe "Budget Investments" do
|
||||
|
||||
scenario "Display following tab when user is following one budget investment at least" do
|
||||
create(:budget_investment, followers: [@user])
|
||||
create(:budget_investment, followers: [user])
|
||||
|
||||
visit user_path(@user)
|
||||
visit user_path(user)
|
||||
|
||||
expect(page).to have_content("1 Following")
|
||||
end
|
||||
|
||||
scenario "Display budget investment tab when user is following one budget investment at least" do
|
||||
create(:budget_investment, followers: [@user])
|
||||
create(:budget_investment, followers: [user])
|
||||
|
||||
visit user_path(@user, filter: "follows")
|
||||
visit user_path(user, filter: "follows")
|
||||
|
||||
expect(page).to have_link("Investments", href: "#investments")
|
||||
end
|
||||
|
||||
scenario "Not display budget investment tab when user is not following any budget investment" do
|
||||
visit user_path(@user, filter: "follows")
|
||||
visit user_path(user, filter: "follows")
|
||||
|
||||
expect(page).not_to have_link("Investments", href: "#investments")
|
||||
end
|
||||
|
||||
@@ -3,8 +3,8 @@ require "rails_helper"
|
||||
describe "Valuation budgets" do
|
||||
|
||||
before do
|
||||
@valuator = create(:valuator, user: create(:user, username: "Rachel", email: "rachel@valuators.org"))
|
||||
login_as(@valuator.user)
|
||||
valuator = create(:valuator, user: create(:user, username: "Rachel", email: "rachel@valuators.org"))
|
||||
login_as(valuator.user)
|
||||
end
|
||||
|
||||
scenario "Disabled with a feature flag" do
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe "Votes" do
|
||||
let!(:verified) { create(:user, verified_at: Time.current) }
|
||||
let!(:unverified) { create(:user) }
|
||||
|
||||
before do
|
||||
@manuela = create(:user, verified_at: Time.current)
|
||||
@pablo = create(:user)
|
||||
end
|
||||
|
||||
describe "Debates" do
|
||||
before { login_as(@manuela) }
|
||||
before { login_as(verified) }
|
||||
|
||||
scenario "Index shows user votes on debates" do
|
||||
|
||||
debate1 = create(:debate)
|
||||
debate2 = create(:debate)
|
||||
debate3 = create(:debate)
|
||||
create(:vote, voter: @manuela, votable: debate1, vote_flag: true)
|
||||
create(:vote, voter: @manuela, votable: debate3, vote_flag: false)
|
||||
create(:vote, voter: verified, votable: debate1, vote_flag: true)
|
||||
create(:vote, voter: verified, votable: debate3, vote_flag: false)
|
||||
|
||||
visit debates_path
|
||||
|
||||
@@ -123,8 +123,8 @@ describe "Votes" do
|
||||
|
||||
scenario "Show" do
|
||||
debate = create(:debate)
|
||||
create(:vote, voter: @manuela, votable: debate, vote_flag: true)
|
||||
create(:vote, voter: @pablo, votable: debate, vote_flag: false)
|
||||
create(:vote, voter: verified, votable: debate, vote_flag: true)
|
||||
create(:vote, voter: unverified, votable: debate, vote_flag: false)
|
||||
|
||||
visit debate_path(debate)
|
||||
|
||||
@@ -185,10 +185,10 @@ describe "Votes" do
|
||||
end
|
||||
|
||||
describe "Proposals" do
|
||||
before { login_as(@manuela) }
|
||||
before { login_as(verified) }
|
||||
|
||||
scenario "Index shows user votes on proposals" do
|
||||
proposal1 = create(:proposal, voters: [@manuela])
|
||||
proposal1 = create(:proposal, voters: [verified])
|
||||
proposal2 = create(:proposal)
|
||||
proposal3 = create(:proposal)
|
||||
|
||||
@@ -210,17 +210,15 @@ describe "Votes" do
|
||||
end
|
||||
|
||||
describe "Single proposal" do
|
||||
before do
|
||||
@proposal = create(:proposal)
|
||||
end
|
||||
let!(:proposal) { create(:proposal) }
|
||||
|
||||
scenario "Show no votes" do
|
||||
visit proposal_path(@proposal)
|
||||
visit proposal_path(proposal)
|
||||
expect(page).to have_content "No supports"
|
||||
end
|
||||
|
||||
scenario "Trying to vote multiple times", :js do
|
||||
visit proposal_path(@proposal)
|
||||
visit proposal_path(proposal)
|
||||
|
||||
within(".supports") do
|
||||
find(".in-favor a").click
|
||||
@@ -231,10 +229,10 @@ describe "Votes" do
|
||||
end
|
||||
|
||||
scenario "Show" do
|
||||
create(:vote, voter: @manuela, votable: @proposal, vote_flag: true)
|
||||
create(:vote, voter: @pablo, votable: @proposal, vote_flag: true)
|
||||
create(:vote, voter: verified, votable: proposal, vote_flag: true)
|
||||
create(:vote, voter: unverified, votable: proposal, vote_flag: true)
|
||||
|
||||
visit proposal_path(@proposal)
|
||||
visit proposal_path(proposal)
|
||||
|
||||
within(".supports") do
|
||||
expect(page).to have_content "2 supports"
|
||||
@@ -242,7 +240,7 @@ describe "Votes" do
|
||||
end
|
||||
|
||||
scenario "Create from proposal show", :js do
|
||||
visit proposal_path(@proposal)
|
||||
visit proposal_path(proposal)
|
||||
|
||||
within(".supports") do
|
||||
find(".in-favor a").click
|
||||
@@ -255,7 +253,7 @@ describe "Votes" do
|
||||
scenario "Create in listed proposal in index", :js do
|
||||
visit proposals_path
|
||||
|
||||
within("#proposal_#{@proposal.id}") do
|
||||
within("#proposal_#{proposal.id}") do
|
||||
find(".in-favor a").click
|
||||
|
||||
expect(page).to have_content "1 support"
|
||||
@@ -267,7 +265,7 @@ describe "Votes" do
|
||||
scenario "Create in featured proposal in index", :js do
|
||||
visit proposals_path
|
||||
|
||||
within("#proposal_#{@proposal.id}") do
|
||||
within("#proposal_#{proposal.id}") do
|
||||
find(".in-favor a").click
|
||||
|
||||
expect(page).to have_content "You have already supported this proposal. Share it!"
|
||||
|
||||
@@ -1,29 +1,26 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe "rake sitemap:create", type: :feature do
|
||||
before do
|
||||
@file ||= Rails.root.join("public", "sitemap.xml")
|
||||
let(:file) { Rails.root.join("public", "sitemap.xml") }
|
||||
|
||||
# To avoid spec failures if file does not exist
|
||||
# Useful on CI environments or if file was created
|
||||
# previous to the specs (to ensure a clean state)
|
||||
File.delete(@file) if File.exist?(@file)
|
||||
before do
|
||||
File.delete(file) if File.exist?(file)
|
||||
|
||||
Rake::Task["sitemap:create"].reenable
|
||||
Rake.application.invoke_task("sitemap:create")
|
||||
end
|
||||
|
||||
it "generates a sitemap" do
|
||||
expect(@file).to exist
|
||||
expect(file).to exist
|
||||
end
|
||||
|
||||
it "generates a valid sitemap" do
|
||||
sitemap = Nokogiri::XML(File.open(@file))
|
||||
sitemap = Nokogiri::XML(File.open(file))
|
||||
expect(sitemap.errors).to be_empty
|
||||
end
|
||||
|
||||
it "generates a sitemap with expected and valid URLs" do
|
||||
sitemap = File.read(@file)
|
||||
sitemap = File.read(file)
|
||||
|
||||
# Static pages
|
||||
expect(sitemap).to include(faq_path)
|
||||
|
||||
Reference in New Issue
Block a user