Change single quotes to double quotes
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
describe Admin::Api::StatsController do
|
||||
|
||||
describe 'GET index' do
|
||||
describe "GET index" do
|
||||
let(:user) { create(:administrator).user }
|
||||
|
||||
context 'events or visits not present' do
|
||||
it 'responds with bad_request' do
|
||||
context "events or visits not present" do
|
||||
it "responds with bad_request" do
|
||||
sign_in user
|
||||
get :show
|
||||
|
||||
@@ -15,23 +15,23 @@ describe Admin::Api::StatsController do
|
||||
end
|
||||
end
|
||||
|
||||
context 'events present' do
|
||||
context "events present" do
|
||||
before do
|
||||
time_1 = Time.zone.local(2015, 01, 01)
|
||||
time_2 = Time.zone.local(2015, 01, 02)
|
||||
time_3 = Time.zone.local(2015, 01, 03)
|
||||
|
||||
create :ahoy_event, name: 'foo', time: time_1
|
||||
create :ahoy_event, name: 'foo', time: time_1
|
||||
create :ahoy_event, name: 'foo', time: time_2
|
||||
create :ahoy_event, name: 'bar', time: time_1
|
||||
create :ahoy_event, name: 'bar', time: time_3
|
||||
create :ahoy_event, name: 'bar', time: time_3
|
||||
create :ahoy_event, name: "foo", time: time_1
|
||||
create :ahoy_event, name: "foo", time: time_1
|
||||
create :ahoy_event, name: "foo", time: time_2
|
||||
create :ahoy_event, name: "bar", time: time_1
|
||||
create :ahoy_event, name: "bar", time: time_3
|
||||
create :ahoy_event, name: "bar", time: time_3
|
||||
end
|
||||
|
||||
it 'returns single events formated for working with c3.js' do
|
||||
it "returns single events formated for working with c3.js" do
|
||||
sign_in user
|
||||
get :show, events: 'foo'
|
||||
get :show, events: "foo"
|
||||
|
||||
expect(response).to be_ok
|
||||
|
||||
@@ -39,9 +39,9 @@ describe Admin::Api::StatsController do
|
||||
expect(data).to eq "x" => ["2015-01-01", "2015-01-02"], "Foo" => [2, 1]
|
||||
end
|
||||
|
||||
it 'returns combined comma separated events formated for working with c3.js' do
|
||||
it "returns combined comma separated events formated for working with c3.js" do
|
||||
sign_in user
|
||||
get :show, events: 'foo,bar'
|
||||
get :show, events: "foo,bar"
|
||||
|
||||
expect(response).to be_ok
|
||||
|
||||
@@ -50,8 +50,8 @@ describe Admin::Api::StatsController do
|
||||
end
|
||||
end
|
||||
|
||||
context 'visits present' do
|
||||
it 'returns visits formated for working with c3.js' do
|
||||
context "visits present" do
|
||||
it "returns visits formated for working with c3.js" do
|
||||
time_1 = Time.zone.local(2015, 01, 01)
|
||||
time_2 = Time.zone.local(2015, 01, 02)
|
||||
|
||||
@@ -69,21 +69,21 @@ describe Admin::Api::StatsController do
|
||||
end
|
||||
end
|
||||
|
||||
context 'visits and events present' do
|
||||
it 'returns combined events and visits formated for working with c3.js' do
|
||||
context "visits and events present" do
|
||||
it "returns combined events and visits formated for working with c3.js" do
|
||||
time_1 = Time.zone.local(2015, 01, 01)
|
||||
time_2 = Time.zone.local(2015, 01, 02)
|
||||
|
||||
create :ahoy_event, name: 'foo', time: time_1
|
||||
create :ahoy_event, name: 'foo', time: time_2
|
||||
create :ahoy_event, name: 'foo', time: time_2
|
||||
create :ahoy_event, name: "foo", time: time_1
|
||||
create :ahoy_event, name: "foo", time: time_2
|
||||
create :ahoy_event, name: "foo", time: time_2
|
||||
|
||||
create :visit, started_at: time_1
|
||||
create :visit, started_at: time_1
|
||||
create :visit, started_at: time_2
|
||||
|
||||
sign_in user
|
||||
get :show, events: 'foo', visits: true
|
||||
get :show, events: "foo", visits: true
|
||||
|
||||
expect(response).to be_ok
|
||||
|
||||
@@ -92,8 +92,8 @@ describe Admin::Api::StatsController do
|
||||
end
|
||||
end
|
||||
|
||||
context 'budget investments present' do
|
||||
it 'returns budget investments formated for working with c3.js' do
|
||||
context "budget investments present" do
|
||||
it "returns budget investments formated for working with c3.js" do
|
||||
time_1 = Time.zone.local(2017, 04, 01)
|
||||
time_2 = Time.zone.local(2017, 04, 02)
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
describe ApplicationController do
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
describe CommentsController do
|
||||
|
||||
describe 'POST create' do
|
||||
describe "POST create" do
|
||||
before do
|
||||
@process = create(:legislation_process, debate_start_date: Date.current - 3.days, debate_end_date: Date.current + 2.days)
|
||||
@question = create(:legislation_question, process: @process, title: "Question 1")
|
||||
@@ -10,7 +10,7 @@ describe CommentsController do
|
||||
@unverified_user = create(:user)
|
||||
end
|
||||
|
||||
it 'creates an comment if the comments are open' do
|
||||
it "creates an comment if the comments are open" do
|
||||
sign_in @user
|
||||
|
||||
expect do
|
||||
@@ -18,7 +18,7 @@ describe CommentsController do
|
||||
end.to change { @question.reload.comments_count }.by(1)
|
||||
end
|
||||
|
||||
it 'does not create a comment if the comments are closed' do
|
||||
it "does not create a comment if the comments are closed" do
|
||||
sign_in @user
|
||||
@process.update_attribute(:debate_end_date, Date.current - 1.day)
|
||||
|
||||
@@ -27,7 +27,7 @@ describe CommentsController do
|
||||
end.not_to change { @question.reload.comments_count }
|
||||
end
|
||||
|
||||
it 'does not create a comment for unverified users when the commentable requires it' do
|
||||
it "does not create a comment for unverified users when the commentable requires it" do
|
||||
sign_in @unverified_user
|
||||
|
||||
expect do
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
describe HasFilters do
|
||||
|
||||
@@ -6,7 +6,7 @@ describe HasFilters do
|
||||
|
||||
controller(FakeController) do
|
||||
include HasFilters
|
||||
has_filters ['all', 'pending', 'reviewed'], only: :index
|
||||
has_filters ["all", "pending", "reviewed"], only: :index
|
||||
|
||||
def index
|
||||
render text: "#{@current_filter} (#{@valid_filters.join(' ')})"
|
||||
@@ -15,23 +15,23 @@ describe HasFilters do
|
||||
|
||||
it "has the valid filters set up" do
|
||||
get :index
|
||||
expect(response.body).to eq('all (all pending reviewed)')
|
||||
expect(response.body).to eq("all (all pending reviewed)")
|
||||
end
|
||||
|
||||
describe "the current filter" do
|
||||
it "defaults to the first one on the list" do
|
||||
get :index
|
||||
expect(response.body).to eq('all (all pending reviewed)')
|
||||
expect(response.body).to eq("all (all pending reviewed)")
|
||||
end
|
||||
|
||||
it "can be changed by the filter param" do
|
||||
get :index, filter: 'pending'
|
||||
expect(response.body).to eq('pending (all pending reviewed)')
|
||||
get :index, filter: "pending"
|
||||
expect(response.body).to eq("pending (all pending reviewed)")
|
||||
end
|
||||
|
||||
it "defaults to the first one on the list if given a bogus filter" do
|
||||
get :index, filter: 'foobar'
|
||||
expect(response.body).to eq('all (all pending reviewed)')
|
||||
get :index, filter: "foobar"
|
||||
expect(response.body).to eq("all (all pending reviewed)")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
describe HasOrders do
|
||||
|
||||
@@ -6,8 +6,8 @@ describe HasOrders do
|
||||
|
||||
controller(FakeController) do
|
||||
include HasOrders
|
||||
has_orders ['created_at', 'votes_count', 'flags_count', 'relevance'], only: :index
|
||||
has_orders ->(c) { ['votes_count', 'flags_count'] }, only: :new
|
||||
has_orders ["created_at", "votes_count", "flags_count", "relevance"], only: :index
|
||||
has_orders ->(c) { ["votes_count", "flags_count"] }, only: :new
|
||||
|
||||
def index
|
||||
render text: "#{@current_order} (#{@valid_orders.join(' ')})"
|
||||
@@ -20,41 +20,41 @@ describe HasOrders do
|
||||
|
||||
it "displays all the orders except relevance when not searching" do
|
||||
get :index
|
||||
expect(response.body).to eq('created_at (created_at votes_count flags_count)')
|
||||
expect(response.body).to eq("created_at (created_at votes_count flags_count)")
|
||||
end
|
||||
|
||||
it "allows specifying the orders via a lambda" do
|
||||
get :new
|
||||
expect(response.body).to eq('votes_count (votes_count flags_count)')
|
||||
expect(response.body).to eq("votes_count (votes_count flags_count)")
|
||||
end
|
||||
|
||||
it "displays relevance when searching" do
|
||||
get :index, search: 'ipsum'
|
||||
expect(response.body).to eq('created_at (created_at votes_count flags_count relevance)')
|
||||
get :index, search: "ipsum"
|
||||
expect(response.body).to eq("created_at (created_at votes_count flags_count relevance)")
|
||||
end
|
||||
|
||||
it "does not overwrite the has_orders options when doing several requests" do
|
||||
get :index
|
||||
# Since has_orders did valid_options.delete, the first call to :index might remove 'relevance' from
|
||||
# the list by mistake.
|
||||
get :index, search: 'ipsum'
|
||||
expect(response.body).to eq('created_at (created_at votes_count flags_count relevance)')
|
||||
get :index, search: "ipsum"
|
||||
expect(response.body).to eq("created_at (created_at votes_count flags_count relevance)")
|
||||
end
|
||||
|
||||
describe "the current order" do
|
||||
it "defaults to the first one on the list" do
|
||||
get :index
|
||||
expect(response.body).to eq('created_at (created_at votes_count flags_count)')
|
||||
expect(response.body).to eq("created_at (created_at votes_count flags_count)")
|
||||
end
|
||||
|
||||
it "can be changed by the order param" do
|
||||
get :index, order: 'votes_count'
|
||||
expect(response.body).to eq('votes_count (created_at votes_count flags_count)')
|
||||
get :index, order: "votes_count"
|
||||
expect(response.body).to eq("votes_count (created_at votes_count flags_count)")
|
||||
end
|
||||
|
||||
it "defaults to the first one on the list if given a bogus order" do
|
||||
get :index, order: 'foobar'
|
||||
expect(response.body).to eq('created_at (created_at votes_count flags_count)')
|
||||
get :index, order: "foobar"
|
||||
expect(response.body).to eq("created_at (created_at votes_count flags_count)")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
describe DebatesController do
|
||||
|
||||
describe 'POST create' do
|
||||
describe "POST create" do
|
||||
before do
|
||||
InvisibleCaptcha.timestamp_enabled = false
|
||||
end
|
||||
@@ -11,38 +11,38 @@ describe DebatesController do
|
||||
InvisibleCaptcha.timestamp_enabled = true
|
||||
end
|
||||
|
||||
it 'creates an ahoy event' do
|
||||
it "creates an ahoy event" do
|
||||
|
||||
sign_in create(:user)
|
||||
|
||||
post :create, debate: { title: 'A sample debate', description: 'this is a sample debate', terms_of_service: 1 }
|
||||
post :create, debate: { title: "A sample debate", description: "this is a sample debate", terms_of_service: 1 }
|
||||
expect(Ahoy::Event.where(name: :debate_created).count).to eq 1
|
||||
expect(Ahoy::Event.last.properties['debate_id']).to eq Debate.last.id
|
||||
expect(Ahoy::Event.last.properties["debate_id"]).to eq Debate.last.id
|
||||
end
|
||||
end
|
||||
|
||||
describe "Vote with too many anonymous votes" do
|
||||
after do
|
||||
Setting['max_ratio_anon_votes_on_debates'] = 50
|
||||
Setting["max_ratio_anon_votes_on_debates"] = 50
|
||||
end
|
||||
|
||||
it 'allows vote if user is allowed' do
|
||||
it "allows vote if user is allowed" do
|
||||
Setting["max_ratio_anon_votes_on_debates"] = 100
|
||||
debate = create(:debate)
|
||||
sign_in create(:user)
|
||||
|
||||
expect do
|
||||
xhr :post, :vote, id: debate.id, value: 'yes'
|
||||
xhr :post, :vote, id: debate.id, value: "yes"
|
||||
end.to change { debate.reload.votes_for.size }.by(1)
|
||||
end
|
||||
|
||||
it 'does not allow vote if user is not allowed' do
|
||||
it "does not allow vote if user is not allowed" do
|
||||
Setting["max_ratio_anon_votes_on_debates"] = 0
|
||||
debate = create(:debate, cached_votes_total: 1000)
|
||||
sign_in create(:user)
|
||||
|
||||
expect do
|
||||
xhr :post, :vote, id: debate.id, value: 'yes'
|
||||
xhr :post, :vote, id: debate.id, value: "yes"
|
||||
end.not_to change { debate.reload.votes_for.size }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
# Useful resource: http://graphql.org/learn/serving-over-http/
|
||||
|
||||
def parser_error_raised?(response)
|
||||
data_is_empty = response['data'].nil?
|
||||
error_is_present = (JSON.parse(response.body)['errors'].first['message'] =~ /^Parse error on/)
|
||||
data_is_empty = response["data"].nil?
|
||||
error_is_present = (JSON.parse(response.body)["errors"].first["message"] =~ /^Parse error on/)
|
||||
data_is_empty && error_is_present
|
||||
end
|
||||
|
||||
@@ -13,24 +13,24 @@ describe GraphqlController, type: :request do
|
||||
|
||||
describe "handles GET request" do
|
||||
specify "with query string inside query params" do
|
||||
get '/graphql', query: "{ proposal(id: #{proposal.id}) { title } }"
|
||||
get "/graphql", query: "{ proposal(id: #{proposal.id}) { title } }"
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(JSON.parse(response.body)['data']['proposal']['title']).to eq(proposal.title)
|
||||
expect(JSON.parse(response.body)["data"]["proposal"]["title"]).to eq(proposal.title)
|
||||
end
|
||||
|
||||
specify "with malformed query string" do
|
||||
get '/graphql', query: 'Malformed query string'
|
||||
get "/graphql", query: "Malformed query string"
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(parser_error_raised?(response)).to be_truthy
|
||||
end
|
||||
|
||||
specify "without query string" do
|
||||
get '/graphql'
|
||||
get "/graphql"
|
||||
|
||||
expect(response).to have_http_status(:bad_request)
|
||||
expect(JSON.parse(response.body)['message']).to eq('Query string not present')
|
||||
expect(JSON.parse(response.body)["message"]).to eq("Query string not present")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -38,32 +38,32 @@ describe GraphqlController, type: :request do
|
||||
let(:json_headers) { { "CONTENT_TYPE" => "application/json" } }
|
||||
|
||||
specify "with json-encoded query string inside body" do
|
||||
post '/graphql', { query: "{ proposal(id: #{proposal.id}) { title } }" }.to_json, json_headers
|
||||
post "/graphql", { query: "{ proposal(id: #{proposal.id}) { title } }" }.to_json, json_headers
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(JSON.parse(response.body)['data']['proposal']['title']).to eq(proposal.title)
|
||||
expect(JSON.parse(response.body)["data"]["proposal"]["title"]).to eq(proposal.title)
|
||||
end
|
||||
|
||||
specify "with raw query string inside body" do
|
||||
graphql_headers = { "CONTENT_TYPE" => "application/graphql" }
|
||||
post '/graphql', "{ proposal(id: #{proposal.id}) { title } }", graphql_headers
|
||||
post "/graphql", "{ proposal(id: #{proposal.id}) { title } }", graphql_headers
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(JSON.parse(response.body)['data']['proposal']['title']).to eq(proposal.title)
|
||||
expect(JSON.parse(response.body)["data"]["proposal"]["title"]).to eq(proposal.title)
|
||||
end
|
||||
|
||||
specify "with malformed query string" do
|
||||
post '/graphql', { query: "Malformed query string" }.to_json, json_headers
|
||||
post "/graphql", { query: "Malformed query string" }.to_json, json_headers
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(parser_error_raised?(response)).to be_truthy
|
||||
end
|
||||
|
||||
it "without query string" do
|
||||
post '/graphql', json_headers
|
||||
post "/graphql", json_headers
|
||||
|
||||
expect(response).to have_http_status(:bad_request)
|
||||
expect(JSON.parse(response.body)['message']).to eq('Query string not present')
|
||||
expect(JSON.parse(response.body)["message"]).to eq("Query string not present")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
describe InstallationController, type: :request do
|
||||
|
||||
describe "consul.json" do
|
||||
let(:test_feature_settings) do
|
||||
{
|
||||
'disabled_feature' => nil,
|
||||
'enabled_feature' => 't'
|
||||
"disabled_feature" => nil,
|
||||
"enabled_feature" => "t"
|
||||
}
|
||||
end
|
||||
|
||||
@@ -30,11 +30,11 @@ describe InstallationController, type: :request do
|
||||
end
|
||||
|
||||
specify "with query string inside query params" do
|
||||
get '/consul.json'
|
||||
get "/consul.json"
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(JSON.parse(response.body)['release']).not_to be_empty
|
||||
expect(JSON.parse(response.body)['features']).to eq(test_feature_settings)
|
||||
expect(JSON.parse(response.body)["release"]).not_to be_empty
|
||||
expect(JSON.parse(response.body)["features"]).to eq(test_feature_settings)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
describe Legislation::AnnotationsController do
|
||||
|
||||
describe 'POST create' do
|
||||
describe "POST create" do
|
||||
before do
|
||||
@process = create(:legislation_process, allegations_start_date: Date.current - 3.days, allegations_end_date: Date.current + 2.days)
|
||||
@draft_version = create(:legislation_draft_version, :published, process: @process, title: "Version 1")
|
||||
@@ -10,7 +10,7 @@ describe Legislation::AnnotationsController do
|
||||
@user = create(:user, :level_two)
|
||||
end
|
||||
|
||||
it 'creates an ahoy event' do
|
||||
it "creates an ahoy event" do
|
||||
sign_in @user
|
||||
|
||||
post :create, process_id: @process.id,
|
||||
@@ -21,10 +21,10 @@ describe Legislation::AnnotationsController do
|
||||
"text": "una anotacion"
|
||||
}
|
||||
expect(Ahoy::Event.where(name: :legislation_annotation_created).count).to eq 1
|
||||
expect(Ahoy::Event.last.properties['legislation_annotation_id']).to eq Legislation::Annotation.last.id
|
||||
expect(Ahoy::Event.last.properties["legislation_annotation_id"]).to eq Legislation::Annotation.last.id
|
||||
end
|
||||
|
||||
it 'does not create an annotation if the draft version is a final version' do
|
||||
it "does not create an annotation if the draft version is a final version" do
|
||||
sign_in @user
|
||||
|
||||
post :create, process_id: @process.id,
|
||||
@@ -38,7 +38,7 @@ describe Legislation::AnnotationsController do
|
||||
expect(response).to have_http_status(:not_found)
|
||||
end
|
||||
|
||||
it 'creates an annotation if the process allegations phase is open' do
|
||||
it "creates an annotation if the process allegations phase is open" do
|
||||
sign_in @user
|
||||
|
||||
expect do
|
||||
@@ -52,7 +52,7 @@ describe Legislation::AnnotationsController do
|
||||
end.to change { @draft_version.annotations.count }.by(1)
|
||||
end
|
||||
|
||||
it 'does not create an annotation if the process allegations phase is not open' do
|
||||
it "does not create an annotation if the process allegations phase is not open" do
|
||||
sign_in @user
|
||||
@process.update_attribute(:allegations_end_date, Date.current - 1.day)
|
||||
|
||||
@@ -67,7 +67,7 @@ describe Legislation::AnnotationsController do
|
||||
end.not_to change { @draft_version.annotations.count }
|
||||
end
|
||||
|
||||
it 'creates an annotation by parsing parameters in JSON' do
|
||||
it "creates an annotation by parsing parameters in JSON" do
|
||||
sign_in @user
|
||||
|
||||
expect do
|
||||
@@ -81,7 +81,7 @@ describe Legislation::AnnotationsController do
|
||||
end.to change { @draft_version.annotations.count }.by(1)
|
||||
end
|
||||
|
||||
it 'creates a new comment on an existing annotation when range is the same' do
|
||||
it "creates a new comment on an existing annotation when range is the same" do
|
||||
annotation = create(:legislation_annotation, draft_version: @draft_version, text: "my annotation",
|
||||
ranges: [{"start" => "/p[1]", "startOffset" => 6, "end" => "/p[1]", "endOffset" => 11}],
|
||||
range_start: "/p[1]", range_start_offset: 6, range_end: "/p[1]", range_end_offset: 11)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
describe Legislation::AnswersController do
|
||||
|
||||
describe 'POST create' do
|
||||
describe "POST create" do
|
||||
before do
|
||||
@process = create(:legislation_process, debate_start_date: Date.current - 3.days, debate_end_date: Date.current + 2.days)
|
||||
@question = create(:legislation_question, process: @process, title: "Question 1")
|
||||
@@ -10,16 +10,16 @@ describe Legislation::AnswersController do
|
||||
@user = create(:user, :level_two)
|
||||
end
|
||||
|
||||
it 'creates an ahoy event' do
|
||||
it "creates an ahoy event" do
|
||||
sign_in @user
|
||||
|
||||
post :create, process_id: @process.id, question_id: @question.id,
|
||||
legislation_answer: { legislation_question_option_id: @question_option.id }
|
||||
expect(Ahoy::Event.where(name: :legislation_answer_created).count).to eq 1
|
||||
expect(Ahoy::Event.last.properties['legislation_answer_id']).to eq Legislation::Answer.last.id
|
||||
expect(Ahoy::Event.last.properties["legislation_answer_id"]).to eq Legislation::Answer.last.id
|
||||
end
|
||||
|
||||
it 'creates an answer if the process debate phase is open' do
|
||||
it "creates an answer if the process debate phase is open" do
|
||||
sign_in @user
|
||||
|
||||
expect do
|
||||
@@ -28,7 +28,7 @@ describe Legislation::AnswersController do
|
||||
end.to change { @question.reload.answers_count }.by(1)
|
||||
end
|
||||
|
||||
it 'does not create an answer if the process debate phase is not open' do
|
||||
it "does not create an answer if the process debate phase is not open" do
|
||||
sign_in @user
|
||||
@process.update_attribute(:debate_end_date, Date.current - 1.day)
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
describe Management::BaseController do
|
||||
|
||||
describe 'managed_user' do
|
||||
describe "managed_user" do
|
||||
|
||||
it "returns existent user with session document info if present" do
|
||||
session[:document_type] = "1"
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
describe Management::SessionsController do
|
||||
|
||||
describe 'Sign in' do
|
||||
describe "Sign in" do
|
||||
it "denies access if wrong manager credentials" do
|
||||
allow_any_instance_of(ManagerAuthenticator).to receive(:auth).and_return(false)
|
||||
expect { get :create, login: "nonexistent", clave_usuario: "wrong"}.to raise_error CanCan::AccessDenied
|
||||
@@ -41,7 +41,7 @@ describe Management::SessionsController do
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Sign out' do
|
||||
describe "Sign out" do
|
||||
it "destroys the session data and redirect" do
|
||||
session[:manager] = {user_key: "31415926", date: "20151031135905", login: "JJB033"}
|
||||
session[:document_type] = "1"
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
describe Management::UsersController do
|
||||
|
||||
describe 'logout' do
|
||||
describe "logout" do
|
||||
it "removes user data from the session" do
|
||||
session[:manager] = {user_key: "31415926", date: "20151031135905", login: "JJB033"}
|
||||
session[:document_type] = "1"
|
||||
|
||||
@@ -1,44 +1,44 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
describe PagesController do
|
||||
|
||||
describe 'Static pages' do
|
||||
it 'includes a privacy page' do
|
||||
describe "Static pages" do
|
||||
it "includes a privacy page" do
|
||||
get :show, id: :privacy
|
||||
expect(response).to be_ok
|
||||
end
|
||||
|
||||
it 'includes a conditions page' do
|
||||
it "includes a conditions page" do
|
||||
get :show, id: :conditions
|
||||
expect(response).to be_ok
|
||||
end
|
||||
|
||||
it 'includes a accessibility page' do
|
||||
it "includes a accessibility page" do
|
||||
get :show, id: :accessibility
|
||||
expect(response).to be_ok
|
||||
end
|
||||
end
|
||||
|
||||
describe 'More info pages' do
|
||||
describe "More info pages" do
|
||||
|
||||
it 'includes a more info page' do
|
||||
get :show, id: 'help/index'
|
||||
it "includes a more info page" do
|
||||
get :show, id: "help/index"
|
||||
expect(response).to be_ok
|
||||
end
|
||||
|
||||
it 'includes a how_to_use page' do
|
||||
get :show, id: 'help/how_to_use/index'
|
||||
it "includes a how_to_use page" do
|
||||
get :show, id: "help/how_to_use/index"
|
||||
expect(response).to be_ok
|
||||
end
|
||||
|
||||
it 'includes a faq page' do
|
||||
get :show, id: 'help/faq/index'
|
||||
it "includes a faq page" do
|
||||
get :show, id: "help/faq/index"
|
||||
expect(response).to be_ok
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Not found pages' do
|
||||
it 'returns a 404 message' do
|
||||
describe "Not found pages" do
|
||||
it "returns a 404 message" do
|
||||
get :show, id: "nonExistentPage"
|
||||
expect(response).to be_missing
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
describe Users::RegistrationsController do
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
# This module tests functionality related with custom application files
|
||||
# TODO test models, controllers, etc...
|
||||
|
||||
describe 'Customization Engine' do
|
||||
describe "Customization Engine" do
|
||||
|
||||
let(:test_key) { I18n.t('account.show.change_credentials_link') }
|
||||
let(:test_key) { I18n.t("account.show.change_credentials_link") }
|
||||
let!(:default_path) { I18n.load_path }
|
||||
|
||||
before do
|
||||
@@ -16,16 +16,16 @@ describe 'Customization Engine' do
|
||||
reset_load_path_and_reload(default_path)
|
||||
end
|
||||
|
||||
it 'loads custom and override original locales' do
|
||||
increase_load_path_and_reload(Dir[Rails.root.join('spec', 'support',
|
||||
'locales', 'custom', '*.{rb,yml}')])
|
||||
expect(test_key).to eq 'Overriden string with custom locales'
|
||||
it "loads custom and override original locales" do
|
||||
increase_load_path_and_reload(Dir[Rails.root.join("spec", "support",
|
||||
"locales", "custom", "*.{rb,yml}")])
|
||||
expect(test_key).to eq "Overriden string with custom locales"
|
||||
end
|
||||
|
||||
it 'does not override original locales' do
|
||||
increase_load_path_and_reload(Dir[Rails.root.join('spec', 'support',
|
||||
'locales', '*.{rb,yml}')])
|
||||
expect(test_key).to eq 'Not overriden string with custom locales'
|
||||
it "does not override original locales" do
|
||||
increase_load_path_and_reload(Dir[Rails.root.join("spec", "support",
|
||||
"locales", "*.{rb,yml}")])
|
||||
expect(test_key).to eq "Not overriden string with custom locales"
|
||||
end
|
||||
|
||||
def reset_load_path_and_reload(path)
|
||||
|
||||
@@ -20,27 +20,27 @@ FactoryBot.define do
|
||||
target_url {["/proposals", "/debates" ].sample}
|
||||
post_started_at { Time.current - 7.days }
|
||||
post_ended_at { Time.current + 7.days }
|
||||
background_color '#FF0000'
|
||||
font_color '#FFFFFF'
|
||||
background_color "#FF0000"
|
||||
font_color "#FFFFFF"
|
||||
end
|
||||
|
||||
factory :web_section do
|
||||
name 'homepage'
|
||||
name "homepage"
|
||||
end
|
||||
|
||||
factory :banner_section, class: 'Banner::Section' do
|
||||
factory :banner_section, class: "Banner::Section" do
|
||||
association :banner_id, factory: :banner
|
||||
association :web_section, factory: :web_section
|
||||
end
|
||||
|
||||
factory :site_customization_page, class: 'SiteCustomization::Page' do
|
||||
factory :site_customization_page, class: "SiteCustomization::Page" do
|
||||
slug "example-page"
|
||||
title "Example page"
|
||||
subtitle "About an example"
|
||||
content "This page is about..."
|
||||
more_info_flag false
|
||||
print_content_flag false
|
||||
status 'draft'
|
||||
status "draft"
|
||||
|
||||
trait :published do
|
||||
status "published"
|
||||
@@ -51,7 +51,7 @@ FactoryBot.define do
|
||||
end
|
||||
end
|
||||
|
||||
factory :site_customization_content_block, class: 'SiteCustomization::ContentBlock' do
|
||||
factory :site_customization_content_block, class: "SiteCustomization::ContentBlock" do
|
||||
name "top_links"
|
||||
locale "en"
|
||||
body "Some top links content"
|
||||
@@ -71,7 +71,7 @@ FactoryBot.define do
|
||||
end
|
||||
end
|
||||
|
||||
factory :widget_card, class: 'Widget::Card' do
|
||||
factory :widget_card, class: "Widget::Card" do
|
||||
sequence(:title) { |n| "Title #{n}" }
|
||||
sequence(:description) { |n| "Description #{n}" }
|
||||
sequence(:link_text) { |n| "Link text #{n}" }
|
||||
@@ -89,12 +89,12 @@ FactoryBot.define do
|
||||
end
|
||||
end
|
||||
|
||||
factory :widget_feed, class: 'Widget::Feed' do
|
||||
factory :widget_feed, class: "Widget::Feed" do
|
||||
end
|
||||
|
||||
factory :i18n_content, class: 'I18nContent' do
|
||||
key 'debates.index.section_footer.description'
|
||||
value_es 'Texto en español'
|
||||
value_en 'Text in english'
|
||||
factory :i18n_content, class: "I18nContent" do
|
||||
key "debates.index.section_footer.description"
|
||||
value_es "Texto en español"
|
||||
value_en "Text in english"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
FactoryBot.define do
|
||||
factory :debate do
|
||||
sequence(:title) { |n| "Debate #{n} title" }
|
||||
description 'Debate description'
|
||||
terms_of_service '1'
|
||||
description "Debate description"
|
||||
terms_of_service "1"
|
||||
association :author, factory: :user
|
||||
|
||||
trait :hidden do
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
FactoryBot.define do
|
||||
factory :legislation_process, class: 'Legislation::Process' do
|
||||
factory :legislation_process, class: "Legislation::Process" do
|
||||
title "A collaborative legislation process"
|
||||
description "Description of the process"
|
||||
summary "Summary of the process"
|
||||
@@ -97,7 +97,7 @@ FactoryBot.define do
|
||||
|
||||
end
|
||||
|
||||
factory :legislation_draft_version, class: 'Legislation::DraftVersion' do
|
||||
factory :legislation_draft_version, class: "Legislation::DraftVersion" do
|
||||
process factory: :legislation_process
|
||||
title "Version 1"
|
||||
changelog "What changed in this version"
|
||||
@@ -126,7 +126,7 @@ LOREM_IPSUM
|
||||
end
|
||||
end
|
||||
|
||||
factory :legislation_annotation, class: 'Legislation::Annotation' do
|
||||
factory :legislation_annotation, class: "Legislation::Annotation" do
|
||||
draft_version factory: :legislation_draft_version
|
||||
author factory: :user
|
||||
quote "ipsum"
|
||||
@@ -138,27 +138,27 @@ LOREM_IPSUM
|
||||
range_end_offset 11
|
||||
end
|
||||
|
||||
factory :legislation_question, class: 'Legislation::Question' do
|
||||
factory :legislation_question, class: "Legislation::Question" do
|
||||
process factory: :legislation_process
|
||||
title "Question text"
|
||||
author factory: :user
|
||||
end
|
||||
|
||||
factory :legislation_question_option, class: 'Legislation::QuestionOption' do
|
||||
factory :legislation_question_option, class: "Legislation::QuestionOption" do
|
||||
question factory: :legislation_question
|
||||
sequence(:value) { |n| "Option #{n}" }
|
||||
end
|
||||
|
||||
factory :legislation_answer, class: 'Legislation::Answer' do
|
||||
factory :legislation_answer, class: "Legislation::Answer" do
|
||||
question factory: :legislation_question
|
||||
question_option factory: :legislation_question_option
|
||||
user
|
||||
end
|
||||
|
||||
factory :legislation_proposal, class: 'Legislation::Proposal' do
|
||||
factory :legislation_proposal, class: "Legislation::Proposal" do
|
||||
sequence(:title) { |n| "Proposal #{n} for a legislation" }
|
||||
summary "This law should include..."
|
||||
terms_of_service '1'
|
||||
terms_of_service "1"
|
||||
process factory: :legislation_process
|
||||
author factory: :user
|
||||
end
|
||||
|
||||
@@ -25,7 +25,7 @@ FactoryBot.define do
|
||||
end
|
||||
end
|
||||
|
||||
factory :poll_question, class: 'Poll::Question' do
|
||||
factory :poll_question, class: "Poll::Question" do
|
||||
poll
|
||||
association :author, factory: :user
|
||||
sequence(:title) { |n| "Question title #{n}" }
|
||||
@@ -38,29 +38,29 @@ FactoryBot.define do
|
||||
end
|
||||
end
|
||||
|
||||
factory :poll_question_answer, class: 'Poll::Question::Answer' do
|
||||
factory :poll_question_answer, class: "Poll::Question::Answer" do
|
||||
association :question, factory: :poll_question
|
||||
sequence(:title) { |n| "Answer title #{n}" }
|
||||
sequence(:description) { |n| "Answer description #{n}" }
|
||||
end
|
||||
|
||||
factory :poll_answer_video, class: 'Poll::Question::Answer::Video' do
|
||||
factory :poll_answer_video, class: "Poll::Question::Answer::Video" do
|
||||
association :answer, factory: :poll_question_answer
|
||||
title "Sample video title"
|
||||
url "https://youtu.be/nhuNb0XtRhQ"
|
||||
end
|
||||
|
||||
factory :poll_booth, class: 'Poll::Booth' do
|
||||
factory :poll_booth, class: "Poll::Booth" do
|
||||
sequence(:name) { |n| "Booth #{n}" }
|
||||
sequence(:location) { |n| "Street #{n}" }
|
||||
end
|
||||
|
||||
factory :poll_booth_assignment, class: 'Poll::BoothAssignment' do
|
||||
factory :poll_booth_assignment, class: "Poll::BoothAssignment" do
|
||||
poll
|
||||
association :booth, factory: :poll_booth
|
||||
end
|
||||
|
||||
factory :poll_officer_assignment, class: 'Poll::OfficerAssignment' do
|
||||
factory :poll_officer_assignment, class: "Poll::OfficerAssignment" do
|
||||
association :officer, factory: :poll_officer
|
||||
association :booth_assignment, factory: :poll_booth_assignment
|
||||
date { Date.current }
|
||||
@@ -70,7 +70,7 @@ FactoryBot.define do
|
||||
end
|
||||
end
|
||||
|
||||
factory :poll_shift, class: 'Poll::Shift' do
|
||||
factory :poll_shift, class: "Poll::Shift" do
|
||||
association :booth, factory: :poll_booth
|
||||
association :officer, factory: :poll_officer
|
||||
date { Date.current }
|
||||
@@ -84,7 +84,7 @@ FactoryBot.define do
|
||||
end
|
||||
end
|
||||
|
||||
factory :poll_voter, class: 'Poll::Voter' do
|
||||
factory :poll_voter, class: "Poll::Voter" do
|
||||
poll
|
||||
association :user, :level_two
|
||||
association :officer, factory: :poll_officer
|
||||
@@ -105,25 +105,25 @@ FactoryBot.define do
|
||||
end
|
||||
end
|
||||
|
||||
factory :poll_answer, class: 'Poll::Answer' do
|
||||
factory :poll_answer, class: "Poll::Answer" do
|
||||
association :question, factory: [:poll_question, :with_answers]
|
||||
association :author, factory: [:user, :level_two]
|
||||
answer { question.question_answers.sample.title }
|
||||
end
|
||||
|
||||
factory :poll_partial_result, class: 'Poll::PartialResult' do
|
||||
factory :poll_partial_result, class: "Poll::PartialResult" do
|
||||
association :question, factory: [:poll_question, :with_answers]
|
||||
association :author, factory: :user
|
||||
origin 'web'
|
||||
origin "web"
|
||||
answer { question.question_answers.sample.title }
|
||||
end
|
||||
|
||||
factory :poll_recount, class: 'Poll::Recount' do
|
||||
factory :poll_recount, class: "Poll::Recount" do
|
||||
association :author, factory: :user
|
||||
origin 'web'
|
||||
origin "web"
|
||||
end
|
||||
|
||||
factory :officing_residence, class: 'Officing::Residence' do
|
||||
factory :officing_residence, class: "Officing::Residence" do
|
||||
user
|
||||
association :officer, factory: :poll_officer
|
||||
document_number
|
||||
|
||||
@@ -2,13 +2,13 @@ FactoryBot.define do
|
||||
factory :proposal do
|
||||
sequence(:title) { |n| "Proposal #{n} title" }
|
||||
sequence(:summary) { |n| "In summary, what we want is... #{n}" }
|
||||
description 'Proposal description'
|
||||
question 'Proposal question'
|
||||
external_url 'http://external_documention.es'
|
||||
video_url 'https://youtu.be/nhuNb0XtRhQ'
|
||||
responsible_name 'John Snow'
|
||||
terms_of_service '1'
|
||||
skip_map '1'
|
||||
description "Proposal description"
|
||||
question "Proposal question"
|
||||
external_url "http://external_documention.es"
|
||||
video_url "https://youtu.be/nhuNb0XtRhQ"
|
||||
responsible_name "John Snow"
|
||||
terms_of_service "1"
|
||||
skip_map "1"
|
||||
association :author, factory: :user
|
||||
|
||||
trait :hidden do
|
||||
|
||||
@@ -3,8 +3,8 @@ FactoryBot.define do
|
||||
sequence(:username) { |n| "Manuela#{n}" }
|
||||
sequence(:email) { |n| "manuela#{n}@consul.dev" }
|
||||
|
||||
password 'judgmentday'
|
||||
terms_of_service '1'
|
||||
password "judgmentday"
|
||||
terms_of_service "1"
|
||||
confirmed_at { Time.current }
|
||||
public_activity true
|
||||
|
||||
@@ -74,7 +74,7 @@ FactoryBot.define do
|
||||
user
|
||||
end
|
||||
|
||||
factory :poll_officer, class: 'Poll::Officer' do
|
||||
factory :poll_officer, class: "Poll::Officer" do
|
||||
user
|
||||
end
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
FactoryBot.define do
|
||||
factory :local_census_record, class: 'LocalCensusRecord' do
|
||||
document_number '12345678A'
|
||||
factory :local_census_record, class: "LocalCensusRecord" do
|
||||
document_number "12345678A"
|
||||
document_type 1
|
||||
date_of_birth Date.new(1970, 1, 31)
|
||||
postal_code '28002'
|
||||
postal_code "28002"
|
||||
end
|
||||
|
||||
sequence(:document_number) { |n| "#{n.to_s.rjust(8, '0')}X" }
|
||||
@@ -14,7 +14,7 @@ FactoryBot.define do
|
||||
document_type "1"
|
||||
date_of_birth { Time.zone.local(1980, 12, 31).to_date }
|
||||
postal_code "28013"
|
||||
terms_of_service '1'
|
||||
terms_of_service "1"
|
||||
|
||||
trait :invalid do
|
||||
postal_code "28001"
|
||||
@@ -26,7 +26,7 @@ FactoryBot.define do
|
||||
document_number
|
||||
document_type 1
|
||||
date_of_birth Date.new(1900, 1, 1)
|
||||
postal_code '28000'
|
||||
postal_code "28000"
|
||||
end
|
||||
|
||||
factory :verification_sms, class: Verification::Sms do
|
||||
@@ -35,9 +35,9 @@ FactoryBot.define do
|
||||
|
||||
factory :verification_letter, class: Verification::Letter do
|
||||
user
|
||||
email 'user@consul.dev'
|
||||
password '1234'
|
||||
verification_code '5555'
|
||||
email "user@consul.dev"
|
||||
password "1234"
|
||||
verification_code "5555"
|
||||
end
|
||||
|
||||
factory :lock do
|
||||
@@ -48,6 +48,6 @@ FactoryBot.define do
|
||||
|
||||
factory :verified_user do
|
||||
document_number
|
||||
document_type 'dni'
|
||||
document_type "dni"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Account' do
|
||||
feature "Account" do
|
||||
|
||||
background do
|
||||
@user = create(:user, username: "Manuela Colau")
|
||||
login_as(@user)
|
||||
end
|
||||
|
||||
scenario 'Show' do
|
||||
scenario "Show" do
|
||||
visit root_path
|
||||
|
||||
click_link "My account"
|
||||
@@ -15,10 +15,10 @@ feature 'Account' do
|
||||
expect(page).to have_current_path(account_path, ignore_query: true)
|
||||
|
||||
expect(page).to have_selector("input[value='Manuela Colau']")
|
||||
expect(page).to have_selector(avatar('Manuela Colau'), count: 1)
|
||||
expect(page).to have_selector(avatar("Manuela Colau"), count: 1)
|
||||
end
|
||||
|
||||
scenario 'Show organization' do
|
||||
scenario "Show organization" do
|
||||
create(:organization, user: @user, name: "Manuela Corp")
|
||||
|
||||
visit account_path
|
||||
@@ -26,18 +26,18 @@ feature 'Account' do
|
||||
expect(page).to have_selector("input[value='Manuela Corp']")
|
||||
expect(page).not_to have_selector("input[value='Manuela Colau']")
|
||||
|
||||
expect(page).to have_selector(avatar('Manuela Corp'), count: 1)
|
||||
expect(page).to have_selector(avatar("Manuela Corp"), count: 1)
|
||||
end
|
||||
|
||||
scenario 'Edit' do
|
||||
scenario "Edit" do
|
||||
visit account_path
|
||||
|
||||
fill_in 'account_username', with: 'Larry Bird'
|
||||
check 'account_email_on_comment'
|
||||
check 'account_email_on_comment_reply'
|
||||
uncheck 'account_email_digest'
|
||||
uncheck 'account_email_on_direct_message'
|
||||
click_button 'Save changes'
|
||||
fill_in "account_username", with: "Larry Bird"
|
||||
check "account_email_on_comment"
|
||||
check "account_email_on_comment_reply"
|
||||
uncheck "account_email_digest"
|
||||
uncheck "account_email_on_direct_message"
|
||||
click_button "Save changes"
|
||||
|
||||
expect(page).to have_content "Changes saved"
|
||||
|
||||
@@ -50,7 +50,7 @@ feature 'Account' do
|
||||
expect(find("#account_email_on_direct_message")).not_to be_checked
|
||||
end
|
||||
|
||||
scenario 'Edit email address' do
|
||||
scenario "Edit email address" do
|
||||
visit account_path
|
||||
|
||||
click_link "Change my credentials"
|
||||
@@ -61,10 +61,10 @@ feature 'Account' do
|
||||
|
||||
click_button "Update"
|
||||
|
||||
notice = 'Your account has been updated successfully;'\
|
||||
' however, we need to verify your new email address.'\
|
||||
' Please check your email and click on the link to'\
|
||||
' complete the confirmation of your new email address.'
|
||||
notice = "Your account has been updated successfully;"\
|
||||
" however, we need to verify your new email address."\
|
||||
" Please check your email and click on the link to"\
|
||||
" complete the confirmation of your new email address."
|
||||
expect(page).to have_content notice
|
||||
|
||||
email = open_last_email
|
||||
@@ -84,15 +84,15 @@ feature 'Account' do
|
||||
expect(page).to have_selector("input[value='new_user_email@example.com']")
|
||||
end
|
||||
|
||||
scenario 'Edit Organization' do
|
||||
scenario "Edit Organization" do
|
||||
create(:organization, user: @user, name: "Manuela Corp")
|
||||
visit account_path
|
||||
|
||||
fill_in 'account_organization_attributes_name', with: 'Google'
|
||||
check 'account_email_on_comment'
|
||||
check 'account_email_on_comment_reply'
|
||||
fill_in "account_organization_attributes_name", with: "Google"
|
||||
check "account_email_on_comment"
|
||||
check "account_email_on_comment_reply"
|
||||
|
||||
click_button 'Save changes'
|
||||
click_button "Save changes"
|
||||
|
||||
expect(page).to have_content "Changes saved"
|
||||
|
||||
@@ -111,8 +111,8 @@ feature 'Account' do
|
||||
login_as(official_user)
|
||||
visit account_path
|
||||
|
||||
check 'account_official_position_badge'
|
||||
click_button 'Save changes'
|
||||
check "account_official_position_badge"
|
||||
click_button "Save changes"
|
||||
expect(page).to have_content "Changes saved"
|
||||
|
||||
visit account_path
|
||||
@@ -126,12 +126,12 @@ feature 'Account' do
|
||||
login_as(official_user2)
|
||||
visit account_path
|
||||
|
||||
expect(page).not_to have_css '#account_official_position_badge'
|
||||
expect(page).not_to have_css "#account_official_position_badge"
|
||||
|
||||
login_as(official_user3)
|
||||
visit account_path
|
||||
|
||||
expect(page).not_to have_css '#account_official_position_badge'
|
||||
expect(page).not_to have_css "#account_official_position_badge"
|
||||
end
|
||||
|
||||
end
|
||||
@@ -139,34 +139,34 @@ feature 'Account' do
|
||||
scenario "Errors on edit" do
|
||||
visit account_path
|
||||
|
||||
fill_in 'account_username', with: ''
|
||||
click_button 'Save changes'
|
||||
fill_in "account_username", with: ""
|
||||
click_button "Save changes"
|
||||
|
||||
expect(page).to have_content error_message
|
||||
end
|
||||
|
||||
scenario 'Errors editing credentials' do
|
||||
scenario "Errors editing credentials" do
|
||||
visit root_path
|
||||
|
||||
click_link 'My account'
|
||||
click_link "My account"
|
||||
|
||||
expect(page).to have_current_path(account_path, ignore_query: true)
|
||||
|
||||
expect(page).to have_link('Change my credentials')
|
||||
click_link 'Change my credentials'
|
||||
click_button 'Update'
|
||||
expect(page).to have_link("Change my credentials")
|
||||
click_link "Change my credentials"
|
||||
click_button "Update"
|
||||
|
||||
expect(page).to have_content error_message
|
||||
end
|
||||
|
||||
scenario 'Erasing account' do
|
||||
scenario "Erasing account" do
|
||||
visit account_path
|
||||
|
||||
click_link 'Erase my account'
|
||||
click_link "Erase my account"
|
||||
|
||||
fill_in 'user_erase_reason', with: 'a test'
|
||||
fill_in "user_erase_reason", with: "a test"
|
||||
|
||||
click_button 'Erase my account'
|
||||
click_button "Erase my account"
|
||||
|
||||
expect(page).to have_content "Goodbye! Your account has been cancelled. We hope to see you again soon."
|
||||
|
||||
@@ -175,26 +175,26 @@ feature 'Account' do
|
||||
expect(page).to have_content "Invalid login or password"
|
||||
end
|
||||
|
||||
context 'Recommendations' do
|
||||
context "Recommendations" do
|
||||
|
||||
background do
|
||||
Setting['feature.user.recommendations'] = true
|
||||
Setting['feature.user.recommendations_on_debates'] = true
|
||||
Setting['feature.user.recommendations_on_proposals'] = true
|
||||
Setting["feature.user.recommendations"] = true
|
||||
Setting["feature.user.recommendations_on_debates"] = true
|
||||
Setting["feature.user.recommendations_on_proposals"] = true
|
||||
end
|
||||
|
||||
after do
|
||||
Setting['feature.user.recommendations'] = nil
|
||||
Setting['feature.user.recommendations_on_debates'] = nil
|
||||
Setting['feature.user.recommendations_on_proposals'] = nil
|
||||
Setting["feature.user.recommendations"] = nil
|
||||
Setting["feature.user.recommendations_on_debates"] = nil
|
||||
Setting["feature.user.recommendations_on_proposals"] = nil
|
||||
end
|
||||
|
||||
scenario 'are enabled by default' do
|
||||
scenario "are enabled by default" do
|
||||
visit account_path
|
||||
|
||||
expect(page).to have_content('Recommendations')
|
||||
expect(page).to have_content('Show debates recommendations')
|
||||
expect(page).to have_content('Show proposals recommendations')
|
||||
expect(page).to have_content("Recommendations")
|
||||
expect(page).to have_content("Show debates recommendations")
|
||||
expect(page).to have_content("Show proposals recommendations")
|
||||
expect(find("#account_recommended_debates")).to be_checked
|
||||
expect(find("#account_recommended_proposals")).to be_checked
|
||||
end
|
||||
@@ -202,16 +202,16 @@ feature 'Account' do
|
||||
scenario "can be disabled through 'My account' page" do
|
||||
visit account_path
|
||||
|
||||
expect(page).to have_content('Recommendations')
|
||||
expect(page).to have_content('Show debates recommendations')
|
||||
expect(page).to have_content('Show proposals recommendations')
|
||||
expect(page).to have_content("Recommendations")
|
||||
expect(page).to have_content("Show debates recommendations")
|
||||
expect(page).to have_content("Show proposals recommendations")
|
||||
expect(find("#account_recommended_debates")).to be_checked
|
||||
expect(find("#account_recommended_proposals")).to be_checked
|
||||
|
||||
uncheck 'account_recommended_debates'
|
||||
uncheck 'account_recommended_proposals'
|
||||
uncheck "account_recommended_debates"
|
||||
uncheck "account_recommended_proposals"
|
||||
|
||||
click_button 'Save changes'
|
||||
click_button "Save changes"
|
||||
|
||||
expect(find("#account_recommended_debates")).not_to be_checked
|
||||
expect(find("#account_recommended_proposals")).not_to be_checked
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Admin activity' do
|
||||
feature "Admin activity" do
|
||||
|
||||
background do
|
||||
@admin = create(:administrator)
|
||||
@@ -14,7 +14,7 @@ feature 'Admin activity' do
|
||||
visit proposal_path(proposal)
|
||||
|
||||
within("#proposal_#{proposal.id}") do
|
||||
accept_confirm { click_link 'Hide' }
|
||||
accept_confirm { click_link "Hide" }
|
||||
end
|
||||
|
||||
visit admin_activity_path
|
||||
@@ -31,7 +31,7 @@ feature 'Admin activity' do
|
||||
proposal2 = create(:proposal)
|
||||
proposal3 = create(:proposal)
|
||||
|
||||
visit moderation_proposals_path(filter: 'all')
|
||||
visit moderation_proposals_path(filter: "all")
|
||||
|
||||
within("#proposal_#{proposal1.id}") do
|
||||
check "proposal_#{proposal1.id}_check"
|
||||
@@ -76,7 +76,7 @@ feature 'Admin activity' do
|
||||
visit debate_path(debate)
|
||||
|
||||
within("#debate_#{debate.id}") do
|
||||
accept_confirm { click_link 'Hide' }
|
||||
accept_confirm { click_link "Hide" }
|
||||
end
|
||||
|
||||
visit admin_activity_path
|
||||
@@ -93,7 +93,7 @@ feature 'Admin activity' do
|
||||
debate2 = create(:debate)
|
||||
debate3 = create(:debate)
|
||||
|
||||
visit moderation_debates_path(filter: 'all')
|
||||
visit moderation_debates_path(filter: "all")
|
||||
|
||||
within("#debate_#{debate1.id}") do
|
||||
check "debate_#{debate1.id}_check"
|
||||
@@ -139,7 +139,7 @@ feature 'Admin activity' do
|
||||
visit debate_path(debate)
|
||||
|
||||
within("#comment_#{comment.id}") do
|
||||
accept_confirm { click_link 'Hide' }
|
||||
accept_confirm { click_link "Hide" }
|
||||
end
|
||||
|
||||
visit admin_activity_path
|
||||
@@ -156,7 +156,7 @@ feature 'Admin activity' do
|
||||
comment2 = create(:comment)
|
||||
comment3 = create(:comment, body: "Offensive!")
|
||||
|
||||
visit moderation_comments_path(filter: 'all')
|
||||
visit moderation_comments_path(filter: "all")
|
||||
|
||||
within("#comment_#{comment1.id}") do
|
||||
check "comment_#{comment1.id}_check"
|
||||
@@ -201,7 +201,7 @@ feature 'Admin activity' do
|
||||
visit proposal_path(proposal)
|
||||
|
||||
within("#proposal_#{proposal.id}") do
|
||||
click_link 'Hide author'
|
||||
click_link "Hide author"
|
||||
end
|
||||
|
||||
visit admin_activity_path
|
||||
@@ -221,7 +221,7 @@ feature 'Admin activity' do
|
||||
visit moderation_users_path(name_or_email: user.username)
|
||||
|
||||
within("#moderation_users") do
|
||||
click_link 'Block'
|
||||
click_link "Block"
|
||||
end
|
||||
|
||||
visit admin_activity_path
|
||||
@@ -238,7 +238,7 @@ feature 'Admin activity' do
|
||||
proposal2 = create(:proposal)
|
||||
proposal3 = create(:proposal)
|
||||
|
||||
visit moderation_proposals_path(filter: 'all')
|
||||
visit moderation_proposals_path(filter: "all")
|
||||
|
||||
within("#proposal_#{proposal1.id}") do
|
||||
check "proposal_#{proposal1.id}_check"
|
||||
@@ -264,7 +264,7 @@ feature 'Admin activity' do
|
||||
debate2 = create(:debate)
|
||||
debate3 = create(:debate)
|
||||
|
||||
visit moderation_debates_path(filter: 'all')
|
||||
visit moderation_debates_path(filter: "all")
|
||||
|
||||
within("#debate_#{debate1.id}") do
|
||||
check "debate_#{debate1.id}_check"
|
||||
@@ -290,7 +290,7 @@ feature 'Admin activity' do
|
||||
comment2 = create(:comment)
|
||||
comment3 = create(:comment, body: "Offensive!")
|
||||
|
||||
visit moderation_comments_path(filter: 'all')
|
||||
visit moderation_comments_path(filter: "all")
|
||||
|
||||
within("#comment_#{comment1.id}") do
|
||||
check "comment_#{comment1.id}_check"
|
||||
@@ -333,10 +333,10 @@ feature 'Admin activity' do
|
||||
|
||||
context "System emails" do
|
||||
scenario "Shows moderation activity on system emails" do
|
||||
proposal = create(:proposal, title: 'Proposal A')
|
||||
proposal = create(:proposal, title: "Proposal A")
|
||||
proposal_notification = create(:proposal_notification, proposal: proposal,
|
||||
title: 'Proposal A Title',
|
||||
body: 'Proposal A Notification Body')
|
||||
title: "Proposal A Title",
|
||||
body: "Proposal A Notification Body")
|
||||
proposal_notification.moderate_system_email(@admin.user)
|
||||
|
||||
visit admin_activity_path
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature "Admin Notifications" do
|
||||
|
||||
@@ -15,22 +15,22 @@ feature "Admin Notifications" do
|
||||
|
||||
context "Show" do
|
||||
scenario "Valid Admin Notification" do
|
||||
notification = create(:admin_notification, title: 'Notification title',
|
||||
body: 'Notification body',
|
||||
link: 'https://www.decide.madrid.es/vota',
|
||||
notification = create(:admin_notification, title: "Notification title",
|
||||
body: "Notification body",
|
||||
link: "https://www.decide.madrid.es/vota",
|
||||
segment_recipient: :all_users)
|
||||
|
||||
visit admin_admin_notification_path(notification)
|
||||
|
||||
expect(page).to have_content('Notification title')
|
||||
expect(page).to have_content('Notification body')
|
||||
expect(page).to have_content('https://www.decide.madrid.es/vota')
|
||||
expect(page).to have_content('All users')
|
||||
expect(page).to have_content("Notification title")
|
||||
expect(page).to have_content("Notification body")
|
||||
expect(page).to have_content("https://www.decide.madrid.es/vota")
|
||||
expect(page).to have_content("All users")
|
||||
end
|
||||
|
||||
scenario "Notification with invalid segment recipient" do
|
||||
invalid_notification = create(:admin_notification)
|
||||
invalid_notification.update_attribute(:segment_recipient, 'invalid_segment')
|
||||
invalid_notification.update_attribute(:segment_recipient, "invalid_segment")
|
||||
|
||||
visit admin_admin_notification_path(invalid_notification)
|
||||
|
||||
@@ -40,30 +40,30 @@ feature "Admin Notifications" do
|
||||
|
||||
context "Index" do
|
||||
scenario "Valid Admin Notifications", :with_frozen_time do
|
||||
draft = create(:admin_notification, segment_recipient: :all_users, title: 'Not yet sent')
|
||||
draft = create(:admin_notification, segment_recipient: :all_users, title: "Not yet sent")
|
||||
sent = create(:admin_notification, :sent, segment_recipient: :administrators,
|
||||
title: 'Sent one')
|
||||
title: "Sent one")
|
||||
|
||||
visit admin_admin_notifications_path
|
||||
|
||||
expect(page).to have_css(".admin_notification", count: 2)
|
||||
|
||||
within("#admin_notification_#{draft.id}") do
|
||||
expect(page).to have_content('Not yet sent')
|
||||
expect(page).to have_content('All users')
|
||||
expect(page).to have_content('Draft')
|
||||
expect(page).to have_content("Not yet sent")
|
||||
expect(page).to have_content("All users")
|
||||
expect(page).to have_content("Draft")
|
||||
end
|
||||
|
||||
within("#admin_notification_#{sent.id}") do
|
||||
expect(page).to have_content('Sent one')
|
||||
expect(page).to have_content('Administrators')
|
||||
expect(page).to have_content("Sent one")
|
||||
expect(page).to have_content("Administrators")
|
||||
expect(page).to have_content(I18n.l(Date.current))
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Notifications with invalid segment recipient" do
|
||||
invalid_notification = create(:admin_notification)
|
||||
invalid_notification.update_attribute(:segment_recipient, 'invalid_segment')
|
||||
invalid_notification.update_attribute(:segment_recipient, "invalid_segment")
|
||||
|
||||
visit admin_admin_notifications_path
|
||||
|
||||
@@ -75,10 +75,10 @@ feature "Admin Notifications" do
|
||||
visit admin_admin_notifications_path
|
||||
click_link "New notification"
|
||||
|
||||
fill_in_admin_notification_form(segment_recipient: 'Proposal authors',
|
||||
title: 'This is a title',
|
||||
body: 'This is a body',
|
||||
link: 'http://www.dummylink.dev')
|
||||
fill_in_admin_notification_form(segment_recipient: "Proposal authors",
|
||||
title: "This is a title",
|
||||
body: "This is a body",
|
||||
link: "http://www.dummylink.dev")
|
||||
|
||||
click_button "Create notification"
|
||||
|
||||
@@ -99,10 +99,10 @@ feature "Admin Notifications" do
|
||||
end
|
||||
|
||||
|
||||
fill_in_admin_notification_form(segment_recipient: 'All users',
|
||||
title: 'Other title',
|
||||
body: 'Other body',
|
||||
link: '')
|
||||
fill_in_admin_notification_form(segment_recipient: "All users",
|
||||
title: "Other title",
|
||||
body: "Other body",
|
||||
link: "")
|
||||
|
||||
click_button "Update notification"
|
||||
|
||||
@@ -173,7 +173,7 @@ feature "Admin Notifications" do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Errors on create' do
|
||||
scenario "Errors on create" do
|
||||
visit new_admin_admin_notification_path
|
||||
|
||||
click_button "Create notification"
|
||||
@@ -219,7 +219,7 @@ feature "Admin Notifications" do
|
||||
|
||||
scenario "Admin notification with invalid segment recipient cannot be sent", :js do
|
||||
invalid_notification = create(:admin_notification)
|
||||
invalid_notification.update_attribute(:segment_recipient, 'invalid_segment')
|
||||
invalid_notification.update_attribute(:segment_recipient, "invalid_segment")
|
||||
visit admin_admin_notification_path(invalid_notification)
|
||||
|
||||
expect(page).not_to have_link("Send")
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Admin administrators' do
|
||||
feature "Admin administrators" do
|
||||
let!(:admin) { create(:administrator) }
|
||||
let!(:user) { create(:user, username: 'Jose Luis Balbin') }
|
||||
let!(:user) { create(:user, username: "Jose Luis Balbin") }
|
||||
let!(:user_administrator) { create(:administrator) }
|
||||
|
||||
background do
|
||||
@@ -10,25 +10,25 @@ feature 'Admin administrators' do
|
||||
visit admin_administrators_path
|
||||
end
|
||||
|
||||
scenario 'Index' do
|
||||
scenario "Index" do
|
||||
expect(page).to have_content user_administrator.id
|
||||
expect(page).to have_content user_administrator.name
|
||||
expect(page).to have_content user_administrator.email
|
||||
expect(page).not_to have_content user.name
|
||||
end
|
||||
|
||||
scenario 'Create Administrator', :js do
|
||||
fill_in 'name_or_email', with: user.email
|
||||
click_button 'Search'
|
||||
scenario "Create Administrator", :js do
|
||||
fill_in "name_or_email", with: user.email
|
||||
click_button "Search"
|
||||
|
||||
expect(page).to have_content user.name
|
||||
click_link 'Add'
|
||||
click_link "Add"
|
||||
within("#administrators") do
|
||||
expect(page).to have_content user.name
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Delete Administrator' do
|
||||
scenario "Delete Administrator" do
|
||||
within "#administrator_#{user_administrator.id}" do
|
||||
click_on "Delete"
|
||||
end
|
||||
@@ -38,7 +38,7 @@ feature 'Admin administrators' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Delete Administrator when its the current user' do
|
||||
scenario "Delete Administrator when its the current user" do
|
||||
|
||||
within "#administrator_#{admin.id}" do
|
||||
click_on "Delete"
|
||||
@@ -49,52 +49,52 @@ feature 'Admin administrators' do
|
||||
end
|
||||
end
|
||||
|
||||
context 'Search' do
|
||||
context "Search" do
|
||||
|
||||
let!(:administrator1) { create(:administrator, user: create(:user,
|
||||
username: 'Bernard Sumner',
|
||||
email: 'bernard@sumner.com')) }
|
||||
username: "Bernard Sumner",
|
||||
email: "bernard@sumner.com")) }
|
||||
let!(:administrator2) { create(:administrator, user: create(:user,
|
||||
username: 'Tony Soprano',
|
||||
email: 'tony@soprano.com')) }
|
||||
username: "Tony Soprano",
|
||||
email: "tony@soprano.com")) }
|
||||
|
||||
background do
|
||||
visit admin_administrators_path
|
||||
end
|
||||
|
||||
scenario 'returns no results if search term is empty' do
|
||||
scenario "returns no results if search term is empty" do
|
||||
expect(page).to have_content(administrator1.name)
|
||||
expect(page).to have_content(administrator2.name)
|
||||
|
||||
fill_in 'name_or_email', with: ' '
|
||||
click_button 'Search'
|
||||
fill_in "name_or_email", with: " "
|
||||
click_button "Search"
|
||||
|
||||
expect(page).to have_content('Administrators: User search')
|
||||
expect(page).to have_content('No results found')
|
||||
expect(page).to have_content("Administrators: User search")
|
||||
expect(page).to have_content("No results found")
|
||||
expect(page).not_to have_content(administrator1.name)
|
||||
expect(page).not_to have_content(administrator2.name)
|
||||
end
|
||||
|
||||
scenario 'search by name' do
|
||||
scenario "search by name" do
|
||||
expect(page).to have_content(administrator1.name)
|
||||
expect(page).to have_content(administrator2.name)
|
||||
|
||||
fill_in 'name_or_email', with: 'Sumn'
|
||||
click_button 'Search'
|
||||
fill_in "name_or_email", with: "Sumn"
|
||||
click_button "Search"
|
||||
|
||||
expect(page).to have_content('Administrators: User search')
|
||||
expect(page).to have_content("Administrators: User search")
|
||||
expect(page).to have_content(administrator1.name)
|
||||
expect(page).not_to have_content(administrator2.name)
|
||||
end
|
||||
|
||||
scenario 'search by email' do
|
||||
scenario "search by email" do
|
||||
expect(page).to have_content(administrator1.email)
|
||||
expect(page).to have_content(administrator2.email)
|
||||
|
||||
fill_in 'name_or_email', with: administrator2.email
|
||||
click_button 'Search'
|
||||
fill_in "name_or_email", with: administrator2.email
|
||||
click_button "Search"
|
||||
|
||||
expect(page).to have_content('Administrators: User search')
|
||||
expect(page).to have_content("Administrators: User search")
|
||||
expect(page).to have_content(administrator2.email)
|
||||
expect(page).not_to have_content(administrator1.email)
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Admin banners magement' do
|
||||
feature "Admin banners magement" do
|
||||
|
||||
background do
|
||||
login_as(create(:administrator).user)
|
||||
@@ -18,96 +18,96 @@ feature 'Admin banners magement' do
|
||||
target_url: "http://www.url.com",
|
||||
post_started_at: (Time.current + 4.days),
|
||||
post_ended_at: (Time.current + 10.days),
|
||||
background_color: '#FF0000',
|
||||
font_color: '#FFFFFF')
|
||||
background_color: "#FF0000",
|
||||
font_color: "#FFFFFF")
|
||||
|
||||
@banner2 = create(:banner, title: "Banner number two",
|
||||
description: "This is the text of banner number two and is not longer active",
|
||||
target_url: "http://www.url.com",
|
||||
post_started_at: (Time.current - 10.days),
|
||||
post_ended_at: (Time.current - 3.days),
|
||||
background_color: '#00FF00',
|
||||
font_color: '#FFFFFF')
|
||||
background_color: "#00FF00",
|
||||
font_color: "#FFFFFF")
|
||||
|
||||
@banner3 = create(:banner, title: "Banner number three",
|
||||
description: "This is the text of banner number three and has style banner-three",
|
||||
target_url: "http://www.url.com",
|
||||
post_started_at: (Time.current - 1.day),
|
||||
post_ended_at: (Time.current + 10.days),
|
||||
background_color: '#0000FF',
|
||||
font_color: '#FFFFFF')
|
||||
background_color: "#0000FF",
|
||||
font_color: "#FFFFFF")
|
||||
|
||||
@banner4 = create(:banner, title: "Banner number four",
|
||||
description: "This is the text of banner number four and has style banner-one",
|
||||
target_url: "http://www.url.com",
|
||||
post_started_at: (DateTime.current - 10.days),
|
||||
post_ended_at: (DateTime.current + 10.days),
|
||||
background_color: '#FFF000',
|
||||
font_color: '#FFFFFF')
|
||||
background_color: "#FFF000",
|
||||
font_color: "#FFFFFF")
|
||||
|
||||
@banner5 = create(:banner, title: "Banner number five",
|
||||
description: "This is the text of banner number five and has style banner-two",
|
||||
target_url: "http://www.url.com",
|
||||
post_started_at: (DateTime.current - 10.days),
|
||||
post_ended_at: (DateTime.current + 10.days),
|
||||
background_color: '#FFFF00',
|
||||
font_color: '#FFFFFF')
|
||||
background_color: "#FFFF00",
|
||||
font_color: "#FFFFFF")
|
||||
end
|
||||
|
||||
scenario 'Index show active banners' do
|
||||
visit admin_banners_path(filter: 'with_active')
|
||||
scenario "Index show active banners" do
|
||||
visit admin_banners_path(filter: "with_active")
|
||||
expect(page).to have_content("There are 3 banners")
|
||||
end
|
||||
|
||||
scenario 'Index show inactive banners' do
|
||||
visit admin_banners_path(filter: 'with_inactive')
|
||||
scenario "Index show inactive banners" do
|
||||
visit admin_banners_path(filter: "with_inactive")
|
||||
expect(page).to have_content("There are 2 banners")
|
||||
end
|
||||
|
||||
scenario 'Index show all banners' do
|
||||
scenario "Index show all banners" do
|
||||
visit admin_banners_path
|
||||
expect(page).to have_content("There are 5 banners")
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Banners publication is listed on admin menu' do
|
||||
scenario "Banners publication is listed on admin menu" do
|
||||
visit admin_root_path
|
||||
|
||||
within('#side_menu') do
|
||||
within("#side_menu") do
|
||||
expect(page).to have_link "Manage banners"
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Publish a banner' do
|
||||
section = create(:web_section, name: 'proposals')
|
||||
scenario "Publish a banner" do
|
||||
section = create(:web_section, name: "proposals")
|
||||
|
||||
visit admin_root_path
|
||||
|
||||
within('#side_menu') do
|
||||
within("#side_menu") do
|
||||
click_link "Manage banners"
|
||||
end
|
||||
|
||||
click_link "Create banner"
|
||||
|
||||
fill_in 'Title', with: 'Such banner'
|
||||
fill_in 'Description', with: 'many text wow link'
|
||||
fill_in 'banner_target_url', with: 'https://www.url.com'
|
||||
fill_in "Title", with: "Such banner"
|
||||
fill_in "Description", with: "many text wow link"
|
||||
fill_in "banner_target_url", with: "https://www.url.com"
|
||||
last_week = Time.current - 7.days
|
||||
next_week = Time.current + 7.days
|
||||
fill_in 'post_started_at', with: last_week.strftime("%d/%m/%Y")
|
||||
fill_in 'post_ended_at', with: next_week.strftime("%d/%m/%Y")
|
||||
fill_in 'banner_background_color', with: '#850000'
|
||||
fill_in 'banner_font_color', with: '#ffb2b2'
|
||||
fill_in "post_started_at", with: last_week.strftime("%d/%m/%Y")
|
||||
fill_in "post_ended_at", with: next_week.strftime("%d/%m/%Y")
|
||||
fill_in "banner_background_color", with: "#850000"
|
||||
fill_in "banner_font_color", with: "#ffb2b2"
|
||||
check "banner_web_section_ids_#{section.id}"
|
||||
|
||||
click_button 'Save changes'
|
||||
click_button "Save changes"
|
||||
|
||||
expect(page).to have_content 'Such banner'
|
||||
expect(page).to have_content "Such banner"
|
||||
|
||||
visit proposals_path
|
||||
|
||||
expect(page).to have_content 'Such banner'
|
||||
expect(page).to have_link 'Such banner many text wow link', href: 'https://www.url.com'
|
||||
expect(page).to have_content "Such banner"
|
||||
expect(page).to have_link "Such banner many text wow link", href: "https://www.url.com"
|
||||
end
|
||||
|
||||
scenario "Publish a banner with a translation different than the current locale", :js do
|
||||
@@ -140,9 +140,9 @@ feature 'Admin banners magement' do
|
||||
scenario "Update banner color when changing from color picker or text_field", :js do
|
||||
visit new_admin_banner_path
|
||||
|
||||
fill_in 'banner_background_color', with: '#850000'
|
||||
fill_in 'banner_font_color', with: '#ffb2b2'
|
||||
fill_in 'Title', with: 'Fun with flags'
|
||||
fill_in "banner_background_color", with: "#850000"
|
||||
fill_in "banner_font_color", with: "#ffb2b2"
|
||||
fill_in "Title", with: "Fun with flags"
|
||||
|
||||
# This last step simulates the blur event on the page. The color pickers and the text_fields
|
||||
# has onChange events that update each one when the other changes, but this is only fired when
|
||||
@@ -151,56 +151,56 @@ feature 'Admin banners magement' do
|
||||
# (so the onChange is fired). The second one never loses the focus, so the onChange is not been fired.
|
||||
# The `fill_in` action clicks out of the text_field and makes the field to lose the focus.
|
||||
|
||||
expect(find("#banner_background_color_picker").value).to eq('#850000')
|
||||
expect(find("#banner_font_color_picker").value).to eq('#ffb2b2')
|
||||
expect(find("#banner_background_color_picker").value).to eq("#850000")
|
||||
expect(find("#banner_font_color_picker").value).to eq("#ffb2b2")
|
||||
end
|
||||
|
||||
scenario 'Edit banner with live refresh', :js do
|
||||
banner1 = create(:banner, title: 'Hello',
|
||||
description: 'Wrong text',
|
||||
target_url: 'http://www.url.com',
|
||||
scenario "Edit banner with live refresh", :js do
|
||||
banner1 = create(:banner, title: "Hello",
|
||||
description: "Wrong text",
|
||||
target_url: "http://www.url.com",
|
||||
post_started_at: (Time.current + 4.days),
|
||||
post_ended_at: (Time.current + 10.days),
|
||||
background_color: '#FF0000',
|
||||
font_color: '#FFFFFF')
|
||||
background_color: "#FF0000",
|
||||
font_color: "#FFFFFF")
|
||||
|
||||
visit admin_root_path
|
||||
|
||||
within('#side_menu') do
|
||||
within("#side_menu") do
|
||||
click_link "Site content"
|
||||
click_link "Manage banners"
|
||||
end
|
||||
|
||||
click_link "Edit banner"
|
||||
|
||||
fill_in 'Title', with: 'Modified title'
|
||||
fill_in 'Description', with: 'Edited text'
|
||||
fill_in "Title", with: "Modified title"
|
||||
fill_in "Description", with: "Edited text"
|
||||
|
||||
page.find("body").click
|
||||
|
||||
within('div#js-banner-background') do
|
||||
expect(page).to have_selector('h2', text: 'Modified title')
|
||||
expect(page).to have_selector('h3', text: 'Edited text')
|
||||
within("div#js-banner-background") do
|
||||
expect(page).to have_selector("h2", text: "Modified title")
|
||||
expect(page).to have_selector("h3", text: "Edited text")
|
||||
end
|
||||
|
||||
click_button 'Save changes'
|
||||
click_button "Save changes"
|
||||
|
||||
visit admin_banners_path
|
||||
expect(page).to have_content 'Modified title'
|
||||
expect(page).to have_content 'Edited text'
|
||||
expect(page).to have_content "Modified title"
|
||||
expect(page).to have_content "Edited text"
|
||||
|
||||
expect(page).not_to have_content 'Hello'
|
||||
expect(page).not_to have_content 'Wrong text'
|
||||
expect(page).not_to have_content "Hello"
|
||||
expect(page).not_to have_content "Wrong text"
|
||||
end
|
||||
|
||||
scenario 'Delete a banner' do
|
||||
create(:banner, title: 'Ugly banner',
|
||||
description: 'Bad text',
|
||||
target_url: 'http://www.url.com',
|
||||
scenario "Delete a banner" do
|
||||
create(:banner, title: "Ugly banner",
|
||||
description: "Bad text",
|
||||
target_url: "http://www.url.com",
|
||||
post_started_at: (Time.current + 4.days),
|
||||
post_ended_at: (Time.current + 10.days),
|
||||
background_color: '#FF0000',
|
||||
font_color: '#FFFFFF')
|
||||
background_color: "#FF0000",
|
||||
font_color: "#FFFFFF")
|
||||
|
||||
visit admin_root_path
|
||||
|
||||
@@ -208,11 +208,11 @@ feature 'Admin banners magement' do
|
||||
click_link "Manage banners"
|
||||
end
|
||||
|
||||
expect(page).to have_content 'Ugly banner'
|
||||
expect(page).to have_content "Ugly banner"
|
||||
|
||||
click_link "Delete banner"
|
||||
|
||||
visit admin_root_path
|
||||
expect(page).not_to have_content 'Ugly banner'
|
||||
expect(page).not_to have_content "Ugly banner"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature "Admin budget groups" do
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature "Admin budget headings" do
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Admin budget investment milestones' do
|
||||
feature "Admin budget investment milestones" do
|
||||
|
||||
it_behaves_like "translatable",
|
||||
"milestone",
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Admin budget phases' do
|
||||
feature "Admin budget phases" do
|
||||
let(:budget) { create(:budget) }
|
||||
|
||||
context 'Edit' do
|
||||
context "Edit" do
|
||||
|
||||
before do
|
||||
admin = create(:administrator)
|
||||
@@ -19,15 +19,15 @@ feature 'Admin budget phases' do
|
||||
scenario "Update phase", :js do
|
||||
visit edit_admin_budget_budget_phase_path(budget, budget.current_phase)
|
||||
|
||||
fill_in 'start_date', with: Date.current + 1.days
|
||||
fill_in 'end_date', with: Date.current + 12.days
|
||||
fill_in "start_date", with: Date.current + 1.days
|
||||
fill_in "end_date", with: Date.current + 12.days
|
||||
fill_in_translatable_ckeditor "summary", :en, with: "New summary of the phase."
|
||||
fill_in_translatable_ckeditor "description", :en, with: "New description of the phase."
|
||||
uncheck 'budget_phase_enabled'
|
||||
click_button 'Save changes'
|
||||
uncheck "budget_phase_enabled"
|
||||
click_button "Save changes"
|
||||
|
||||
expect(page).to have_current_path(edit_admin_budget_path(budget))
|
||||
expect(page).to have_content 'Changes saved'
|
||||
expect(page).to have_content "Changes saved"
|
||||
|
||||
expect(budget.current_phase.starts_at.to_date).to eq((Date.current + 1.days).to_date)
|
||||
expect(budget.current_phase.ends_at.to_date).to eq((Date.current + 12.days).to_date)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Admin comments' do
|
||||
feature "Admin comments" do
|
||||
|
||||
background do
|
||||
admin = create(:administrator)
|
||||
@@ -18,7 +18,7 @@ feature 'Admin comments' do
|
||||
|
||||
visit proposal_path(proposal)
|
||||
within("#proposal_#{proposal.id}") do
|
||||
click_link 'Hide author'
|
||||
click_link "Hide author"
|
||||
end
|
||||
|
||||
visit admin_comments_path
|
||||
@@ -66,10 +66,10 @@ feature 'Admin comments' do
|
||||
end
|
||||
|
||||
scenario "Restore" do
|
||||
comment = create(:comment, :hidden, body: 'Not really SPAM')
|
||||
comment = create(:comment, :hidden, body: "Not really SPAM")
|
||||
visit admin_comments_path
|
||||
|
||||
click_link 'Restore'
|
||||
click_link "Restore"
|
||||
|
||||
expect(page).not_to have_content(comment.body)
|
||||
|
||||
@@ -78,13 +78,13 @@ feature 'Admin comments' do
|
||||
end
|
||||
|
||||
scenario "Confirm hide" do
|
||||
comment = create(:comment, :hidden, body: 'SPAM')
|
||||
comment = create(:comment, :hidden, body: "SPAM")
|
||||
visit admin_comments_path
|
||||
|
||||
click_link 'Confirm moderation'
|
||||
click_link "Confirm moderation"
|
||||
|
||||
expect(page).not_to have_content(comment.body)
|
||||
click_link('Confirmed')
|
||||
click_link("Confirmed")
|
||||
expect(page).to have_content(comment.body)
|
||||
|
||||
expect(comment.reload).to be_confirmed_hide
|
||||
@@ -92,49 +92,49 @@ feature 'Admin comments' do
|
||||
|
||||
scenario "Current filter is properly highlighted" do
|
||||
visit admin_comments_path
|
||||
expect(page).not_to have_link('Pending')
|
||||
expect(page).to have_link('All')
|
||||
expect(page).to have_link('Confirmed')
|
||||
expect(page).not_to have_link("Pending")
|
||||
expect(page).to have_link("All")
|
||||
expect(page).to have_link("Confirmed")
|
||||
|
||||
visit admin_comments_path(filter: 'Pending')
|
||||
expect(page).not_to have_link('Pending')
|
||||
expect(page).to have_link('All')
|
||||
expect(page).to have_link('Confirmed')
|
||||
visit admin_comments_path(filter: "Pending")
|
||||
expect(page).not_to have_link("Pending")
|
||||
expect(page).to have_link("All")
|
||||
expect(page).to have_link("Confirmed")
|
||||
|
||||
visit admin_comments_path(filter: 'all')
|
||||
expect(page).to have_link('Pending')
|
||||
expect(page).not_to have_link('All')
|
||||
expect(page).to have_link('Confirmed')
|
||||
visit admin_comments_path(filter: "all")
|
||||
expect(page).to have_link("Pending")
|
||||
expect(page).not_to have_link("All")
|
||||
expect(page).to have_link("Confirmed")
|
||||
|
||||
visit admin_comments_path(filter: 'with_confirmed_hide')
|
||||
expect(page).to have_link('Pending')
|
||||
expect(page).to have_link('All')
|
||||
expect(page).not_to have_link('Confirmed')
|
||||
visit admin_comments_path(filter: "with_confirmed_hide")
|
||||
expect(page).to have_link("Pending")
|
||||
expect(page).to have_link("All")
|
||||
expect(page).not_to have_link("Confirmed")
|
||||
end
|
||||
|
||||
scenario "Filtering comments" do
|
||||
create(:comment, :hidden, body: "Unconfirmed comment")
|
||||
create(:comment, :hidden, :with_confirmed_hide, body: "Confirmed comment")
|
||||
|
||||
visit admin_comments_path(filter: 'all')
|
||||
expect(page).to have_content('Unconfirmed comment')
|
||||
expect(page).to have_content('Confirmed comment')
|
||||
visit admin_comments_path(filter: "all")
|
||||
expect(page).to have_content("Unconfirmed comment")
|
||||
expect(page).to have_content("Confirmed comment")
|
||||
|
||||
visit admin_comments_path(filter: 'with_confirmed_hide')
|
||||
expect(page).not_to have_content('Unconfirmed comment')
|
||||
expect(page).to have_content('Confirmed comment')
|
||||
visit admin_comments_path(filter: "with_confirmed_hide")
|
||||
expect(page).not_to have_content("Unconfirmed comment")
|
||||
expect(page).to have_content("Confirmed comment")
|
||||
end
|
||||
|
||||
scenario "Action links remember the pagination setting and the filter" do
|
||||
per_page = Kaminari.config.default_per_page
|
||||
(per_page + 2).times { create(:comment, :hidden, :with_confirmed_hide) }
|
||||
|
||||
visit admin_comments_path(filter: 'with_confirmed_hide', page: 2)
|
||||
visit admin_comments_path(filter: "with_confirmed_hide", page: 2)
|
||||
|
||||
click_on('Restore', match: :first, exact: true)
|
||||
click_on("Restore", match: :first, exact: true)
|
||||
|
||||
expect(current_url).to include('filter=with_confirmed_hide')
|
||||
expect(current_url).to include('page=2')
|
||||
expect(current_url).to include("filter=with_confirmed_hide")
|
||||
expect(current_url).to include("page=2")
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,15 +1,15 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Admin debates' do
|
||||
feature "Admin debates" do
|
||||
|
||||
scenario 'Disabled with a feature flag' do
|
||||
Setting['feature.debates'] = nil
|
||||
scenario "Disabled with a feature flag" do
|
||||
Setting["feature.debates"] = nil
|
||||
admin = create(:administrator)
|
||||
login_as(admin.user)
|
||||
|
||||
expect{ visit admin_debates_path }.to raise_exception(FeatureFlags::FeatureDisabled)
|
||||
|
||||
Setting['feature.debates'] = true
|
||||
Setting["feature.debates"] = true
|
||||
end
|
||||
|
||||
background do
|
||||
@@ -17,11 +17,11 @@ feature 'Admin debates' do
|
||||
login_as(admin.user)
|
||||
end
|
||||
|
||||
scenario 'Restore' do
|
||||
scenario "Restore" do
|
||||
debate = create(:debate, :hidden)
|
||||
visit admin_debates_path
|
||||
|
||||
click_link 'Restore'
|
||||
click_link "Restore"
|
||||
|
||||
expect(page).not_to have_content(debate.title)
|
||||
|
||||
@@ -29,14 +29,14 @@ feature 'Admin debates' do
|
||||
expect(debate).to be_ignored_flag
|
||||
end
|
||||
|
||||
scenario 'Confirm hide' do
|
||||
scenario "Confirm hide" do
|
||||
debate = create(:debate, :hidden)
|
||||
visit admin_debates_path
|
||||
|
||||
click_link 'Confirm moderation'
|
||||
click_link "Confirm moderation"
|
||||
|
||||
expect(page).not_to have_content(debate.title)
|
||||
click_link('Confirmed')
|
||||
click_link("Confirmed")
|
||||
expect(page).to have_content(debate.title)
|
||||
|
||||
expect(debate.reload).to be_confirmed_hide
|
||||
@@ -44,53 +44,53 @@ feature 'Admin debates' do
|
||||
|
||||
scenario "Current filter is properly highlighted" do
|
||||
visit admin_debates_path
|
||||
expect(page).not_to have_link('Pending')
|
||||
expect(page).to have_link('All')
|
||||
expect(page).to have_link('Confirmed')
|
||||
expect(page).not_to have_link("Pending")
|
||||
expect(page).to have_link("All")
|
||||
expect(page).to have_link("Confirmed")
|
||||
|
||||
visit admin_debates_path(filter: 'Pending')
|
||||
expect(page).not_to have_link('Pending')
|
||||
expect(page).to have_link('All')
|
||||
expect(page).to have_link('Confirmed')
|
||||
visit admin_debates_path(filter: "Pending")
|
||||
expect(page).not_to have_link("Pending")
|
||||
expect(page).to have_link("All")
|
||||
expect(page).to have_link("Confirmed")
|
||||
|
||||
visit admin_debates_path(filter: 'all')
|
||||
expect(page).to have_link('Pending')
|
||||
expect(page).not_to have_link('All')
|
||||
expect(page).to have_link('Confirmed')
|
||||
visit admin_debates_path(filter: "all")
|
||||
expect(page).to have_link("Pending")
|
||||
expect(page).not_to have_link("All")
|
||||
expect(page).to have_link("Confirmed")
|
||||
|
||||
visit admin_debates_path(filter: 'with_confirmed_hide')
|
||||
expect(page).to have_link('All')
|
||||
expect(page).to have_link('Pending')
|
||||
expect(page).not_to have_link('Confirmed')
|
||||
visit admin_debates_path(filter: "with_confirmed_hide")
|
||||
expect(page).to have_link("All")
|
||||
expect(page).to have_link("Pending")
|
||||
expect(page).not_to have_link("Confirmed")
|
||||
end
|
||||
|
||||
scenario "Filtering debates" do
|
||||
create(:debate, :hidden, title: "Unconfirmed debate")
|
||||
create(:debate, :hidden, :with_confirmed_hide, title: "Confirmed debate")
|
||||
|
||||
visit admin_debates_path(filter: 'pending')
|
||||
expect(page).to have_content('Unconfirmed debate')
|
||||
expect(page).not_to have_content('Confirmed debate')
|
||||
visit admin_debates_path(filter: "pending")
|
||||
expect(page).to have_content("Unconfirmed debate")
|
||||
expect(page).not_to have_content("Confirmed debate")
|
||||
|
||||
visit admin_debates_path(filter: 'all')
|
||||
expect(page).to have_content('Unconfirmed debate')
|
||||
expect(page).to have_content('Confirmed debate')
|
||||
visit admin_debates_path(filter: "all")
|
||||
expect(page).to have_content("Unconfirmed debate")
|
||||
expect(page).to have_content("Confirmed debate")
|
||||
|
||||
visit admin_debates_path(filter: 'with_confirmed_hide')
|
||||
expect(page).not_to have_content('Unconfirmed debate')
|
||||
expect(page).to have_content('Confirmed debate')
|
||||
visit admin_debates_path(filter: "with_confirmed_hide")
|
||||
expect(page).not_to have_content("Unconfirmed debate")
|
||||
expect(page).to have_content("Confirmed debate")
|
||||
end
|
||||
|
||||
scenario "Action links remember the pagination setting and the filter" do
|
||||
per_page = Kaminari.config.default_per_page
|
||||
(per_page + 2).times { create(:debate, :hidden, :with_confirmed_hide) }
|
||||
|
||||
visit admin_debates_path(filter: 'with_confirmed_hide', page: 2)
|
||||
visit admin_debates_path(filter: "with_confirmed_hide", page: 2)
|
||||
|
||||
click_on('Restore', match: :first, exact: true)
|
||||
click_on("Restore", match: :first, exact: true)
|
||||
|
||||
expect(current_url).to include('filter=with_confirmed_hide')
|
||||
expect(current_url).to include('page=2')
|
||||
expect(current_url).to include("filter=with_confirmed_hide")
|
||||
expect(current_url).to include("page=2")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature "Admin download user emails" do
|
||||
|
||||
let(:admin_user) { create(:user, newsletter: false, email: 'admin@consul.dev') }
|
||||
let(:admin_user) { create(:user, newsletter: false, email: "admin@consul.dev") }
|
||||
|
||||
background do
|
||||
create(:administrator, user: admin_user)
|
||||
@@ -12,14 +12,14 @@ feature "Admin download user emails" do
|
||||
context "Download only emails from segment users with newsletter flag & present email " do
|
||||
|
||||
before do
|
||||
create(:user, email: 'user@consul.dev')
|
||||
create(:user, email: "user@consul.dev")
|
||||
|
||||
create(:administrator, user: create(:user, newsletter: true, email: 'admin_news1@consul.dev'))
|
||||
create(:administrator, user: create(:user, newsletter: true, email: 'admin_news2@consul.dev'))
|
||||
create(:administrator, user: create(:user, newsletter: true, email: "admin_news1@consul.dev"))
|
||||
create(:administrator, user: create(:user, newsletter: true, email: "admin_news2@consul.dev"))
|
||||
|
||||
create(:administrator, user: create(:user, newsletter: false, email: 'no_news@consul.dev'))
|
||||
create(:administrator, user: create(:user, newsletter: false, email: "no_news@consul.dev"))
|
||||
|
||||
admin_without_email = create(:user, newsletter: true, email: 'no_email@consul.dev')
|
||||
admin_without_email = create(:user, newsletter: true, email: "no_email@consul.dev")
|
||||
create(:administrator, user: admin_without_email)
|
||||
admin_without_email.update_attribute(:email, nil)
|
||||
end
|
||||
@@ -27,23 +27,23 @@ feature "Admin download user emails" do
|
||||
scenario "returns the selected users segment csv file" do
|
||||
visit admin_emails_download_index_path
|
||||
|
||||
within('#admin_download_emails') do
|
||||
select 'Administrators', from: 'users_segment'
|
||||
click_button 'Download emails list'
|
||||
within("#admin_download_emails") do
|
||||
select "Administrators", from: "users_segment"
|
||||
click_button "Download emails list"
|
||||
end
|
||||
|
||||
header = page.response_headers['Content-Disposition']
|
||||
header = page.response_headers["Content-Disposition"]
|
||||
expect(header).to match /^attachment/
|
||||
expect(header).to match /filename="Administrators.csv"$/
|
||||
|
||||
file_contents = page.body.split(',')
|
||||
file_contents = page.body.split(",")
|
||||
expect(file_contents.count).to eq(2)
|
||||
expect(file_contents).to include('admin_news1@consul.dev')
|
||||
expect(file_contents).to include('admin_news2@consul.dev')
|
||||
expect(file_contents).not_to include('admin@consul.dev')
|
||||
expect(file_contents).not_to include('user@consul.dev')
|
||||
expect(file_contents).not_to include('no_news@consul.dev')
|
||||
expect(file_contents).not_to include('no_email@consul.dev')
|
||||
expect(file_contents).to include("admin_news1@consul.dev")
|
||||
expect(file_contents).to include("admin_news2@consul.dev")
|
||||
expect(file_contents).not_to include("admin@consul.dev")
|
||||
expect(file_contents).not_to include("user@consul.dev")
|
||||
expect(file_contents).not_to include("no_news@consul.dev")
|
||||
expect(file_contents).not_to include("no_email@consul.dev")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature "Admin newsletter emails" do
|
||||
|
||||
@@ -11,7 +11,7 @@ feature "Admin newsletter emails" do
|
||||
context "Show" do
|
||||
scenario "Valid newsletter" do
|
||||
newsletter = create(:newsletter, subject: "This is a subject",
|
||||
segment_recipient: 'all_users',
|
||||
segment_recipient: "all_users",
|
||||
from: "no-reply@consul.dev",
|
||||
body: "This is a body")
|
||||
|
||||
@@ -25,7 +25,7 @@ feature "Admin newsletter emails" do
|
||||
|
||||
scenario "Invalid newsletter" do
|
||||
invalid_newsletter = create(:newsletter)
|
||||
invalid_newsletter.update_attribute(:segment_recipient, 'invalid_segment')
|
||||
invalid_newsletter.update_attribute(:segment_recipient, "invalid_segment")
|
||||
|
||||
visit admin_newsletter_path(invalid_newsletter)
|
||||
|
||||
@@ -52,7 +52,7 @@ feature "Admin newsletter emails" do
|
||||
|
||||
scenario "Invalid newsletter" do
|
||||
invalid_newsletter = create(:newsletter)
|
||||
invalid_newsletter.update_attribute(:segment_recipient, 'invalid_segment')
|
||||
invalid_newsletter.update_attribute(:segment_recipient, "invalid_segment")
|
||||
|
||||
visit admin_newsletters_path
|
||||
|
||||
@@ -108,7 +108,7 @@ feature "Admin newsletter emails" do
|
||||
expect(page).to have_css(".newsletter", count: 0)
|
||||
end
|
||||
|
||||
scenario 'Errors on create' do
|
||||
scenario "Errors on create" do
|
||||
visit new_admin_newsletter_path
|
||||
|
||||
click_button "Create Newsletter"
|
||||
@@ -139,7 +139,7 @@ feature "Admin newsletter emails" do
|
||||
|
||||
scenario "Invalid newsletter cannot be sent", :js do
|
||||
invalid_newsletter = create(:newsletter)
|
||||
invalid_newsletter.update_attribute(:segment_recipient, 'invalid_segment')
|
||||
invalid_newsletter.update_attribute(:segment_recipient, "invalid_segment")
|
||||
visit admin_newsletter_path(invalid_newsletter)
|
||||
|
||||
expect(page).not_to have_link("Send")
|
||||
|
||||
@@ -1,41 +1,41 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Admin feature flags' do
|
||||
feature "Admin feature flags" do
|
||||
|
||||
background do
|
||||
Setting['feature.spending_proposals'] = true
|
||||
Setting['feature.spending_proposal_features.voting_allowed'] = true
|
||||
Setting["feature.spending_proposals"] = true
|
||||
Setting["feature.spending_proposal_features.voting_allowed"] = true
|
||||
login_as(create(:administrator).user)
|
||||
end
|
||||
|
||||
after do
|
||||
Setting['feature.spending_proposals'] = nil
|
||||
Setting['feature.spending_proposal_features.voting_allowed'] = nil
|
||||
Setting["feature.spending_proposals"] = nil
|
||||
Setting["feature.spending_proposal_features.voting_allowed"] = nil
|
||||
end
|
||||
|
||||
scenario 'Enabled features are listed on menu' do
|
||||
scenario "Enabled features are listed on menu" do
|
||||
visit admin_root_path
|
||||
|
||||
within('#side_menu') do
|
||||
within("#side_menu") do
|
||||
expect(page).to have_link "Spending proposals"
|
||||
expect(page).to have_link "Hidden debates"
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Disable a feature' do
|
||||
setting_id = Setting.find_by(key: 'feature.spending_proposals').id
|
||||
scenario "Disable a feature" do
|
||||
setting_id = Setting.find_by(key: "feature.spending_proposals").id
|
||||
|
||||
visit admin_settings_path
|
||||
|
||||
within("#edit_setting_#{setting_id}") do
|
||||
expect(page).to have_button "Disable"
|
||||
expect(page).not_to have_button "Enable"
|
||||
click_button 'Disable'
|
||||
click_button "Disable"
|
||||
end
|
||||
|
||||
visit admin_root_path
|
||||
|
||||
within('#side_menu') do
|
||||
within("#side_menu") do
|
||||
expect(page).not_to have_link "Budgets"
|
||||
expect(page).not_to have_link "Spending proposals"
|
||||
end
|
||||
@@ -44,13 +44,13 @@ feature 'Admin feature flags' do
|
||||
expect{ visit admin_spending_proposals_path }.to raise_exception(FeatureFlags::FeatureDisabled)
|
||||
end
|
||||
|
||||
scenario 'Enable a disabled feature' do
|
||||
Setting['feature.spending_proposals'] = nil
|
||||
setting_id = Setting.find_by(key: 'feature.spending_proposals').id
|
||||
scenario "Enable a disabled feature" do
|
||||
Setting["feature.spending_proposals"] = nil
|
||||
setting_id = Setting.find_by(key: "feature.spending_proposals").id
|
||||
|
||||
visit admin_root_path
|
||||
|
||||
within('#side_menu') do
|
||||
within("#side_menu") do
|
||||
expect(page).not_to have_link "Budgets"
|
||||
expect(page).not_to have_link "Spending proposals"
|
||||
end
|
||||
@@ -60,12 +60,12 @@ feature 'Admin feature flags' do
|
||||
within("#edit_setting_#{setting_id}") do
|
||||
expect(page).to have_button "Enable"
|
||||
expect(page).not_to have_button "Disable"
|
||||
click_button 'Enable'
|
||||
click_button "Enable"
|
||||
end
|
||||
|
||||
visit admin_root_path
|
||||
|
||||
within('#side_menu') do
|
||||
within("#side_menu") do
|
||||
expect(page).to have_link "Spending proposals"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Admin geozones' do
|
||||
feature "Admin geozones" do
|
||||
|
||||
background do
|
||||
login_as(create(:administrator).user)
|
||||
end
|
||||
|
||||
scenario 'Show list of geozones' do
|
||||
chamberi = create(:geozone, name: 'Chamberí')
|
||||
retiro = create(:geozone, name: 'Retiro')
|
||||
scenario "Show list of geozones" do
|
||||
chamberi = create(:geozone, name: "Chamberí")
|
||||
retiro = create(:geozone, name: "Retiro")
|
||||
|
||||
visit admin_geozones_path
|
||||
|
||||
@@ -16,85 +16,85 @@ feature 'Admin geozones' do
|
||||
expect(page).to have_content(retiro.name)
|
||||
end
|
||||
|
||||
scenario 'Create new geozone' do
|
||||
scenario "Create new geozone" do
|
||||
visit admin_root_path
|
||||
|
||||
within('#side_menu') { click_link 'Manage geozones' }
|
||||
within("#side_menu") { click_link "Manage geozones" }
|
||||
|
||||
click_link 'Create geozone'
|
||||
click_link "Create geozone"
|
||||
|
||||
fill_in 'geozone_name', with: 'Fancy District'
|
||||
fill_in 'geozone_external_code', with: 123
|
||||
fill_in 'geozone_census_code', with: 44
|
||||
fill_in "geozone_name", with: "Fancy District"
|
||||
fill_in "geozone_external_code", with: 123
|
||||
fill_in "geozone_census_code", with: 44
|
||||
|
||||
click_button 'Save changes'
|
||||
click_button "Save changes"
|
||||
|
||||
expect(page).to have_content 'Fancy District'
|
||||
expect(page).to have_content "Fancy District"
|
||||
|
||||
visit admin_geozones_path
|
||||
|
||||
expect(page).to have_content 'Fancy District'
|
||||
expect(page).to have_content "Fancy District"
|
||||
end
|
||||
|
||||
scenario 'Edit geozone with no associated elements' do
|
||||
geozone = create(:geozone, name: 'Edit me!', census_code: '012')
|
||||
scenario "Edit geozone with no associated elements" do
|
||||
geozone = create(:geozone, name: "Edit me!", census_code: "012")
|
||||
|
||||
visit admin_geozones_path
|
||||
|
||||
within("#geozone_#{geozone.id}") { click_link 'Edit' }
|
||||
within("#geozone_#{geozone.id}") { click_link "Edit" }
|
||||
|
||||
fill_in 'geozone_name', with: 'New geozone name'
|
||||
fill_in 'geozone_census_code', with: '333'
|
||||
fill_in "geozone_name", with: "New geozone name"
|
||||
fill_in "geozone_census_code", with: "333"
|
||||
|
||||
click_button 'Save changes'
|
||||
click_button "Save changes"
|
||||
|
||||
within("#geozone_#{geozone.id}") do
|
||||
expect(page).to have_content 'New geozone name'
|
||||
expect(page).to have_content '333'
|
||||
expect(page).to have_content "New geozone name"
|
||||
expect(page).to have_content "333"
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Edit geozone with associated elements' do
|
||||
geozone = create(:geozone, name: 'Edit me!')
|
||||
create(:proposal, title: 'Proposal with geozone', geozone: geozone)
|
||||
scenario "Edit geozone with associated elements" do
|
||||
geozone = create(:geozone, name: "Edit me!")
|
||||
create(:proposal, title: "Proposal with geozone", geozone: geozone)
|
||||
|
||||
visit admin_geozones_path
|
||||
|
||||
within("#geozone_#{geozone.id}") { click_link 'Edit' }
|
||||
within("#geozone_#{geozone.id}") { click_link "Edit" }
|
||||
|
||||
fill_in 'geozone_name', with: 'New geozone name'
|
||||
fill_in "geozone_name", with: "New geozone name"
|
||||
|
||||
click_button 'Save changes'
|
||||
click_button "Save changes"
|
||||
|
||||
within("#geozone_#{geozone.id}") do
|
||||
expect(page).to have_content 'New geozone name'
|
||||
expect(page).to have_content "New geozone name"
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Delete geozone with no associated elements' do
|
||||
geozone = create(:geozone, name: 'Delete me!')
|
||||
scenario "Delete geozone with no associated elements" do
|
||||
geozone = create(:geozone, name: "Delete me!")
|
||||
|
||||
visit admin_geozones_path
|
||||
|
||||
within("#geozone_#{geozone.id}") { click_link 'Delete' }
|
||||
within("#geozone_#{geozone.id}") { click_link "Delete" }
|
||||
|
||||
expect(page).to have_content 'Geozone successfully deleted'
|
||||
expect(page).not_to have_content('Delete me!')
|
||||
expect(page).to have_content "Geozone successfully deleted"
|
||||
expect(page).not_to have_content("Delete me!")
|
||||
expect(Geozone.where(id: geozone.id)).to be_empty
|
||||
end
|
||||
|
||||
scenario 'Delete geozone with associated element' do
|
||||
geozone = create(:geozone, name: 'Delete me!')
|
||||
scenario "Delete geozone with associated element" do
|
||||
geozone = create(:geozone, name: "Delete me!")
|
||||
create(:proposal, geozone: geozone)
|
||||
|
||||
visit admin_geozones_path
|
||||
|
||||
within("#geozone_#{geozone.id}") { click_link 'Delete' }
|
||||
within("#geozone_#{geozone.id}") { click_link "Delete" }
|
||||
|
||||
expect(page).to have_content "This geozone can't be deleted since there are elements attached to it"
|
||||
|
||||
within("#geozone_#{geozone.id}") do
|
||||
expect(page).to have_content 'Delete me!'
|
||||
expect(page).to have_content "Delete me!"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Admin hidden budget investments' do
|
||||
feature "Admin hidden budget investments" do
|
||||
|
||||
let(:budget) { create(:budget) }
|
||||
let(:group) { create(:budget_group, name: 'Music', budget: budget) }
|
||||
let(:heading) { create(:budget_heading, name: 'Black metal', price: 666666, group: group) }
|
||||
let(:group) { create(:budget_group, name: "Music", budget: budget) }
|
||||
let(:heading) { create(:budget_heading, name: "Black metal", price: 666666, group: group) }
|
||||
|
||||
background do
|
||||
admin = create(:administrator)
|
||||
login_as(admin.user)
|
||||
end
|
||||
|
||||
scenario 'Disabled with a feature flag' do
|
||||
Setting['feature.budgets'] = nil
|
||||
scenario "Disabled with a feature flag" do
|
||||
Setting["feature.budgets"] = nil
|
||||
|
||||
expect{ visit admin_hidden_budget_investments_path }.to raise_exception(FeatureFlags::FeatureDisabled)
|
||||
|
||||
Setting['feature.budgets'] = true
|
||||
Setting["feature.budgets"] = true
|
||||
end
|
||||
|
||||
scenario 'List shows all relevant info' do
|
||||
scenario "List shows all relevant info" do
|
||||
investment = create(:budget_investment, :hidden, heading: heading)
|
||||
|
||||
visit admin_hidden_budget_investments_path
|
||||
@@ -28,12 +28,12 @@ feature 'Admin hidden budget investments' do
|
||||
expect(page).to have_content(investment.description)
|
||||
end
|
||||
|
||||
scenario 'Restore' do
|
||||
scenario "Restore" do
|
||||
investment = create(:budget_investment, :hidden, heading: heading)
|
||||
|
||||
visit admin_hidden_budget_investments_path
|
||||
|
||||
click_link 'Restore'
|
||||
click_link "Restore"
|
||||
|
||||
expect(page).not_to have_content(investment.title)
|
||||
|
||||
@@ -42,18 +42,18 @@ feature 'Admin hidden budget investments' do
|
||||
expect(investment).to be_ignored_flag
|
||||
end
|
||||
|
||||
scenario 'Confirm hide' do
|
||||
scenario "Confirm hide" do
|
||||
investment = create(:budget_investment, :hidden, heading: heading)
|
||||
visit admin_hidden_budget_investments_path
|
||||
|
||||
click_link('Pending')
|
||||
click_link("Pending")
|
||||
expect(page).to have_content(investment.title)
|
||||
|
||||
click_link 'Confirm moderation'
|
||||
click_link "Confirm moderation"
|
||||
|
||||
expect(page).not_to have_content(investment.title)
|
||||
|
||||
click_link('Confirmed')
|
||||
click_link("Confirmed")
|
||||
expect(page).to have_content(investment.title)
|
||||
|
||||
expect(investment.reload).to be_confirmed_hide
|
||||
@@ -61,48 +61,48 @@ feature 'Admin hidden budget investments' do
|
||||
|
||||
scenario "Current filter is properly highlighted" do
|
||||
visit admin_hidden_budget_investments_path
|
||||
expect(page).not_to have_link('All')
|
||||
expect(page).to have_link('Pending')
|
||||
expect(page).to have_link('Confirmed')
|
||||
expect(page).not_to have_link("All")
|
||||
expect(page).to have_link("Pending")
|
||||
expect(page).to have_link("Confirmed")
|
||||
|
||||
visit admin_hidden_budget_investments_path(filter: 'without_confirmed_hide')
|
||||
expect(page).to have_link('All')
|
||||
expect(page).to have_link('Confirmed')
|
||||
expect(page).not_to have_link('Pending')
|
||||
visit admin_hidden_budget_investments_path(filter: "without_confirmed_hide")
|
||||
expect(page).to have_link("All")
|
||||
expect(page).to have_link("Confirmed")
|
||||
expect(page).not_to have_link("Pending")
|
||||
|
||||
visit admin_hidden_budget_investments_path(filter: 'with_confirmed_hide')
|
||||
expect(page).to have_link('All')
|
||||
expect(page).to have_link('Pending')
|
||||
expect(page).not_to have_link('Confirmed')
|
||||
visit admin_hidden_budget_investments_path(filter: "with_confirmed_hide")
|
||||
expect(page).to have_link("All")
|
||||
expect(page).to have_link("Pending")
|
||||
expect(page).not_to have_link("Confirmed")
|
||||
end
|
||||
|
||||
scenario 'Filtering investments' do
|
||||
create(:budget_investment, :hidden, heading: heading, title: 'Unconfirmed investment')
|
||||
create(:budget_investment, :hidden, :with_confirmed_hide, heading: heading, title: 'Confirmed investment')
|
||||
scenario "Filtering investments" do
|
||||
create(:budget_investment, :hidden, heading: heading, title: "Unconfirmed investment")
|
||||
create(:budget_investment, :hidden, :with_confirmed_hide, heading: heading, title: "Confirmed investment")
|
||||
|
||||
visit admin_hidden_budget_investments_path(filter: 'without_confirmed_hide')
|
||||
expect(page).to have_content('Unconfirmed investment')
|
||||
expect(page).not_to have_content('Confirmed investment')
|
||||
visit admin_hidden_budget_investments_path(filter: "without_confirmed_hide")
|
||||
expect(page).to have_content("Unconfirmed investment")
|
||||
expect(page).not_to have_content("Confirmed investment")
|
||||
|
||||
visit admin_hidden_budget_investments_path(filter: 'all')
|
||||
expect(page).to have_content('Unconfirmed investment')
|
||||
expect(page).to have_content('Confirmed investment')
|
||||
visit admin_hidden_budget_investments_path(filter: "all")
|
||||
expect(page).to have_content("Unconfirmed investment")
|
||||
expect(page).to have_content("Confirmed investment")
|
||||
|
||||
visit admin_hidden_budget_investments_path(filter: 'with_confirmed_hide')
|
||||
expect(page).not_to have_content('Unconfirmed investment')
|
||||
expect(page).to have_content('Confirmed investment')
|
||||
visit admin_hidden_budget_investments_path(filter: "with_confirmed_hide")
|
||||
expect(page).not_to have_content("Unconfirmed investment")
|
||||
expect(page).to have_content("Confirmed investment")
|
||||
end
|
||||
|
||||
scenario "Action links remember the pagination setting and the filter" do
|
||||
per_page = Kaminari.config.default_per_page
|
||||
(per_page + 2).times { create(:budget_investment, :hidden, :with_confirmed_hide, heading: heading) }
|
||||
|
||||
visit admin_hidden_budget_investments_path(filter: 'with_confirmed_hide', page: 2)
|
||||
visit admin_hidden_budget_investments_path(filter: "with_confirmed_hide", page: 2)
|
||||
|
||||
click_on('Restore', match: :first, exact: true)
|
||||
click_on("Restore", match: :first, exact: true)
|
||||
|
||||
expect(current_url).to include('filter=with_confirmed_hide')
|
||||
expect(current_url).to include('page=2')
|
||||
expect(current_url).to include("filter=with_confirmed_hide")
|
||||
expect(current_url).to include("page=2")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Admin hidden proposals' do
|
||||
feature "Admin hidden proposals" do
|
||||
|
||||
background do
|
||||
admin = create(:administrator)
|
||||
login_as(admin.user)
|
||||
end
|
||||
|
||||
scenario 'Disabled with a feature flag' do
|
||||
Setting['feature.proposals'] = nil
|
||||
scenario "Disabled with a feature flag" do
|
||||
Setting["feature.proposals"] = nil
|
||||
admin = create(:administrator)
|
||||
login_as(admin.user)
|
||||
|
||||
expect{ visit admin_hidden_proposals_path }.to raise_exception(FeatureFlags::FeatureDisabled)
|
||||
|
||||
Setting['feature.proposals'] = true
|
||||
Setting["feature.proposals"] = true
|
||||
end
|
||||
|
||||
scenario 'List shows all relevant info' do
|
||||
scenario "List shows all relevant info" do
|
||||
proposal = create(:proposal, :hidden)
|
||||
visit admin_hidden_proposals_path
|
||||
|
||||
@@ -29,11 +29,11 @@ feature 'Admin hidden proposals' do
|
||||
expect(page).to have_content(proposal.video_url)
|
||||
end
|
||||
|
||||
scenario 'Restore' do
|
||||
scenario "Restore" do
|
||||
proposal = create(:proposal, :hidden)
|
||||
visit admin_hidden_proposals_path
|
||||
|
||||
click_link 'Restore'
|
||||
click_link "Restore"
|
||||
|
||||
expect(page).not_to have_content(proposal.title)
|
||||
|
||||
@@ -41,14 +41,14 @@ feature 'Admin hidden proposals' do
|
||||
expect(proposal).to be_ignored_flag
|
||||
end
|
||||
|
||||
scenario 'Confirm hide' do
|
||||
scenario "Confirm hide" do
|
||||
proposal = create(:proposal, :hidden)
|
||||
visit admin_hidden_proposals_path
|
||||
|
||||
click_link 'Confirm moderation'
|
||||
click_link "Confirm moderation"
|
||||
|
||||
expect(page).not_to have_content(proposal.title)
|
||||
click_link('Confirmed')
|
||||
click_link("Confirmed")
|
||||
expect(page).to have_content(proposal.title)
|
||||
|
||||
expect(proposal.reload).to be_confirmed_hide
|
||||
@@ -56,53 +56,53 @@ feature 'Admin hidden proposals' do
|
||||
|
||||
scenario "Current filter is properly highlighted" do
|
||||
visit admin_hidden_proposals_path
|
||||
expect(page).not_to have_link('Pending')
|
||||
expect(page).to have_link('All')
|
||||
expect(page).to have_link('Confirmed')
|
||||
expect(page).not_to have_link("Pending")
|
||||
expect(page).to have_link("All")
|
||||
expect(page).to have_link("Confirmed")
|
||||
|
||||
visit admin_hidden_proposals_path(filter: 'Pending')
|
||||
expect(page).not_to have_link('Pending')
|
||||
expect(page).to have_link('All')
|
||||
expect(page).to have_link('Confirmed')
|
||||
visit admin_hidden_proposals_path(filter: "Pending")
|
||||
expect(page).not_to have_link("Pending")
|
||||
expect(page).to have_link("All")
|
||||
expect(page).to have_link("Confirmed")
|
||||
|
||||
visit admin_hidden_proposals_path(filter: 'all')
|
||||
expect(page).to have_link('Pending')
|
||||
expect(page).not_to have_link('All')
|
||||
expect(page).to have_link('Confirmed')
|
||||
visit admin_hidden_proposals_path(filter: "all")
|
||||
expect(page).to have_link("Pending")
|
||||
expect(page).not_to have_link("All")
|
||||
expect(page).to have_link("Confirmed")
|
||||
|
||||
visit admin_hidden_proposals_path(filter: 'with_confirmed_hide')
|
||||
expect(page).to have_link('All')
|
||||
expect(page).to have_link('Pending')
|
||||
expect(page).not_to have_link('Confirmed')
|
||||
visit admin_hidden_proposals_path(filter: "with_confirmed_hide")
|
||||
expect(page).to have_link("All")
|
||||
expect(page).to have_link("Pending")
|
||||
expect(page).not_to have_link("Confirmed")
|
||||
end
|
||||
|
||||
scenario "Filtering proposals" do
|
||||
create(:proposal, :hidden, title: "Unconfirmed proposal")
|
||||
create(:proposal, :hidden, :with_confirmed_hide, title: "Confirmed proposal")
|
||||
|
||||
visit admin_hidden_proposals_path(filter: 'pending')
|
||||
expect(page).to have_content('Unconfirmed proposal')
|
||||
expect(page).not_to have_content('Confirmed proposal')
|
||||
visit admin_hidden_proposals_path(filter: "pending")
|
||||
expect(page).to have_content("Unconfirmed proposal")
|
||||
expect(page).not_to have_content("Confirmed proposal")
|
||||
|
||||
visit admin_hidden_proposals_path(filter: 'all')
|
||||
expect(page).to have_content('Unconfirmed proposal')
|
||||
expect(page).to have_content('Confirmed proposal')
|
||||
visit admin_hidden_proposals_path(filter: "all")
|
||||
expect(page).to have_content("Unconfirmed proposal")
|
||||
expect(page).to have_content("Confirmed proposal")
|
||||
|
||||
visit admin_hidden_proposals_path(filter: 'with_confirmed_hide')
|
||||
expect(page).not_to have_content('Unconfirmed proposal')
|
||||
expect(page).to have_content('Confirmed proposal')
|
||||
visit admin_hidden_proposals_path(filter: "with_confirmed_hide")
|
||||
expect(page).not_to have_content("Unconfirmed proposal")
|
||||
expect(page).to have_content("Confirmed proposal")
|
||||
end
|
||||
|
||||
scenario "Action links remember the pagination setting and the filter" do
|
||||
per_page = Kaminari.config.default_per_page
|
||||
(per_page + 2).times { create(:proposal, :hidden, :with_confirmed_hide) }
|
||||
|
||||
visit admin_hidden_proposals_path(filter: 'with_confirmed_hide', page: 2)
|
||||
visit admin_hidden_proposals_path(filter: "with_confirmed_hide", page: 2)
|
||||
|
||||
click_on('Restore', match: :first, exact: true)
|
||||
click_on("Restore", match: :first, exact: true)
|
||||
|
||||
expect(current_url).to include('filter=with_confirmed_hide')
|
||||
expect(current_url).to include('page=2')
|
||||
expect(current_url).to include("filter=with_confirmed_hide")
|
||||
expect(current_url).to include("page=2")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Admin hidden users' do
|
||||
feature "Admin hidden users" do
|
||||
|
||||
background do
|
||||
admin = create(:administrator)
|
||||
login_as(admin.user)
|
||||
end
|
||||
|
||||
scenario 'Show user activity' do
|
||||
scenario "Show user activity" do
|
||||
user = create(:user, :hidden)
|
||||
|
||||
debate1 = create(:debate, :hidden, author: user)
|
||||
debate2 = create(:debate, author: user)
|
||||
comment1 = create(:comment, :hidden, user: user, commentable: debate2, body: "You have the manners of a beggar")
|
||||
comment2 = create(:comment, user: user, commentable: debate2, body: 'Not Spam')
|
||||
comment2 = create(:comment, user: user, commentable: debate2, body: "Not Spam")
|
||||
|
||||
visit admin_hidden_user_path(user)
|
||||
|
||||
@@ -23,25 +23,25 @@ feature 'Admin hidden users' do
|
||||
expect(page).to have_content(comment2.body)
|
||||
end
|
||||
|
||||
scenario 'Restore' do
|
||||
scenario "Restore" do
|
||||
user = create(:user, :hidden)
|
||||
visit admin_hidden_users_path
|
||||
|
||||
click_link 'Restore'
|
||||
click_link "Restore"
|
||||
|
||||
expect(page).not_to have_content(user.username)
|
||||
|
||||
expect(user.reload).not_to be_hidden
|
||||
end
|
||||
|
||||
scenario 'Confirm hide' do
|
||||
scenario "Confirm hide" do
|
||||
user = create(:user, :hidden)
|
||||
visit admin_hidden_users_path
|
||||
|
||||
click_link 'Confirm moderation'
|
||||
click_link "Confirm moderation"
|
||||
|
||||
expect(page).not_to have_content(user.username)
|
||||
click_link('Confirmed')
|
||||
click_link("Confirmed")
|
||||
expect(page).to have_content(user.username)
|
||||
|
||||
expect(user.reload).to be_confirmed_hide
|
||||
@@ -49,49 +49,49 @@ feature 'Admin hidden users' do
|
||||
|
||||
scenario "Current filter is properly highlighted" do
|
||||
visit admin_hidden_users_path
|
||||
expect(page).not_to have_link('Pending')
|
||||
expect(page).to have_link('All')
|
||||
expect(page).to have_link('Confirmed')
|
||||
expect(page).not_to have_link("Pending")
|
||||
expect(page).to have_link("All")
|
||||
expect(page).to have_link("Confirmed")
|
||||
|
||||
visit admin_hidden_users_path(filter: 'Pending')
|
||||
expect(page).not_to have_link('Pending')
|
||||
expect(page).to have_link('All')
|
||||
expect(page).to have_link('Confirmed')
|
||||
visit admin_hidden_users_path(filter: "Pending")
|
||||
expect(page).not_to have_link("Pending")
|
||||
expect(page).to have_link("All")
|
||||
expect(page).to have_link("Confirmed")
|
||||
|
||||
visit admin_hidden_users_path(filter: 'all')
|
||||
expect(page).to have_link('Pending')
|
||||
expect(page).not_to have_link('All')
|
||||
expect(page).to have_link('Confirmed')
|
||||
visit admin_hidden_users_path(filter: "all")
|
||||
expect(page).to have_link("Pending")
|
||||
expect(page).not_to have_link("All")
|
||||
expect(page).to have_link("Confirmed")
|
||||
|
||||
visit admin_hidden_users_path(filter: 'with_confirmed_hide')
|
||||
expect(page).to have_link('All')
|
||||
expect(page).to have_link('Pending')
|
||||
expect(page).not_to have_link('Confirmed')
|
||||
visit admin_hidden_users_path(filter: "with_confirmed_hide")
|
||||
expect(page).to have_link("All")
|
||||
expect(page).to have_link("Pending")
|
||||
expect(page).not_to have_link("Confirmed")
|
||||
end
|
||||
|
||||
scenario "Filtering users" do
|
||||
create(:user, :hidden, username: "Unconfirmed")
|
||||
create(:user, :hidden, :with_confirmed_hide, username: "Confirmed user")
|
||||
|
||||
visit admin_hidden_users_path(filter: 'all')
|
||||
expect(page).to have_content('Unconfirmed')
|
||||
expect(page).to have_content('Confirmed user')
|
||||
visit admin_hidden_users_path(filter: "all")
|
||||
expect(page).to have_content("Unconfirmed")
|
||||
expect(page).to have_content("Confirmed user")
|
||||
|
||||
visit admin_hidden_users_path(filter: 'with_confirmed_hide')
|
||||
expect(page).not_to have_content('Unconfirmed')
|
||||
expect(page).to have_content('Confirmed user')
|
||||
visit admin_hidden_users_path(filter: "with_confirmed_hide")
|
||||
expect(page).not_to have_content("Unconfirmed")
|
||||
expect(page).to have_content("Confirmed user")
|
||||
end
|
||||
|
||||
scenario "Action links remember the pagination setting and the filter" do
|
||||
per_page = Kaminari.config.default_per_page
|
||||
(per_page + 2).times { create(:user, :hidden, :with_confirmed_hide) }
|
||||
|
||||
visit admin_hidden_users_path(filter: 'with_confirmed_hide', page: 2)
|
||||
visit admin_hidden_users_path(filter: "with_confirmed_hide", page: 2)
|
||||
|
||||
click_on('Restore', match: :first, exact: true)
|
||||
click_on("Restore", match: :first, exact: true)
|
||||
|
||||
expect(current_url).to include('filter=with_confirmed_hide')
|
||||
expect(current_url).to include('page=2')
|
||||
expect(current_url).to include("filter=with_confirmed_hide")
|
||||
expect(current_url).to include("page=2")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Homepage' do
|
||||
feature "Homepage" do
|
||||
|
||||
background do
|
||||
admin = create(:administrator).user
|
||||
login_as(admin)
|
||||
|
||||
Setting['feature.homepage.widgets.feeds.proposals'] = false
|
||||
Setting['feature.homepage.widgets.feeds.debates'] = false
|
||||
Setting['feature.homepage.widgets.feeds.processes'] = false
|
||||
Setting['feature.user.recommendations'] = false
|
||||
Setting["feature.homepage.widgets.feeds.proposals"] = false
|
||||
Setting["feature.homepage.widgets.feeds.debates"] = false
|
||||
Setting["feature.homepage.widgets.feeds.processes"] = false
|
||||
Setting["feature.user.recommendations"] = false
|
||||
end
|
||||
|
||||
let!(:proposals_feed) { create(:widget_feed, kind: "proposals") }
|
||||
let!(:debates_feed) { create(:widget_feed, kind: "debates") }
|
||||
let!(:processes_feed) { create(:widget_feed, kind: "processes") }
|
||||
|
||||
let(:user_recommendations) { Setting.where(key: 'feature.user.recommendations').first }
|
||||
let(:user_recommendations) { Setting.where(key: "feature.user.recommendations").first }
|
||||
let(:user) { create(:user) }
|
||||
|
||||
context "Header" do
|
||||
@@ -25,7 +25,7 @@ feature 'Homepage' do
|
||||
|
||||
visit new_admin_widget_card_path(header_card: true)
|
||||
|
||||
click_link Setting['org_name'] + " Administration"
|
||||
click_link Setting["org_name"] + " Administration"
|
||||
|
||||
expect(page).to have_current_path(admin_root_path)
|
||||
end
|
||||
@@ -109,7 +109,7 @@ feature 'Homepage' do
|
||||
|
||||
visit admin_homepage_path
|
||||
within("#widget_feed_#{processes_feed.id}") do
|
||||
select '3', from: 'widget_feed_limit'
|
||||
select "3", from: "widget_feed_limit"
|
||||
accept_confirm { click_button "Enable" }
|
||||
end
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Admin legislation draft versions' do
|
||||
feature "Admin legislation draft versions" do
|
||||
|
||||
background do
|
||||
admin = create(:administrator)
|
||||
@@ -15,8 +15,8 @@ feature 'Admin legislation draft versions' do
|
||||
|
||||
context "Feature flag" do
|
||||
|
||||
scenario 'Disabled with a feature flag' do
|
||||
Setting['feature.legislation'] = nil
|
||||
scenario "Disabled with a feature flag" do
|
||||
Setting["feature.legislation"] = nil
|
||||
process = create(:legislation_process)
|
||||
expect{ visit admin_legislation_process_draft_versions_path(process) }.to raise_exception(FeatureFlags::FeatureDisabled)
|
||||
end
|
||||
@@ -25,61 +25,61 @@ feature 'Admin legislation draft versions' do
|
||||
|
||||
context "Index" do
|
||||
|
||||
scenario 'Displaying legislation process draft versions' do
|
||||
process = create(:legislation_process, title: 'An example legislation process')
|
||||
draft_version = create(:legislation_draft_version, process: process, title: 'Version 1')
|
||||
scenario "Displaying legislation process draft versions" do
|
||||
process = create(:legislation_process, title: "An example legislation process")
|
||||
draft_version = create(:legislation_draft_version, process: process, title: "Version 1")
|
||||
|
||||
visit admin_legislation_processes_path(filter: 'all')
|
||||
visit admin_legislation_processes_path(filter: "all")
|
||||
|
||||
click_link 'An example legislation process'
|
||||
click_link 'Drafting'
|
||||
click_link 'Version 1'
|
||||
click_link "An example legislation process"
|
||||
click_link "Drafting"
|
||||
click_link "Version 1"
|
||||
|
||||
expect(page).to have_content(draft_version.title)
|
||||
expect(page).to have_content(draft_version.changelog)
|
||||
end
|
||||
end
|
||||
|
||||
context 'Create' do
|
||||
scenario 'Valid legislation draft version' do
|
||||
process = create(:legislation_process, title: 'An example legislation process')
|
||||
context "Create" do
|
||||
scenario "Valid legislation draft version" do
|
||||
process = create(:legislation_process, title: "An example legislation process")
|
||||
|
||||
visit admin_root_path
|
||||
|
||||
within('#side_menu') do
|
||||
within("#side_menu") do
|
||||
click_link "Collaborative Legislation"
|
||||
end
|
||||
|
||||
click_link "All"
|
||||
|
||||
expect(page).to have_content 'An example legislation process'
|
||||
expect(page).to have_content "An example legislation process"
|
||||
|
||||
click_link 'An example legislation process'
|
||||
click_link 'Drafting'
|
||||
click_link "An example legislation process"
|
||||
click_link "Drafting"
|
||||
|
||||
click_link 'Create version'
|
||||
click_link "Create version"
|
||||
|
||||
fill_in 'Version title', with: 'Version 3'
|
||||
fill_in 'Changes', with: 'Version 3 changes'
|
||||
fill_in 'Text', with: 'Version 3 body'
|
||||
fill_in "Version title", with: "Version 3"
|
||||
fill_in "Changes", with: "Version 3 changes"
|
||||
fill_in "Text", with: "Version 3 body"
|
||||
|
||||
within('.end') do
|
||||
click_button 'Create version'
|
||||
within(".end") do
|
||||
click_button "Create version"
|
||||
end
|
||||
|
||||
expect(page).to have_content 'An example legislation process'
|
||||
expect(page).to have_content 'Version 3'
|
||||
expect(page).to have_content "An example legislation process"
|
||||
expect(page).to have_content "Version 3"
|
||||
end
|
||||
end
|
||||
|
||||
context 'Update' do
|
||||
scenario 'Valid legislation draft version', :js do
|
||||
process = create(:legislation_process, title: 'An example legislation process')
|
||||
draft_version = create(:legislation_draft_version, title: 'Version 1', process: process)
|
||||
context "Update" do
|
||||
scenario "Valid legislation draft version", :js do
|
||||
process = create(:legislation_process, title: "An example legislation process")
|
||||
draft_version = create(:legislation_draft_version, title: "Version 1", process: process)
|
||||
|
||||
visit admin_root_path
|
||||
|
||||
within('#side_menu') do
|
||||
within("#side_menu") do
|
||||
click_link "Collaborative Legislation"
|
||||
end
|
||||
|
||||
@@ -87,24 +87,24 @@ feature 'Admin legislation draft versions' do
|
||||
|
||||
expect(page).not_to have_link "All"
|
||||
|
||||
click_link 'An example legislation process'
|
||||
click_link 'Drafting'
|
||||
click_link "An example legislation process"
|
||||
click_link "Drafting"
|
||||
|
||||
click_link 'Version 1'
|
||||
click_link "Version 1"
|
||||
|
||||
fill_in 'Version title', with: 'Version 1b'
|
||||
fill_in "Version title", with: "Version 1b"
|
||||
|
||||
click_link 'Launch text editor'
|
||||
click_link "Launch text editor"
|
||||
|
||||
fill_in 'Text', with: '# Version 1 body\r\n\r\nParagraph\r\n\r\n>Quote'
|
||||
fill_in "Text", with: "# Version 1 body\r\n\r\nParagraph\r\n\r\n>Quote"
|
||||
|
||||
within('.fullscreen') do
|
||||
click_link 'Close text editor'
|
||||
within(".fullscreen") do
|
||||
click_link "Close text editor"
|
||||
end
|
||||
|
||||
click_button 'Save changes'
|
||||
click_button "Save changes"
|
||||
|
||||
expect(page).to have_content 'Version 1b'
|
||||
expect(page).to have_content "Version 1b"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Admin legislation processes' do
|
||||
feature "Admin legislation processes" do
|
||||
|
||||
background do
|
||||
admin = create(:administrator)
|
||||
@@ -18,8 +18,8 @@ feature 'Admin legislation processes' do
|
||||
|
||||
context "Feature flag" do
|
||||
|
||||
scenario 'Disabled with a feature flag' do
|
||||
Setting['feature.legislation'] = nil
|
||||
scenario "Disabled with a feature flag" do
|
||||
Setting["feature.legislation"] = nil
|
||||
expect{ visit admin_legislation_processes_path }
|
||||
.to raise_exception(FeatureFlags::FeatureDisabled)
|
||||
end
|
||||
@@ -28,9 +28,9 @@ feature 'Admin legislation processes' do
|
||||
|
||||
context "Index" do
|
||||
|
||||
scenario 'Displaying legislation processes' do
|
||||
scenario "Displaying legislation processes" do
|
||||
process = create(:legislation_process)
|
||||
visit admin_legislation_processes_path(filter: 'all')
|
||||
visit admin_legislation_processes_path(filter: "all")
|
||||
|
||||
expect(page).to have_content(process.title)
|
||||
end
|
||||
@@ -48,100 +48,100 @@ feature 'Admin legislation processes' do
|
||||
|
||||
end
|
||||
|
||||
context 'Create' do
|
||||
scenario 'Valid legislation process' do
|
||||
context "Create" do
|
||||
scenario "Valid legislation process" do
|
||||
visit admin_root_path
|
||||
|
||||
within('#side_menu') do
|
||||
within("#side_menu") do
|
||||
click_link "Collaborative Legislation"
|
||||
end
|
||||
|
||||
expect(page).not_to have_content 'An example legislation process'
|
||||
expect(page).not_to have_content "An example legislation process"
|
||||
|
||||
click_link "New process"
|
||||
|
||||
fill_in 'Process Title', with: 'An example legislation process'
|
||||
fill_in 'Summary', with: 'Summary of the process'
|
||||
fill_in 'Description', with: 'Describing the process'
|
||||
fill_in "Process Title", with: "An example legislation process"
|
||||
fill_in "Summary", with: "Summary of the process"
|
||||
fill_in "Description", with: "Describing the process"
|
||||
|
||||
base_date = Date.current
|
||||
fill_in 'legislation_process[start_date]', with: base_date.strftime("%d/%m/%Y")
|
||||
fill_in 'legislation_process[end_date]', with: (base_date + 5.days).strftime("%d/%m/%Y")
|
||||
fill_in "legislation_process[start_date]", with: base_date.strftime("%d/%m/%Y")
|
||||
fill_in "legislation_process[end_date]", with: (base_date + 5.days).strftime("%d/%m/%Y")
|
||||
|
||||
fill_in 'legislation_process[debate_start_date]',
|
||||
fill_in "legislation_process[debate_start_date]",
|
||||
with: base_date.strftime("%d/%m/%Y")
|
||||
fill_in 'legislation_process[debate_end_date]',
|
||||
fill_in "legislation_process[debate_end_date]",
|
||||
with: (base_date + 2.days).strftime("%d/%m/%Y")
|
||||
fill_in 'legislation_process[draft_start_date]',
|
||||
fill_in "legislation_process[draft_start_date]",
|
||||
with: (base_date - 3.days).strftime("%d/%m/%Y")
|
||||
fill_in 'legislation_process[draft_end_date]',
|
||||
fill_in "legislation_process[draft_end_date]",
|
||||
with: (base_date - 1.days).strftime("%d/%m/%Y")
|
||||
fill_in 'legislation_process[draft_publication_date]',
|
||||
fill_in "legislation_process[draft_publication_date]",
|
||||
with: (base_date + 3.days).strftime("%d/%m/%Y")
|
||||
fill_in 'legislation_process[allegations_start_date]',
|
||||
fill_in "legislation_process[allegations_start_date]",
|
||||
with: (base_date + 3.days).strftime("%d/%m/%Y")
|
||||
fill_in 'legislation_process[allegations_end_date]',
|
||||
fill_in "legislation_process[allegations_end_date]",
|
||||
with: (base_date + 5.days).strftime("%d/%m/%Y")
|
||||
fill_in 'legislation_process[result_publication_date]',
|
||||
fill_in "legislation_process[result_publication_date]",
|
||||
with: (base_date + 7.days).strftime("%d/%m/%Y")
|
||||
|
||||
click_button 'Create process'
|
||||
click_button "Create process"
|
||||
|
||||
expect(page).to have_content 'An example legislation process'
|
||||
expect(page).to have_content 'Process created successfully'
|
||||
expect(page).to have_content "An example legislation process"
|
||||
expect(page).to have_content "Process created successfully"
|
||||
|
||||
click_link 'Click to visit'
|
||||
click_link "Click to visit"
|
||||
|
||||
expect(page).to have_content 'An example legislation process'
|
||||
expect(page).not_to have_content 'Summary of the process'
|
||||
expect(page).to have_content 'Describing the process'
|
||||
expect(page).to have_content "An example legislation process"
|
||||
expect(page).not_to have_content "Summary of the process"
|
||||
expect(page).to have_content "Describing the process"
|
||||
|
||||
visit legislation_processes_path
|
||||
|
||||
expect(page).to have_content 'An example legislation process'
|
||||
expect(page).to have_content 'Summary of the process'
|
||||
expect(page).not_to have_content 'Describing the process'
|
||||
expect(page).to have_content "An example legislation process"
|
||||
expect(page).to have_content "Summary of the process"
|
||||
expect(page).not_to have_content "Describing the process"
|
||||
end
|
||||
|
||||
scenario 'Legislation process in draft phase' do
|
||||
scenario "Legislation process in draft phase" do
|
||||
visit admin_root_path
|
||||
|
||||
within('#side_menu') do
|
||||
within("#side_menu") do
|
||||
click_link "Collaborative Legislation"
|
||||
end
|
||||
|
||||
expect(page).not_to have_content 'An example legislation process'
|
||||
expect(page).not_to have_content "An example legislation process"
|
||||
|
||||
click_link "New process"
|
||||
|
||||
fill_in 'Process Title', with: 'An example legislation process in draft phase'
|
||||
fill_in 'Summary', with: 'Summary of the process'
|
||||
fill_in 'Description', with: 'Describing the process'
|
||||
fill_in "Process Title", with: "An example legislation process in draft phase"
|
||||
fill_in "Summary", with: "Summary of the process"
|
||||
fill_in "Description", with: "Describing the process"
|
||||
|
||||
base_date = Date.current - 2.days
|
||||
fill_in 'legislation_process[start_date]', with: base_date.strftime("%d/%m/%Y")
|
||||
fill_in 'legislation_process[end_date]', with: (base_date + 5.days).strftime("%d/%m/%Y")
|
||||
fill_in "legislation_process[start_date]", with: base_date.strftime("%d/%m/%Y")
|
||||
fill_in "legislation_process[end_date]", with: (base_date + 5.days).strftime("%d/%m/%Y")
|
||||
|
||||
fill_in 'legislation_process[draft_start_date]', with: base_date.strftime("%d/%m/%Y")
|
||||
fill_in 'legislation_process[draft_end_date]', with: (base_date + 3.days).strftime("%d/%m/%Y")
|
||||
check 'legislation_process[draft_phase_enabled]'
|
||||
fill_in "legislation_process[draft_start_date]", with: base_date.strftime("%d/%m/%Y")
|
||||
fill_in "legislation_process[draft_end_date]", with: (base_date + 3.days).strftime("%d/%m/%Y")
|
||||
check "legislation_process[draft_phase_enabled]"
|
||||
|
||||
click_button 'Create process'
|
||||
click_button "Create process"
|
||||
|
||||
expect(page).to have_content 'An example legislation process in draft phase'
|
||||
expect(page).to have_content 'Process created successfully'
|
||||
expect(page).to have_content "An example legislation process in draft phase"
|
||||
expect(page).to have_content "Process created successfully"
|
||||
|
||||
click_link 'Click to visit'
|
||||
click_link "Click to visit"
|
||||
|
||||
expect(page).to have_content 'An example legislation process in draft phase'
|
||||
expect(page).not_to have_content 'Summary of the process'
|
||||
expect(page).to have_content 'Describing the process'
|
||||
expect(page).to have_content "An example legislation process in draft phase"
|
||||
expect(page).not_to have_content "Summary of the process"
|
||||
expect(page).to have_content "Describing the process"
|
||||
|
||||
visit legislation_processes_path
|
||||
|
||||
expect(page).not_to have_content 'An example legislation process in draft phase'
|
||||
expect(page).not_to have_content 'Summary of the process'
|
||||
expect(page).not_to have_content 'Describing the process'
|
||||
expect(page).not_to have_content "An example legislation process in draft phase"
|
||||
expect(page).not_to have_content "Summary of the process"
|
||||
expect(page).not_to have_content "Describing the process"
|
||||
end
|
||||
|
||||
scenario "Create a legislation process with an image", :js do
|
||||
@@ -167,18 +167,18 @@ feature 'Admin legislation processes' do
|
||||
end
|
||||
end
|
||||
|
||||
context 'Update' do
|
||||
context "Update" do
|
||||
let!(:process) do
|
||||
create(:legislation_process,
|
||||
title: 'An example legislation process',
|
||||
summary: 'Summarizing the process',
|
||||
description: 'Description of the process')
|
||||
title: "An example legislation process",
|
||||
summary: "Summarizing the process",
|
||||
description: "Description of the process")
|
||||
end
|
||||
|
||||
scenario 'Remove summary text' do
|
||||
scenario "Remove summary text" do
|
||||
visit admin_root_path
|
||||
|
||||
within('#side_menu') do
|
||||
within("#side_menu") do
|
||||
click_link "Collaborative Legislation"
|
||||
end
|
||||
|
||||
@@ -188,20 +188,20 @@ feature 'Admin legislation processes' do
|
||||
expect(find("#legislation_process_debate_phase_enabled")).to be_checked
|
||||
expect(find("#legislation_process_published")).to be_checked
|
||||
|
||||
fill_in 'Summary', with: ''
|
||||
fill_in "Summary", with: ""
|
||||
click_button "Save changes"
|
||||
|
||||
expect(page).to have_content "Process updated successfully"
|
||||
|
||||
visit legislation_processes_path
|
||||
expect(page).not_to have_content 'Summarizing the process'
|
||||
expect(page).to have_content 'Description of the process'
|
||||
expect(page).not_to have_content "Summarizing the process"
|
||||
expect(page).to have_content "Description of the process"
|
||||
end
|
||||
|
||||
scenario 'Deactivate draft publication' do
|
||||
scenario "Deactivate draft publication" do
|
||||
visit admin_root_path
|
||||
|
||||
within('#side_menu') do
|
||||
within("#side_menu") do
|
||||
click_link "Collaborative Legislation"
|
||||
end
|
||||
|
||||
@@ -216,9 +216,9 @@ feature 'Admin legislation processes' do
|
||||
expect(find("#debate_start_date").value).not_to be_blank
|
||||
expect(find("#debate_end_date").value).not_to be_blank
|
||||
|
||||
click_link 'Click to visit'
|
||||
click_link "Click to visit"
|
||||
|
||||
expect(page).not_to have_content 'Draft publication'
|
||||
expect(page).not_to have_content "Draft publication"
|
||||
end
|
||||
|
||||
scenario "Change proposal categories" do
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Admin legislation processes' do
|
||||
feature "Admin legislation processes" do
|
||||
|
||||
background do
|
||||
admin = create(:administrator)
|
||||
@@ -9,7 +9,7 @@ feature 'Admin legislation processes' do
|
||||
|
||||
context "Index" do
|
||||
|
||||
scenario 'Displaying legislation proposals' do
|
||||
scenario "Displaying legislation proposals" do
|
||||
proposal = create(:legislation_proposal, cached_votes_score: 10)
|
||||
|
||||
visit admin_legislation_process_proposals_path(proposal.legislation_process_id)
|
||||
@@ -18,38 +18,38 @@ feature 'Admin legislation processes' do
|
||||
expect(page).to have_content(proposal.title)
|
||||
expect(page).to have_content(proposal.id)
|
||||
expect(page).to have_content(proposal.cached_votes_score)
|
||||
expect(page).to have_content('Select')
|
||||
expect(page).to have_content("Select")
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Selecting legislation proposals', :js do
|
||||
scenario "Selecting legislation proposals", :js do
|
||||
proposal = create(:legislation_proposal, cached_votes_score: 10)
|
||||
|
||||
visit admin_legislation_process_proposals_path(proposal.legislation_process_id)
|
||||
click_link 'Select'
|
||||
click_link "Select"
|
||||
|
||||
within "#legislation_proposal_#{proposal.id}" do
|
||||
expect(page).to have_content('Selected')
|
||||
expect(page).to have_content("Selected")
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Sorting legislation proposals by title', js: true do
|
||||
scenario "Sorting legislation proposals by title", js: true do
|
||||
process = create(:legislation_process)
|
||||
create(:legislation_proposal, title: 'bbbb', legislation_process_id: process.id)
|
||||
create(:legislation_proposal, title: 'aaaa', legislation_process_id: process.id)
|
||||
create(:legislation_proposal, title: 'cccc', legislation_process_id: process.id)
|
||||
create(:legislation_proposal, title: "bbbb", legislation_process_id: process.id)
|
||||
create(:legislation_proposal, title: "aaaa", legislation_process_id: process.id)
|
||||
create(:legislation_proposal, title: "cccc", legislation_process_id: process.id)
|
||||
|
||||
visit admin_legislation_process_proposals_path(process.id)
|
||||
select "Title", from: "order-selector-participation"
|
||||
|
||||
within('#legislation_proposals_list') do
|
||||
within all('.legislation_proposal')[0] { expect(page).to have_content('aaaa') }
|
||||
within all('.legislation_proposal')[1] { expect(page).to have_content('bbbb') }
|
||||
within all('.legislation_proposal')[2] { expect(page).to have_content('cccc') }
|
||||
within("#legislation_proposals_list") do
|
||||
within all(".legislation_proposal")[0] { expect(page).to have_content("aaaa") }
|
||||
within all(".legislation_proposal")[1] { expect(page).to have_content("bbbb") }
|
||||
within all(".legislation_proposal")[2] { expect(page).to have_content("cccc") }
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Sorting legislation proposals by supports', js: true do
|
||||
scenario "Sorting legislation proposals by supports", js: true do
|
||||
process = create(:legislation_process)
|
||||
create(:legislation_proposal, cached_votes_score: 10, legislation_process_id: process.id)
|
||||
create(:legislation_proposal, cached_votes_score: 30, legislation_process_id: process.id)
|
||||
@@ -58,26 +58,26 @@ feature 'Admin legislation processes' do
|
||||
visit admin_legislation_process_proposals_path(process.id)
|
||||
select "Total supports", from: "order-selector-participation"
|
||||
|
||||
within('#legislation_proposals_list') do
|
||||
within all('.legislation_proposal')[0] { expect(page).to have_content('30') }
|
||||
within all('.legislation_proposal')[1] { expect(page).to have_content('20') }
|
||||
within all('.legislation_proposal')[2] { expect(page).to have_content('10') }
|
||||
within("#legislation_proposals_list") do
|
||||
within all(".legislation_proposal")[0] { expect(page).to have_content("30") }
|
||||
within all(".legislation_proposal")[1] { expect(page).to have_content("20") }
|
||||
within all(".legislation_proposal")[2] { expect(page).to have_content("10") }
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Sorting legislation proposals by Id', js: true do
|
||||
scenario "Sorting legislation proposals by Id", js: true do
|
||||
process = create(:legislation_process)
|
||||
proposal1 = create(:legislation_proposal, title: 'bbbb', legislation_process_id: process.id)
|
||||
proposal2 = create(:legislation_proposal, title: 'aaaa', legislation_process_id: process.id)
|
||||
proposal3 = create(:legislation_proposal, title: 'cccc', legislation_process_id: process.id)
|
||||
proposal1 = create(:legislation_proposal, title: "bbbb", legislation_process_id: process.id)
|
||||
proposal2 = create(:legislation_proposal, title: "aaaa", legislation_process_id: process.id)
|
||||
proposal3 = create(:legislation_proposal, title: "cccc", legislation_process_id: process.id)
|
||||
|
||||
visit admin_legislation_process_proposals_path(process.id, order: :title)
|
||||
select "Id", from: "order-selector-participation"
|
||||
|
||||
within('#legislation_proposals_list') do
|
||||
within all('.legislation_proposal')[0] { expect(page).to have_content(proposal1.id) }
|
||||
within all('.legislation_proposal')[1] { expect(page).to have_content(proposal2.id) }
|
||||
within all('.legislation_proposal')[2] { expect(page).to have_content(proposal3.id) }
|
||||
within("#legislation_proposals_list") do
|
||||
within all(".legislation_proposal")[0] { expect(page).to have_content(proposal1.id) }
|
||||
within all(".legislation_proposal")[1] { expect(page).to have_content(proposal2.id) }
|
||||
within all(".legislation_proposal")[2] { expect(page).to have_content(proposal3.id) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Admin legislation questions' do
|
||||
feature "Admin legislation questions" do
|
||||
|
||||
background do
|
||||
admin = create(:administrator)
|
||||
@@ -17,14 +17,14 @@ feature 'Admin legislation questions' do
|
||||
context "Feature flag" do
|
||||
|
||||
background do
|
||||
Setting['feature.legislation'] = nil
|
||||
Setting["feature.legislation"] = nil
|
||||
end
|
||||
|
||||
after do
|
||||
Setting['feature.legislation'] = true
|
||||
Setting["feature.legislation"] = true
|
||||
end
|
||||
|
||||
scenario 'Disabled with a feature flag' do
|
||||
scenario "Disabled with a feature flag" do
|
||||
expect{ visit admin_legislation_process_questions_path(process) }.to raise_exception(FeatureFlags::FeatureDisabled)
|
||||
end
|
||||
|
||||
@@ -32,51 +32,51 @@ feature 'Admin legislation questions' do
|
||||
|
||||
context "Index" do
|
||||
|
||||
scenario 'Displaying legislation process questions' do
|
||||
question = create(:legislation_question, process: process, title: 'Question 1')
|
||||
question = create(:legislation_question, process: process, title: 'Question 2')
|
||||
scenario "Displaying legislation process questions" do
|
||||
question = create(:legislation_question, process: process, title: "Question 1")
|
||||
question = create(:legislation_question, process: process, title: "Question 2")
|
||||
|
||||
visit admin_legislation_processes_path(filter: 'all')
|
||||
visit admin_legislation_processes_path(filter: "all")
|
||||
|
||||
click_link 'An example legislation process'
|
||||
click_link 'Debate'
|
||||
click_link "An example legislation process"
|
||||
click_link "Debate"
|
||||
|
||||
expect(page).to have_content('Question 1')
|
||||
expect(page).to have_content('Question 2')
|
||||
expect(page).to have_content("Question 1")
|
||||
expect(page).to have_content("Question 2")
|
||||
end
|
||||
end
|
||||
|
||||
context 'Create' do
|
||||
scenario 'Valid legislation question' do
|
||||
context "Create" do
|
||||
scenario "Valid legislation question" do
|
||||
visit admin_root_path
|
||||
|
||||
within('#side_menu') do
|
||||
within("#side_menu") do
|
||||
click_link "Collaborative Legislation"
|
||||
end
|
||||
|
||||
click_link "All"
|
||||
|
||||
expect(page).to have_content 'An example legislation process'
|
||||
expect(page).to have_content "An example legislation process"
|
||||
|
||||
click_link 'An example legislation process'
|
||||
click_link 'Debate'
|
||||
click_link "An example legislation process"
|
||||
click_link "Debate"
|
||||
|
||||
click_link 'Create question'
|
||||
click_link "Create question"
|
||||
|
||||
fill_in 'Question', with: 'Question 3'
|
||||
click_button 'Create question'
|
||||
fill_in "Question", with: "Question 3"
|
||||
click_button "Create question"
|
||||
|
||||
expect(page).to have_content 'Question 3'
|
||||
expect(page).to have_content "Question 3"
|
||||
end
|
||||
end
|
||||
|
||||
context 'Update' do
|
||||
scenario 'Valid legislation question', :js do
|
||||
question = create(:legislation_question, title: 'Question 2', process: process)
|
||||
context "Update" do
|
||||
scenario "Valid legislation question", :js do
|
||||
question = create(:legislation_question, title: "Question 2", process: process)
|
||||
|
||||
visit admin_root_path
|
||||
|
||||
within('#side_menu') do
|
||||
within("#side_menu") do
|
||||
click_link "Collaborative Legislation"
|
||||
end
|
||||
|
||||
@@ -84,32 +84,32 @@ feature 'Admin legislation questions' do
|
||||
|
||||
expect(page).not_to have_link "All"
|
||||
|
||||
click_link 'An example legislation process'
|
||||
click_link 'Debate'
|
||||
click_link "An example legislation process"
|
||||
click_link "Debate"
|
||||
|
||||
click_link 'Question 2'
|
||||
click_link "Question 2"
|
||||
|
||||
fill_in 'Question', with: 'Question 2b'
|
||||
click_button 'Save changes'
|
||||
fill_in "Question", with: "Question 2b"
|
||||
click_button "Save changes"
|
||||
|
||||
expect(page).to have_content 'Question 2b'
|
||||
expect(page).to have_content "Question 2b"
|
||||
end
|
||||
end
|
||||
|
||||
context 'Delete' do
|
||||
scenario 'Legislation question', :js do
|
||||
create(:legislation_question, title: 'Question 1', process: process)
|
||||
question = create(:legislation_question, title: 'Question 2', process: process)
|
||||
question_option = create(:legislation_question_option, question: question, value: 'Yes')
|
||||
context "Delete" do
|
||||
scenario "Legislation question", :js do
|
||||
create(:legislation_question, title: "Question 1", process: process)
|
||||
question = create(:legislation_question, title: "Question 2", process: process)
|
||||
question_option = create(:legislation_question_option, question: question, value: "Yes")
|
||||
create(:legislation_answer, question: question, question_option: question_option)
|
||||
|
||||
visit edit_admin_legislation_process_question_path(process, question)
|
||||
|
||||
click_link 'Delete'
|
||||
click_link "Delete"
|
||||
|
||||
expect(page).to have_content 'Questions'
|
||||
expect(page).to have_content 'Question 1'
|
||||
expect(page).not_to have_content 'Question 2'
|
||||
expect(page).to have_content "Questions"
|
||||
expect(page).to have_content "Question 1"
|
||||
expect(page).not_to have_content "Question 2"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -170,49 +170,49 @@ feature 'Admin legislation questions' do
|
||||
question.update_attributes(title_en: "Title in English", title_es: "Título en Español")
|
||||
end
|
||||
|
||||
scenario 'Add translation for question option', :js do
|
||||
scenario "Add translation for question option", :js do
|
||||
visit edit_question_url
|
||||
|
||||
click_on 'Add option'
|
||||
click_on "Add option"
|
||||
|
||||
find('#nested_question_options input').set('Option 1')
|
||||
find("#nested_question_options input").set("Option 1")
|
||||
|
||||
click_link "Español"
|
||||
|
||||
find('#nested_question_options input').set('Opción 1')
|
||||
find("#nested_question_options input").set("Opción 1")
|
||||
|
||||
click_button "Save changes"
|
||||
visit edit_question_url
|
||||
|
||||
expect(page).to have_field(field_en[:id], with: 'Option 1')
|
||||
expect(page).to have_field(field_en[:id], with: "Option 1")
|
||||
|
||||
click_link "Español"
|
||||
|
||||
expect(page).to have_field(field_es[:id], with: 'Opción 1')
|
||||
expect(page).to have_field(field_es[:id], with: "Opción 1")
|
||||
end
|
||||
|
||||
scenario 'Add new question option after changing active locale', :js do
|
||||
scenario "Add new question option after changing active locale", :js do
|
||||
visit edit_question_url
|
||||
|
||||
click_link "Español"
|
||||
|
||||
click_on 'Add option'
|
||||
click_on "Add option"
|
||||
|
||||
find('#nested_question_options input').set('Opción 1')
|
||||
find("#nested_question_options input").set("Opción 1")
|
||||
|
||||
click_link "English"
|
||||
|
||||
find('#nested_question_options input').set('Option 1')
|
||||
find("#nested_question_options input").set("Option 1")
|
||||
|
||||
click_button "Save changes"
|
||||
|
||||
visit edit_question_url
|
||||
|
||||
expect(page).to have_field(field_en[:id], with: 'Option 1')
|
||||
expect(page).to have_field(field_en[:id], with: "Option 1")
|
||||
|
||||
click_link "Español"
|
||||
|
||||
expect(page).to have_field(field_es[:id], with: 'Opción 1')
|
||||
expect(page).to have_field(field_es[:id], with: "Opción 1")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Admin managers' do
|
||||
feature "Admin managers" do
|
||||
background do
|
||||
@admin = create(:administrator)
|
||||
@user = create(:user)
|
||||
@@ -9,74 +9,74 @@ feature 'Admin managers' do
|
||||
visit admin_managers_path
|
||||
end
|
||||
|
||||
scenario 'Index' do
|
||||
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
|
||||
end
|
||||
|
||||
scenario 'Create Manager', :js do
|
||||
fill_in 'name_or_email', with: @user.email
|
||||
click_button 'Search'
|
||||
scenario "Create Manager", :js do
|
||||
fill_in "name_or_email", with: @user.email
|
||||
click_button "Search"
|
||||
|
||||
expect(page).to have_content @user.name
|
||||
click_link 'Add'
|
||||
click_link "Add"
|
||||
within("#managers") do
|
||||
expect(page).to have_content @user.name
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Delete Manager' do
|
||||
click_link 'Delete'
|
||||
scenario "Delete Manager" do
|
||||
click_link "Delete"
|
||||
|
||||
within("#managers") do
|
||||
expect(page).not_to have_content @manager.name
|
||||
end
|
||||
end
|
||||
|
||||
context 'Search' do
|
||||
context "Search" do
|
||||
|
||||
background do
|
||||
user = create(:user, username: 'Taylor Swift', email: 'taylor@swift.com')
|
||||
user2 = create(:user, username: 'Stephanie Corneliussen', email: 'steph@mrrobot.com')
|
||||
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
|
||||
scenario "returns no results if search term is empty" do
|
||||
expect(page).to have_content(@manager1.name)
|
||||
expect(page).to have_content(@manager2.name)
|
||||
|
||||
fill_in 'name_or_email', with: ' '
|
||||
click_button 'Search'
|
||||
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).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)
|
||||
end
|
||||
|
||||
scenario 'search by name' do
|
||||
scenario "search by name" do
|
||||
expect(page).to have_content(@manager1.name)
|
||||
expect(page).to have_content(@manager2.name)
|
||||
|
||||
fill_in 'name_or_email', with: 'Taylor'
|
||||
click_button 'Search'
|
||||
fill_in "name_or_email", with: "Taylor"
|
||||
click_button "Search"
|
||||
|
||||
expect(page).to have_content('Managers: User search')
|
||||
expect(page).to have_content("Managers: User search")
|
||||
expect(page).to have_content(@manager1.name)
|
||||
expect(page).not_to have_content(@manager2.name)
|
||||
end
|
||||
|
||||
scenario 'search by email' do
|
||||
scenario "search by email" do
|
||||
expect(page).to have_content(@manager1.email)
|
||||
expect(page).to have_content(@manager2.email)
|
||||
|
||||
fill_in 'name_or_email', with: @manager2.email
|
||||
click_button 'Search'
|
||||
fill_in "name_or_email", with: @manager2.email
|
||||
click_button "Search"
|
||||
|
||||
expect(page).to have_content('Managers: User search')
|
||||
expect(page).to have_content("Managers: User search")
|
||||
expect(page).to have_content(@manager2.email)
|
||||
expect(page).not_to have_content(@manager1.email)
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Admin milestone statuses' do
|
||||
feature "Admin milestone statuses" do
|
||||
|
||||
background do
|
||||
admin = create(:administrator)
|
||||
@@ -8,7 +8,7 @@ feature 'Admin milestone statuses' do
|
||||
end
|
||||
|
||||
context "Index" do
|
||||
scenario 'Displaying only not hidden statuses' do
|
||||
scenario "Displaying only not hidden statuses" do
|
||||
status1 = create(:milestone_status)
|
||||
status2 = create(:milestone_status)
|
||||
|
||||
@@ -23,7 +23,7 @@ feature 'Admin milestone statuses' do
|
||||
expect(page).to have_content status2.description
|
||||
end
|
||||
|
||||
scenario 'Displaying no statuses text' do
|
||||
scenario "Displaying no statuses text" do
|
||||
visit admin_milestone_statuses_path
|
||||
|
||||
expect(page).to have_content("There are no milestone statuses created")
|
||||
@@ -34,23 +34,23 @@ feature 'Admin milestone statuses' do
|
||||
scenario "Create status" do
|
||||
visit admin_milestone_statuses_path
|
||||
|
||||
click_link 'Create new milestone status'
|
||||
click_link "Create new milestone status"
|
||||
|
||||
fill_in 'milestone_status_name', with: 'New status name'
|
||||
fill_in 'milestone_status_description', with: 'This status description'
|
||||
click_button 'Create Milestone Status'
|
||||
fill_in "milestone_status_name", with: "New status name"
|
||||
fill_in "milestone_status_description", with: "This status description"
|
||||
click_button "Create Milestone Status"
|
||||
|
||||
expect(page).to have_content 'New status name'
|
||||
expect(page).to have_content 'This status description'
|
||||
expect(page).to have_content "New status name"
|
||||
expect(page).to have_content "This status description"
|
||||
end
|
||||
|
||||
scenario "Show validation errors in status form" do
|
||||
visit admin_milestone_statuses_path
|
||||
|
||||
click_link 'Create new milestone status'
|
||||
click_link "Create new milestone status"
|
||||
|
||||
fill_in 'milestone_status_description', with: 'This status description'
|
||||
click_button 'Create Milestone Status'
|
||||
fill_in "milestone_status_description", with: "This status description"
|
||||
click_button "Create Milestone Status"
|
||||
|
||||
within "#new_milestone_status" do
|
||||
expect(page).to have_content "can't be blank", count: 1
|
||||
@@ -68,12 +68,12 @@ feature 'Admin milestone statuses' do
|
||||
click_link "Edit"
|
||||
end
|
||||
|
||||
fill_in 'milestone_status_name', with: 'Other status name'
|
||||
fill_in 'milestone_status_description', with: 'Other status description'
|
||||
click_button 'Update Milestone Status'
|
||||
fill_in "milestone_status_name", with: "Other status name"
|
||||
fill_in "milestone_status_description", with: "Other status description"
|
||||
click_button "Update Milestone Status"
|
||||
|
||||
expect(page).to have_content 'Other status name'
|
||||
expect(page).to have_content 'Other status description'
|
||||
expect(page).to have_content "Other status name"
|
||||
expect(page).to have_content "Other status description"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,82 +1,82 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Admin moderators' do
|
||||
feature "Admin moderators" do
|
||||
background do
|
||||
@admin = create(:administrator)
|
||||
@user = create(:user, username: 'Jose Luis Balbin')
|
||||
@user = create(:user, username: "Jose Luis Balbin")
|
||||
@moderator = create(:moderator)
|
||||
login_as(@admin.user)
|
||||
visit admin_moderators_path
|
||||
end
|
||||
|
||||
scenario 'Index' do
|
||||
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
|
||||
end
|
||||
|
||||
scenario 'Create Moderator', :js do
|
||||
fill_in 'name_or_email', with: @user.email
|
||||
click_button 'Search'
|
||||
scenario "Create Moderator", :js do
|
||||
fill_in "name_or_email", with: @user.email
|
||||
click_button "Search"
|
||||
|
||||
expect(page).to have_content @user.name
|
||||
click_link 'Add'
|
||||
click_link "Add"
|
||||
within("#moderators") do
|
||||
expect(page).to have_content @user.name
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Delete Moderator' do
|
||||
click_link 'Delete'
|
||||
scenario "Delete Moderator" do
|
||||
click_link "Delete"
|
||||
|
||||
within("#moderators") do
|
||||
expect(page).not_to have_content @moderator.name
|
||||
end
|
||||
end
|
||||
|
||||
context 'Search' do
|
||||
context "Search" do
|
||||
|
||||
background do
|
||||
user = create(:user, username: 'Elizabeth Bathory', email: 'elizabeth@bathory.com')
|
||||
user2 = create(:user, username: 'Ada Lovelace', email: 'ada@lovelace.com')
|
||||
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
|
||||
scenario "returns no results if search term is empty" do
|
||||
expect(page).to have_content(@moderator1.name)
|
||||
expect(page).to have_content(@moderator2.name)
|
||||
|
||||
fill_in 'name_or_email', with: ' '
|
||||
click_button 'Search'
|
||||
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).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)
|
||||
end
|
||||
|
||||
scenario 'search by name' do
|
||||
scenario "search by name" do
|
||||
expect(page).to have_content(@moderator1.name)
|
||||
expect(page).to have_content(@moderator2.name)
|
||||
|
||||
fill_in 'name_or_email', with: 'Eliz'
|
||||
click_button 'Search'
|
||||
fill_in "name_or_email", with: "Eliz"
|
||||
click_button "Search"
|
||||
|
||||
expect(page).to have_content('Moderators: User search')
|
||||
expect(page).to have_content("Moderators: User search")
|
||||
expect(page).to have_content(@moderator1.name)
|
||||
expect(page).not_to have_content(@moderator2.name)
|
||||
end
|
||||
|
||||
scenario 'search by email' do
|
||||
scenario "search by email" do
|
||||
expect(page).to have_content(@moderator1.email)
|
||||
expect(page).to have_content(@moderator2.email)
|
||||
|
||||
fill_in 'name_or_email', with: @moderator2.email
|
||||
click_button 'Search'
|
||||
fill_in "name_or_email", with: @moderator2.email
|
||||
click_button "Search"
|
||||
|
||||
expect(page).to have_content('Moderators: User search')
|
||||
expect(page).to have_content("Moderators: User search")
|
||||
expect(page).to have_content(@moderator2.email)
|
||||
expect(page).not_to have_content(@moderator1.email)
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Admin officials' do
|
||||
feature "Admin officials" do
|
||||
|
||||
background do
|
||||
@citizen = create(:user, username: "Citizen Kane")
|
||||
@@ -9,7 +9,7 @@ feature 'Admin officials' do
|
||||
login_as(@admin.user)
|
||||
end
|
||||
|
||||
scenario 'Index' do
|
||||
scenario "Index" do
|
||||
visit admin_officials_path
|
||||
|
||||
expect(page).to have_content @official.name
|
||||
@@ -18,7 +18,7 @@ feature 'Admin officials' do
|
||||
expect(page).to have_content @official.official_level
|
||||
end
|
||||
|
||||
scenario 'Edit an official' do
|
||||
scenario "Edit an official" do
|
||||
visit admin_officials_path
|
||||
click_link @official.name
|
||||
|
||||
@@ -28,49 +28,49 @@ feature 'Admin officials' do
|
||||
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
|
||||
click_button 'Update User'
|
||||
fill_in "user_official_position", with: "School Teacher"
|
||||
select "3", from: "user_official_level", exact: false
|
||||
click_button "Update User"
|
||||
|
||||
expect(page).to have_content 'Details of official saved'
|
||||
expect(page).to have_content "Details of official saved"
|
||||
|
||||
visit admin_officials_path
|
||||
|
||||
expect(page).to have_content @official.name
|
||||
expect(page).to have_content 'School Teacher'
|
||||
expect(page).to have_content '3'
|
||||
expect(page).to have_content "School Teacher"
|
||||
expect(page).to have_content "3"
|
||||
end
|
||||
|
||||
scenario 'Create an official' do
|
||||
scenario "Create an official" do
|
||||
visit admin_officials_path
|
||||
fill_in 'name_or_email', with: @citizen.email
|
||||
click_button 'Search'
|
||||
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
|
||||
|
||||
click_link @citizen.name
|
||||
|
||||
fill_in 'user_official_position', with: 'Hospital manager'
|
||||
select '4', from: 'user_official_level', exact: false
|
||||
click_button 'Update User'
|
||||
fill_in "user_official_position", with: "Hospital manager"
|
||||
select "4", from: "user_official_level", exact: false
|
||||
click_button "Update User"
|
||||
|
||||
expect(page).to have_content 'Details of official saved'
|
||||
expect(page).to have_content "Details of official saved"
|
||||
|
||||
visit admin_officials_path
|
||||
|
||||
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'
|
||||
expect(page).to have_content "Hospital manager"
|
||||
expect(page).to have_content "4"
|
||||
end
|
||||
|
||||
scenario 'Destroy' do
|
||||
scenario "Destroy" do
|
||||
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_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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Admin::Organizations' do
|
||||
feature "Admin::Organizations" do
|
||||
|
||||
background do
|
||||
administrator = create(:user)
|
||||
@@ -89,13 +89,13 @@ feature 'Admin::Organizations' do
|
||||
visit admin_organizations_path
|
||||
within("#organization_#{organization.id}") do
|
||||
expect(page).to have_current_path(admin_organizations_path, ignore_query: true)
|
||||
expect(page).to have_link('Verify')
|
||||
expect(page).to have_link('Reject')
|
||||
expect(page).to have_link("Verify")
|
||||
expect(page).to have_link("Reject")
|
||||
|
||||
click_on 'Verify'
|
||||
click_on "Verify"
|
||||
end
|
||||
expect(page).to have_current_path(admin_organizations_path, ignore_query: true)
|
||||
expect(page).to have_content 'Verified'
|
||||
expect(page).to have_content "Verified"
|
||||
|
||||
expect(organization.reload.verified?).to eq(true)
|
||||
end
|
||||
@@ -108,17 +108,17 @@ feature 'Admin::Organizations' do
|
||||
click_on "Verified"
|
||||
|
||||
within("#organization_#{organization.id}") do
|
||||
expect(page).to have_content 'Verified'
|
||||
expect(page).not_to have_link('Verify')
|
||||
expect(page).to have_link('Reject')
|
||||
expect(page).to have_content "Verified"
|
||||
expect(page).not_to have_link("Verify")
|
||||
expect(page).to have_link("Reject")
|
||||
|
||||
click_on 'Reject'
|
||||
click_on "Reject"
|
||||
end
|
||||
expect(page).to have_current_path(admin_organizations_path, ignore_query: true)
|
||||
expect(page).not_to have_content organization.name
|
||||
|
||||
click_on 'Rejected'
|
||||
expect(page).to have_content 'Rejected'
|
||||
click_on "Rejected"
|
||||
expect(page).to have_content "Rejected"
|
||||
expect(page).to have_content organization.name
|
||||
|
||||
expect(organization.reload.rejected?).to eq(true)
|
||||
@@ -131,14 +131,14 @@ feature 'Admin::Organizations' do
|
||||
click_on "Rejected"
|
||||
|
||||
within("#organization_#{organization.id}") do
|
||||
expect(page).to have_link('Verify')
|
||||
expect(page).not_to have_link('Reject', exact: true)
|
||||
expect(page).to have_link("Verify")
|
||||
expect(page).not_to have_link("Reject", exact: true)
|
||||
|
||||
click_on 'Verify'
|
||||
click_on "Verify"
|
||||
end
|
||||
expect(page).to have_current_path(admin_organizations_path, ignore_query: true)
|
||||
expect(page).not_to have_content organization.name
|
||||
click_on('Verified')
|
||||
click_on("Verified")
|
||||
|
||||
expect(page).to have_content organization.name
|
||||
|
||||
@@ -147,34 +147,34 @@ feature 'Admin::Organizations' do
|
||||
|
||||
scenario "Current filter is properly highlighted" do
|
||||
visit admin_organizations_path
|
||||
expect(page).not_to have_link('Pending')
|
||||
expect(page).to have_link('All')
|
||||
expect(page).to have_link('Verified')
|
||||
expect(page).to have_link('Rejected')
|
||||
expect(page).not_to have_link("Pending")
|
||||
expect(page).to have_link("All")
|
||||
expect(page).to have_link("Verified")
|
||||
expect(page).to have_link("Rejected")
|
||||
|
||||
visit admin_organizations_path(filter: 'all')
|
||||
expect(page).not_to have_link('All')
|
||||
expect(page).to have_link('Pending')
|
||||
expect(page).to have_link('Verified')
|
||||
expect(page).to have_link('Rejected')
|
||||
visit admin_organizations_path(filter: "all")
|
||||
expect(page).not_to have_link("All")
|
||||
expect(page).to have_link("Pending")
|
||||
expect(page).to have_link("Verified")
|
||||
expect(page).to have_link("Rejected")
|
||||
|
||||
visit admin_organizations_path(filter: 'pending')
|
||||
expect(page).to have_link('All')
|
||||
expect(page).not_to have_link('Pending')
|
||||
expect(page).to have_link('Verified')
|
||||
expect(page).to have_link('Rejected')
|
||||
visit admin_organizations_path(filter: "pending")
|
||||
expect(page).to have_link("All")
|
||||
expect(page).not_to have_link("Pending")
|
||||
expect(page).to have_link("Verified")
|
||||
expect(page).to have_link("Rejected")
|
||||
|
||||
visit admin_organizations_path(filter: 'verified')
|
||||
expect(page).to have_link('All')
|
||||
expect(page).to have_link('Pending')
|
||||
expect(page).not_to have_link('Verified')
|
||||
expect(page).to have_link('Rejected')
|
||||
visit admin_organizations_path(filter: "verified")
|
||||
expect(page).to have_link("All")
|
||||
expect(page).to have_link("Pending")
|
||||
expect(page).not_to have_link("Verified")
|
||||
expect(page).to have_link("Rejected")
|
||||
|
||||
visit admin_organizations_path(filter: 'rejected')
|
||||
expect(page).to have_link('All')
|
||||
expect(page).to have_link('Pending')
|
||||
expect(page).to have_link('Verified')
|
||||
expect(page).not_to have_link('Rejected')
|
||||
visit admin_organizations_path(filter: "rejected")
|
||||
expect(page).to have_link("All")
|
||||
expect(page).to have_link("Pending")
|
||||
expect(page).to have_link("Verified")
|
||||
expect(page).not_to have_link("Rejected")
|
||||
end
|
||||
|
||||
scenario "Filtering organizations" do
|
||||
@@ -182,37 +182,37 @@ feature 'Admin::Organizations' do
|
||||
create(:organization, :rejected, name: "Rejected Organization")
|
||||
create(:organization, :verified, name: "Verified Organization")
|
||||
|
||||
visit admin_organizations_path(filter: 'all')
|
||||
expect(page).to have_content('Pending Organization')
|
||||
expect(page).to have_content('Rejected Organization')
|
||||
expect(page).to have_content('Verified Organization')
|
||||
visit admin_organizations_path(filter: "all")
|
||||
expect(page).to have_content("Pending Organization")
|
||||
expect(page).to have_content("Rejected Organization")
|
||||
expect(page).to have_content("Verified Organization")
|
||||
|
||||
visit admin_organizations_path(filter: 'pending')
|
||||
expect(page).to have_content('Pending Organization')
|
||||
expect(page).not_to have_content('Rejected Organization')
|
||||
expect(page).not_to have_content('Verified Organization')
|
||||
visit admin_organizations_path(filter: "pending")
|
||||
expect(page).to have_content("Pending Organization")
|
||||
expect(page).not_to have_content("Rejected Organization")
|
||||
expect(page).not_to have_content("Verified Organization")
|
||||
|
||||
visit admin_organizations_path(filter: 'verified')
|
||||
expect(page).not_to have_content('Pending Organization')
|
||||
expect(page).not_to have_content('Rejected Organization')
|
||||
expect(page).to have_content('Verified Organization')
|
||||
visit admin_organizations_path(filter: "verified")
|
||||
expect(page).not_to have_content("Pending Organization")
|
||||
expect(page).not_to have_content("Rejected Organization")
|
||||
expect(page).to have_content("Verified Organization")
|
||||
|
||||
visit admin_organizations_path(filter: 'rejected')
|
||||
expect(page).not_to have_content('Pending Organization')
|
||||
expect(page).to have_content('Rejected Organization')
|
||||
expect(page).not_to have_content('Verified Organization')
|
||||
visit admin_organizations_path(filter: "rejected")
|
||||
expect(page).not_to have_content("Pending Organization")
|
||||
expect(page).to have_content("Rejected Organization")
|
||||
expect(page).not_to have_content("Verified Organization")
|
||||
end
|
||||
|
||||
scenario "Verifying organization links remember the pagination setting and the filter" do
|
||||
per_page = Kaminari.config.default_per_page
|
||||
(per_page + 2).times { create(:organization) }
|
||||
|
||||
visit admin_organizations_path(filter: 'pending', page: 2)
|
||||
visit admin_organizations_path(filter: "pending", page: 2)
|
||||
|
||||
click_on('Verify', match: :first)
|
||||
click_on("Verify", match: :first)
|
||||
|
||||
expect(current_url).to include('filter=pending')
|
||||
expect(current_url).to include('page=2')
|
||||
expect(current_url).to include("filter=pending")
|
||||
expect(current_url).to include("page=2")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Admin booths assignments' do
|
||||
feature "Admin booths assignments" do
|
||||
|
||||
background do
|
||||
admin = create(:administrator)
|
||||
login_as(admin.user)
|
||||
end
|
||||
|
||||
feature 'Admin Booth Assignment management' do
|
||||
feature "Admin Booth Assignment management" do
|
||||
|
||||
let!(:poll) { create(:poll) }
|
||||
let!(:booth) { create(:poll_booth) }
|
||||
|
||||
scenario 'List Polls and Booths to manage', :js do
|
||||
scenario "List Polls and Booths to manage", :js do
|
||||
second_poll = create(:poll)
|
||||
second_booth = create(:poll_booth)
|
||||
|
||||
@@ -22,37 +22,37 @@ feature 'Admin booths assignments' do
|
||||
expect(page).to have_content(second_poll.name)
|
||||
|
||||
within("#poll_#{second_poll.id}") do
|
||||
click_link 'Manage assignments'
|
||||
click_link "Manage assignments"
|
||||
end
|
||||
|
||||
expect(page).to have_content "Assignments for poll '#{second_poll.name}'"
|
||||
expect(page).to have_content "Assignments for poll "#{second_poll.name}""
|
||||
|
||||
expect(page).to have_content(booth.name)
|
||||
expect(page).to have_content(second_booth.name)
|
||||
end
|
||||
|
||||
scenario 'Assign booth to poll', :js do
|
||||
scenario "Assign booth to poll", :js do
|
||||
visit admin_poll_path(poll)
|
||||
within('#poll-resources') do
|
||||
click_link 'Booths (0)'
|
||||
within("#poll-resources") do
|
||||
click_link "Booths (0)"
|
||||
end
|
||||
|
||||
expect(page).to have_content 'There are no booths assigned to this poll.'
|
||||
expect(page).to have_content "There are no booths assigned to this poll."
|
||||
expect(page).not_to have_content booth.name
|
||||
|
||||
fill_in 'search-booths', with: booth.name
|
||||
click_button 'Search'
|
||||
fill_in "search-booths", with: booth.name
|
||||
click_button "Search"
|
||||
expect(page).to have_content(booth.name)
|
||||
|
||||
visit manage_admin_poll_booth_assignments_path(poll)
|
||||
|
||||
expect(page).to have_content "Assignments for poll '#{poll.name}'"
|
||||
expect(page).to have_content "Assignments for poll "#{poll.name}""
|
||||
|
||||
within("#poll_booth_#{booth.id}") do
|
||||
expect(page).to have_content(booth.name)
|
||||
expect(page).to have_content "Unassigned"
|
||||
|
||||
click_link 'Assign booth'
|
||||
click_link "Assign booth"
|
||||
|
||||
expect(page).not_to have_content "Unassigned"
|
||||
expect(page).to have_content "Assigned"
|
||||
@@ -60,38 +60,38 @@ feature 'Admin booths assignments' do
|
||||
end
|
||||
|
||||
visit admin_poll_path(poll)
|
||||
within('#poll-resources') do
|
||||
click_link 'Booths (1)'
|
||||
within("#poll-resources") do
|
||||
click_link "Booths (1)"
|
||||
end
|
||||
|
||||
expect(page).not_to have_content 'There are no booths assigned to this poll.'
|
||||
expect(page).not_to have_content "There are no booths assigned to this poll."
|
||||
expect(page).to have_content booth.name
|
||||
end
|
||||
|
||||
scenario 'Unassign booth from poll', :js do
|
||||
scenario "Unassign booth from poll", :js do
|
||||
assignment = create(:poll_booth_assignment, poll: poll, booth: booth)
|
||||
|
||||
visit admin_poll_path(poll)
|
||||
within('#poll-resources') do
|
||||
click_link 'Booths (1)'
|
||||
within("#poll-resources") do
|
||||
click_link "Booths (1)"
|
||||
end
|
||||
|
||||
expect(page).not_to have_content 'There are no booths assigned to this poll.'
|
||||
expect(page).not_to have_content "There are no booths assigned to this poll."
|
||||
expect(page).to have_content booth.name
|
||||
|
||||
fill_in 'search-booths', with: booth.name
|
||||
click_button 'Search'
|
||||
fill_in "search-booths", with: booth.name
|
||||
click_button "Search"
|
||||
expect(page).to have_content(booth.name)
|
||||
|
||||
visit manage_admin_poll_booth_assignments_path(poll)
|
||||
|
||||
expect(page).to have_content "Assignments for poll '#{poll.name}'"
|
||||
expect(page).to have_content "Assignments for poll "#{poll.name}""
|
||||
|
||||
within("#poll_booth_#{booth.id}") do
|
||||
expect(page).to have_content(booth.name)
|
||||
expect(page).to have_content "Assigned"
|
||||
|
||||
click_link 'Unassign booth'
|
||||
click_link "Unassign booth"
|
||||
|
||||
expect(page).to have_content "Unassigned"
|
||||
expect(page).not_to have_content "Assigned"
|
||||
@@ -99,15 +99,15 @@ feature 'Admin booths assignments' do
|
||||
end
|
||||
|
||||
visit admin_poll_path(poll)
|
||||
within('#poll-resources') do
|
||||
click_link 'Booths (0)'
|
||||
within("#poll-resources") do
|
||||
click_link "Booths (0)"
|
||||
end
|
||||
|
||||
expect(page).to have_content 'There are no booths assigned to this poll.'
|
||||
expect(page).to have_content "There are no booths assigned to this poll."
|
||||
expect(page).not_to have_content booth.name
|
||||
end
|
||||
|
||||
scenario 'Unassing booth whith associated shifts', :js do
|
||||
scenario "Unassing booth whith associated shifts", :js do
|
||||
assignment = create(:poll_booth_assignment, poll: poll, booth: booth)
|
||||
officer = create(:poll_officer)
|
||||
create(:poll_officer_assignment, officer: officer, booth_assignment: assignment)
|
||||
@@ -119,7 +119,7 @@ feature 'Admin booths assignments' do
|
||||
expect(page).to have_content(booth.name)
|
||||
expect(page).to have_content "Assigned"
|
||||
|
||||
accept_confirm { click_link 'Unassign booth' }
|
||||
accept_confirm { click_link "Unassign booth" }
|
||||
|
||||
expect(page).to have_content "Unassigned"
|
||||
expect(page).not_to have_content "Assigned"
|
||||
@@ -137,14 +137,14 @@ feature 'Admin booths assignments' do
|
||||
expect(page).to have_content(booth.name)
|
||||
expect(page).to have_content "Assigned"
|
||||
|
||||
expect(page).not_to have_link 'Unassign booth'
|
||||
expect(page).not_to have_link "Unassign booth"
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
feature 'Show' do
|
||||
scenario 'Lists all assigned poll officers' do
|
||||
feature "Show" do
|
||||
scenario "Lists all assigned poll officers" do
|
||||
poll = create(:poll)
|
||||
booth = create(:poll_booth)
|
||||
booth_assignment = create(:poll_booth_assignment, poll: poll, booth: booth)
|
||||
@@ -156,18 +156,18 @@ feature 'Admin booths assignments' do
|
||||
officer_2 = officer_assignment_2.officer
|
||||
|
||||
visit admin_poll_path(poll)
|
||||
click_link 'Booths (2)'
|
||||
click_link "Booths (2)"
|
||||
|
||||
within('#assigned_booths_list') { click_link booth.name }
|
||||
within("#assigned_booths_list") { click_link booth.name }
|
||||
|
||||
click_link 'Officers'
|
||||
within('#officers_list') do
|
||||
click_link "Officers"
|
||||
within("#officers_list") do
|
||||
expect(page).to have_content officer.name
|
||||
expect(page).not_to have_content officer_2.name
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Lists all recounts for the booth assignment' do
|
||||
scenario "Lists all recounts for the booth assignment" do
|
||||
poll = create(:poll, starts_at: 2.weeks.ago, ends_at: 1.week.ago)
|
||||
booth = create(:poll_booth)
|
||||
booth_assignment = create(:poll_booth_assignment, poll: poll, booth: booth)
|
||||
@@ -181,22 +181,22 @@ feature 'Admin booths assignments' do
|
||||
booth_assignment_2 = create(:poll_booth_assignment, poll: poll)
|
||||
|
||||
visit admin_poll_path(poll)
|
||||
click_link 'Booths (2)'
|
||||
click_link "Booths (2)"
|
||||
|
||||
within('#assigned_booths_list') { click_link booth.name }
|
||||
within("#assigned_booths_list") { click_link booth.name }
|
||||
|
||||
click_link 'Recounts'
|
||||
click_link "Recounts"
|
||||
|
||||
within('#totals') do
|
||||
within("#totals") do
|
||||
within("#total_system") { expect(page).to have_content "2" }
|
||||
end
|
||||
|
||||
within('#recounts_list') do
|
||||
within("#recounts_list") do
|
||||
within("#recounting_#{poll.starts_at.to_date.strftime('%Y%m%d')}") do
|
||||
expect(page).to have_content 1
|
||||
end
|
||||
within("#recounting_#{(poll.ends_at.to_date - 5.days).strftime('%Y%m%d')}") do
|
||||
expect(page).to have_content '-'
|
||||
expect(page).to have_content "-"
|
||||
end
|
||||
within("#recounting_#{poll.ends_at.to_date.strftime('%Y%m%d')}") do
|
||||
expect(page).to have_content 1
|
||||
@@ -204,47 +204,47 @@ feature 'Admin booths assignments' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Results for a booth assignment' do
|
||||
scenario "Results for a booth assignment" do
|
||||
poll = create(:poll)
|
||||
booth_assignment = create(:poll_booth_assignment, poll: poll)
|
||||
other_booth_assignment = create(:poll_booth_assignment, poll: poll)
|
||||
|
||||
question_1 = create(:poll_question, poll: poll)
|
||||
create(:poll_question_answer, title: 'Yes', question: question_1)
|
||||
create(:poll_question_answer, title: 'No', question: question_1)
|
||||
create(:poll_question_answer, title: "Yes", question: question_1)
|
||||
create(:poll_question_answer, title: "No", question: question_1)
|
||||
|
||||
question_2 = create(:poll_question, poll: poll)
|
||||
create(:poll_question_answer, title: 'Today', question: question_2)
|
||||
create(:poll_question_answer, title: 'Tomorrow', question: question_2)
|
||||
create(:poll_question_answer, title: "Today", question: question_2)
|
||||
create(:poll_question_answer, title: "Tomorrow", question: question_2)
|
||||
|
||||
create(:poll_partial_result,
|
||||
booth_assignment: booth_assignment,
|
||||
question: question_1,
|
||||
answer: 'Yes',
|
||||
answer: "Yes",
|
||||
amount: 11)
|
||||
|
||||
create(:poll_partial_result,
|
||||
booth_assignment: booth_assignment,
|
||||
question: question_1,
|
||||
answer: 'No',
|
||||
answer: "No",
|
||||
amount: 4)
|
||||
|
||||
create(:poll_partial_result,
|
||||
booth_assignment: booth_assignment,
|
||||
question: question_2,
|
||||
answer: 'Today',
|
||||
answer: "Today",
|
||||
amount: 5)
|
||||
|
||||
create(:poll_partial_result,
|
||||
booth_assignment: booth_assignment,
|
||||
question: question_2,
|
||||
answer: 'Tomorrow',
|
||||
answer: "Tomorrow",
|
||||
amount: 6)
|
||||
|
||||
create(:poll_partial_result,
|
||||
booth_assignment: other_booth_assignment,
|
||||
question: question_1,
|
||||
answer: 'Yes',
|
||||
answer: "Yes",
|
||||
amount: 9999)
|
||||
|
||||
create(:poll_recount,
|
||||
@@ -261,7 +261,7 @@ feature 'Admin booths assignments' do
|
||||
|
||||
visit admin_poll_booth_assignment_path(poll, booth_assignment)
|
||||
|
||||
click_link 'Results'
|
||||
click_link "Results"
|
||||
|
||||
expect(page).to have_content(question_1.title)
|
||||
|
||||
@@ -287,9 +287,9 @@ feature 'Admin booths assignments' do
|
||||
expect(page).to have_content(6)
|
||||
end
|
||||
|
||||
within('#white_results') { expect(page).to have_content('21') }
|
||||
within('#null_results') { expect(page).to have_content('44') }
|
||||
within('#total_results') { expect(page).to have_content('66') }
|
||||
within("#white_results") { expect(page).to have_content("21") }
|
||||
within("#null_results") { expect(page).to have_content("44") }
|
||||
within("#total_results") { expect(page).to have_content("66") }
|
||||
end
|
||||
|
||||
scenario "No results" do
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Admin booths' do
|
||||
feature "Admin booths" do
|
||||
|
||||
background do
|
||||
admin = create(:administrator)
|
||||
login_as(admin.user)
|
||||
end
|
||||
|
||||
scenario 'Index empty' do
|
||||
scenario "Index empty" do
|
||||
visit admin_root_path
|
||||
|
||||
within('#side_menu') do
|
||||
within("#side_menu") do
|
||||
click_link "Booths location"
|
||||
end
|
||||
|
||||
expect(page).to have_content "There are no active booths for any upcoming poll."
|
||||
end
|
||||
|
||||
scenario 'Index' do
|
||||
scenario "Index" do
|
||||
3.times { create(:poll_booth) }
|
||||
|
||||
visit admin_root_path
|
||||
|
||||
within('#side_menu') do
|
||||
within("#side_menu") do
|
||||
click_link "Booths location"
|
||||
end
|
||||
|
||||
@@ -59,7 +59,7 @@ feature 'Admin booths' do
|
||||
expect(page).not_to have_link "Edit booth"
|
||||
end
|
||||
|
||||
scenario 'Show' do
|
||||
scenario "Show" do
|
||||
booth = create(:poll_booth)
|
||||
|
||||
visit admin_booths_path
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Officer Assignments' do
|
||||
feature "Officer Assignments" do
|
||||
|
||||
background do
|
||||
admin = create(:administrator)
|
||||
@@ -23,9 +23,9 @@ feature 'Officer Assignments' do
|
||||
|
||||
visit admin_poll_path(poll)
|
||||
|
||||
click_link 'Officers (2)'
|
||||
click_link "Officers (2)"
|
||||
|
||||
within('#officer_assignments') do
|
||||
within("#officer_assignments") do
|
||||
expect(page).to have_content officer1.name
|
||||
expect(page).to have_content officer2.name
|
||||
expect(page).not_to have_content officer3.name
|
||||
@@ -52,12 +52,12 @@ feature 'Officer Assignments' do
|
||||
|
||||
visit admin_poll_path(poll)
|
||||
|
||||
click_link 'Officers (2)'
|
||||
click_link "Officers (2)"
|
||||
|
||||
fill_in "search-officers", with: "John"
|
||||
click_button "Search"
|
||||
|
||||
within('#search-officers-results') do
|
||||
within("#search-officers-results") do
|
||||
expect(page).to have_content officer1.name
|
||||
expect(page).to have_content officer2.name
|
||||
expect(page).not_to have_content officer3.name
|
||||
|
||||
@@ -1,36 +1,36 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Admin poll officers' do
|
||||
feature "Admin poll officers" do
|
||||
|
||||
background do
|
||||
@admin = create(:administrator)
|
||||
@user = create(:user, username: 'Pedro Jose Garcia')
|
||||
@user = create(:user, username: "Pedro Jose Garcia")
|
||||
@officer = create(:poll_officer)
|
||||
login_as(@admin.user)
|
||||
visit admin_officers_path
|
||||
end
|
||||
|
||||
scenario 'Index' do
|
||||
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
|
||||
end
|
||||
|
||||
scenario 'Create', :js do
|
||||
fill_in 'email', with: @user.email
|
||||
click_button 'Search'
|
||||
scenario "Create", :js do
|
||||
fill_in "email", with: @user.email
|
||||
click_button "Search"
|
||||
|
||||
expect(page).to have_content @user.name
|
||||
click_link 'Add'
|
||||
click_link "Add"
|
||||
within("#officers") do
|
||||
expect(page).to have_content @user.name
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Delete' do
|
||||
click_link 'Delete position'
|
||||
scenario "Delete" do
|
||||
click_link "Delete position"
|
||||
|
||||
expect(page).not_to have_css '#officers'
|
||||
expect(page).not_to have_css "#officers"
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Answers' do
|
||||
feature "Answers" do
|
||||
|
||||
background do
|
||||
admin = create(:administrator)
|
||||
@@ -13,57 +13,57 @@ feature 'Answers' do
|
||||
%w[title],
|
||||
{ "description" => :ckeditor }
|
||||
|
||||
scenario 'Create' do
|
||||
scenario "Create" do
|
||||
question = create(:poll_question)
|
||||
title = 'Whatever the question may be, the answer is always 42'
|
||||
title = "Whatever the question may be, the answer is always 42"
|
||||
description = "The Hitchhiker's Guide To The Universe"
|
||||
|
||||
visit admin_question_path(question)
|
||||
click_link 'Add answer'
|
||||
click_link "Add answer"
|
||||
|
||||
fill_in 'Answer', with: title
|
||||
fill_in 'Description', with: description
|
||||
fill_in "Answer", with: title
|
||||
fill_in "Description", with: description
|
||||
|
||||
click_button 'Save'
|
||||
click_button "Save"
|
||||
|
||||
expect(page).to have_content(title)
|
||||
expect(page).to have_content(description)
|
||||
end
|
||||
|
||||
scenario 'Create second answer and place after the first one' do
|
||||
scenario "Create second answer and place after the first one" do
|
||||
question = create(:poll_question)
|
||||
answer = create(:poll_question_answer, title: 'First', question: question, given_order: 1)
|
||||
title = 'Second'
|
||||
answer = create(:poll_question_answer, title: "First", question: question, given_order: 1)
|
||||
title = "Second"
|
||||
description = "Description"
|
||||
|
||||
visit admin_question_path(question)
|
||||
click_link 'Add answer'
|
||||
click_link "Add answer"
|
||||
|
||||
fill_in 'Answer', with: title
|
||||
fill_in 'Description', with: description
|
||||
fill_in "Answer", with: title
|
||||
fill_in "Description", with: description
|
||||
|
||||
click_button 'Save'
|
||||
click_button "Save"
|
||||
|
||||
expect(page.body.index('First')).to be < page.body.index('Second')
|
||||
expect(page.body.index("First")).to be < page.body.index("Second")
|
||||
end
|
||||
|
||||
scenario 'Update' do
|
||||
scenario "Update" do
|
||||
question = create(:poll_question)
|
||||
answer = create(:poll_question_answer, question: question, title: "Answer title", given_order: 2)
|
||||
answer2 = create(:poll_question_answer, question: question, title: "Another title", given_order: 1)
|
||||
|
||||
visit admin_answer_path(answer)
|
||||
|
||||
click_link 'Edit answer'
|
||||
click_link "Edit answer"
|
||||
|
||||
old_title = answer.title
|
||||
new_title = 'Ex Machina'
|
||||
new_title = "Ex Machina"
|
||||
|
||||
fill_in 'Answer', with: new_title
|
||||
fill_in "Answer", with: new_title
|
||||
|
||||
click_button 'Save'
|
||||
click_button "Save"
|
||||
|
||||
expect(page).to have_content('Changes saved')
|
||||
expect(page).to have_content("Changes saved")
|
||||
expect(page).to have_content(new_title)
|
||||
|
||||
visit admin_question_path(question)
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Images' do
|
||||
feature "Images" do
|
||||
|
||||
background do
|
||||
admin = create(:administrator)
|
||||
login_as(admin.user)
|
||||
end
|
||||
|
||||
context 'Index' do
|
||||
scenario 'Answer with no images' do
|
||||
context "Index" do
|
||||
scenario "Answer with no images" do
|
||||
answer = create(:poll_question_answer,
|
||||
question: create(:poll_question))
|
||||
|
||||
@@ -17,7 +17,7 @@ feature 'Images' do
|
||||
expect(page).not_to have_css("img[title='']")
|
||||
end
|
||||
|
||||
scenario 'Answer with images' do
|
||||
scenario "Answer with images" do
|
||||
answer = create(:poll_question_answer,
|
||||
question: create(:poll_question))
|
||||
image = create(:image, imageable: answer)
|
||||
@@ -29,24 +29,24 @@ feature 'Images' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Add image to answer', :js do
|
||||
scenario "Add image to answer", :js do
|
||||
answer = create(:poll_question_answer,
|
||||
question: create(:poll_question))
|
||||
image = create(:image)
|
||||
|
||||
visit admin_answer_images_path(answer)
|
||||
expect(page).not_to have_css("img[title='clippy.jpg']")
|
||||
expect(page).not_to have_content('clippy.jpg')
|
||||
expect(page).not_to have_content("clippy.jpg")
|
||||
|
||||
visit new_admin_answer_image_path(answer)
|
||||
imageable_attach_new_file(image, Rails.root.join('spec/fixtures/files/clippy.jpg'))
|
||||
click_button 'Save image'
|
||||
imageable_attach_new_file(image, Rails.root.join("spec/fixtures/files/clippy.jpg"))
|
||||
click_button "Save image"
|
||||
|
||||
expect(page).to have_css("img[title='clippy.jpg']")
|
||||
expect(page).to have_content('clippy.jpg')
|
||||
expect(page).to have_content("clippy.jpg")
|
||||
end
|
||||
|
||||
scenario 'Remove image from answer', :js do
|
||||
scenario "Remove image from answer", :js do
|
||||
answer = create(:poll_question_answer,
|
||||
question: create(:poll_question))
|
||||
image = create(:image, imageable: answer)
|
||||
@@ -55,8 +55,8 @@ feature 'Images' do
|
||||
expect(page).to have_css("img[title='#{image.title}']")
|
||||
expect(page).to have_content(image.title)
|
||||
|
||||
accept_confirm 'Are you sure?' do
|
||||
click_link 'Remove image'
|
||||
accept_confirm "Are you sure?" do
|
||||
click_link "Remove image"
|
||||
end
|
||||
|
||||
expect(page).not_to have_css("img[title='#{image.title}']")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Videos' do
|
||||
feature "Videos" do
|
||||
|
||||
background do
|
||||
admin = create(:administrator)
|
||||
@@ -21,8 +21,8 @@ feature 'Videos' do
|
||||
|
||||
click_link "Add video"
|
||||
|
||||
fill_in 'poll_question_answer_video_title', with: video_title
|
||||
fill_in 'poll_question_answer_video_url', with: video_url
|
||||
fill_in "poll_question_answer_video_title", with: video_title
|
||||
fill_in "poll_question_answer_video_url", with: video_url
|
||||
|
||||
click_button "Save"
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Admin poll questions' do
|
||||
feature "Admin poll questions" do
|
||||
|
||||
background do
|
||||
login_as(create(:administrator).user)
|
||||
@@ -11,7 +11,7 @@ feature 'Admin poll questions' do
|
||||
"edit_admin_question_path",
|
||||
%w[title]
|
||||
|
||||
scenario 'Index' do
|
||||
scenario "Index" do
|
||||
poll1 = create(:poll)
|
||||
poll2 = create(:poll)
|
||||
question1 = create(:poll_question, poll: poll1)
|
||||
@@ -30,7 +30,7 @@ feature 'Admin poll questions' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Show' do
|
||||
scenario "Show" do
|
||||
geozone = create(:geozone)
|
||||
poll = create(:poll, geozone_restricted: true, geozone_ids: [geozone.id])
|
||||
question = create(:poll_question, poll: poll)
|
||||
@@ -41,8 +41,8 @@ feature 'Admin poll questions' do
|
||||
expect(page).to have_content(question.author.name)
|
||||
end
|
||||
|
||||
scenario 'Create' do
|
||||
poll = create(:poll, name: 'Movies')
|
||||
scenario "Create" do
|
||||
poll = create(:poll, name: "Movies")
|
||||
title = "Star Wars: Episode IV - A New Hope"
|
||||
description = %{
|
||||
During the battle, Rebel spies managed to steal secret plans to the Empire's ultimate weapon, the DEATH STAR, an armored space station
|
||||
@@ -54,16 +54,16 @@ feature 'Admin poll questions' do
|
||||
visit admin_questions_path
|
||||
click_link "Create question"
|
||||
|
||||
select 'Movies', from: 'poll_question_poll_id'
|
||||
fill_in 'Question', with: title
|
||||
select "Movies", from: "poll_question_poll_id"
|
||||
fill_in "Question", with: title
|
||||
|
||||
click_button 'Save'
|
||||
click_button "Save"
|
||||
|
||||
expect(page).to have_content(title)
|
||||
end
|
||||
|
||||
scenario 'Create from successful proposal' do
|
||||
poll = create(:poll, name: 'Proposals')
|
||||
scenario "Create from successful proposal" do
|
||||
poll = create(:poll, name: "Proposals")
|
||||
proposal = create(:proposal, :successful)
|
||||
|
||||
visit admin_proposal_path(proposal)
|
||||
@@ -71,18 +71,18 @@ feature 'Admin poll questions' do
|
||||
click_link "Create question"
|
||||
|
||||
expect(page).to have_current_path(new_admin_question_path, ignore_query: true)
|
||||
expect(page).to have_field('Question', with: proposal.title)
|
||||
expect(page).to have_field("Question", with: proposal.title)
|
||||
|
||||
select 'Proposals', from: 'poll_question_poll_id'
|
||||
select "Proposals", from: "poll_question_poll_id"
|
||||
|
||||
click_button 'Save'
|
||||
click_button "Save"
|
||||
|
||||
expect(page).to have_content(proposal.title)
|
||||
expect(page).to have_link(proposal.title, href: proposal_path(proposal))
|
||||
expect(page).to have_link(proposal.author.name, href: user_path(proposal.author))
|
||||
end
|
||||
|
||||
scenario 'Update' do
|
||||
scenario "Update" do
|
||||
question1 = create(:poll_question)
|
||||
|
||||
visit admin_questions_path
|
||||
@@ -92,9 +92,9 @@ feature 'Admin poll questions' do
|
||||
|
||||
old_title = question1.title
|
||||
new_title = "Potatoes are great and everyone should have one"
|
||||
fill_in 'Question', with: new_title
|
||||
fill_in "Question", with: new_title
|
||||
|
||||
click_button 'Save'
|
||||
click_button "Save"
|
||||
|
||||
expect(page).to have_content "Changes saved"
|
||||
expect(page).to have_content new_title
|
||||
@@ -105,7 +105,7 @@ feature 'Admin poll questions' do
|
||||
expect(page).not_to have_content(old_title)
|
||||
end
|
||||
|
||||
scenario 'Destroy' do
|
||||
scenario "Destroy" do
|
||||
question1 = create(:poll_question)
|
||||
question2 = create(:poll_question)
|
||||
|
||||
@@ -141,11 +141,11 @@ feature 'Admin poll questions' do
|
||||
scenario "translates the poll name in options", :js do
|
||||
visit @edit_question_url
|
||||
|
||||
expect(page).to have_select('poll_question_poll_id', options: [poll.name_en])
|
||||
expect(page).to have_select("poll_question_poll_id", options: [poll.name_en])
|
||||
|
||||
select('Español', from: 'locale-switcher')
|
||||
select("Español", from: "locale-switcher")
|
||||
|
||||
expect(page).to have_select('poll_question_poll_id', options: [poll.name_es])
|
||||
expect(page).to have_select("poll_question_poll_id", options: [poll.name_es])
|
||||
end
|
||||
|
||||
scenario "uses fallback if name is not translated to current locale", :js do
|
||||
@@ -155,11 +155,11 @@ feature 'Admin poll questions' do
|
||||
|
||||
visit @edit_question_url
|
||||
|
||||
expect(page).to have_select('poll_question_poll_id', options: [poll.name_en])
|
||||
expect(page).to have_select("poll_question_poll_id", options: [poll.name_en])
|
||||
|
||||
select('Français', from: 'locale-switcher')
|
||||
select("Français", from: "locale-switcher")
|
||||
|
||||
expect(page).to have_select('poll_question_poll_id', options: [poll.name_es])
|
||||
expect(page).to have_select("poll_question_poll_id", options: [poll.name_es])
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Admin shifts' do
|
||||
feature "Admin shifts" do
|
||||
|
||||
background do
|
||||
admin = create(:administrator)
|
||||
@@ -50,9 +50,9 @@ feature 'Admin shifts' do
|
||||
click_button "Search"
|
||||
click_link "Edit shifts"
|
||||
|
||||
expect(page).to have_select('shift_date_vote_collection_date', options: ["Select day", *vote_collection_dates])
|
||||
expect(page).not_to have_select('shift_date_recount_scrutiny_date')
|
||||
select I18n.l(Date.current, format: :long), from: 'shift_date_vote_collection_date'
|
||||
expect(page).to have_select("shift_date_vote_collection_date", options: ["Select day", *vote_collection_dates])
|
||||
expect(page).not_to have_select("shift_date_recount_scrutiny_date")
|
||||
select I18n.l(Date.current, format: :long), from: "shift_date_vote_collection_date"
|
||||
click_button "Add shift"
|
||||
|
||||
expect(page).to have_content "Shift added"
|
||||
@@ -74,11 +74,11 @@ feature 'Admin shifts' do
|
||||
click_button "Search"
|
||||
click_link "Edit shifts"
|
||||
|
||||
select "Recount & Scrutiny", from: 'shift_task'
|
||||
select "Recount & Scrutiny", from: "shift_task"
|
||||
|
||||
expect(page).to have_select('shift_date_recount_scrutiny_date', options: ["Select day", *recount_scrutiny_dates])
|
||||
expect(page).not_to have_select('shift_date_vote_collection_date')
|
||||
select I18n.l(poll.ends_at.to_date + 4.days, format: :long), from: 'shift_date_recount_scrutiny_date'
|
||||
expect(page).to have_select("shift_date_recount_scrutiny_date", options: ["Select day", *recount_scrutiny_dates])
|
||||
expect(page).not_to have_select("shift_date_vote_collection_date")
|
||||
select I18n.l(poll.ends_at.to_date + 4.days, format: :long), from: "shift_date_recount_scrutiny_date"
|
||||
click_button "Add shift"
|
||||
|
||||
expect(page).to have_content "Shift added"
|
||||
@@ -117,9 +117,9 @@ feature 'Admin shifts' do
|
||||
click_button "Search"
|
||||
click_link "Edit shifts"
|
||||
|
||||
expect(page).to have_select('shift_date_vote_collection_date', options: ["Select day", *vote_collection_dates])
|
||||
select "Recount & Scrutiny", from: 'shift_task'
|
||||
expect(page).to have_select('shift_date_recount_scrutiny_date', options: ["Select day", *recount_scrutiny_dates])
|
||||
expect(page).to have_select("shift_date_vote_collection_date", options: ["Select day", *vote_collection_dates])
|
||||
select "Recount & Scrutiny", from: "shift_task"
|
||||
expect(page).to have_select("shift_date_recount_scrutiny_date", options: ["Select day", *recount_scrutiny_dates])
|
||||
end
|
||||
|
||||
scenario "Error on create", :js do
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Admin proposal notifications' do
|
||||
feature "Admin proposal notifications" do
|
||||
|
||||
background do
|
||||
admin = create(:administrator)
|
||||
login_as(admin.user)
|
||||
end
|
||||
|
||||
scenario 'List shows all relevant info' do
|
||||
scenario "List shows all relevant info" do
|
||||
proposal_notification = create(:proposal_notification, :hidden)
|
||||
visit admin_proposal_notifications_path
|
||||
|
||||
@@ -15,11 +15,11 @@ feature 'Admin proposal notifications' do
|
||||
expect(page).to have_content(proposal_notification.body)
|
||||
end
|
||||
|
||||
scenario 'Restore' do
|
||||
scenario "Restore" do
|
||||
proposal_notification = create(:proposal_notification, :hidden, created_at: Date.current - 5.days)
|
||||
visit admin_proposal_notifications_path
|
||||
|
||||
click_link 'Restore'
|
||||
click_link "Restore"
|
||||
|
||||
expect(page).not_to have_content(proposal_notification.title)
|
||||
|
||||
@@ -28,14 +28,14 @@ feature 'Admin proposal notifications' do
|
||||
expect(proposal_notification).not_to be_moderated
|
||||
end
|
||||
|
||||
scenario 'Confirm hide' do
|
||||
scenario "Confirm hide" do
|
||||
proposal_notification = create(:proposal_notification, :hidden, created_at: Date.current - 5.days)
|
||||
visit admin_proposal_notifications_path
|
||||
|
||||
click_link 'Confirm moderation'
|
||||
click_link "Confirm moderation"
|
||||
|
||||
expect(page).not_to have_content(proposal_notification.title)
|
||||
click_link('Confirmed')
|
||||
click_link("Confirmed")
|
||||
expect(page).to have_content(proposal_notification.title)
|
||||
|
||||
expect(proposal_notification.reload).to be_confirmed_hide
|
||||
@@ -43,53 +43,53 @@ feature 'Admin proposal notifications' do
|
||||
|
||||
scenario "Current filter is properly highlighted" do
|
||||
visit admin_proposal_notifications_path
|
||||
expect(page).not_to have_link('Pending')
|
||||
expect(page).to have_link('All')
|
||||
expect(page).to have_link('Confirmed')
|
||||
expect(page).not_to have_link("Pending")
|
||||
expect(page).to have_link("All")
|
||||
expect(page).to have_link("Confirmed")
|
||||
|
||||
visit admin_proposal_notifications_path(filter: 'Pending')
|
||||
expect(page).not_to have_link('Pending')
|
||||
expect(page).to have_link('All')
|
||||
expect(page).to have_link('Confirmed')
|
||||
visit admin_proposal_notifications_path(filter: "Pending")
|
||||
expect(page).not_to have_link("Pending")
|
||||
expect(page).to have_link("All")
|
||||
expect(page).to have_link("Confirmed")
|
||||
|
||||
visit admin_proposal_notifications_path(filter: 'all')
|
||||
expect(page).to have_link('Pending')
|
||||
expect(page).not_to have_link('All')
|
||||
expect(page).to have_link('Confirmed')
|
||||
visit admin_proposal_notifications_path(filter: "all")
|
||||
expect(page).to have_link("Pending")
|
||||
expect(page).not_to have_link("All")
|
||||
expect(page).to have_link("Confirmed")
|
||||
|
||||
visit admin_proposal_notifications_path(filter: 'with_confirmed_hide')
|
||||
expect(page).to have_link('All')
|
||||
expect(page).to have_link('Pending')
|
||||
expect(page).not_to have_link('Confirmed')
|
||||
visit admin_proposal_notifications_path(filter: "with_confirmed_hide")
|
||||
expect(page).to have_link("All")
|
||||
expect(page).to have_link("Pending")
|
||||
expect(page).not_to have_link("Confirmed")
|
||||
end
|
||||
|
||||
scenario "Filtering proposals" do
|
||||
create(:proposal_notification, :hidden, title: "Unconfirmed notification")
|
||||
create(:proposal_notification, :hidden, :with_confirmed_hide, title: "Confirmed notification")
|
||||
|
||||
visit admin_proposal_notifications_path(filter: 'pending')
|
||||
expect(page).to have_content('Unconfirmed notification')
|
||||
expect(page).not_to have_content('Confirmed notification')
|
||||
visit admin_proposal_notifications_path(filter: "pending")
|
||||
expect(page).to have_content("Unconfirmed notification")
|
||||
expect(page).not_to have_content("Confirmed notification")
|
||||
|
||||
visit admin_proposal_notifications_path(filter: 'all')
|
||||
expect(page).to have_content('Unconfirmed notification')
|
||||
expect(page).to have_content('Confirmed notification')
|
||||
visit admin_proposal_notifications_path(filter: "all")
|
||||
expect(page).to have_content("Unconfirmed notification")
|
||||
expect(page).to have_content("Confirmed notification")
|
||||
|
||||
visit admin_proposal_notifications_path(filter: 'with_confirmed_hide')
|
||||
expect(page).not_to have_content('Unconfirmed notification')
|
||||
expect(page).to have_content('Confirmed notification')
|
||||
visit admin_proposal_notifications_path(filter: "with_confirmed_hide")
|
||||
expect(page).not_to have_content("Unconfirmed notification")
|
||||
expect(page).to have_content("Confirmed notification")
|
||||
end
|
||||
|
||||
scenario "Action links remember the pagination setting and the filter" do
|
||||
per_page = Kaminari.config.default_per_page
|
||||
(per_page + 2).times { create(:proposal_notification, :hidden, :with_confirmed_hide) }
|
||||
|
||||
visit admin_proposal_notifications_path(filter: 'with_confirmed_hide', page: 2)
|
||||
visit admin_proposal_notifications_path(filter: "with_confirmed_hide", page: 2)
|
||||
|
||||
click_on('Restore', match: :first, exact: true)
|
||||
click_on("Restore", match: :first, exact: true)
|
||||
|
||||
expect(current_url).to include('filter=with_confirmed_hide')
|
||||
expect(current_url).to include('page=2')
|
||||
expect(current_url).to include("filter=with_confirmed_hide")
|
||||
expect(current_url).to include("page=2")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Admin settings' do
|
||||
feature "Admin settings" do
|
||||
|
||||
background do
|
||||
@setting1 = create(:setting)
|
||||
@@ -9,7 +9,7 @@ feature 'Admin settings' do
|
||||
login_as(create(:administrator).user)
|
||||
end
|
||||
|
||||
scenario 'Index' do
|
||||
scenario "Index" do
|
||||
visit admin_settings_path
|
||||
|
||||
expect(page).to have_content @setting1.key
|
||||
@@ -17,21 +17,21 @@ feature 'Admin settings' do
|
||||
expect(page).to have_content @setting3.key
|
||||
end
|
||||
|
||||
scenario 'Update' do
|
||||
scenario "Update" do
|
||||
visit admin_settings_path
|
||||
|
||||
within("#edit_setting_#{@setting2.id}") do
|
||||
fill_in "setting_#{@setting2.id}", with: 'Super Users of level 2'
|
||||
click_button 'Update'
|
||||
fill_in "setting_#{@setting2.id}", with: "Super Users of level 2"
|
||||
click_button "Update"
|
||||
end
|
||||
|
||||
expect(page).to have_content 'Value updated'
|
||||
expect(page).to have_content "Value updated"
|
||||
end
|
||||
|
||||
describe "Update map" do
|
||||
|
||||
scenario "Should not be able when map feature deactivated" do
|
||||
Setting['feature.map'] = false
|
||||
Setting["feature.map"] = false
|
||||
admin = create(:administrator).user
|
||||
login_as(admin)
|
||||
visit admin_settings_path
|
||||
@@ -41,7 +41,7 @@ feature 'Admin settings' do
|
||||
end
|
||||
|
||||
scenario "Should be able when map feature activated" do
|
||||
Setting['feature.map'] = true
|
||||
Setting["feature.map"] = true
|
||||
admin = create(:administrator).user
|
||||
login_as(admin)
|
||||
visit admin_settings_path
|
||||
@@ -51,7 +51,7 @@ feature 'Admin settings' do
|
||||
end
|
||||
|
||||
scenario "Should show successful notice" do
|
||||
Setting['feature.map'] = true
|
||||
Setting["feature.map"] = true
|
||||
admin = create(:administrator).user
|
||||
login_as(admin)
|
||||
visit admin_settings_path
|
||||
@@ -64,7 +64,7 @@ feature 'Admin settings' do
|
||||
end
|
||||
|
||||
scenario "Should display marker by default", :js do
|
||||
Setting['feature.map'] = true
|
||||
Setting["feature.map"] = true
|
||||
admin = create(:administrator).user
|
||||
login_as(admin)
|
||||
|
||||
@@ -75,7 +75,7 @@ feature 'Admin settings' do
|
||||
end
|
||||
|
||||
scenario "Should update marker", :js do
|
||||
Setting['feature.map'] = true
|
||||
Setting["feature.map"] = true
|
||||
admin = create(:administrator).user
|
||||
login_as(admin)
|
||||
|
||||
@@ -95,7 +95,7 @@ feature 'Admin settings' do
|
||||
describe "Skip verification" do
|
||||
|
||||
scenario "deactivate skip verification", :js do
|
||||
Setting["feature.user.skip_verification"] = 'true'
|
||||
Setting["feature.user.skip_verification"] = "true"
|
||||
setting = Setting.where(key: "feature.user.skip_verification").first
|
||||
|
||||
visit admin_settings_path
|
||||
@@ -105,7 +105,7 @@ feature 'Admin settings' do
|
||||
find("#edit_setting_#{setting.id} .button").click
|
||||
end
|
||||
|
||||
expect(page).to have_content 'Value updated'
|
||||
expect(page).to have_content "Value updated"
|
||||
end
|
||||
|
||||
scenario "activate skip verification", :js do
|
||||
@@ -119,7 +119,7 @@ feature 'Admin settings' do
|
||||
find("#edit_setting_#{setting.id} .button").click
|
||||
end
|
||||
|
||||
expect(page).to have_content 'Value updated'
|
||||
expect(page).to have_content "Value updated"
|
||||
|
||||
Setting["feature.user.skip_verification"] = nil
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Signature sheets' do
|
||||
feature "Signature sheets" do
|
||||
|
||||
background do
|
||||
admin = create(:administrator)
|
||||
@@ -8,7 +8,7 @@ feature 'Signature sheets' do
|
||||
end
|
||||
|
||||
context "Index" do
|
||||
scenario 'Lists all signature_sheets' do
|
||||
scenario "Lists all signature_sheets" do
|
||||
3.times { create(:signature_sheet) }
|
||||
|
||||
visit admin_signature_sheets_path
|
||||
@@ -20,7 +20,7 @@ feature 'Signature sheets' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Orders signature_sheets by created_at DESC' do
|
||||
scenario "Orders signature_sheets by created_at DESC" do
|
||||
signature_sheet1 = create(:signature_sheet)
|
||||
signature_sheet2 = create(:signature_sheet)
|
||||
signature_sheet3 = create(:signature_sheet)
|
||||
@@ -32,8 +32,8 @@ feature 'Signature sheets' do
|
||||
end
|
||||
end
|
||||
|
||||
context 'Create' do
|
||||
scenario 'Proposal' do
|
||||
context "Create" do
|
||||
scenario "Proposal" do
|
||||
proposal = create(:proposal)
|
||||
visit new_admin_signature_sheet_path
|
||||
|
||||
@@ -49,10 +49,10 @@ feature 'Signature sheets' do
|
||||
expect(page).to have_content "1 support"
|
||||
end
|
||||
|
||||
scenario 'Budget Investment' do
|
||||
scenario "Budget Investment" do
|
||||
investment = create(:budget_investment)
|
||||
budget = investment.budget
|
||||
budget.update(phase: 'selecting')
|
||||
budget.update(phase: "selecting")
|
||||
|
||||
visit new_admin_signature_sheet_path
|
||||
|
||||
@@ -70,7 +70,7 @@ feature 'Signature sheets' do
|
||||
|
||||
end
|
||||
|
||||
scenario 'Errors on create' do
|
||||
scenario "Errors on create" do
|
||||
visit new_admin_signature_sheet_path
|
||||
|
||||
click_button "Create signature sheet"
|
||||
@@ -78,7 +78,7 @@ feature 'Signature sheets' do
|
||||
expect(page).to have_content error_message
|
||||
end
|
||||
|
||||
scenario 'Show' do
|
||||
scenario "Show" do
|
||||
proposal = create(:proposal)
|
||||
user = Administrator.first.user
|
||||
signature_sheet = create(:signature_sheet,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature "Admin custom content blocks" do
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature "Admin custom images" do
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature "Admin custom information texts" do
|
||||
|
||||
@@ -12,41 +12,41 @@ feature "Admin custom information texts" do
|
||||
"admin_site_customization_information_texts_path",
|
||||
%w[value]
|
||||
|
||||
scenario 'page is correctly loaded' do
|
||||
scenario "page is correctly loaded" do
|
||||
visit admin_site_customization_information_texts_path
|
||||
|
||||
click_link 'Debates'
|
||||
expect(page).to have_content 'Help about debates'
|
||||
click_link "Debates"
|
||||
expect(page).to have_content "Help about debates"
|
||||
|
||||
click_link 'Community'
|
||||
expect(page).to have_content 'Access the community'
|
||||
click_link "Community"
|
||||
expect(page).to have_content "Access the community"
|
||||
|
||||
within("#information-texts-tabs") { click_link "Proposals" }
|
||||
expect(page).to have_content 'Create proposal'
|
||||
expect(page).to have_content "Create proposal"
|
||||
|
||||
within "#information-texts-tabs" do
|
||||
click_link "Polls"
|
||||
end
|
||||
|
||||
expect(page).to have_content 'Results'
|
||||
expect(page).to have_content "Results"
|
||||
|
||||
click_link 'Layouts'
|
||||
expect(page).to have_content 'Accessibility'
|
||||
click_link "Layouts"
|
||||
expect(page).to have_content "Accessibility"
|
||||
|
||||
click_link 'Emails'
|
||||
expect(page).to have_content 'Confirm your email'
|
||||
click_link "Emails"
|
||||
expect(page).to have_content "Confirm your email"
|
||||
|
||||
within "#information-texts-tabs" do
|
||||
click_link "Management"
|
||||
end
|
||||
|
||||
expect(page).to have_content 'This user account is already verified.'
|
||||
expect(page).to have_content "This user account is already verified."
|
||||
|
||||
click_link 'Welcome'
|
||||
expect(page).to have_content 'See all debates'
|
||||
click_link "Welcome"
|
||||
expect(page).to have_content "See all debates"
|
||||
end
|
||||
|
||||
scenario 'check that tabs are highlight when click it' do
|
||||
scenario "check that tabs are highlight when click it" do
|
||||
visit admin_site_customization_information_texts_path
|
||||
|
||||
within("#information-texts-tabs") { click_link "Proposals" }
|
||||
@@ -62,46 +62,46 @@ feature "Admin custom information texts" do
|
||||
visit admin_site_customization_information_texts_path
|
||||
|
||||
select "Français", from: "translation_locale"
|
||||
fill_in "contents_content_#{key}values_value_fr", with: 'Titre personalise du débat'
|
||||
fill_in "contents_content_#{key}values_value_fr", with: "Titre personalise du débat"
|
||||
|
||||
click_button "Save"
|
||||
|
||||
expect(page).to have_content 'Translation updated successfully'
|
||||
expect(page).to have_content "Translation updated successfully"
|
||||
|
||||
select "Français", from: "translation_locale"
|
||||
|
||||
expect(page).to have_content 'Titre personalise du débat'
|
||||
expect(page).not_to have_content 'Titre du débat'
|
||||
expect(page).to have_content "Titre personalise du débat"
|
||||
expect(page).not_to have_content "Titre du débat"
|
||||
end
|
||||
|
||||
scenario "Update a translation", :js do
|
||||
key = "debates.form.debate_title"
|
||||
content = create(:i18n_content, key: key, value_fr: 'Titre personalise du débat')
|
||||
content = create(:i18n_content, key: key, value_fr: "Titre personalise du débat")
|
||||
|
||||
visit admin_site_customization_information_texts_path
|
||||
|
||||
select "Français", from: "translation_locale"
|
||||
fill_in "contents_content_#{key}values_value_fr", with: 'Titre personalise again du débat'
|
||||
fill_in "contents_content_#{key}values_value_fr", with: "Titre personalise again du débat"
|
||||
|
||||
click_button 'Save'
|
||||
expect(page).to have_content 'Translation updated successfully'
|
||||
click_button "Save"
|
||||
expect(page).to have_content "Translation updated successfully"
|
||||
|
||||
click_link 'Français'
|
||||
click_link "Français"
|
||||
|
||||
expect(page).to have_content 'Titre personalise again du débat'
|
||||
expect(page).not_to have_content 'Titre personalise du débat'
|
||||
expect(page).to have_content "Titre personalise again du débat"
|
||||
expect(page).not_to have_content "Titre personalise du débat"
|
||||
end
|
||||
|
||||
scenario "Remove a translation", :js do
|
||||
first_key = "debates.form.debate_title"
|
||||
debate_title = create(:i18n_content, key: first_key,
|
||||
value_en: 'Custom debate title',
|
||||
value_es: 'Título personalizado de debate')
|
||||
value_en: "Custom debate title",
|
||||
value_es: "Título personalizado de debate")
|
||||
|
||||
second_key = "debates.form.debate_text"
|
||||
debate_text = create(:i18n_content, key: second_key,
|
||||
value_en: 'Custom debate text',
|
||||
value_es: 'Texto personalizado de debate')
|
||||
value_en: "Custom debate text",
|
||||
value_es: "Texto personalizado de debate")
|
||||
|
||||
visit admin_site_customization_information_texts_path
|
||||
|
||||
@@ -111,17 +111,17 @@ feature "Admin custom information texts" do
|
||||
|
||||
expect(page).not_to have_link "Español"
|
||||
|
||||
click_link 'English'
|
||||
expect(page).to have_content 'Custom debate text'
|
||||
expect(page).to have_content 'Custom debate title'
|
||||
click_link "English"
|
||||
expect(page).to have_content "Custom debate text"
|
||||
expect(page).to have_content "Custom debate title"
|
||||
|
||||
debate_title.reload
|
||||
debate_text.reload
|
||||
|
||||
expect(debate_text.value_es).to be(nil)
|
||||
expect(debate_title.value_es).to be(nil)
|
||||
expect(debate_text.value_en).to eq('Custom debate text')
|
||||
expect(debate_title.value_en).to eq('Custom debate title')
|
||||
expect(debate_text.value_en).to eq("Custom debate text")
|
||||
expect(debate_title.value_en).to eq("Custom debate title")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature "Admin custom pages" do
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Stats' do
|
||||
feature "Stats" do
|
||||
|
||||
background do
|
||||
admin = create(:administrator)
|
||||
@@ -8,9 +8,9 @@ feature 'Stats' do
|
||||
visit root_path
|
||||
end
|
||||
|
||||
context 'Summary' do
|
||||
context "Summary" do
|
||||
|
||||
scenario 'General' do
|
||||
scenario "General" do
|
||||
create(:debate)
|
||||
2.times { create(:proposal) }
|
||||
3.times { create(:comment, commentable: Debate.first) }
|
||||
@@ -24,7 +24,7 @@ feature 'Stats' do
|
||||
expect(page).to have_content "Visits 4"
|
||||
end
|
||||
|
||||
scenario 'Votes' do
|
||||
scenario "Votes" do
|
||||
debate = create(:debate)
|
||||
create(:vote, votable: debate)
|
||||
|
||||
@@ -46,7 +46,7 @@ feature 'Stats' do
|
||||
|
||||
context "Users" do
|
||||
|
||||
scenario 'Summary' do
|
||||
scenario "Summary" do
|
||||
1.times { create(:user, :level_three) }
|
||||
2.times { create(:user, :level_two) }
|
||||
3.times { create(:user) }
|
||||
@@ -88,10 +88,10 @@ feature 'Stats' do
|
||||
expect(page).to have_content "Total users 1"
|
||||
end
|
||||
|
||||
scenario 'Level 2 user Graph' do
|
||||
scenario "Level 2 user Graph" do
|
||||
create(:geozone)
|
||||
visit account_path
|
||||
click_link 'Verify my account'
|
||||
click_link "Verify my account"
|
||||
verify_residence
|
||||
confirm_phone
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature "System Emails" do
|
||||
|
||||
@@ -11,89 +11,89 @@ feature "System Emails" do
|
||||
scenario "Lists all system emails with correct actions" do
|
||||
visit admin_system_emails_path
|
||||
|
||||
within('#proposal_notification_digest') do
|
||||
expect(page).to have_link('View')
|
||||
within("#proposal_notification_digest") do
|
||||
expect(page).to have_link("View")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "View" do
|
||||
scenario "#proposal_notification_digest" do
|
||||
proposal_a = create(:proposal, title: 'Proposal A')
|
||||
proposal_b = create(:proposal, title: 'Proposal B')
|
||||
proposal_a = create(:proposal, title: "Proposal A")
|
||||
proposal_b = create(:proposal, title: "Proposal B")
|
||||
proposal_notification_a = create(:proposal_notification, proposal: proposal_a,
|
||||
title: 'Proposal A Title',
|
||||
body: 'Proposal A Notification Body')
|
||||
title: "Proposal A Title",
|
||||
body: "Proposal A Notification Body")
|
||||
proposal_notification_b = create(:proposal_notification, proposal: proposal_b,
|
||||
title: 'Proposal B Title',
|
||||
body: 'Proposal B Notification Body')
|
||||
title: "Proposal B Title",
|
||||
body: "Proposal B Notification Body")
|
||||
create(:notification, notifiable: proposal_notification_a)
|
||||
create(:notification, notifiable: proposal_notification_b)
|
||||
|
||||
visit admin_system_email_view_path('proposal_notification_digest')
|
||||
visit admin_system_email_view_path("proposal_notification_digest")
|
||||
|
||||
expect(page).to have_content('Proposal notifications in')
|
||||
expect(page).to have_link('Proposal A Title', href: proposal_url(proposal_a,
|
||||
anchor: 'tab-notifications'))
|
||||
expect(page).to have_link('Proposal B Title', href: proposal_url(proposal_b,
|
||||
anchor: 'tab-notifications'))
|
||||
expect(page).to have_content('Proposal A Notification Body')
|
||||
expect(page).to have_content('Proposal B Notification Body')
|
||||
expect(page).to have_content("Proposal notifications in")
|
||||
expect(page).to have_link("Proposal A Title", href: proposal_url(proposal_a,
|
||||
anchor: "tab-notifications"))
|
||||
expect(page).to have_link("Proposal B Title", href: proposal_url(proposal_b,
|
||||
anchor: "tab-notifications"))
|
||||
expect(page).to have_content("Proposal A Notification Body")
|
||||
expect(page).to have_content("Proposal B Notification Body")
|
||||
end
|
||||
end
|
||||
|
||||
context "Preview Pending" do
|
||||
scenario "#proposal_notification_digest" do
|
||||
proposal_a = create(:proposal, title: 'Proposal A')
|
||||
proposal_b = create(:proposal, title: 'Proposal B')
|
||||
proposal_a = create(:proposal, title: "Proposal A")
|
||||
proposal_b = create(:proposal, title: "Proposal B")
|
||||
proposal_notification_a = create(:proposal_notification, proposal: proposal_a,
|
||||
title: 'Proposal A Title',
|
||||
body: 'Proposal A Notification Body')
|
||||
title: "Proposal A Title",
|
||||
body: "Proposal A Notification Body")
|
||||
proposal_notification_b = create(:proposal_notification, proposal: proposal_b,
|
||||
title: 'Proposal B Title',
|
||||
body: 'Proposal B Notification Body')
|
||||
title: "Proposal B Title",
|
||||
body: "Proposal B Notification Body")
|
||||
create(:notification, notifiable: proposal_notification_a, emailed_at: nil)
|
||||
create(:notification, notifiable: proposal_notification_b, emailed_at: nil)
|
||||
|
||||
visit admin_system_email_preview_pending_path('proposal_notification_digest')
|
||||
visit admin_system_email_preview_pending_path("proposal_notification_digest")
|
||||
|
||||
expect(page).to have_content('This is the content pending to be sent')
|
||||
expect(page).to have_link('Proposal A', href: proposal_url(proposal_a))
|
||||
expect(page).to have_link('Proposal B', href: proposal_url(proposal_b))
|
||||
expect(page).to have_link('Proposal A Title', href: proposal_url(proposal_a,
|
||||
anchor: 'tab-notifications'))
|
||||
expect(page).to have_link('Proposal B Title', href: proposal_url(proposal_b,
|
||||
anchor: 'tab-notifications'))
|
||||
expect(page).to have_content("This is the content pending to be sent")
|
||||
expect(page).to have_link("Proposal A", href: proposal_url(proposal_a))
|
||||
expect(page).to have_link("Proposal B", href: proposal_url(proposal_b))
|
||||
expect(page).to have_link("Proposal A Title", href: proposal_url(proposal_a,
|
||||
anchor: "tab-notifications"))
|
||||
expect(page).to have_link("Proposal B Title", href: proposal_url(proposal_b,
|
||||
anchor: "tab-notifications"))
|
||||
end
|
||||
|
||||
scenario "#moderate_pending" do
|
||||
proposal1 = create(:proposal, title: 'Proposal A')
|
||||
proposal2 = create(:proposal, title: 'Proposal B')
|
||||
proposal1 = create(:proposal, title: "Proposal A")
|
||||
proposal2 = create(:proposal, title: "Proposal B")
|
||||
proposal_notification1 = create(:proposal_notification, proposal: proposal1,
|
||||
title: 'Proposal A Title',
|
||||
body: 'Proposal A Notification Body')
|
||||
title: "Proposal A Title",
|
||||
body: "Proposal A Notification Body")
|
||||
proposal_notification2 = create(:proposal_notification, proposal: proposal2)
|
||||
create(:notification, notifiable: proposal_notification1, emailed_at: nil)
|
||||
create(:notification, notifiable: proposal_notification2, emailed_at: nil)
|
||||
|
||||
visit admin_system_email_preview_pending_path('proposal_notification_digest')
|
||||
visit admin_system_email_preview_pending_path("proposal_notification_digest")
|
||||
|
||||
within("#proposal_notification_#{proposal_notification1.id}") do
|
||||
click_on "Moderate notification send"
|
||||
end
|
||||
|
||||
visit admin_system_email_preview_pending_path('proposal_notification_digest')
|
||||
visit admin_system_email_preview_pending_path("proposal_notification_digest")
|
||||
|
||||
expect(Notification.count).to equal(1)
|
||||
expect(Activity.last.actionable_type).to eq('ProposalNotification')
|
||||
expect(Activity.last.actionable_type).to eq("ProposalNotification")
|
||||
expect(page).not_to have_content("Proposal A Title")
|
||||
end
|
||||
|
||||
scenario "#send_pending" do
|
||||
proposal = create(:proposal)
|
||||
proposal_notification = create(:proposal_notification, proposal: proposal,
|
||||
title: 'Proposal A Title',
|
||||
body: 'Proposal A Notification Body')
|
||||
title: "Proposal A Title",
|
||||
body: "Proposal A Notification Body")
|
||||
voter = create(:user, :level_two)
|
||||
create(:notification, notifiable: proposal_notification, user: voter, emailed_at: nil)
|
||||
create(:follow, user: voter, followable: proposal)
|
||||
|
||||
@@ -1,37 +1,37 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Admin tags' do
|
||||
feature "Admin tags" do
|
||||
|
||||
background do
|
||||
@tag1 = create(:tag, :category)
|
||||
login_as(create(:administrator).user)
|
||||
end
|
||||
|
||||
scenario 'Index' do
|
||||
scenario "Index" do
|
||||
debate = create(:debate)
|
||||
debate.tag_list.add(create(:tag, :category, name: "supertag"))
|
||||
visit admin_tags_path
|
||||
|
||||
expect(page).to have_content @tag1.name
|
||||
expect(page).to have_content 'supertag'
|
||||
expect(page).to have_content "supertag"
|
||||
end
|
||||
|
||||
scenario 'Create' do
|
||||
scenario "Create" do
|
||||
visit admin_tags_path
|
||||
|
||||
expect(page).not_to have_content 'important issues'
|
||||
expect(page).not_to have_content "important issues"
|
||||
|
||||
within("form.new_tag") do
|
||||
fill_in "tag_name", with: 'important issues'
|
||||
click_button 'Create topic'
|
||||
fill_in "tag_name", with: "important issues"
|
||||
click_button "Create topic"
|
||||
end
|
||||
|
||||
visit admin_tags_path
|
||||
|
||||
expect(page).to have_content 'important issues'
|
||||
expect(page).to have_content "important issues"
|
||||
end
|
||||
|
||||
scenario 'Delete' do
|
||||
scenario "Delete" do
|
||||
tag2 = create(:tag, :category, name: "bad tag")
|
||||
create(:debate, tag_list: tag2.name)
|
||||
visit admin_tags_path
|
||||
@@ -40,7 +40,7 @@ feature 'Admin tags' do
|
||||
expect(page).to have_content tag2.name
|
||||
|
||||
within("#tag_#{tag2.id}") do
|
||||
click_link 'Destroy topic'
|
||||
click_link "Destroy topic"
|
||||
end
|
||||
|
||||
visit admin_tags_path
|
||||
@@ -48,7 +48,7 @@ feature 'Admin tags' do
|
||||
expect(page).not_to have_content tag2.name
|
||||
end
|
||||
|
||||
scenario 'Delete tag with hidden taggables' do
|
||||
scenario "Delete tag with hidden taggables" do
|
||||
tag2 = create(:tag, :category, name: "bad tag")
|
||||
debate = create(:debate, tag_list: tag2.name)
|
||||
debate.hide
|
||||
@@ -59,7 +59,7 @@ feature 'Admin tags' do
|
||||
expect(page).to have_content tag2.name
|
||||
|
||||
within("#tag_#{tag2.id}") do
|
||||
click_link 'Destroy topic'
|
||||
click_link "Destroy topic"
|
||||
end
|
||||
|
||||
visit admin_tags_path
|
||||
@@ -81,7 +81,7 @@ feature 'Admin tags' do
|
||||
|
||||
within("form.new_tag") do
|
||||
fill_in "tag_name", with: "wow_category"
|
||||
click_button 'Create topic'
|
||||
click_button "Create topic"
|
||||
end
|
||||
|
||||
expect(ActsAsTaggableOn::Tag.category.where(name: "wow_category")).to exist
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Admin users' do
|
||||
feature "Admin users" do
|
||||
background do
|
||||
@admin = create(:administrator)
|
||||
@user = create(:user, username: 'Jose Luis Balbin')
|
||||
@user = create(:user, username: "Jose Luis Balbin")
|
||||
login_as(@admin.user)
|
||||
visit admin_users_path
|
||||
end
|
||||
|
||||
scenario 'Index' do
|
||||
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
|
||||
end
|
||||
|
||||
scenario 'The username links to their public profile' do
|
||||
scenario "The username links to their public profile" do
|
||||
click_link @user.name
|
||||
|
||||
expect(current_path).to eq(user_path(@user))
|
||||
end
|
||||
|
||||
scenario 'Search' do
|
||||
scenario "Search" do
|
||||
fill_in :search, with: "Luis"
|
||||
click_button 'Search'
|
||||
click_button "Search"
|
||||
|
||||
expect(page).to have_content @user.name
|
||||
expect(page).to have_content @user.email
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature "Valuator groups" do
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Admin valuators' do
|
||||
feature "Admin valuators" do
|
||||
|
||||
background do
|
||||
@admin = create(:administrator)
|
||||
@user = create(:user, username: 'Jose Luis Balbin')
|
||||
@user = create(:user, username: "Jose Luis Balbin")
|
||||
@valuator = create(:valuator)
|
||||
login_as(@admin.user)
|
||||
visit admin_valuators_path
|
||||
@@ -18,20 +18,20 @@ feature 'Admin valuators' do
|
||||
expect(page).to have_content @valuator.email
|
||||
end
|
||||
|
||||
scenario 'Index' do
|
||||
scenario "Index" do
|
||||
expect(page).to have_content(@valuator.name)
|
||||
expect(page).to have_content(@valuator.email)
|
||||
expect(page).not_to have_content(@user.name)
|
||||
end
|
||||
|
||||
scenario 'Create', :js do
|
||||
fill_in 'name_or_email', with: @user.email
|
||||
click_button 'Search'
|
||||
scenario "Create", :js do
|
||||
fill_in "name_or_email", with: @user.email
|
||||
click_button "Search"
|
||||
|
||||
expect(page).to have_content(@user.name)
|
||||
click_button 'Add to valuators'
|
||||
click_button "Add to valuators"
|
||||
|
||||
within('#valuators') do
|
||||
within("#valuators") do
|
||||
expect(page).to have_content(@user.name)
|
||||
end
|
||||
end
|
||||
@@ -39,7 +39,7 @@ feature 'Admin valuators' do
|
||||
scenario "Edit" do
|
||||
visit edit_admin_valuator_path(@valuator)
|
||||
|
||||
fill_in 'valuator_description', with: 'Valuator for health'
|
||||
fill_in "valuator_description", with: "Valuator for health"
|
||||
click_button "Update valuator"
|
||||
|
||||
expect(page).to have_content "Valuator updated successfully"
|
||||
@@ -47,57 +47,57 @@ feature 'Admin valuators' do
|
||||
expect(page).to have_content "Valuator for health"
|
||||
end
|
||||
|
||||
scenario 'Destroy' do
|
||||
click_link 'Delete'
|
||||
scenario "Destroy" do
|
||||
click_link "Delete"
|
||||
|
||||
within('#valuators') do
|
||||
within("#valuators") do
|
||||
expect(page).not_to have_content(@valuator.name)
|
||||
end
|
||||
end
|
||||
|
||||
context 'Search' do
|
||||
context "Search" do
|
||||
|
||||
background do
|
||||
user = create(:user, username: 'David Foster Wallace', email: 'david@wallace.com')
|
||||
user2 = create(:user, username: 'Steven Erikson', email: 'steven@erikson.com')
|
||||
user = create(:user, username: "David Foster Wallace", email: "david@wallace.com")
|
||||
user2 = create(:user, username: "Steven Erikson", email: "steven@erikson.com")
|
||||
@valuator1 = create(:valuator, user: user)
|
||||
@valuator2 = create(:valuator, user: user2)
|
||||
visit admin_valuators_path
|
||||
end
|
||||
|
||||
scenario 'returns no results if search term is empty' do
|
||||
scenario "returns no results if search term is empty" do
|
||||
expect(page).to have_content(@valuator1.name)
|
||||
expect(page).to have_content(@valuator2.name)
|
||||
|
||||
fill_in 'name_or_email', with: ' '
|
||||
click_button 'Search'
|
||||
fill_in "name_or_email", with: " "
|
||||
click_button "Search"
|
||||
|
||||
expect(page).to have_content('Valuators: User search')
|
||||
expect(page).to have_content('No results found')
|
||||
expect(page).to have_content("Valuators: User search")
|
||||
expect(page).to have_content("No results found")
|
||||
expect(page).not_to have_content(@valuator1.name)
|
||||
expect(page).not_to have_content(@valuator2.name)
|
||||
end
|
||||
|
||||
scenario 'search by name' do
|
||||
scenario "search by name" do
|
||||
expect(page).to have_content(@valuator1.name)
|
||||
expect(page).to have_content(@valuator2.name)
|
||||
|
||||
fill_in 'name_or_email', with: 'Foster'
|
||||
click_button 'Search'
|
||||
fill_in "name_or_email", with: "Foster"
|
||||
click_button "Search"
|
||||
|
||||
expect(page).to have_content('Valuators: User search')
|
||||
expect(page).to have_content("Valuators: User search")
|
||||
expect(page).to have_content(@valuator1.name)
|
||||
expect(page).not_to have_content(@valuator2.name)
|
||||
end
|
||||
|
||||
scenario 'search by email' do
|
||||
scenario "search by email" do
|
||||
expect(page).to have_content(@valuator1.email)
|
||||
expect(page).to have_content(@valuator2.email)
|
||||
|
||||
fill_in 'name_or_email', with: @valuator2.email
|
||||
click_button 'Search'
|
||||
fill_in "name_or_email", with: @valuator2.email
|
||||
click_button "Search"
|
||||
|
||||
expect(page).to have_content('Valuators: User search')
|
||||
expect(page).to have_content("Valuators: User search")
|
||||
expect(page).to have_content(@valuator2.email)
|
||||
expect(page).not_to have_content(@valuator1.email)
|
||||
end
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Incomplete verifications' do
|
||||
feature "Incomplete verifications" do
|
||||
|
||||
background do
|
||||
admin = create(:administrator)
|
||||
login_as(admin.user)
|
||||
end
|
||||
|
||||
scenario 'Index' do
|
||||
scenario "Index" do
|
||||
incompletely_verified_user1 = create(:user, :incomplete_verification)
|
||||
incompletely_verified_user2 = create(:user, :incomplete_verification)
|
||||
never_tried_to_verify_user = create(:user)
|
||||
@@ -21,7 +21,7 @@ feature 'Incomplete verifications' do
|
||||
expect(page).not_to have_content(verified_user.username)
|
||||
end
|
||||
|
||||
scenario 'Search' do
|
||||
scenario "Search" do
|
||||
verified_user = create(:user, :level_two, username: "Juan Carlos")
|
||||
unverified_user = create(:user, :incomplete_verification, username: "Juan_anonymous")
|
||||
unverified_user = create(:user, :incomplete_verification, username: "Isabel_anonymous")
|
||||
@@ -55,7 +55,7 @@ feature 'Incomplete verifications' do
|
||||
visit admin_verifications_path
|
||||
|
||||
within "#user_#{incompletely_verified_user.id}" do
|
||||
expect(page).to have_content 'Phone not given'
|
||||
expect(page).to have_content "Phone not given"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -68,7 +68,7 @@ feature 'Incomplete verifications' do
|
||||
visit admin_verifications_path
|
||||
|
||||
within "#user_#{incompletely_verified_user.id}" do
|
||||
expect(page).to have_content 'Has not confirmed the sms code'
|
||||
expect(page).to have_content "Has not confirmed the sms code"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Admin' do
|
||||
feature "Admin" do
|
||||
let(:user) { create(:user) }
|
||||
let(:administrator) do
|
||||
create(:administrator, user: user)
|
||||
user
|
||||
end
|
||||
|
||||
scenario 'Access as regular user is not authorized' do
|
||||
scenario "Access as regular user is not authorized" do
|
||||
login_as(user)
|
||||
visit admin_root_path
|
||||
|
||||
@@ -16,7 +16,7 @@ feature 'Admin' do
|
||||
expect(page).to have_content "You do not have permission to access this page"
|
||||
end
|
||||
|
||||
scenario 'Access as moderator is not authorized' do
|
||||
scenario "Access as moderator is not authorized" do
|
||||
create(:moderator, user: user)
|
||||
login_as(user)
|
||||
visit admin_root_path
|
||||
@@ -26,7 +26,7 @@ feature 'Admin' do
|
||||
expect(page).to have_content "You do not have permission to access this page"
|
||||
end
|
||||
|
||||
scenario 'Access as valuator is not authorized' do
|
||||
scenario "Access as valuator is not authorized" do
|
||||
create(:valuator, user: user)
|
||||
login_as(user)
|
||||
visit admin_root_path
|
||||
@@ -36,7 +36,7 @@ feature 'Admin' do
|
||||
expect(page).to have_content "You do not have permission to access this page"
|
||||
end
|
||||
|
||||
scenario 'Access as manager is not authorized' do
|
||||
scenario "Access as manager is not authorized" do
|
||||
create(:manager, user: user)
|
||||
login_as(user)
|
||||
visit admin_root_path
|
||||
@@ -46,7 +46,7 @@ feature 'Admin' do
|
||||
expect(page).to have_content "You do not have permission to access this page"
|
||||
end
|
||||
|
||||
scenario 'Access as poll officer is not authorized' do
|
||||
scenario "Access as poll officer is not authorized" do
|
||||
create(:poll_officer, user: user)
|
||||
login_as(user)
|
||||
visit admin_root_path
|
||||
@@ -56,7 +56,7 @@ feature 'Admin' do
|
||||
expect(page).to have_content "You do not have permission to access this page"
|
||||
end
|
||||
|
||||
scenario 'Access as administrator is authorized' do
|
||||
scenario "Access as administrator is authorized" do
|
||||
login_as(administrator)
|
||||
visit admin_root_path
|
||||
|
||||
@@ -70,24 +70,24 @@ feature 'Admin' do
|
||||
login_as(administrator)
|
||||
visit root_path
|
||||
|
||||
expect(page).to have_link('Administration')
|
||||
expect(page).to have_link('Moderation')
|
||||
expect(page).to have_link('Valuation')
|
||||
expect(page).to have_link('Management')
|
||||
expect(page).to have_link("Administration")
|
||||
expect(page).to have_link("Moderation")
|
||||
expect(page).to have_link("Valuation")
|
||||
expect(page).to have_link("Management")
|
||||
|
||||
Setting['feature.spending_proposals'] = nil
|
||||
Setting["feature.spending_proposals"] = nil
|
||||
end
|
||||
|
||||
scenario 'Admin dashboard' do
|
||||
scenario "Admin dashboard" do
|
||||
login_as(administrator)
|
||||
visit root_path
|
||||
|
||||
click_link 'Administration'
|
||||
click_link "Administration"
|
||||
|
||||
expect(page).to have_current_path(admin_root_path)
|
||||
expect(page).to have_css('#admin_menu')
|
||||
expect(page).not_to have_css('#moderation_menu')
|
||||
expect(page).not_to have_css('#valuation_menu')
|
||||
expect(page).to have_css("#admin_menu")
|
||||
expect(page).not_to have_css("#moderation_menu")
|
||||
expect(page).not_to have_css("#valuation_menu")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Banner' do
|
||||
feature "Banner" do
|
||||
|
||||
scenario "The banner is shown correctly" do
|
||||
create(:web_section, name: 'homepage')
|
||||
banner = create(:banner, title: 'Hello',
|
||||
description: 'Banner description',
|
||||
target_url: 'http://www.url.com',
|
||||
create(:web_section, name: "homepage")
|
||||
banner = create(:banner, title: "Hello",
|
||||
description: "Banner description",
|
||||
target_url: "http://www.url.com",
|
||||
post_started_at: (Time.current - 4.days),
|
||||
post_ended_at: (Time.current + 10.days),
|
||||
background_color: '#FF0000',
|
||||
font_color: '#FFFFFF')
|
||||
section = WebSection.where(name: 'homepage').last
|
||||
background_color: "#FF0000",
|
||||
font_color: "#FFFFFF")
|
||||
section = WebSection.where(name: "homepage").last
|
||||
create(:banner_section, web_section: section, banner_id: banner.id)
|
||||
|
||||
visit root_path
|
||||
|
||||
within('.banner') do
|
||||
expect(page).to have_content('Banner description')
|
||||
expect(find('h2')[:style]).to eq("color:#{banner.font_color}")
|
||||
expect(find('h3')[:style]).to eq("color:#{banner.font_color}")
|
||||
within(".banner") do
|
||||
expect(page).to have_content("Banner description")
|
||||
expect(find("h2")[:style]).to eq("color:#{banner.font_color}")
|
||||
expect(find("h3")[:style]).to eq("color:#{banner.font_color}")
|
||||
end
|
||||
|
||||
visit debates_path
|
||||
|
||||
expect(page).not_to have_content('Banner description')
|
||||
expect(page).not_to have_content("Banner description")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Budget Poll Officing' do
|
||||
feature "Budget Poll Officing" do
|
||||
|
||||
scenario 'Show sidebar menu if officer has shifts assigned' do
|
||||
scenario "Show sidebar menu if officer has shifts assigned" do
|
||||
poll = create(:poll)
|
||||
booth = create(:poll_booth)
|
||||
booth_assignment = create(:poll_booth_assignment, poll: poll, booth: booth)
|
||||
@@ -24,7 +24,7 @@ feature 'Budget Poll Officing' do
|
||||
expect(page).to have_content("Total recounts and results")
|
||||
end
|
||||
|
||||
scenario 'Do not show sidebar menu if officer has no shifts assigned' do
|
||||
scenario "Do not show sidebar menu if officer has no shifts assigned" do
|
||||
user = create(:user)
|
||||
officer = create(:poll_officer, user: user)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Ballots' do
|
||||
feature "Ballots" do
|
||||
|
||||
let!(:user) { create(:user, :level_two) }
|
||||
let!(:budget) { create(:budget, phase: "balloting") }
|
||||
@@ -149,7 +149,7 @@ feature 'Ballots' do
|
||||
end
|
||||
|
||||
within("#budget_investment_#{investment.id}") do
|
||||
find('.remove a').click
|
||||
find(".remove a").click
|
||||
end
|
||||
|
||||
expect(page).to have_css("#amount-spent", text: "€0")
|
||||
@@ -278,7 +278,7 @@ feature 'Ballots' do
|
||||
|
||||
background { login_as(user) }
|
||||
|
||||
scenario 'Select my heading', :js do
|
||||
scenario "Select my heading", :js do
|
||||
visit budget_path(budget)
|
||||
click_link "States"
|
||||
click_link "California"
|
||||
@@ -292,7 +292,7 @@ feature 'Ballots' do
|
||||
expect(page).to have_css("#budget_heading_#{california.id}.is-active")
|
||||
end
|
||||
|
||||
scenario 'Change my heading', :js do
|
||||
scenario "Change my heading", :js do
|
||||
investment1 = create(:budget_investment, :selected, heading: california)
|
||||
investment2 = create(:budget_investment, :selected, heading: new_york)
|
||||
|
||||
@@ -302,7 +302,7 @@ feature 'Ballots' do
|
||||
visit budget_investments_path(budget, heading_id: california.id)
|
||||
|
||||
within("#budget_investment_#{investment1.id}") do
|
||||
find('.remove a').click
|
||||
find(".remove a").click
|
||||
end
|
||||
|
||||
visit budget_investments_path(budget, heading_id: new_york.id)
|
||||
@@ -315,7 +315,7 @@ feature 'Ballots' do
|
||||
expect(page).not_to have_css("#budget_heading_#{california.id}.is-active")
|
||||
end
|
||||
|
||||
scenario 'View another heading' do
|
||||
scenario "View another heading" do
|
||||
investment = create(:budget_investment, :selected, heading: california)
|
||||
|
||||
ballot = create(:budget_ballot, user: user, budget: budget)
|
||||
@@ -330,7 +330,7 @@ feature 'Ballots' do
|
||||
|
||||
end
|
||||
|
||||
context 'Showing the ballot' do
|
||||
context "Showing the ballot" do
|
||||
scenario "Do not display heading name if there is only one heading in the group (example: group city)" do
|
||||
group = create(:budget_group, budget: budget)
|
||||
heading = create(:budget_heading, group: group)
|
||||
@@ -341,7 +341,7 @@ feature 'Ballots' do
|
||||
expect(page).to have_current_path(budget_investments_path(budget), ignore_query: true)
|
||||
end
|
||||
|
||||
scenario 'Displaying the correct group, heading, count & amount' do
|
||||
scenario "Displaying the correct group, heading, count & amount" do
|
||||
group1 = create(:budget_group, budget: budget)
|
||||
group2 = create(:budget_group, budget: budget)
|
||||
|
||||
@@ -378,7 +378,7 @@ feature 'Ballots' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Display links to vote on groups with no investments voted yet' do
|
||||
scenario "Display links to vote on groups with no investments voted yet" do
|
||||
group = create(:budget_group, budget: budget)
|
||||
heading = create(:budget_heading, name: "District 1", group: group, price: 100)
|
||||
|
||||
@@ -392,7 +392,7 @@ feature 'Ballots' do
|
||||
|
||||
end
|
||||
|
||||
scenario 'Removing investments from ballot', :js do
|
||||
scenario "Removing investments from ballot", :js do
|
||||
investment = create(:budget_investment, :selected, price: 10, heading: new_york)
|
||||
ballot = create(:budget_ballot, user: user, budget: budget)
|
||||
ballot.investments << investment
|
||||
@@ -403,14 +403,14 @@ feature 'Ballots' do
|
||||
expect(page).to have_content("You have voted one investment")
|
||||
|
||||
within("#budget_investment_#{investment.id}") do
|
||||
find('.icon-x').click
|
||||
find(".icon-x").click
|
||||
end
|
||||
|
||||
expect(page).to have_current_path(budget_ballot_path(budget))
|
||||
expect(page).to have_content("You have voted 0 investments")
|
||||
end
|
||||
|
||||
scenario 'Removing investments from ballot (sidebar)', :js do
|
||||
scenario "Removing investments from ballot (sidebar)", :js do
|
||||
investment1 = create(:budget_investment, :selected, price: 10000, heading: new_york)
|
||||
investment2 = create(:budget_investment, :selected, price: 20000, heading: new_york)
|
||||
|
||||
@@ -432,7 +432,7 @@ feature 'Ballots' do
|
||||
end
|
||||
|
||||
within("#sidebar #budget_investment_#{investment1.id}_sidebar") do
|
||||
find('.icon-x').click
|
||||
find(".icon-x").click
|
||||
end
|
||||
|
||||
expect(page).to have_css("#amount-spent", text: "€20,000")
|
||||
@@ -447,7 +447,7 @@ feature 'Ballots' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Back link after removing an investment from Ballot', :js do
|
||||
scenario "Back link after removing an investment from Ballot", :js do
|
||||
investment = create(:budget_investment, :selected, heading: new_york, price: 10)
|
||||
|
||||
login_as(user)
|
||||
@@ -459,7 +459,7 @@ feature 'Ballots' do
|
||||
expect(page).to have_content("You have voted one investment")
|
||||
|
||||
within("#budget_investment_#{investment.id}") do
|
||||
find('.icon-x').click
|
||||
find(".icon-x").click
|
||||
end
|
||||
|
||||
expect(page).to have_content("You have voted 0 investments")
|
||||
@@ -469,21 +469,21 @@ feature 'Ballots' do
|
||||
expect(page).to have_current_path(budget_investments_path(budget, heading_id: new_york.id))
|
||||
end
|
||||
|
||||
context 'Permissions' do
|
||||
context "Permissions" do
|
||||
|
||||
scenario 'User not logged in', :js do
|
||||
scenario "User not logged in", :js do
|
||||
investment = create(:budget_investment, :selected, heading: new_york)
|
||||
|
||||
visit budget_investments_path(budget, heading_id: new_york.id)
|
||||
|
||||
within("#budget_investment_#{investment.id}") do
|
||||
find("div.ballot").hover
|
||||
expect(page).to have_content 'You must Sign in or Sign up to continue.'
|
||||
expect(page).to have_selector('.in-favor a', visible: false)
|
||||
expect(page).to have_content "You must Sign in or Sign up to continue."
|
||||
expect(page).to have_selector(".in-favor a", visible: false)
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'User not verified', :js do
|
||||
scenario "User not verified", :js do
|
||||
unverified_user = create(:user)
|
||||
investment = create(:budget_investment, :selected, heading: new_york)
|
||||
|
||||
@@ -492,12 +492,12 @@ feature 'Ballots' do
|
||||
|
||||
within("#budget_investment_#{investment.id}") do
|
||||
find("div.ballot").hover
|
||||
expect(page).to have_content 'Only verified users can vote on investments'
|
||||
expect(page).to have_selector('.in-favor a', visible: false)
|
||||
expect(page).to have_content "Only verified users can vote on investments"
|
||||
expect(page).to have_selector(".in-favor a", visible: false)
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'User is organization', :js do
|
||||
scenario "User is organization", :js do
|
||||
org = create(:organization)
|
||||
investment = create(:budget_investment, :selected, heading: new_york)
|
||||
|
||||
@@ -510,7 +510,7 @@ feature 'Ballots' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Unselected investments' do
|
||||
scenario "Unselected investments" do
|
||||
investment = create(:budget_investment, heading: new_york, title: "WTF asdfasfd")
|
||||
|
||||
login_as(user)
|
||||
@@ -521,7 +521,7 @@ feature 'Ballots' do
|
||||
expect(page).not_to have_css("#budget_investment_#{investment.id}")
|
||||
end
|
||||
|
||||
scenario 'Investments with feasibility undecided are not shown' do
|
||||
scenario "Investments with feasibility undecided are not shown" do
|
||||
investment = create(:budget_investment, feasibility: "undecided", heading: new_york)
|
||||
|
||||
login_as(user)
|
||||
@@ -535,7 +535,7 @@ feature 'Ballots' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Different district', :js do
|
||||
scenario "Different district", :js do
|
||||
bi1 = create(:budget_investment, :selected, heading: california)
|
||||
bi2 = create(:budget_investment, :selected, heading: new_york)
|
||||
|
||||
@@ -547,12 +547,12 @@ feature 'Ballots' do
|
||||
|
||||
within("#budget_investment_#{bi2.id}") do
|
||||
find("div.ballot").hover
|
||||
expect(page).to have_content('already voted a different heading')
|
||||
expect(page).to have_selector('.in-favor a', visible: false)
|
||||
expect(page).to have_content("already voted a different heading")
|
||||
expect(page).to have_selector(".in-favor a", visible: false)
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Insufficient funds (on page load)', :js do
|
||||
scenario "Insufficient funds (on page load)", :js do
|
||||
bi1 = create(:budget_investment, :selected, heading: california, price: 600)
|
||||
bi2 = create(:budget_investment, :selected, heading: california, price: 500)
|
||||
|
||||
@@ -564,12 +564,12 @@ feature 'Ballots' do
|
||||
|
||||
within("#budget_investment_#{bi2.id}") do
|
||||
find("div.ballot").hover
|
||||
expect(page).to have_content('You have already assigned the available budget')
|
||||
expect(page).to have_selector('.in-favor a', visible: false)
|
||||
expect(page).to have_content("You have already assigned the available budget")
|
||||
expect(page).to have_selector(".in-favor a", visible: false)
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Insufficient funds (added after create)', :js do
|
||||
scenario "Insufficient funds (added after create)", :js do
|
||||
bi1 = create(:budget_investment, :selected, heading: california, price: 600)
|
||||
bi2 = create(:budget_investment, :selected, heading: california, price: 500)
|
||||
|
||||
@@ -578,21 +578,21 @@ feature 'Ballots' do
|
||||
|
||||
within("#budget_investment_#{bi1.id}") do
|
||||
find("div.ballot").hover
|
||||
expect(page).not_to have_content('You have already assigned the available budget')
|
||||
expect(page).to have_selector('.in-favor a', visible: true)
|
||||
expect(page).not_to have_content("You have already assigned the available budget")
|
||||
expect(page).to have_selector(".in-favor a", visible: true)
|
||||
end
|
||||
|
||||
add_to_ballot(bi1)
|
||||
|
||||
within("#budget_investment_#{bi2.id}") do
|
||||
find("div.ballot").hover
|
||||
expect(page).to have_content('You have already assigned the available budget')
|
||||
expect(page).to have_selector('.in-favor a', visible: false)
|
||||
expect(page).to have_content("You have already assigned the available budget")
|
||||
expect(page).to have_selector(".in-favor a", visible: false)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
scenario 'Insufficient funds (removed after destroy)', :js do
|
||||
scenario "Insufficient funds (removed after destroy)", :js do
|
||||
bi1 = create(:budget_investment, :selected, heading: california, price: 600)
|
||||
bi2 = create(:budget_investment, :selected, heading: california, price: 500)
|
||||
|
||||
@@ -604,23 +604,23 @@ feature 'Ballots' do
|
||||
|
||||
within("#budget_investment_#{bi2.id}") do
|
||||
find("div.ballot").hover
|
||||
expect(page).to have_content('You have already assigned the available budget')
|
||||
expect(page).to have_selector('.in-favor a', visible: false)
|
||||
expect(page).to have_content("You have already assigned the available budget")
|
||||
expect(page).to have_selector(".in-favor a", visible: false)
|
||||
end
|
||||
|
||||
within("#budget_investment_#{bi1.id}") do
|
||||
find('.remove a').click
|
||||
find(".remove a").click
|
||||
expect(page).to have_css ".add a"
|
||||
end
|
||||
|
||||
within("#budget_investment_#{bi2.id}") do
|
||||
find("div.ballot").hover
|
||||
expect(page).not_to have_content('You have already assigned the available budget')
|
||||
expect(page).to have_selector('.in-favor a', visible: true)
|
||||
expect(page).not_to have_content("You have already assigned the available budget")
|
||||
expect(page).to have_selector(".in-favor a", visible: true)
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Insufficient funds (removed after destroying from sidebar)', :js do
|
||||
scenario "Insufficient funds (removed after destroying from sidebar)", :js do
|
||||
bi1 = create(:budget_investment, :selected, heading: california, price: 600)
|
||||
bi2 = create(:budget_investment, :selected, heading: california, price: 500)
|
||||
|
||||
@@ -632,20 +632,20 @@ feature 'Ballots' do
|
||||
|
||||
within("#budget_investment_#{bi2.id}") do
|
||||
find("div.ballot").hover
|
||||
expect(page).to have_content('You have already assigned the available budget')
|
||||
expect(page).to have_selector('.in-favor a', visible: false)
|
||||
expect(page).to have_content("You have already assigned the available budget")
|
||||
expect(page).to have_selector(".in-favor a", visible: false)
|
||||
end
|
||||
|
||||
within("#budget_investment_#{bi1.id}_sidebar") do
|
||||
find('.icon-x').click
|
||||
find(".icon-x").click
|
||||
end
|
||||
|
||||
expect(page).not_to have_css "#budget_investment_#{bi1.id}_sidebar"
|
||||
|
||||
within("#budget_investment_#{bi2.id}") do
|
||||
find("div.ballot").hover
|
||||
expect(page).not_to have_content('You have already assigned the available budget')
|
||||
expect(page).to have_selector('.in-favor a', visible: true)
|
||||
expect(page).not_to have_content("You have already assigned the available budget")
|
||||
expect(page).to have_selector(".in-favor a", visible: true)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -660,18 +660,18 @@ feature 'Ballots' do
|
||||
new_york.update(price: 10)
|
||||
|
||||
within("#budget_investment_#{investment1.id}") do
|
||||
expect(page).to have_selector('.in-favor a', visible: true)
|
||||
find('.add a').click
|
||||
expect(page).to have_selector(".in-favor a", visible: true)
|
||||
find(".add a").click
|
||||
expect(page).not_to have_content "Remove"
|
||||
expect(page).to have_selector('.participation-not-allowed', visible: false)
|
||||
expect(page).to have_selector(".participation-not-allowed", visible: false)
|
||||
find("div.ballot").hover
|
||||
expect(page).to have_selector('.participation-not-allowed', visible: true)
|
||||
expect(page).to have_selector('.in-favor a', visible: false)
|
||||
expect(page).to have_selector(".participation-not-allowed", visible: true)
|
||||
expect(page).to have_selector(".in-favor a", visible: false)
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Balloting is disabled when budget isn't in the balotting phase", :js do
|
||||
budget.update(phase: 'accepting')
|
||||
budget.update(phase: "accepting")
|
||||
|
||||
bi1 = create(:budget_investment, :selected, heading: california, price: 600)
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Executions' do
|
||||
feature "Executions" do
|
||||
|
||||
let(:budget) { create(:budget, phase: 'finished') }
|
||||
let(:budget) { create(:budget, phase: "finished") }
|
||||
let(:group) { create(:budget_group, budget: budget) }
|
||||
let(:heading) { create(:budget_heading, group: group) }
|
||||
|
||||
@@ -11,15 +11,15 @@ feature 'Executions' do
|
||||
let!(:investment4) { create(:budget_investment, :winner, heading: heading) }
|
||||
let!(:investment3) { create(:budget_investment, :incompatible, heading: heading) }
|
||||
|
||||
scenario 'only displays investments with milestones' do
|
||||
scenario "only displays investments with milestones" do
|
||||
create(:milestone, milestoneable: investment1)
|
||||
|
||||
visit budget_path(budget)
|
||||
click_link 'See results'
|
||||
click_link "See results"
|
||||
|
||||
expect(page).to have_link('Milestones')
|
||||
expect(page).to have_link("Milestones")
|
||||
|
||||
click_link 'Milestones'
|
||||
click_link "Milestones"
|
||||
|
||||
expect(page).to have_content(investment1.title)
|
||||
expect(page).not_to have_content(investment2.title)
|
||||
@@ -34,67 +34,67 @@ feature 'Executions' do
|
||||
empty_heading = create(:budget_heading, group: empty_group, price: 1000)
|
||||
|
||||
visit budget_path(budget)
|
||||
click_link 'See results'
|
||||
click_link "See results"
|
||||
|
||||
expect(page).to have_content(heading.name)
|
||||
expect(page).to have_content(empty_heading.name)
|
||||
|
||||
click_link 'Milestones'
|
||||
click_link "Milestones"
|
||||
|
||||
expect(page).to have_content(heading.name)
|
||||
expect(page).not_to have_content(empty_heading.name)
|
||||
end
|
||||
|
||||
scenario "Show message when there are no winning investments with the selected status", :js do
|
||||
create(:milestone_status, name: I18n.t('seeds.budgets.statuses.executed'))
|
||||
create(:milestone_status, name: I18n.t("seeds.budgets.statuses.executed"))
|
||||
|
||||
visit budget_path(budget)
|
||||
|
||||
click_link 'See results'
|
||||
click_link 'Milestones'
|
||||
click_link "See results"
|
||||
click_link "Milestones"
|
||||
|
||||
expect(page).not_to have_content('No winner investments in this state')
|
||||
expect(page).not_to have_content("No winner investments in this state")
|
||||
|
||||
select 'Executed (0)', from: 'status'
|
||||
select "Executed (0)", from: "status"
|
||||
|
||||
expect(page).to have_content('No winner investments in this state')
|
||||
expect(page).to have_content("No winner investments in this state")
|
||||
end
|
||||
|
||||
context 'Images' do
|
||||
context "Images" do
|
||||
|
||||
scenario 'renders milestone image if available' do
|
||||
scenario "renders milestone image if available" do
|
||||
milestone1 = create(:milestone, milestoneable: investment1)
|
||||
create(:image, imageable: milestone1)
|
||||
|
||||
visit budget_path(budget)
|
||||
|
||||
click_link 'See results'
|
||||
click_link 'Milestones'
|
||||
click_link "See results"
|
||||
click_link "Milestones"
|
||||
|
||||
expect(page).to have_content(investment1.title)
|
||||
expect(page).to have_css("img[alt='#{milestone1.image.title}']")
|
||||
end
|
||||
|
||||
scenario 'renders investment image if no milestone image is available' do
|
||||
scenario "renders investment image if no milestone image is available" do
|
||||
create(:milestone, milestoneable: investment2)
|
||||
create(:image, imageable: investment2)
|
||||
|
||||
visit budget_path(budget)
|
||||
|
||||
click_link 'See results'
|
||||
click_link 'Milestones'
|
||||
click_link "See results"
|
||||
click_link "Milestones"
|
||||
|
||||
expect(page).to have_content(investment2.title)
|
||||
expect(page).to have_css("img[alt='#{investment2.image.title}']")
|
||||
end
|
||||
|
||||
scenario 'renders default image if no milestone nor investment images are available' do
|
||||
scenario "renders default image if no milestone nor investment images are available" do
|
||||
create(:milestone, milestoneable: investment4)
|
||||
|
||||
visit budget_path(budget)
|
||||
|
||||
click_link 'See results'
|
||||
click_link 'Milestones'
|
||||
click_link "See results"
|
||||
click_link "Milestones"
|
||||
|
||||
expect(page).to have_content(investment4.title)
|
||||
expect(page).to have_css("img[alt='#{investment4.title}']")
|
||||
@@ -113,13 +113,13 @@ feature 'Executions' do
|
||||
milestone4 = create(:milestone, milestoneable: investment1,
|
||||
publication_date: Date.yesterday)
|
||||
|
||||
create(:image, imageable: milestone2, title: 'Image for first milestone with image')
|
||||
create(:image, imageable: milestone3, title: 'Image for second milestone with image')
|
||||
create(:image, imageable: milestone2, title: "Image for first milestone with image")
|
||||
create(:image, imageable: milestone3, title: "Image for second milestone with image")
|
||||
|
||||
visit budget_path(budget)
|
||||
|
||||
click_link 'See results'
|
||||
click_link 'Milestones'
|
||||
click_link "See results"
|
||||
click_link "Milestones"
|
||||
|
||||
expect(page).to have_content(investment1.title)
|
||||
expect(page).to have_css("img[alt='#{milestone3.image.title}']")
|
||||
@@ -127,12 +127,12 @@ feature 'Executions' do
|
||||
|
||||
end
|
||||
|
||||
context 'Filters' do
|
||||
context "Filters" do
|
||||
|
||||
let!(:status1) { create(:milestone_status, name: "Studying the project") }
|
||||
let!(:status2) { create(:milestone_status, name: "Bidding") }
|
||||
|
||||
scenario 'Filters select with counter are shown' do
|
||||
scenario "Filters select with counter are shown" do
|
||||
create(:milestone, milestoneable: investment1,
|
||||
publication_date: Date.yesterday,
|
||||
status: status1)
|
||||
@@ -143,44 +143,44 @@ feature 'Executions' do
|
||||
|
||||
visit budget_path(budget)
|
||||
|
||||
click_link 'See results'
|
||||
click_link 'Milestones'
|
||||
click_link "See results"
|
||||
click_link "Milestones"
|
||||
|
||||
expect(page).to have_content("All (2)")
|
||||
expect(page).to have_content("#{status1.name} (1)")
|
||||
expect(page).to have_content("#{status2.name} (1)")
|
||||
end
|
||||
|
||||
scenario 'by milestone status', :js do
|
||||
scenario "by milestone status", :js do
|
||||
create(:milestone, milestoneable: investment1, status: status1)
|
||||
create(:milestone, milestoneable: investment2, status: status2)
|
||||
create(:milestone_status, name: I18n.t('seeds.budgets.statuses.executing_project'))
|
||||
create(:milestone_status, name: I18n.t("seeds.budgets.statuses.executing_project"))
|
||||
|
||||
visit budget_path(budget)
|
||||
|
||||
click_link 'See results'
|
||||
click_link 'Milestones'
|
||||
click_link "See results"
|
||||
click_link "Milestones"
|
||||
|
||||
expect(page).to have_content(investment1.title)
|
||||
expect(page).to have_content(investment2.title)
|
||||
|
||||
select 'Studying the project (1)', from: 'status'
|
||||
select "Studying the project (1)", from: "status"
|
||||
|
||||
expect(page).to have_content(investment1.title)
|
||||
expect(page).not_to have_content(investment2.title)
|
||||
|
||||
select 'Bidding (1)', from: 'status'
|
||||
select "Bidding (1)", from: "status"
|
||||
|
||||
expect(page).to have_content(investment2.title)
|
||||
expect(page).not_to have_content(investment1.title)
|
||||
|
||||
select 'Executing the project (0)', from: 'status'
|
||||
select "Executing the project (0)", from: "status"
|
||||
|
||||
expect(page).not_to have_content(investment1.title)
|
||||
expect(page).not_to have_content(investment2.title)
|
||||
end
|
||||
|
||||
scenario 'are based on latest milestone status', :js do
|
||||
scenario "are based on latest milestone status", :js do
|
||||
create(:milestone, milestoneable: investment1,
|
||||
publication_date: 1.month.ago,
|
||||
status: status1)
|
||||
@@ -190,17 +190,17 @@ feature 'Executions' do
|
||||
status: status2)
|
||||
|
||||
visit budget_path(budget)
|
||||
click_link 'See results'
|
||||
click_link 'Milestones'
|
||||
click_link "See results"
|
||||
click_link "Milestones"
|
||||
|
||||
select 'Studying the project (0)', from: 'status'
|
||||
select "Studying the project (0)", from: "status"
|
||||
expect(page).not_to have_content(investment1.title)
|
||||
|
||||
select 'Bidding (1)', from: 'status'
|
||||
select "Bidding (1)", from: "status"
|
||||
expect(page).to have_content(investment1.title)
|
||||
end
|
||||
|
||||
scenario 'milestones with future dates are not shown', :js do
|
||||
scenario "milestones with future dates are not shown", :js do
|
||||
create(:milestone, milestoneable: investment1,
|
||||
publication_date: Date.yesterday,
|
||||
status: status1)
|
||||
@@ -210,18 +210,18 @@ feature 'Executions' do
|
||||
status: status2)
|
||||
|
||||
visit budget_path(budget)
|
||||
click_link 'See results'
|
||||
click_link 'Milestones'
|
||||
click_link "See results"
|
||||
click_link "Milestones"
|
||||
|
||||
select 'Studying the project (1)', from: 'status'
|
||||
select "Studying the project (1)", from: "status"
|
||||
expect(page).to have_content(investment1.title)
|
||||
|
||||
select 'Bidding (0)', from: 'status'
|
||||
select "Bidding (0)", from: "status"
|
||||
expect(page).not_to have_content(investment1.title)
|
||||
end
|
||||
end
|
||||
|
||||
context 'Heading Order' do
|
||||
context "Heading Order" do
|
||||
|
||||
def create_heading_with_investment_with_milestone(group:, name:)
|
||||
heading = create(:budget_heading, group: group, name: name)
|
||||
@@ -230,30 +230,30 @@ feature 'Executions' do
|
||||
heading
|
||||
end
|
||||
|
||||
scenario 'Non-city headings are displayed in alphabetical order' do
|
||||
scenario "Non-city headings are displayed in alphabetical order" do
|
||||
heading.destroy!
|
||||
z_heading = create_heading_with_investment_with_milestone(group: group, name: 'Zzz')
|
||||
a_heading = create_heading_with_investment_with_milestone(group: group, name: 'Aaa')
|
||||
m_heading = create_heading_with_investment_with_milestone(group: group, name: 'Mmm')
|
||||
z_heading = create_heading_with_investment_with_milestone(group: group, name: "Zzz")
|
||||
a_heading = create_heading_with_investment_with_milestone(group: group, name: "Aaa")
|
||||
m_heading = create_heading_with_investment_with_milestone(group: group, name: "Mmm")
|
||||
|
||||
visit budget_executions_path(budget)
|
||||
|
||||
expect(page).to have_css('.budget-execution', count: 3)
|
||||
expect(page).to have_css(".budget-execution", count: 3)
|
||||
expect(a_heading.name).to appear_before(m_heading.name)
|
||||
expect(m_heading.name).to appear_before(z_heading.name)
|
||||
end
|
||||
end
|
||||
|
||||
context 'No milestones' do
|
||||
context "No milestones" do
|
||||
|
||||
scenario 'Milestone not yet published' do
|
||||
scenario "Milestone not yet published" do
|
||||
status = create(:milestone_status)
|
||||
unpublished_milestone = create(:milestone, milestoneable: investment1,
|
||||
status: status, publication_date: Date.tomorrow)
|
||||
|
||||
visit budget_executions_path(budget, status: status.id)
|
||||
|
||||
expect(page).to have_content('No winner investments in this state')
|
||||
expect(page).to have_content("No winner investments in this state")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -925,7 +925,7 @@ feature 'Budget Investments' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Ballot is not visible' do
|
||||
scenario "Ballot is not visible" do
|
||||
login_as(author)
|
||||
|
||||
visit budget_investments_path(budget, heading_id: heading.id)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Results' do
|
||||
feature "Results" do
|
||||
|
||||
let(:budget) { create(:budget, phase: "finished") }
|
||||
let(:group) { create(:budget_group, budget: budget) }
|
||||
@@ -21,7 +21,7 @@ feature 'Results' do
|
||||
visit budget_path(budget)
|
||||
click_link "See results"
|
||||
|
||||
expect(page).to have_selector('a.is-active', text: budget.headings.first.name)
|
||||
expect(page).to have_selector("a.is-active", text: budget.headings.first.name)
|
||||
|
||||
within("#budget-investments-compatible") do
|
||||
expect(page).to have_content investment1.title
|
||||
@@ -65,7 +65,7 @@ feature 'Results' do
|
||||
end
|
||||
|
||||
scenario "If budget is in a phase different from finished results can't be accessed" do
|
||||
budget.update(phase: (Budget::Phase::PHASE_KINDS - ['drafting', 'finished']).sample)
|
||||
budget.update(phase: (Budget::Phase::PHASE_KINDS - ["drafting", "finished"]).sample)
|
||||
visit budget_path(budget)
|
||||
expect(page).not_to have_link "See results"
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Email campaigns' do
|
||||
feature "Email campaigns" do
|
||||
|
||||
background do
|
||||
@campaign1 = create(:campaign)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'CKEditor' do
|
||||
feature "CKEditor" do
|
||||
|
||||
scenario 'is present before & after turbolinks update page', :js do
|
||||
scenario "is present before & after turbolinks update page", :js do
|
||||
author = create(:user)
|
||||
login_as(author)
|
||||
|
||||
@@ -10,8 +10,8 @@ feature 'CKEditor' do
|
||||
|
||||
expect(page).to have_css "#cke_debate_description"
|
||||
|
||||
click_link 'Debates'
|
||||
click_link 'Start a debate'
|
||||
click_link "Debates"
|
||||
click_link "Start a debate"
|
||||
|
||||
expect(page).to have_css "#cke_debate_description"
|
||||
end
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
include ActionView::Helpers::DateHelper
|
||||
|
||||
feature 'Commenting Budget::Investments' do
|
||||
feature "Commenting Budget::Investments" do
|
||||
let(:user) { create :user }
|
||||
let(:investment) { create :budget_investment }
|
||||
|
||||
scenario 'Index' do
|
||||
scenario "Index" do
|
||||
3.times { create(:comment, commentable: investment) }
|
||||
valuation_comment = create(:comment, :valuation, commentable: investment, subject: 'Not viable')
|
||||
valuation_comment = create(:comment, :valuation, commentable: investment, subject: "Not viable")
|
||||
|
||||
visit budget_investment_path(investment.budget, investment)
|
||||
|
||||
expect(page).to have_css('.comment', count: 3)
|
||||
expect(page).not_to have_content('Not viable')
|
||||
expect(page).to have_css(".comment", count: 3)
|
||||
expect(page).not_to have_content("Not viable")
|
||||
|
||||
within("#comments") do
|
||||
Comment.not_valuations.last(3).each do |comment|
|
||||
@@ -23,11 +23,11 @@ feature 'Commenting Budget::Investments' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Show' do
|
||||
scenario "Show" do
|
||||
parent_comment = create(:comment, commentable: investment)
|
||||
first_child = create(:comment, commentable: investment, parent: parent_comment)
|
||||
second_child = create(:comment, commentable: investment, parent: parent_comment)
|
||||
valuation_comment = create(:comment, :valuation, commentable: investment, subject: 'Not viable')
|
||||
valuation_comment = create(:comment, :valuation, commentable: investment, subject: "Not viable")
|
||||
|
||||
visit comment_path(parent_comment)
|
||||
|
||||
@@ -35,7 +35,7 @@ feature 'Commenting Budget::Investments' do
|
||||
expect(page).to have_content parent_comment.body
|
||||
expect(page).to have_content first_child.body
|
||||
expect(page).to have_content second_child.body
|
||||
expect(page).not_to have_content('Not viable')
|
||||
expect(page).not_to have_content("Not viable")
|
||||
|
||||
expect(page).to have_link "Go back to #{investment.title}", href: budget_investment_path(investment.budget, investment)
|
||||
|
||||
@@ -44,33 +44,33 @@ feature 'Commenting Budget::Investments' do
|
||||
expect(page).to have_selector("ul#comment_#{second_child.id}>li", count: 1)
|
||||
end
|
||||
|
||||
scenario 'Collapsable comments', :js do
|
||||
scenario "Collapsable comments", :js do
|
||||
parent_comment = create(:comment, body: "Main comment", commentable: investment)
|
||||
child_comment = create(:comment, body: "First subcomment", commentable: investment, parent: parent_comment)
|
||||
grandchild_comment = create(:comment, body: "Last subcomment", commentable: investment, parent: child_comment)
|
||||
|
||||
visit budget_investment_path(investment.budget, investment)
|
||||
|
||||
expect(page).to have_css('.comment', count: 3)
|
||||
expect(page).to have_css(".comment", count: 3)
|
||||
|
||||
find("#comment_#{child_comment.id}_children_arrow").click
|
||||
|
||||
expect(page).to have_css('.comment', count: 2)
|
||||
expect(page).to have_css(".comment", count: 2)
|
||||
expect(page).not_to have_content grandchild_comment.body
|
||||
|
||||
find("#comment_#{child_comment.id}_children_arrow").click
|
||||
|
||||
expect(page).to have_css('.comment', count: 3)
|
||||
expect(page).to have_css(".comment", count: 3)
|
||||
expect(page).to have_content grandchild_comment.body
|
||||
|
||||
find("#comment_#{parent_comment.id}_children_arrow").click
|
||||
|
||||
expect(page).to have_css('.comment', count: 1)
|
||||
expect(page).to have_css(".comment", count: 1)
|
||||
expect(page).not_to have_content child_comment.body
|
||||
expect(page).not_to have_content grandchild_comment.body
|
||||
end
|
||||
|
||||
scenario 'Comment order' do
|
||||
scenario "Comment order" do
|
||||
c1 = create(:comment, :with_confidence_score, commentable: investment, cached_votes_up: 100,
|
||||
cached_votes_total: 120, created_at: Time.current - 2)
|
||||
c2 = create(:comment, :with_confidence_score, commentable: investment, cached_votes_up: 10,
|
||||
@@ -94,7 +94,7 @@ feature 'Commenting Budget::Investments' do
|
||||
expect(c2.body).to appear_before(c3.body)
|
||||
end
|
||||
|
||||
scenario 'Creation date works differently in roots and in child comments, when sorting by confidence_score' do
|
||||
scenario "Creation date works differently in roots and in child comments, when sorting by confidence_score" do
|
||||
old_root = create(:comment, commentable: investment, created_at: Time.current - 10)
|
||||
new_root = create(:comment, commentable: investment, created_at: Time.current)
|
||||
old_child = create(:comment, commentable: investment, parent_id: new_root.id, created_at: Time.current - 10)
|
||||
@@ -116,39 +116,39 @@ feature 'Commenting Budget::Investments' do
|
||||
expect(old_child.body).to appear_before(new_child.body)
|
||||
end
|
||||
|
||||
scenario 'Turns links into html links' do
|
||||
create :comment, commentable: investment, body: 'Built with http://rubyonrails.org/'
|
||||
scenario "Turns links into html links" do
|
||||
create :comment, commentable: investment, body: "Built with http://rubyonrails.org/"
|
||||
|
||||
visit budget_investment_path(investment.budget, investment)
|
||||
|
||||
within first('.comment') do
|
||||
expect(page).to have_content 'Built with http://rubyonrails.org/'
|
||||
expect(page).to have_link('http://rubyonrails.org/', href: 'http://rubyonrails.org/')
|
||||
expect(find_link('http://rubyonrails.org/')[:rel]).to eq('nofollow')
|
||||
expect(find_link('http://rubyonrails.org/')[:target]).to eq('_blank')
|
||||
within first(".comment") do
|
||||
expect(page).to have_content "Built with http://rubyonrails.org/"
|
||||
expect(page).to have_link("http://rubyonrails.org/", href: "http://rubyonrails.org/")
|
||||
expect(find_link("http://rubyonrails.org/")[:rel]).to eq("nofollow")
|
||||
expect(find_link("http://rubyonrails.org/")[:target]).to eq("_blank")
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Sanitizes comment body for security' do
|
||||
scenario "Sanitizes comment body for security" do
|
||||
create :comment, commentable: investment,
|
||||
body: "<script>alert('hola')</script> <a href=\"javascript:alert('sorpresa!')\">click me<a/> http://www.url.com"
|
||||
|
||||
visit budget_investment_path(investment.budget, investment)
|
||||
|
||||
within first('.comment') do
|
||||
within first(".comment") do
|
||||
expect(page).to have_content "click me http://www.url.com"
|
||||
expect(page).to have_link('http://www.url.com', href: 'http://www.url.com')
|
||||
expect(page).not_to have_link('click me')
|
||||
expect(page).to have_link("http://www.url.com", href: "http://www.url.com")
|
||||
expect(page).not_to have_link("click me")
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Paginated comments' do
|
||||
scenario "Paginated comments" do
|
||||
per_page = 10
|
||||
(per_page + 2).times { create(:comment, commentable: investment)}
|
||||
|
||||
visit budget_investment_path(investment.budget, investment)
|
||||
|
||||
expect(page).to have_css('.comment', count: per_page)
|
||||
expect(page).to have_css(".comment", count: per_page)
|
||||
within("ul.pagination") do
|
||||
expect(page).to have_content("1")
|
||||
expect(page).to have_content("2")
|
||||
@@ -156,50 +156,50 @@ feature 'Commenting Budget::Investments' do
|
||||
click_link "Next", exact: false
|
||||
end
|
||||
|
||||
expect(page).to have_css('.comment', count: 2)
|
||||
expect(page).to have_css(".comment", count: 2)
|
||||
end
|
||||
|
||||
feature 'Not logged user' do
|
||||
scenario 'can not see comments forms' do
|
||||
feature "Not logged user" do
|
||||
scenario "can not see comments forms" do
|
||||
create(:comment, commentable: investment)
|
||||
visit budget_investment_path(investment.budget, investment)
|
||||
|
||||
expect(page).to have_content 'You must Sign in or Sign up to leave a comment'
|
||||
within('#comments') do
|
||||
expect(page).not_to have_content 'Write a comment'
|
||||
expect(page).not_to have_content 'Reply'
|
||||
expect(page).to have_content "You must Sign in or Sign up to leave a comment"
|
||||
within("#comments") do
|
||||
expect(page).not_to have_content "Write a comment"
|
||||
expect(page).not_to have_content "Reply"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Create', :js do
|
||||
scenario "Create", :js do
|
||||
login_as(user)
|
||||
visit budget_investment_path(investment.budget, investment)
|
||||
|
||||
fill_in "comment-body-budget_investment_#{investment.id}", with: 'Have you thought about...?'
|
||||
click_button 'Publish comment'
|
||||
fill_in "comment-body-budget_investment_#{investment.id}", with: "Have you thought about...?"
|
||||
click_button "Publish comment"
|
||||
|
||||
within "#tab-comments-label" do
|
||||
expect(page).to have_content 'Comments (1)'
|
||||
expect(page).to have_content "Comments (1)"
|
||||
end
|
||||
|
||||
within "#comments" do
|
||||
expect(page).to have_content 'Have you thought about...?'
|
||||
expect(page).to have_content "Have you thought about...?"
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Errors on create', :js do
|
||||
scenario "Errors on create", :js do
|
||||
login_as(user)
|
||||
visit budget_investment_path(investment.budget, investment)
|
||||
|
||||
click_button 'Publish comment'
|
||||
click_button "Publish comment"
|
||||
|
||||
expect(page).to have_content "Can't be blank"
|
||||
end
|
||||
|
||||
scenario 'Reply', :js do
|
||||
citizen = create(:user, username: 'Ana')
|
||||
manuela = create(:user, username: 'Manuela')
|
||||
scenario "Reply", :js do
|
||||
citizen = create(:user, username: "Ana")
|
||||
manuela = create(:user, username: "Manuela")
|
||||
comment = create(:comment, commentable: investment, user: citizen)
|
||||
|
||||
login_as(manuela)
|
||||
@@ -208,18 +208,18 @@ feature 'Commenting Budget::Investments' do
|
||||
click_link "Reply"
|
||||
|
||||
within "#js-comment-form-comment_#{comment.id}" do
|
||||
fill_in "comment-body-comment_#{comment.id}", with: 'It will be done next week.'
|
||||
click_button 'Publish reply'
|
||||
fill_in "comment-body-comment_#{comment.id}", with: "It will be done next week."
|
||||
click_button "Publish reply"
|
||||
end
|
||||
|
||||
within "#comment_#{comment.id}" do
|
||||
expect(page).to have_content 'It will be done next week.'
|
||||
expect(page).to have_content "It will be done next week."
|
||||
end
|
||||
|
||||
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}", visible: true)
|
||||
end
|
||||
|
||||
scenario 'Errors on reply', :js do
|
||||
scenario "Errors on reply", :js do
|
||||
comment = create(:comment, commentable: investment, user: user)
|
||||
|
||||
login_as(user)
|
||||
@@ -228,7 +228,7 @@ feature 'Commenting Budget::Investments' do
|
||||
click_link "Reply"
|
||||
|
||||
within "#js-comment-form-comment_#{comment.id}" do
|
||||
click_button 'Publish reply'
|
||||
click_button "Publish reply"
|
||||
expect(page).to have_content "Can't be blank"
|
||||
end
|
||||
|
||||
@@ -300,8 +300,8 @@ feature 'Commenting Budget::Investments' do
|
||||
|
||||
visit budget_investment_path(investment.budget, investment)
|
||||
within "#comment_#{comment.id}" do
|
||||
expect(page).to have_content('User deleted')
|
||||
expect(page).to have_content('this should be visible')
|
||||
expect(page).to have_content("User deleted")
|
||||
expect(page).to have_content("this should be visible")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -338,7 +338,7 @@ feature 'Commenting Budget::Investments' do
|
||||
within "#js-comment-form-comment_#{comment.id}" do
|
||||
fill_in "comment-body-comment_#{comment.id}", with: "I am moderating!"
|
||||
check "comment-as-moderator-comment_#{comment.id}"
|
||||
click_button 'Publish reply'
|
||||
click_button "Publish reply"
|
||||
end
|
||||
|
||||
within "#comment_#{comment.id}" do
|
||||
@@ -394,7 +394,7 @@ feature 'Commenting Budget::Investments' do
|
||||
within "#js-comment-form-comment_#{comment.id}" do
|
||||
fill_in "comment-body-comment_#{comment.id}", with: "Top of the world!"
|
||||
check "comment-as-administrator-comment_#{comment.id}"
|
||||
click_button 'Publish reply'
|
||||
click_button "Publish reply"
|
||||
end
|
||||
|
||||
within "#comment_#{comment.id}" do
|
||||
@@ -417,7 +417,7 @@ feature 'Commenting Budget::Investments' do
|
||||
end
|
||||
end
|
||||
|
||||
feature 'Voting comments' do
|
||||
feature "Voting comments" do
|
||||
|
||||
background do
|
||||
@manuela = create(:user, verified_at: Time.current)
|
||||
@@ -429,7 +429,7 @@ feature 'Commenting Budget::Investments' do
|
||||
login_as(@manuela)
|
||||
end
|
||||
|
||||
scenario 'Show' do
|
||||
scenario "Show" do
|
||||
create(:vote, voter: @manuela, votable: @comment, vote_flag: true)
|
||||
create(:vote, voter: @pablo, votable: @comment, vote_flag: false)
|
||||
|
||||
@@ -448,7 +448,7 @@ feature 'Commenting Budget::Investments' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Create', :js do
|
||||
scenario "Create", :js do
|
||||
visit budget_investment_path(@budget, @investment)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
@@ -466,23 +466,23 @@ feature 'Commenting Budget::Investments' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Update', :js do
|
||||
scenario "Update", :js do
|
||||
visit budget_investment_path(@budget, @investment)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
find('.in_favor a').click
|
||||
find(".in_favor a").click
|
||||
|
||||
within('.in_favor') do
|
||||
within(".in_favor") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
find('.against a').click
|
||||
find(".against a").click
|
||||
|
||||
within('.in_favor') do
|
||||
within(".in_favor") do
|
||||
expect(page).to have_content "0"
|
||||
end
|
||||
|
||||
within('.against') do
|
||||
within(".against") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
@@ -490,18 +490,18 @@ feature 'Commenting Budget::Investments' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Trying to vote multiple times', :js do
|
||||
scenario "Trying to vote multiple times", :js do
|
||||
visit budget_investment_path(@budget, @investment)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
find('.in_favor a').click
|
||||
find('.in_favor a').click
|
||||
find(".in_favor a").click
|
||||
find(".in_favor a").click
|
||||
|
||||
within('.in_favor') do
|
||||
within(".in_favor") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
within('.against') do
|
||||
within(".against") do
|
||||
expect(page).to have_content "0"
|
||||
end
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Internal valuation comments on Budget::Investments' do
|
||||
feature "Internal valuation comments on Budget::Investments" do
|
||||
let(:user) { create(:user) }
|
||||
let(:valuator_user) { create(:valuator).user }
|
||||
let(:admin_user) { create(:administrator).user }
|
||||
@@ -10,63 +10,63 @@ feature 'Internal valuation comments on Budget::Investments' do
|
||||
let(:investment) { create(:budget_investment, budget: budget, group: group, heading: heading) }
|
||||
|
||||
background do
|
||||
Setting['feature.budgets'] = true
|
||||
Setting["feature.budgets"] = true
|
||||
investment.valuators << valuator_user.valuator
|
||||
login_as(valuator_user)
|
||||
end
|
||||
|
||||
after do
|
||||
Setting['feature.budgets'] = nil
|
||||
Setting["feature.budgets"] = nil
|
||||
end
|
||||
|
||||
context 'Show valuation comments' do
|
||||
context 'Show valuation comments without public comments' do
|
||||
context "Show valuation comments" do
|
||||
context "Show valuation comments without public comments" do
|
||||
background do
|
||||
public_comment = create(:comment, commentable: investment, body: 'Public comment')
|
||||
public_comment = create(:comment, commentable: investment, body: "Public comment")
|
||||
create(:comment, commentable: investment, author: valuator_user,
|
||||
body: 'Public valuator comment')
|
||||
body: "Public valuator comment")
|
||||
create(:comment, commentable: investment, author: admin_user, parent: public_comment)
|
||||
|
||||
valuator_valuation = create(:comment, :valuation, commentable: investment,
|
||||
author: valuator_user,
|
||||
body: 'Valuator Valuation')
|
||||
body: "Valuator Valuation")
|
||||
create(:comment, :valuation, commentable: investment, author: admin_user,
|
||||
body: 'Admin Valuation')
|
||||
body: "Admin Valuation")
|
||||
admin_response = create(:comment, :valuation, commentable: investment, author: admin_user,
|
||||
body: 'Admin Valuation response',
|
||||
body: "Admin Valuation response",
|
||||
parent: valuator_valuation)
|
||||
create(:comment, :valuation, commentable: investment, author: admin_user,
|
||||
body: 'Valuator Valuation response', parent: admin_response)
|
||||
body: "Valuator Valuation response", parent: admin_response)
|
||||
end
|
||||
|
||||
scenario 'Valuation Show page without public comments' do
|
||||
scenario "Valuation Show page without public comments" do
|
||||
visit valuation_budget_budget_investment_path(budget, investment)
|
||||
|
||||
expect(page).not_to have_content('Comment as admin')
|
||||
expect(page).not_to have_content('Public comment')
|
||||
expect(page).not_to have_content('Public valuator comment')
|
||||
expect(page).to have_content('Leave your comment')
|
||||
expect(page).to have_content('Valuator Valuation')
|
||||
expect(page).to have_content('Admin Valuation')
|
||||
expect(page).to have_content('Admin Valuation response')
|
||||
expect(page).to have_content('Valuator Valuation response')
|
||||
expect(page).not_to have_content("Comment as admin")
|
||||
expect(page).not_to have_content("Public comment")
|
||||
expect(page).not_to have_content("Public valuator comment")
|
||||
expect(page).to have_content("Leave your comment")
|
||||
expect(page).to have_content("Valuator Valuation")
|
||||
expect(page).to have_content("Admin Valuation")
|
||||
expect(page).to have_content("Admin Valuation response")
|
||||
expect(page).to have_content("Valuator Valuation response")
|
||||
end
|
||||
|
||||
scenario 'Valuation Edit page without public comments' do
|
||||
scenario "Valuation Edit page without public comments" do
|
||||
visit edit_valuation_budget_budget_investment_path(budget, investment)
|
||||
|
||||
expect(page).not_to have_content('Comment as admin')
|
||||
expect(page).not_to have_content('Public comment')
|
||||
expect(page).not_to have_content('Public valuator comment')
|
||||
expect(page).to have_content('Leave your comment')
|
||||
expect(page).to have_content('Valuator Valuation')
|
||||
expect(page).to have_content('Admin Valuation')
|
||||
expect(page).to have_content('Admin Valuation response')
|
||||
expect(page).to have_content('Valuator Valuation response')
|
||||
expect(page).not_to have_content("Comment as admin")
|
||||
expect(page).not_to have_content("Public comment")
|
||||
expect(page).not_to have_content("Public valuator comment")
|
||||
expect(page).to have_content("Leave your comment")
|
||||
expect(page).to have_content("Valuator Valuation")
|
||||
expect(page).to have_content("Admin Valuation")
|
||||
expect(page).to have_content("Admin Valuation response")
|
||||
expect(page).to have_content("Valuator Valuation response")
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Collapsable comments', :js do
|
||||
scenario "Collapsable comments", :js do
|
||||
parent_comment = create(:comment, :valuation, author: valuator_user, body: "Main comment",
|
||||
commentable: investment)
|
||||
child_comment = create(:comment, :valuation, author: valuator_user, body: "First child",
|
||||
@@ -78,55 +78,55 @@ feature 'Internal valuation comments on Budget::Investments' do
|
||||
|
||||
visit valuation_budget_budget_investment_path(budget, investment)
|
||||
|
||||
expect(page).to have_css('.comment', count: 3)
|
||||
expect(page).to have_css(".comment", count: 3)
|
||||
|
||||
find("#comment_#{child_comment.id}_children_arrow").click
|
||||
|
||||
expect(page).to have_css('.comment', count: 2)
|
||||
expect(page).to have_css(".comment", count: 2)
|
||||
expect(page).not_to have_content grandchild_comment.body
|
||||
|
||||
find("#comment_#{child_comment.id}_children_arrow").click
|
||||
|
||||
expect(page).to have_css('.comment', count: 3)
|
||||
expect(page).to have_css(".comment", count: 3)
|
||||
expect(page).to have_content grandchild_comment.body
|
||||
|
||||
find("#comment_#{parent_comment.id}_children_arrow").click
|
||||
|
||||
expect(page).to have_css('.comment', count: 1)
|
||||
expect(page).to have_css(".comment", count: 1)
|
||||
expect(page).not_to have_content child_comment.body
|
||||
expect(page).not_to have_content grandchild_comment.body
|
||||
end
|
||||
|
||||
scenario 'Comment order' do
|
||||
scenario "Comment order" do
|
||||
create(:comment, :valuation, commentable: investment,
|
||||
author: valuator_user,
|
||||
body: 'Valuator Valuation',
|
||||
body: "Valuator Valuation",
|
||||
created_at: Time.current - 1)
|
||||
admin_valuation = create(:comment, :valuation, commentable: investment,
|
||||
author: admin_user,
|
||||
body: 'Admin Valuation',
|
||||
body: "Admin Valuation",
|
||||
created_at: Time.current - 2)
|
||||
|
||||
visit valuation_budget_budget_investment_path(budget, investment)
|
||||
|
||||
expect(admin_valuation.body).to appear_before('Valuator Valuation')
|
||||
expect(admin_valuation.body).to appear_before("Valuator Valuation")
|
||||
end
|
||||
|
||||
scenario 'Turns links into html links' do
|
||||
scenario "Turns links into html links" do
|
||||
create(:comment, :valuation, author: admin_user, commentable: investment,
|
||||
body: 'Check http://rubyonrails.org/')
|
||||
body: "Check http://rubyonrails.org/")
|
||||
|
||||
visit valuation_budget_budget_investment_path(budget, investment)
|
||||
|
||||
within first('.comment') do
|
||||
expect(page).to have_content('Check http://rubyonrails.org/')
|
||||
expect(page).to have_link('http://rubyonrails.org/', href: 'http://rubyonrails.org/')
|
||||
expect(find_link('http://rubyonrails.org/')[:rel]).to eq('nofollow')
|
||||
expect(find_link('http://rubyonrails.org/')[:target]).to eq('_blank')
|
||||
within first(".comment") do
|
||||
expect(page).to have_content("Check http://rubyonrails.org/")
|
||||
expect(page).to have_link("http://rubyonrails.org/", href: "http://rubyonrails.org/")
|
||||
expect(find_link("http://rubyonrails.org/")[:rel]).to eq("nofollow")
|
||||
expect(find_link("http://rubyonrails.org/")[:target]).to eq("_blank")
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Sanitizes comment body for security' do
|
||||
scenario "Sanitizes comment body for security" do
|
||||
comment_with_js = "<script>alert('hola')</script> <a href=\"javascript:alert('sorpresa!')\">"\
|
||||
"click me<a/> http://www.url.com"
|
||||
create(:comment, :valuation, author: admin_user, commentable: investment,
|
||||
@@ -134,14 +134,14 @@ feature 'Internal valuation comments on Budget::Investments' do
|
||||
|
||||
visit valuation_budget_budget_investment_path(budget, investment)
|
||||
|
||||
within first('.comment') do
|
||||
within first(".comment") do
|
||||
expect(page).to have_content("click me http://www.url.com")
|
||||
expect(page).to have_link('http://www.url.com', href: 'http://www.url.com')
|
||||
expect(page).not_to have_link('click me')
|
||||
expect(page).to have_link("http://www.url.com", href: "http://www.url.com")
|
||||
expect(page).not_to have_link("click me")
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Paginated comments' do
|
||||
scenario "Paginated comments" do
|
||||
per_page = 10
|
||||
(per_page + 2).times do
|
||||
create(:comment, :valuation, commentable: investment, author: valuator_user)
|
||||
@@ -149,7 +149,7 @@ feature 'Internal valuation comments on Budget::Investments' do
|
||||
|
||||
visit valuation_budget_budget_investment_path(budget, investment)
|
||||
|
||||
expect(page).to have_css('.comment', count: per_page)
|
||||
expect(page).to have_css(".comment", count: per_page)
|
||||
within("ul.pagination") do
|
||||
expect(page).to have_content("1")
|
||||
expect(page).to have_content("2")
|
||||
@@ -157,40 +157,40 @@ feature 'Internal valuation comments on Budget::Investments' do
|
||||
click_link "Next", exact: false
|
||||
end
|
||||
|
||||
expect(page).to have_css('.comment', count: 2)
|
||||
expect(page).to have_css(".comment", count: 2)
|
||||
end
|
||||
end
|
||||
|
||||
context 'Valuation comment creation' do
|
||||
scenario 'Normal users cannot create valuation comments altering public comments form' do
|
||||
comment = build(:comment, body: 'HACKERMAN IS HERE', valuation: true, author: user)
|
||||
context "Valuation comment creation" do
|
||||
scenario "Normal users cannot create valuation comments altering public comments form" do
|
||||
comment = build(:comment, body: "HACKERMAN IS HERE", valuation: true, author: user)
|
||||
expect(comment).not_to be_valid
|
||||
expect(comment.errors.size).to eq(1)
|
||||
end
|
||||
|
||||
scenario 'Create comment', :js do
|
||||
scenario "Create comment", :js do
|
||||
visit valuation_budget_budget_investment_path(budget, investment)
|
||||
|
||||
fill_in "comment-body-budget_investment_#{investment.id}", with: 'Have you thought about...?'
|
||||
click_button 'Publish comment'
|
||||
fill_in "comment-body-budget_investment_#{investment.id}", with: "Have you thought about...?"
|
||||
click_button "Publish comment"
|
||||
|
||||
within "#comments" do
|
||||
expect(page).to have_content('Have you thought about...?')
|
||||
expect(page).to have_content("Have you thought about...?")
|
||||
end
|
||||
|
||||
visit budget_investment_path(investment.budget, investment)
|
||||
expect(page).not_to have_content('Have you thought about...?')
|
||||
expect(page).not_to have_content("Have you thought about...?")
|
||||
end
|
||||
|
||||
scenario 'Errors on create without comment text', :js do
|
||||
scenario "Errors on create without comment text", :js do
|
||||
visit valuation_budget_budget_investment_path(budget, investment)
|
||||
|
||||
click_button 'Publish comment'
|
||||
click_button "Publish comment"
|
||||
|
||||
expect(page).to have_content "Can't be blank"
|
||||
end
|
||||
|
||||
scenario 'Reply to existing valuation', :js do
|
||||
scenario "Reply to existing valuation", :js do
|
||||
comment = create(:comment, :valuation, author: admin_user, commentable: investment)
|
||||
|
||||
login_as(valuator_user)
|
||||
@@ -199,21 +199,21 @@ feature 'Internal valuation comments on Budget::Investments' do
|
||||
click_link "Reply"
|
||||
|
||||
within "#js-comment-form-comment_#{comment.id}" do
|
||||
fill_in "comment-body-comment_#{comment.id}", with: 'It will be done next week.'
|
||||
click_button 'Publish reply'
|
||||
fill_in "comment-body-comment_#{comment.id}", with: "It will be done next week."
|
||||
click_button "Publish reply"
|
||||
end
|
||||
|
||||
within "#comment_#{comment.id}" do
|
||||
expect(page).to have_content 'It will be done next week.'
|
||||
expect(page).to have_content "It will be done next week."
|
||||
end
|
||||
|
||||
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}", visible: true)
|
||||
|
||||
visit budget_investment_path(investment.budget, investment)
|
||||
expect(page).not_to have_content('It will be done next week.')
|
||||
expect(page).not_to have_content("It will be done next week.")
|
||||
end
|
||||
|
||||
scenario 'Errors on reply without comment text', :js do
|
||||
scenario "Errors on reply without comment text", :js do
|
||||
comment = create(:comment, :valuation, author: admin_user, commentable: investment)
|
||||
|
||||
visit valuation_budget_budget_investment_path(budget, investment)
|
||||
@@ -221,7 +221,7 @@ feature 'Internal valuation comments on Budget::Investments' do
|
||||
click_link "Reply"
|
||||
|
||||
within "#js-comment-form-comment_#{comment.id}" do
|
||||
click_button 'Publish reply'
|
||||
click_button "Publish reply"
|
||||
expect(page).to have_content "Can't be blank"
|
||||
end
|
||||
|
||||
@@ -238,9 +238,9 @@ feature 'Internal valuation comments on Budget::Investments' do
|
||||
visit valuation_budget_budget_investment_path(budget, investment)
|
||||
expect(page).to have_css(".comment.comment.comment.comment.comment.comment.comment.comment")
|
||||
|
||||
expect(page).to have_no_css('.comment-votes')
|
||||
expect(page).to have_no_css('.js-flag-actions')
|
||||
expect(page).to have_no_css('.js-moderation-actions')
|
||||
expect(page).to have_no_css(".comment-votes")
|
||||
expect(page).to have_no_css(".js-flag-actions")
|
||||
expect(page).to have_no_css(".js-moderation-actions")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -251,8 +251,8 @@ feature 'Internal valuation comments on Budget::Investments' do
|
||||
|
||||
visit valuation_budget_budget_investment_path(budget, investment)
|
||||
within "#comment_#{comment.id}" do
|
||||
expect(page).to have_content('User deleted')
|
||||
expect(page).to have_content('this should be visible')
|
||||
expect(page).to have_content("User deleted")
|
||||
expect(page).to have_content("this should be visible")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -284,7 +284,7 @@ feature 'Internal valuation comments on Budget::Investments' do
|
||||
within "#js-comment-form-comment_#{comment.id}" do
|
||||
fill_in "comment-body-comment_#{comment.id}", with: "Top of the world!"
|
||||
check "comment-as-administrator-comment_#{comment.id}"
|
||||
click_button 'Publish reply'
|
||||
click_button "Publish reply"
|
||||
end
|
||||
|
||||
within "#comment_#{comment.id}" do
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
include ActionView::Helpers::DateHelper
|
||||
|
||||
feature 'Commenting debates' do
|
||||
feature "Commenting debates" do
|
||||
let(:user) { create :user }
|
||||
let(:debate) { create :debate }
|
||||
|
||||
scenario 'Index' do
|
||||
scenario "Index" do
|
||||
3.times { create(:comment, commentable: debate) }
|
||||
|
||||
visit debate_path(debate)
|
||||
|
||||
expect(page).to have_css('.comment', count: 3)
|
||||
expect(page).to have_css(".comment", count: 3)
|
||||
|
||||
comment = Comment.last
|
||||
within first('.comment') do
|
||||
within first(".comment") do
|
||||
expect(page).to have_content comment.user.name
|
||||
expect(page).to have_content I18n.l(comment.created_at, format: :datetime)
|
||||
expect(page).to have_content comment.body
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Show' do
|
||||
scenario "Show" do
|
||||
parent_comment = create(:comment, commentable: debate)
|
||||
first_child = create(:comment, commentable: debate, parent: parent_comment)
|
||||
second_child = create(:comment, commentable: debate, parent: parent_comment)
|
||||
@@ -39,33 +39,33 @@ feature 'Commenting debates' do
|
||||
expect(page).to have_selector("ul#comment_#{second_child.id}>li", count: 1)
|
||||
end
|
||||
|
||||
scenario 'Collapsable comments', :js do
|
||||
scenario "Collapsable comments", :js do
|
||||
parent_comment = create(:comment, body: "Main comment", commentable: debate)
|
||||
child_comment = create(:comment, body: "First subcomment", commentable: debate, parent: parent_comment)
|
||||
grandchild_comment = create(:comment, body: "Last subcomment", commentable: debate, parent: child_comment)
|
||||
|
||||
visit debate_path(debate)
|
||||
|
||||
expect(page).to have_css('.comment', count: 3)
|
||||
expect(page).to have_css(".comment", count: 3)
|
||||
|
||||
find("#comment_#{child_comment.id}_children_arrow").click
|
||||
|
||||
expect(page).to have_css('.comment', count: 2)
|
||||
expect(page).to have_css(".comment", count: 2)
|
||||
expect(page).not_to have_content grandchild_comment.body
|
||||
|
||||
find("#comment_#{child_comment.id}_children_arrow").click
|
||||
|
||||
expect(page).to have_css('.comment', count: 3)
|
||||
expect(page).to have_css(".comment", count: 3)
|
||||
expect(page).to have_content grandchild_comment.body
|
||||
|
||||
find("#comment_#{parent_comment.id}_children_arrow").click
|
||||
|
||||
expect(page).to have_css('.comment', count: 1)
|
||||
expect(page).to have_css(".comment", count: 1)
|
||||
expect(page).not_to have_content child_comment.body
|
||||
expect(page).not_to have_content grandchild_comment.body
|
||||
end
|
||||
|
||||
scenario 'Comment order' do
|
||||
scenario "Comment order" do
|
||||
c1 = create(:comment, :with_confidence_score, commentable: debate, cached_votes_up: 100,
|
||||
cached_votes_total: 120, created_at: Time.current - 2)
|
||||
c2 = create(:comment, :with_confidence_score, commentable: debate, cached_votes_up: 10,
|
||||
@@ -89,7 +89,7 @@ feature 'Commenting debates' do
|
||||
expect(c2.body).to appear_before(c3.body)
|
||||
end
|
||||
|
||||
scenario 'Creation date works differently in roots and in child comments, even when sorting by confidence_score' do
|
||||
scenario "Creation date works differently in roots and in child comments, even when sorting by confidence_score" do
|
||||
old_root = create(:comment, commentable: debate, created_at: Time.current - 10)
|
||||
new_root = create(:comment, commentable: debate, created_at: Time.current)
|
||||
old_child = create(:comment, commentable: debate, parent_id: new_root.id, created_at: Time.current - 10)
|
||||
@@ -111,39 +111,39 @@ feature 'Commenting debates' do
|
||||
expect(old_child.body).to appear_before(new_child.body)
|
||||
end
|
||||
|
||||
scenario 'Turns links into html links' do
|
||||
create :comment, commentable: debate, body: 'Built with http://rubyonrails.org/'
|
||||
scenario "Turns links into html links" do
|
||||
create :comment, commentable: debate, body: "Built with http://rubyonrails.org/"
|
||||
|
||||
visit debate_path(debate)
|
||||
|
||||
within first('.comment') do
|
||||
expect(page).to have_content 'Built with http://rubyonrails.org/'
|
||||
expect(page).to have_link('http://rubyonrails.org/', href: 'http://rubyonrails.org/')
|
||||
expect(find_link('http://rubyonrails.org/')[:rel]).to eq('nofollow')
|
||||
expect(find_link('http://rubyonrails.org/')[:target]).to eq('_blank')
|
||||
within first(".comment") do
|
||||
expect(page).to have_content "Built with http://rubyonrails.org/"
|
||||
expect(page).to have_link("http://rubyonrails.org/", href: "http://rubyonrails.org/")
|
||||
expect(find_link("http://rubyonrails.org/")[:rel]).to eq("nofollow")
|
||||
expect(find_link("http://rubyonrails.org/")[:target]).to eq("_blank")
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Sanitizes comment body for security' do
|
||||
scenario "Sanitizes comment body for security" do
|
||||
create :comment, commentable: debate,
|
||||
body: "<script>alert('hola')</script> <a href=\"javascript:alert('sorpresa!')\">click me<a/> http://www.url.com"
|
||||
|
||||
visit debate_path(debate)
|
||||
|
||||
within first('.comment') do
|
||||
within first(".comment") do
|
||||
expect(page).to have_content "click me http://www.url.com"
|
||||
expect(page).to have_link('http://www.url.com', href: 'http://www.url.com')
|
||||
expect(page).not_to have_link('click me')
|
||||
expect(page).to have_link("http://www.url.com", href: "http://www.url.com")
|
||||
expect(page).not_to have_link("click me")
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Paginated comments' do
|
||||
scenario "Paginated comments" do
|
||||
per_page = 10
|
||||
(per_page + 2).times { create(:comment, commentable: debate)}
|
||||
|
||||
visit debate_path(debate)
|
||||
|
||||
expect(page).to have_css('.comment', count: per_page)
|
||||
expect(page).to have_css(".comment", count: per_page)
|
||||
within("ul.pagination") do
|
||||
expect(page).to have_content("1")
|
||||
expect(page).to have_content("2")
|
||||
@@ -151,47 +151,47 @@ feature 'Commenting debates' do
|
||||
click_link "Next", exact: false
|
||||
end
|
||||
|
||||
expect(page).to have_css('.comment', count: 2)
|
||||
expect(page).to have_css(".comment", count: 2)
|
||||
end
|
||||
|
||||
feature 'Not logged user' do
|
||||
scenario 'can not see comments forms' do
|
||||
feature "Not logged user" do
|
||||
scenario "can not see comments forms" do
|
||||
create(:comment, commentable: debate)
|
||||
visit debate_path(debate)
|
||||
|
||||
expect(page).to have_content 'You must Sign in or Sign up to leave a comment'
|
||||
within('#comments') do
|
||||
expect(page).not_to have_content 'Write a comment'
|
||||
expect(page).not_to have_content 'Reply'
|
||||
expect(page).to have_content "You must Sign in or Sign up to leave a comment"
|
||||
within("#comments") do
|
||||
expect(page).not_to have_content "Write a comment"
|
||||
expect(page).not_to have_content "Reply"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Create', :js do
|
||||
scenario "Create", :js do
|
||||
login_as(user)
|
||||
visit debate_path(debate)
|
||||
|
||||
fill_in "comment-body-debate_#{debate.id}", with: 'Have you thought about...?'
|
||||
click_button 'Publish comment'
|
||||
fill_in "comment-body-debate_#{debate.id}", with: "Have you thought about...?"
|
||||
click_button "Publish comment"
|
||||
|
||||
within "#comments" do
|
||||
expect(page).to have_content 'Have you thought about...?'
|
||||
expect(page).to have_content '(1)'
|
||||
expect(page).to have_content "Have you thought about...?"
|
||||
expect(page).to have_content "(1)"
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Errors on create', :js do
|
||||
scenario "Errors on create", :js do
|
||||
login_as(user)
|
||||
visit debate_path(debate)
|
||||
|
||||
click_button 'Publish comment'
|
||||
click_button "Publish comment"
|
||||
|
||||
expect(page).to have_content "Can't be blank"
|
||||
end
|
||||
|
||||
scenario 'Reply', :js do
|
||||
citizen = create(:user, username: 'Ana')
|
||||
manuela = create(:user, username: 'Manuela')
|
||||
scenario "Reply", :js do
|
||||
citizen = create(:user, username: "Ana")
|
||||
manuela = create(:user, username: "Manuela")
|
||||
comment = create(:comment, commentable: debate, user: citizen)
|
||||
|
||||
login_as(manuela)
|
||||
@@ -200,18 +200,18 @@ feature 'Commenting debates' do
|
||||
click_link "Reply"
|
||||
|
||||
within "#js-comment-form-comment_#{comment.id}" do
|
||||
fill_in "comment-body-comment_#{comment.id}", with: 'It will be done next week.'
|
||||
click_button 'Publish reply'
|
||||
fill_in "comment-body-comment_#{comment.id}", with: "It will be done next week."
|
||||
click_button "Publish reply"
|
||||
end
|
||||
|
||||
within "#comment_#{comment.id}" do
|
||||
expect(page).to have_content 'It will be done next week.'
|
||||
expect(page).to have_content "It will be done next week."
|
||||
end
|
||||
|
||||
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}", visible: true)
|
||||
end
|
||||
|
||||
scenario 'Errors on reply', :js do
|
||||
scenario "Errors on reply", :js do
|
||||
comment = create(:comment, commentable: debate, user: user)
|
||||
|
||||
login_as(user)
|
||||
@@ -220,7 +220,7 @@ feature 'Commenting debates' do
|
||||
click_link "Reply"
|
||||
|
||||
within "#js-comment-form-comment_#{comment.id}" do
|
||||
click_button 'Publish reply'
|
||||
click_button "Publish reply"
|
||||
expect(page).to have_content "Can't be blank"
|
||||
end
|
||||
|
||||
@@ -287,29 +287,29 @@ feature 'Commenting debates' do
|
||||
|
||||
scenario "Erasing a comment's author" do
|
||||
debate = create(:debate)
|
||||
comment = create(:comment, commentable: debate, body: 'this should be visible')
|
||||
comment = create(:comment, commentable: debate, body: "this should be visible")
|
||||
comment.user.erase
|
||||
|
||||
visit debate_path(debate)
|
||||
within "#comment_#{comment.id}" do
|
||||
expect(page).to have_content('User deleted')
|
||||
expect(page).to have_content('this should be visible')
|
||||
expect(page).to have_content("User deleted")
|
||||
expect(page).to have_content("this should be visible")
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Submit button is disabled after clicking', :js do
|
||||
scenario "Submit button is disabled after clicking", :js do
|
||||
debate = create(:debate)
|
||||
login_as(user)
|
||||
visit debate_path(debate)
|
||||
|
||||
fill_in "comment-body-debate_#{debate.id}", with: 'Testing submit button!'
|
||||
click_button 'Publish comment'
|
||||
fill_in "comment-body-debate_#{debate.id}", with: "Testing submit button!"
|
||||
click_button "Publish comment"
|
||||
|
||||
# The button's text should now be "..."
|
||||
# The button"s text should now be "..."
|
||||
# This should be checked before the Ajax request is finished
|
||||
expect(page).not_to have_button 'Publish comment'
|
||||
expect(page).not_to have_button "Publish comment"
|
||||
|
||||
expect(page).to have_content('Testing submit button!')
|
||||
expect(page).to have_content("Testing submit button!")
|
||||
end
|
||||
|
||||
feature "Moderators" do
|
||||
@@ -345,7 +345,7 @@ feature 'Commenting debates' do
|
||||
within "#js-comment-form-comment_#{comment.id}" do
|
||||
fill_in "comment-body-comment_#{comment.id}", with: "I am moderating!"
|
||||
check "comment-as-moderator-comment_#{comment.id}"
|
||||
click_button 'Publish reply'
|
||||
click_button "Publish reply"
|
||||
end
|
||||
|
||||
within "#comment_#{comment.id}" do
|
||||
@@ -401,7 +401,7 @@ feature 'Commenting debates' do
|
||||
within "#js-comment-form-comment_#{comment.id}" do
|
||||
fill_in "comment-body-comment_#{comment.id}", with: "Top of the world!"
|
||||
check "comment-as-administrator-comment_#{comment.id}"
|
||||
click_button 'Publish reply'
|
||||
click_button "Publish reply"
|
||||
end
|
||||
|
||||
within "#comment_#{comment.id}" do
|
||||
@@ -424,7 +424,7 @@ feature 'Commenting debates' do
|
||||
end
|
||||
end
|
||||
|
||||
feature 'Voting comments' do
|
||||
feature "Voting comments" do
|
||||
background do
|
||||
@manuela = create(:user, verified_at: Time.current)
|
||||
@pablo = create(:user)
|
||||
@@ -434,7 +434,7 @@ feature 'Commenting debates' do
|
||||
login_as(@manuela)
|
||||
end
|
||||
|
||||
scenario 'Show' do
|
||||
scenario "Show" do
|
||||
create(:vote, voter: @manuela, votable: @comment, vote_flag: true)
|
||||
create(:vote, voter: @pablo, votable: @comment, vote_flag: false)
|
||||
|
||||
@@ -453,7 +453,7 @@ feature 'Commenting debates' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Create', :js do
|
||||
scenario "Create", :js do
|
||||
visit debate_path(@debate)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
@@ -471,23 +471,23 @@ feature 'Commenting debates' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Update', :js do
|
||||
scenario "Update", :js do
|
||||
visit debate_path(@debate)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
find('.in_favor a').click
|
||||
find(".in_favor a").click
|
||||
|
||||
within('.in_favor') do
|
||||
within(".in_favor") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
find('.against a').click
|
||||
find(".against a").click
|
||||
|
||||
within('.in_favor') do
|
||||
within(".in_favor") do
|
||||
expect(page).to have_content "0"
|
||||
end
|
||||
|
||||
within('.against') do
|
||||
within(".against") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
@@ -495,22 +495,22 @@ feature 'Commenting debates' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Trying to vote multiple times', :js do
|
||||
scenario "Trying to vote multiple times", :js do
|
||||
visit debate_path(@debate)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
find('.in_favor a').click
|
||||
within('.in_favor') do
|
||||
find(".in_favor a").click
|
||||
within(".in_favor") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
find('.in_favor a').click
|
||||
within('.in_favor') do
|
||||
find(".in_favor a").click
|
||||
within(".in_favor") do
|
||||
expect(page).not_to have_content "2"
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
within('.against') do
|
||||
within(".against") do
|
||||
expect(page).to have_content "0"
|
||||
end
|
||||
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
include ActionView::Helpers::DateHelper
|
||||
|
||||
feature 'Commenting legislation questions' do
|
||||
feature "Commenting legislation questions" do
|
||||
let(:user) { create :user }
|
||||
let(:legislation_annotation) { create :legislation_annotation, author: user }
|
||||
|
||||
scenario 'Index' do
|
||||
scenario "Index" do
|
||||
3.times { create(:comment, commentable: legislation_annotation) }
|
||||
|
||||
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
|
||||
legislation_annotation.draft_version,
|
||||
legislation_annotation)
|
||||
|
||||
expect(page).to have_css('.comment', count: 4)
|
||||
expect(page).to have_css(".comment", count: 4)
|
||||
|
||||
comment = Comment.first
|
||||
within first('.comment') do
|
||||
within first(".comment") do
|
||||
expect(page).to have_content comment.user.name
|
||||
expect(page).to have_content I18n.l(comment.created_at, format: :datetime)
|
||||
expect(page).to have_content comment.body
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Show' do
|
||||
scenario "Show" do
|
||||
parent_comment = create(:comment, commentable: legislation_annotation)
|
||||
first_child = create(:comment, commentable: legislation_annotation, parent: parent_comment)
|
||||
second_child = create(:comment, commentable: legislation_annotation, parent: parent_comment)
|
||||
@@ -44,7 +44,7 @@ feature 'Commenting legislation questions' do
|
||||
expect(page).to have_selector("ul#comment_#{second_child.id}>li", count: 1)
|
||||
end
|
||||
|
||||
scenario 'Collapsable comments', :js do
|
||||
scenario "Collapsable comments", :js do
|
||||
parent_comment = legislation_annotation.comments.first
|
||||
child_comment = create(:comment, body: "First subcomment", commentable: legislation_annotation, parent: parent_comment)
|
||||
grandchild_comment = create(:comment, body: "Last subcomment", commentable: legislation_annotation, parent: child_comment)
|
||||
@@ -53,26 +53,26 @@ feature 'Commenting legislation questions' do
|
||||
legislation_annotation.draft_version,
|
||||
legislation_annotation)
|
||||
|
||||
expect(page).to have_css('.comment', count: 3)
|
||||
expect(page).to have_css(".comment", count: 3)
|
||||
|
||||
find("#comment_#{child_comment.id}_children_arrow").click
|
||||
|
||||
expect(page).to have_css('.comment', count: 2)
|
||||
expect(page).to have_css(".comment", count: 2)
|
||||
expect(page).not_to have_content grandchild_comment.body
|
||||
|
||||
find("#comment_#{child_comment.id}_children_arrow").click
|
||||
|
||||
expect(page).to have_css('.comment', count: 3)
|
||||
expect(page).to have_css(".comment", count: 3)
|
||||
expect(page).to have_content grandchild_comment.body
|
||||
|
||||
find("#comment_#{parent_comment.id}_children_arrow").click
|
||||
|
||||
expect(page).to have_css('.comment', count: 1)
|
||||
expect(page).to have_css(".comment", count: 1)
|
||||
expect(page).not_to have_content child_comment.body
|
||||
expect(page).not_to have_content grandchild_comment.body
|
||||
end
|
||||
|
||||
scenario 'Comment order' do
|
||||
scenario "Comment order" do
|
||||
c1 = create(:comment, :with_confidence_score, commentable: legislation_annotation, cached_votes_up: 100,
|
||||
cached_votes_total: 120, created_at: Time.current - 2)
|
||||
c2 = create(:comment, :with_confidence_score, commentable: legislation_annotation, cached_votes_up: 10,
|
||||
@@ -105,7 +105,7 @@ feature 'Commenting legislation questions' do
|
||||
expect(c2.body).to appear_before(c3.body)
|
||||
end
|
||||
|
||||
xscenario 'Creation date works differently in roots and in child comments, even when sorting by confidence_score' do
|
||||
xscenario "Creation date works differently in roots and in child comments, even when sorting by confidence_score" do
|
||||
old_root = create(:comment, commentable: legislation_annotation, created_at: Time.current - 10)
|
||||
new_root = create(:comment, commentable: legislation_annotation, created_at: Time.current)
|
||||
old_child = create(:comment, commentable: legislation_annotation, parent_id: new_root.id, created_at: Time.current - 10)
|
||||
@@ -136,23 +136,23 @@ feature 'Commenting legislation questions' do
|
||||
expect(old_child.body).to appear_before(new_child.body)
|
||||
end
|
||||
|
||||
scenario 'Turns links into html links' do
|
||||
scenario "Turns links into html links" do
|
||||
legislation_annotation = create :legislation_annotation, author: user
|
||||
legislation_annotation.comments << create(:comment, body: 'Built with http://rubyonrails.org/')
|
||||
legislation_annotation.comments << create(:comment, body: "Built with http://rubyonrails.org/")
|
||||
|
||||
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
|
||||
legislation_annotation.draft_version,
|
||||
legislation_annotation)
|
||||
|
||||
within all('.comment').last do
|
||||
expect(page).to have_content 'Built with http://rubyonrails.org/'
|
||||
expect(page).to have_link('http://rubyonrails.org/', href: 'http://rubyonrails.org/')
|
||||
expect(find_link('http://rubyonrails.org/')[:rel]).to eq('nofollow')
|
||||
expect(find_link('http://rubyonrails.org/')[:target]).to eq('_blank')
|
||||
within all(".comment").last do
|
||||
expect(page).to have_content "Built with http://rubyonrails.org/"
|
||||
expect(page).to have_link("http://rubyonrails.org/", href: "http://rubyonrails.org/")
|
||||
expect(find_link("http://rubyonrails.org/")[:rel]).to eq("nofollow")
|
||||
expect(find_link("http://rubyonrails.org/")[:target]).to eq("_blank")
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Sanitizes comment body for security' do
|
||||
scenario "Sanitizes comment body for security" do
|
||||
create :comment, commentable: legislation_annotation,
|
||||
body: "<script>alert('hola')</script> <a href=\"javascript:alert('sorpresa!')\">click me<a/> http://www.url.com"
|
||||
|
||||
@@ -160,14 +160,14 @@ feature 'Commenting legislation questions' do
|
||||
legislation_annotation.draft_version,
|
||||
legislation_annotation)
|
||||
|
||||
within all('.comment').last do
|
||||
within all(".comment").last do
|
||||
expect(page).to have_content "click me http://www.url.com"
|
||||
expect(page).to have_link('http://www.url.com', href: 'http://www.url.com')
|
||||
expect(page).not_to have_link('click me')
|
||||
expect(page).to have_link("http://www.url.com", href: "http://www.url.com")
|
||||
expect(page).not_to have_link("click me")
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Paginated comments' do
|
||||
scenario "Paginated comments" do
|
||||
per_page = 10
|
||||
(per_page + 2).times { create(:comment, commentable: legislation_annotation)}
|
||||
|
||||
@@ -175,7 +175,7 @@ feature 'Commenting legislation questions' do
|
||||
legislation_annotation.draft_version,
|
||||
legislation_annotation)
|
||||
|
||||
expect(page).to have_css('.comment', count: per_page)
|
||||
expect(page).to have_css(".comment", count: per_page)
|
||||
within("ul.pagination") do
|
||||
expect(page).to have_content("1")
|
||||
expect(page).to have_content("2")
|
||||
@@ -183,53 +183,53 @@ feature 'Commenting legislation questions' do
|
||||
click_link "Next", exact: false
|
||||
end
|
||||
|
||||
expect(page).to have_css('.comment', count: 3)
|
||||
expect(page).to have_css(".comment", count: 3)
|
||||
end
|
||||
|
||||
feature 'Not logged user' do
|
||||
scenario 'can not see comments forms' do
|
||||
feature "Not logged user" do
|
||||
scenario "can not see comments forms" do
|
||||
create(:comment, commentable: legislation_annotation)
|
||||
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
|
||||
legislation_annotation.draft_version,
|
||||
legislation_annotation)
|
||||
|
||||
expect(page).to have_content 'You must Sign in or Sign up to leave a comment'
|
||||
within('#comments') do
|
||||
expect(page).not_to have_content 'Write a comment'
|
||||
expect(page).not_to have_content 'Reply'
|
||||
expect(page).to have_content "You must Sign in or Sign up to leave a comment"
|
||||
within("#comments") do
|
||||
expect(page).not_to have_content "Write a comment"
|
||||
expect(page).not_to have_content "Reply"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Create', :js do
|
||||
scenario "Create", :js do
|
||||
login_as(user)
|
||||
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
|
||||
legislation_annotation.draft_version,
|
||||
legislation_annotation)
|
||||
|
||||
fill_in "comment-body-legislation_annotation_#{legislation_annotation.id}", with: 'Have you thought about...?'
|
||||
click_button 'Publish comment'
|
||||
fill_in "comment-body-legislation_annotation_#{legislation_annotation.id}", with: "Have you thought about...?"
|
||||
click_button "Publish comment"
|
||||
|
||||
within "#comments" do
|
||||
expect(page).to have_content 'Have you thought about...?'
|
||||
expect(page).to have_content '(2)'
|
||||
expect(page).to have_content "Have you thought about...?"
|
||||
expect(page).to have_content "(2)"
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Errors on create', :js do
|
||||
scenario "Errors on create", :js do
|
||||
login_as(user)
|
||||
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
|
||||
legislation_annotation.draft_version,
|
||||
legislation_annotation)
|
||||
|
||||
click_button 'Publish comment'
|
||||
click_button "Publish comment"
|
||||
|
||||
expect(page).to have_content "Can't be blank"
|
||||
end
|
||||
|
||||
scenario 'Reply', :js do
|
||||
citizen = create(:user, username: 'Ana')
|
||||
manuela = create(:user, username: 'Manuela')
|
||||
scenario "Reply", :js do
|
||||
citizen = create(:user, username: "Ana")
|
||||
manuela = create(:user, username: "Manuela")
|
||||
legislation_annotation = create(:legislation_annotation, author: citizen)
|
||||
comment = legislation_annotation.comments.first
|
||||
|
||||
@@ -241,18 +241,18 @@ feature 'Commenting legislation questions' do
|
||||
click_link "Reply"
|
||||
|
||||
within "#js-comment-form-comment_#{comment.id}" do
|
||||
fill_in "comment-body-comment_#{comment.id}", with: 'It will be done next week.'
|
||||
click_button 'Publish reply'
|
||||
fill_in "comment-body-comment_#{comment.id}", with: "It will be done next week."
|
||||
click_button "Publish reply"
|
||||
end
|
||||
|
||||
within "#comment_#{comment.id}" do
|
||||
expect(page).to have_content 'It will be done next week.'
|
||||
expect(page).to have_content "It will be done next week."
|
||||
end
|
||||
|
||||
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}", visible: true)
|
||||
end
|
||||
|
||||
scenario 'Errors on reply', :js do
|
||||
scenario "Errors on reply", :js do
|
||||
comment = legislation_annotation.comments.first
|
||||
|
||||
login_as(user)
|
||||
@@ -263,7 +263,7 @@ feature 'Commenting legislation questions' do
|
||||
click_link "Reply"
|
||||
|
||||
within "#js-comment-form-comment_#{comment.id}" do
|
||||
click_button 'Publish reply'
|
||||
click_button "Publish reply"
|
||||
expect(page).to have_content "Can't be blank"
|
||||
end
|
||||
|
||||
@@ -338,7 +338,7 @@ feature 'Commenting legislation questions' do
|
||||
|
||||
scenario "Erasing a comment's author" do
|
||||
legislation_annotation = create(:legislation_annotation)
|
||||
comment = create(:comment, commentable: legislation_annotation, body: 'this should be visible')
|
||||
comment = create(:comment, commentable: legislation_annotation, body: "this should be visible")
|
||||
comment.user.erase
|
||||
|
||||
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process,
|
||||
@@ -346,12 +346,12 @@ feature 'Commenting legislation questions' do
|
||||
legislation_annotation)
|
||||
|
||||
within "#comment_#{comment.id}" do
|
||||
expect(page).to have_content('User deleted')
|
||||
expect(page).to have_content('this should be visible')
|
||||
expect(page).to have_content("User deleted")
|
||||
expect(page).to have_content("this should be visible")
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Submit button is disabled after clicking', :js do
|
||||
scenario "Submit button is disabled after clicking", :js do
|
||||
legislation_annotation = create(:legislation_annotation)
|
||||
login_as(user)
|
||||
|
||||
@@ -359,14 +359,14 @@ feature 'Commenting legislation questions' do
|
||||
legislation_annotation.draft_version,
|
||||
legislation_annotation)
|
||||
|
||||
fill_in "comment-body-legislation_annotation_#{legislation_annotation.id}", with: 'Testing submit button!'
|
||||
click_button 'Publish comment'
|
||||
fill_in "comment-body-legislation_annotation_#{legislation_annotation.id}", with: "Testing submit button!"
|
||||
click_button "Publish comment"
|
||||
|
||||
# The button's text should now be "..."
|
||||
# This should be checked before the Ajax request is finished
|
||||
expect(page).not_to have_button 'Publish comment'
|
||||
expect(page).not_to have_button "Publish comment"
|
||||
|
||||
expect(page).to have_content('Testing submit button!')
|
||||
expect(page).to have_content("Testing submit button!")
|
||||
end
|
||||
|
||||
feature "Moderators" do
|
||||
@@ -407,7 +407,7 @@ feature 'Commenting legislation questions' do
|
||||
within "#js-comment-form-comment_#{comment.id}" do
|
||||
fill_in "comment-body-comment_#{comment.id}", with: "I am moderating!"
|
||||
check "comment-as-moderator-comment_#{comment.id}"
|
||||
click_button 'Publish reply'
|
||||
click_button "Publish reply"
|
||||
end
|
||||
|
||||
within "#comment_#{comment.id}" do
|
||||
@@ -470,7 +470,7 @@ feature 'Commenting legislation questions' do
|
||||
within "#js-comment-form-comment_#{comment.id}" do
|
||||
fill_in "comment-body-comment_#{comment.id}", with: "Top of the world!"
|
||||
check "comment-as-administrator-comment_#{comment.id}"
|
||||
click_button 'Publish reply'
|
||||
click_button "Publish reply"
|
||||
end
|
||||
|
||||
within "#comment_#{comment.id}" do
|
||||
@@ -495,7 +495,7 @@ feature 'Commenting legislation questions' do
|
||||
end
|
||||
end
|
||||
|
||||
feature 'Voting comments' do
|
||||
feature "Voting comments" do
|
||||
background do
|
||||
@manuela = create(:user, verified_at: Time.current)
|
||||
@pablo = create(:user)
|
||||
@@ -505,7 +505,7 @@ feature 'Commenting legislation questions' do
|
||||
login_as(@manuela)
|
||||
end
|
||||
|
||||
scenario 'Show' do
|
||||
scenario "Show" do
|
||||
create(:vote, voter: @manuela, votable: @comment, vote_flag: true)
|
||||
create(:vote, voter: @pablo, votable: @comment, vote_flag: false)
|
||||
|
||||
@@ -526,7 +526,7 @@ feature 'Commenting legislation questions' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Create', :js do
|
||||
scenario "Create", :js do
|
||||
visit legislation_process_draft_version_annotation_path(@legislation_annotation.draft_version.process,
|
||||
@legislation_annotation.draft_version,
|
||||
@legislation_annotation)
|
||||
@@ -546,25 +546,25 @@ feature 'Commenting legislation questions' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Update', :js do
|
||||
scenario "Update", :js do
|
||||
visit legislation_process_draft_version_annotation_path(@legislation_annotation.draft_version.process,
|
||||
@legislation_annotation.draft_version,
|
||||
@legislation_annotation)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
find('.in_favor a').click
|
||||
find(".in_favor a").click
|
||||
|
||||
within('.in_favor') do
|
||||
within(".in_favor") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
find('.against a').click
|
||||
find(".against a").click
|
||||
|
||||
within('.in_favor') do
|
||||
within(".in_favor") do
|
||||
expect(page).to have_content "0"
|
||||
end
|
||||
|
||||
within('.against') do
|
||||
within(".against") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
@@ -572,24 +572,24 @@ feature 'Commenting legislation questions' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Trying to vote multiple times', :js do
|
||||
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)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
find('.in_favor a').click
|
||||
within('.in_favor') do
|
||||
find(".in_favor a").click
|
||||
within(".in_favor") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
find('.in_favor a').click
|
||||
within('.in_favor') do
|
||||
find(".in_favor a").click
|
||||
within(".in_favor") do
|
||||
expect(page).not_to have_content "2"
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
within('.against') do
|
||||
within(".against") do
|
||||
expect(page).to have_content "0"
|
||||
end
|
||||
|
||||
@@ -623,9 +623,9 @@ feature 'Commenting legislation questions' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'View comments of annotations in an included range' do
|
||||
scenario "View comments of annotations in an included range" do
|
||||
within("#annotation-link") do
|
||||
find('.icon-expand').click
|
||||
find(".icon-expand").click
|
||||
end
|
||||
|
||||
expect(page).to have_css(".comment", count: 2)
|
||||
@@ -642,12 +642,12 @@ feature 'Commenting legislation questions' do
|
||||
click_link "Reply"
|
||||
|
||||
within "#js-comment-form-comment_#{comment.id}" do
|
||||
fill_in "comment-body-comment_#{comment.id}", with: 'replying in single annotation thread'
|
||||
click_button 'Publish reply'
|
||||
fill_in "comment-body-comment_#{comment.id}", with: "replying in single annotation thread"
|
||||
click_button "Publish reply"
|
||||
end
|
||||
|
||||
within "#comment_#{comment.id}" do
|
||||
expect(page).to have_content 'replying in single annotation thread'
|
||||
expect(page).to have_content "replying in single annotation thread"
|
||||
end
|
||||
|
||||
visit legislation_process_draft_version_path(draft_version.process, draft_version)
|
||||
@@ -661,7 +661,7 @@ feature 'Commenting legislation questions' do
|
||||
end
|
||||
|
||||
within("#annotation-link") do
|
||||
find('.icon-expand').click
|
||||
find(".icon-expand").click
|
||||
end
|
||||
|
||||
expect(page).to have_css(".comment", count: 3)
|
||||
@@ -672,7 +672,7 @@ feature 'Commenting legislation questions' do
|
||||
|
||||
scenario "Reply on a multiple annotation thread and display it in the single annotation thread" do
|
||||
within("#annotation-link") do
|
||||
find('.icon-expand').click
|
||||
find(".icon-expand").click
|
||||
end
|
||||
|
||||
comment = annotation2.comments.first
|
||||
@@ -681,12 +681,12 @@ feature 'Commenting legislation questions' do
|
||||
end
|
||||
|
||||
within "#js-comment-form-comment_#{comment.id}" do
|
||||
fill_in "comment-body-comment_#{comment.id}", with: 'replying in multiple annotation thread'
|
||||
click_button 'Publish reply'
|
||||
fill_in "comment-body-comment_#{comment.id}", with: "replying in multiple annotation thread"
|
||||
click_button "Publish reply"
|
||||
end
|
||||
|
||||
within "#comment_#{comment.id}" do
|
||||
expect(page).to have_content 'replying in multiple annotation thread'
|
||||
expect(page).to have_content "replying in multiple annotation thread"
|
||||
end
|
||||
|
||||
visit legislation_process_draft_version_path(draft_version.process, draft_version)
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
include ActionView::Helpers::DateHelper
|
||||
|
||||
feature 'Commenting legislation questions' do
|
||||
feature "Commenting legislation questions" do
|
||||
|
||||
let(:user) { create :user, :level_two }
|
||||
let(:process) { create :legislation_process, :in_debate_phase }
|
||||
let(:legislation_question) { create :legislation_question, process: process }
|
||||
|
||||
context "Concerns" do
|
||||
it_behaves_like 'notifiable in-app', Legislation::Question
|
||||
it_behaves_like "notifiable in-app", Legislation::Question
|
||||
end
|
||||
|
||||
scenario 'Index' do
|
||||
scenario "Index" do
|
||||
3.times { create(:comment, commentable: legislation_question) }
|
||||
|
||||
visit legislation_process_question_path(legislation_question.process, legislation_question)
|
||||
|
||||
expect(page).to have_css('.comment', count: 3)
|
||||
expect(page).to have_css(".comment", count: 3)
|
||||
|
||||
comment = Comment.last
|
||||
within first('.comment') do
|
||||
within first(".comment") do
|
||||
expect(page).to have_content comment.user.name
|
||||
expect(page).to have_content I18n.l(comment.created_at, format: :datetime)
|
||||
expect(page).to have_content comment.body
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Show' do
|
||||
scenario "Show" do
|
||||
parent_comment = create(:comment, commentable: legislation_question)
|
||||
first_child = create(:comment, commentable: legislation_question, parent: parent_comment)
|
||||
second_child = create(:comment, commentable: legislation_question, parent: parent_comment)
|
||||
@@ -46,33 +46,33 @@ feature 'Commenting legislation questions' do
|
||||
expect(page).to have_selector("ul#comment_#{second_child.id}>li", count: 1)
|
||||
end
|
||||
|
||||
scenario 'Collapsable comments', :js do
|
||||
scenario "Collapsable comments", :js do
|
||||
parent_comment = create(:comment, body: "Main comment", commentable: legislation_question)
|
||||
child_comment = create(:comment, body: "First subcomment", commentable: legislation_question, parent: parent_comment)
|
||||
grandchild_comment = create(:comment, body: "Last subcomment", commentable: legislation_question, parent: child_comment)
|
||||
|
||||
visit legislation_process_question_path(legislation_question.process, legislation_question)
|
||||
|
||||
expect(page).to have_css('.comment', count: 3)
|
||||
expect(page).to have_css(".comment", count: 3)
|
||||
|
||||
find("#comment_#{child_comment.id}_children_arrow").click
|
||||
|
||||
expect(page).to have_css('.comment', count: 2)
|
||||
expect(page).to have_css(".comment", count: 2)
|
||||
expect(page).not_to have_content grandchild_comment.body
|
||||
|
||||
find("#comment_#{child_comment.id}_children_arrow").click
|
||||
|
||||
expect(page).to have_css('.comment', count: 3)
|
||||
expect(page).to have_css(".comment", count: 3)
|
||||
expect(page).to have_content grandchild_comment.body
|
||||
|
||||
find("#comment_#{parent_comment.id}_children_arrow").click
|
||||
|
||||
expect(page).to have_css('.comment', count: 1)
|
||||
expect(page).to have_css(".comment", count: 1)
|
||||
expect(page).not_to have_content child_comment.body
|
||||
expect(page).not_to have_content grandchild_comment.body
|
||||
end
|
||||
|
||||
scenario 'Comment order' do
|
||||
scenario "Comment order" do
|
||||
c1 = create(:comment, :with_confidence_score, commentable: legislation_question, cached_votes_up: 100,
|
||||
cached_votes_total: 120, created_at: Time.current - 2)
|
||||
c2 = create(:comment, :with_confidence_score, commentable: legislation_question, cached_votes_up: 10,
|
||||
@@ -96,7 +96,7 @@ feature 'Commenting legislation questions' do
|
||||
expect(c2.body).to appear_before(c3.body)
|
||||
end
|
||||
|
||||
scenario 'Creation date works differently in roots and in child comments, even when sorting by confidence_score' do
|
||||
scenario "Creation date works differently in roots and in child comments, even when sorting by confidence_score" do
|
||||
old_root = create(:comment, commentable: legislation_question, created_at: Time.current - 10)
|
||||
new_root = create(:comment, commentable: legislation_question, created_at: Time.current)
|
||||
old_child = create(:comment, commentable: legislation_question, parent_id: new_root.id, created_at: Time.current - 10)
|
||||
@@ -118,39 +118,39 @@ feature 'Commenting legislation questions' do
|
||||
expect(old_child.body).to appear_before(new_child.body)
|
||||
end
|
||||
|
||||
scenario 'Turns links into html links' do
|
||||
create :comment, commentable: legislation_question, body: 'Built with http://rubyonrails.org/'
|
||||
scenario "Turns links into html links" do
|
||||
create :comment, commentable: legislation_question, body: "Built with http://rubyonrails.org/"
|
||||
|
||||
visit legislation_process_question_path(legislation_question.process, legislation_question)
|
||||
|
||||
within first('.comment') do
|
||||
expect(page).to have_content 'Built with http://rubyonrails.org/'
|
||||
expect(page).to have_link('http://rubyonrails.org/', href: 'http://rubyonrails.org/')
|
||||
expect(find_link('http://rubyonrails.org/')[:rel]).to eq('nofollow')
|
||||
expect(find_link('http://rubyonrails.org/')[:target]).to eq('_blank')
|
||||
within first(".comment") do
|
||||
expect(page).to have_content "Built with http://rubyonrails.org/"
|
||||
expect(page).to have_link("http://rubyonrails.org/", href: "http://rubyonrails.org/")
|
||||
expect(find_link("http://rubyonrails.org/")[:rel]).to eq("nofollow")
|
||||
expect(find_link("http://rubyonrails.org/")[:target]).to eq("_blank")
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Sanitizes comment body for security' do
|
||||
scenario "Sanitizes comment body for security" do
|
||||
create :comment, commentable: legislation_question,
|
||||
body: "<script>alert('hola')</script> <a href=\"javascript:alert('sorpresa!')\">click me<a/> http://www.url.com"
|
||||
|
||||
visit legislation_process_question_path(legislation_question.process, legislation_question)
|
||||
|
||||
within first('.comment') do
|
||||
within first(".comment") do
|
||||
expect(page).to have_content "click me http://www.url.com"
|
||||
expect(page).to have_link('http://www.url.com', href: 'http://www.url.com')
|
||||
expect(page).not_to have_link('click me')
|
||||
expect(page).to have_link("http://www.url.com", href: "http://www.url.com")
|
||||
expect(page).not_to have_link("click me")
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Paginated comments' do
|
||||
scenario "Paginated comments" do
|
||||
per_page = 10
|
||||
(per_page + 2).times { create(:comment, commentable: legislation_question)}
|
||||
|
||||
visit legislation_process_question_path(legislation_question.process, legislation_question)
|
||||
|
||||
expect(page).to have_css('.comment', count: per_page)
|
||||
expect(page).to have_css(".comment", count: per_page)
|
||||
within("ul.pagination") do
|
||||
expect(page).to have_content("1")
|
||||
expect(page).to have_content("2")
|
||||
@@ -158,40 +158,40 @@ feature 'Commenting legislation questions' do
|
||||
click_link "Next", exact: false
|
||||
end
|
||||
|
||||
expect(page).to have_css('.comment', count: 2)
|
||||
expect(page).to have_css(".comment", count: 2)
|
||||
end
|
||||
|
||||
feature 'Not logged user' do
|
||||
scenario 'can not see comments forms' do
|
||||
feature "Not logged user" do
|
||||
scenario "can not see comments forms" do
|
||||
create(:comment, commentable: legislation_question)
|
||||
visit legislation_process_question_path(legislation_question.process, legislation_question)
|
||||
|
||||
expect(page).to have_content 'You must Sign in or Sign up to leave a comment'
|
||||
within('#comments') do
|
||||
expect(page).not_to have_content 'Write a comment'
|
||||
expect(page).not_to have_content 'Reply'
|
||||
expect(page).to have_content "You must Sign in or Sign up to leave a comment"
|
||||
within("#comments") do
|
||||
expect(page).not_to have_content "Write a comment"
|
||||
expect(page).not_to have_content "Reply"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Create', :js do
|
||||
scenario "Create", :js do
|
||||
login_as(user)
|
||||
visit legislation_process_question_path(legislation_question.process, legislation_question)
|
||||
|
||||
fill_in "comment-body-legislation_question_#{legislation_question.id}", with: 'Have you thought about...?'
|
||||
click_button 'Publish answer'
|
||||
fill_in "comment-body-legislation_question_#{legislation_question.id}", with: "Have you thought about...?"
|
||||
click_button "Publish answer"
|
||||
|
||||
within "#comments" do
|
||||
expect(page).to have_content 'Have you thought about...?'
|
||||
expect(page).to have_content '(1)'
|
||||
expect(page).to have_content "Have you thought about...?"
|
||||
expect(page).to have_content "(1)"
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Errors on create', :js do
|
||||
scenario "Errors on create", :js do
|
||||
login_as(user)
|
||||
visit legislation_process_question_path(legislation_question.process, legislation_question)
|
||||
|
||||
click_button 'Publish answer'
|
||||
click_button "Publish answer"
|
||||
|
||||
expect(page).to have_content "Can't be blank"
|
||||
end
|
||||
@@ -214,9 +214,9 @@ feature 'Commenting legislation questions' do
|
||||
expect(page).to have_content "Closed phase"
|
||||
end
|
||||
|
||||
scenario 'Reply', :js do
|
||||
citizen = create(:user, username: 'Ana')
|
||||
manuela = create(:user, :level_two, username: 'Manuela')
|
||||
scenario "Reply", :js do
|
||||
citizen = create(:user, username: "Ana")
|
||||
manuela = create(:user, :level_two, username: "Manuela")
|
||||
comment = create(:comment, commentable: legislation_question, user: citizen)
|
||||
|
||||
login_as(manuela)
|
||||
@@ -225,18 +225,18 @@ feature 'Commenting legislation questions' do
|
||||
click_link "Reply"
|
||||
|
||||
within "#js-comment-form-comment_#{comment.id}" do
|
||||
fill_in "comment-body-comment_#{comment.id}", with: 'It will be done next week.'
|
||||
click_button 'Publish reply'
|
||||
fill_in "comment-body-comment_#{comment.id}", with: "It will be done next week."
|
||||
click_button "Publish reply"
|
||||
end
|
||||
|
||||
within "#comment_#{comment.id}" do
|
||||
expect(page).to have_content 'It will be done next week.'
|
||||
expect(page).to have_content "It will be done next week."
|
||||
end
|
||||
|
||||
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}", visible: true)
|
||||
end
|
||||
|
||||
scenario 'Errors on reply', :js do
|
||||
scenario "Errors on reply", :js do
|
||||
comment = create(:comment, commentable: legislation_question, user: user)
|
||||
|
||||
login_as(user)
|
||||
@@ -245,7 +245,7 @@ feature 'Commenting legislation questions' do
|
||||
click_link "Reply"
|
||||
|
||||
within "#js-comment-form-comment_#{comment.id}" do
|
||||
click_button 'Publish reply'
|
||||
click_button "Publish reply"
|
||||
expect(page).to have_content "Can't be blank"
|
||||
end
|
||||
|
||||
@@ -311,28 +311,28 @@ feature 'Commenting legislation questions' do
|
||||
end
|
||||
|
||||
scenario "Erasing a comment's author" do
|
||||
comment = create(:comment, commentable: legislation_question, body: 'this should be visible')
|
||||
comment = create(:comment, commentable: legislation_question, body: "this should be visible")
|
||||
comment.user.erase
|
||||
|
||||
visit legislation_process_question_path(legislation_question.process, legislation_question)
|
||||
within "#comment_#{comment.id}" do
|
||||
expect(page).to have_content('User deleted')
|
||||
expect(page).to have_content('this should be visible')
|
||||
expect(page).to have_content("User deleted")
|
||||
expect(page).to have_content("this should be visible")
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Submit button is disabled after clicking', :js do
|
||||
scenario "Submit button is disabled after clicking", :js do
|
||||
login_as(user)
|
||||
visit legislation_process_question_path(legislation_question.process, legislation_question)
|
||||
|
||||
fill_in "comment-body-legislation_question_#{legislation_question.id}", with: 'Testing submit button!'
|
||||
click_button 'Publish answer'
|
||||
fill_in "comment-body-legislation_question_#{legislation_question.id}", with: "Testing submit button!"
|
||||
click_button "Publish answer"
|
||||
|
||||
# The button's text should now be "..."
|
||||
# This should be checked before the Ajax request is finished
|
||||
expect(page).not_to have_button 'Publish answer'
|
||||
expect(page).not_to have_button "Publish answer"
|
||||
|
||||
expect(page).to have_content('Testing submit button!')
|
||||
expect(page).to have_content("Testing submit button!")
|
||||
end
|
||||
|
||||
feature "Moderators" do
|
||||
@@ -368,7 +368,7 @@ feature 'Commenting legislation questions' do
|
||||
within "#js-comment-form-comment_#{comment.id}" do
|
||||
fill_in "comment-body-comment_#{comment.id}", with: "I am moderating!"
|
||||
check "comment-as-moderator-comment_#{comment.id}"
|
||||
click_button 'Publish reply'
|
||||
click_button "Publish reply"
|
||||
end
|
||||
|
||||
within "#comment_#{comment.id}" do
|
||||
@@ -424,7 +424,7 @@ feature 'Commenting legislation questions' do
|
||||
within "#js-comment-form-comment_#{comment.id}" do
|
||||
fill_in "comment-body-comment_#{comment.id}", with: "Top of the world!"
|
||||
check "comment-as-administrator-comment_#{comment.id}"
|
||||
click_button 'Publish reply'
|
||||
click_button "Publish reply"
|
||||
end
|
||||
|
||||
within "#comment_#{comment.id}" do
|
||||
@@ -447,7 +447,7 @@ feature 'Commenting legislation questions' do
|
||||
end
|
||||
end
|
||||
|
||||
feature 'Voting comments' do
|
||||
feature "Voting comments" do
|
||||
background do
|
||||
@manuela = create(:user, verified_at: Time.current)
|
||||
@pablo = create(:user)
|
||||
@@ -457,7 +457,7 @@ feature 'Commenting legislation questions' do
|
||||
login_as(@manuela)
|
||||
end
|
||||
|
||||
scenario 'Show' do
|
||||
scenario "Show" do
|
||||
create(:vote, voter: @manuela, votable: @comment, vote_flag: true)
|
||||
create(:vote, voter: @pablo, votable: @comment, vote_flag: false)
|
||||
|
||||
@@ -476,7 +476,7 @@ feature 'Commenting legislation questions' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Create', :js do
|
||||
scenario "Create", :js do
|
||||
visit legislation_process_question_path(@legislation_question.process, @legislation_question)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
@@ -494,23 +494,23 @@ feature 'Commenting legislation questions' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Update', :js do
|
||||
scenario "Update", :js do
|
||||
visit legislation_process_question_path(@legislation_question.process, @legislation_question)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
find('.in_favor a').click
|
||||
find(".in_favor a").click
|
||||
|
||||
within('.in_favor') do
|
||||
within(".in_favor") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
find('.against a').click
|
||||
find(".against a").click
|
||||
|
||||
within('.in_favor') do
|
||||
within(".in_favor") do
|
||||
expect(page).to have_content "0"
|
||||
end
|
||||
|
||||
within('.against') do
|
||||
within(".against") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
@@ -518,22 +518,22 @@ feature 'Commenting legislation questions' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Trying to vote multiple times', :js do
|
||||
scenario "Trying to vote multiple times", :js do
|
||||
visit legislation_process_question_path(@legislation_question.process, @legislation_question)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
find('.in_favor a').click
|
||||
within('.in_favor') do
|
||||
find(".in_favor a").click
|
||||
within(".in_favor") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
find('.in_favor a').click
|
||||
within('.in_favor') do
|
||||
find(".in_favor a").click
|
||||
within(".in_favor") do
|
||||
expect(page).not_to have_content "2"
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
within('.against') do
|
||||
within(".against") do
|
||||
expect(page).to have_content "0"
|
||||
end
|
||||
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
include ActionView::Helpers::DateHelper
|
||||
|
||||
feature 'Commenting polls' do
|
||||
feature "Commenting polls" do
|
||||
let(:user) { create :user }
|
||||
let(:poll) { create(:poll, author: create(:user)) }
|
||||
|
||||
scenario 'Index' do
|
||||
scenario "Index" do
|
||||
3.times { create(:comment, commentable: poll) }
|
||||
|
||||
visit poll_path(poll)
|
||||
|
||||
expect(page).to have_css('.comment', count: 3)
|
||||
expect(page).to have_css(".comment", count: 3)
|
||||
|
||||
comment = Comment.last
|
||||
within first('.comment') do
|
||||
within first(".comment") do
|
||||
expect(page).to have_content comment.user.name
|
||||
expect(page).to have_content I18n.l(comment.created_at, format: :datetime)
|
||||
expect(page).to have_content comment.body
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Show' do
|
||||
scenario "Show" do
|
||||
skip "Feature not implemented yet, review soon"
|
||||
|
||||
parent_comment = create(:comment, commentable: poll)
|
||||
@@ -40,33 +40,33 @@ feature 'Commenting polls' do
|
||||
expect(page).to have_selector("ul#comment_#{second_child.id}>li", count: 1)
|
||||
end
|
||||
|
||||
scenario 'Collapsable comments', :js do
|
||||
scenario "Collapsable comments", :js do
|
||||
parent_comment = create(:comment, body: "Main comment", commentable: poll)
|
||||
child_comment = create(:comment, body: "First subcomment", commentable: poll, parent: parent_comment)
|
||||
grandchild_comment = create(:comment, body: "Last subcomment", commentable: poll, parent: child_comment)
|
||||
|
||||
visit poll_path(poll)
|
||||
|
||||
expect(page).to have_css('.comment', count: 3)
|
||||
expect(page).to have_css(".comment", count: 3)
|
||||
|
||||
find("#comment_#{child_comment.id}_children_arrow").click
|
||||
|
||||
expect(page).to have_css('.comment', count: 2)
|
||||
expect(page).to have_css(".comment", count: 2)
|
||||
expect(page).not_to have_content grandchild_comment.body
|
||||
|
||||
find("#comment_#{child_comment.id}_children_arrow").click
|
||||
|
||||
expect(page).to have_css('.comment', count: 3)
|
||||
expect(page).to have_css(".comment", count: 3)
|
||||
expect(page).to have_content grandchild_comment.body
|
||||
|
||||
find("#comment_#{parent_comment.id}_children_arrow").click
|
||||
|
||||
expect(page).to have_css('.comment', count: 1)
|
||||
expect(page).to have_css(".comment", count: 1)
|
||||
expect(page).not_to have_content child_comment.body
|
||||
expect(page).not_to have_content grandchild_comment.body
|
||||
end
|
||||
|
||||
scenario 'Comment order' do
|
||||
scenario "Comment order" do
|
||||
c1 = create(:comment, :with_confidence_score, commentable: poll, cached_votes_up: 100,
|
||||
cached_votes_total: 120, created_at: Time.current - 2)
|
||||
c2 = create(:comment, :with_confidence_score, commentable: poll, cached_votes_up: 10,
|
||||
@@ -90,7 +90,7 @@ feature 'Commenting polls' do
|
||||
expect(c2.body).to appear_before(c3.body)
|
||||
end
|
||||
|
||||
scenario 'Creation date works differently in roots and in child comments, when sorting by confidence_score' do
|
||||
scenario "Creation date works differently in roots and in child comments, when sorting by confidence_score" do
|
||||
old_root = create(:comment, commentable: poll, created_at: Time.current - 10)
|
||||
new_root = create(:comment, commentable: poll, created_at: Time.current)
|
||||
old_child = create(:comment, commentable: poll, parent_id: new_root.id, created_at: Time.current - 10)
|
||||
@@ -112,39 +112,39 @@ feature 'Commenting polls' do
|
||||
expect(old_child.body).to appear_before(new_child.body)
|
||||
end
|
||||
|
||||
scenario 'Turns links into html links' do
|
||||
create :comment, commentable: poll, body: 'Built with http://rubyonrails.org/'
|
||||
scenario "Turns links into html links" do
|
||||
create :comment, commentable: poll, body: "Built with http://rubyonrails.org/"
|
||||
|
||||
visit poll_path(poll)
|
||||
|
||||
within first('.comment') do
|
||||
expect(page).to have_content 'Built with http://rubyonrails.org/'
|
||||
expect(page).to have_link('http://rubyonrails.org/', href: 'http://rubyonrails.org/')
|
||||
expect(find_link('http://rubyonrails.org/')[:rel]).to eq('nofollow')
|
||||
expect(find_link('http://rubyonrails.org/')[:target]).to eq('_blank')
|
||||
within first(".comment") do
|
||||
expect(page).to have_content "Built with http://rubyonrails.org/"
|
||||
expect(page).to have_link("http://rubyonrails.org/", href: "http://rubyonrails.org/")
|
||||
expect(find_link("http://rubyonrails.org/")[:rel]).to eq("nofollow")
|
||||
expect(find_link("http://rubyonrails.org/")[:target]).to eq("_blank")
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Sanitizes comment body for security' do
|
||||
scenario "Sanitizes comment body for security" do
|
||||
create :comment, commentable: poll,
|
||||
body: "<script>alert('hola')</script> <a href=\"javascript:alert('sorpresa!')\">click me<a/> http://www.url.com"
|
||||
|
||||
visit poll_path(poll)
|
||||
|
||||
within first('.comment') do
|
||||
within first(".comment") do
|
||||
expect(page).to have_content "click me http://www.url.com"
|
||||
expect(page).to have_link('http://www.url.com', href: 'http://www.url.com')
|
||||
expect(page).not_to have_link('click me')
|
||||
expect(page).to have_link("http://www.url.com", href: "http://www.url.com")
|
||||
expect(page).not_to have_link("click me")
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Paginated comments' do
|
||||
scenario "Paginated comments" do
|
||||
per_page = 10
|
||||
(per_page + 2).times { create(:comment, commentable: poll)}
|
||||
|
||||
visit poll_path(poll)
|
||||
|
||||
expect(page).to have_css('.comment', count: per_page)
|
||||
expect(page).to have_css(".comment", count: per_page)
|
||||
within("ul.pagination") do
|
||||
expect(page).to have_content("1")
|
||||
expect(page).to have_content("2")
|
||||
@@ -152,50 +152,50 @@ feature 'Commenting polls' do
|
||||
click_link "Next", exact: false
|
||||
end
|
||||
|
||||
expect(page).to have_css('.comment', count: 2)
|
||||
expect(page).to have_css(".comment", count: 2)
|
||||
end
|
||||
|
||||
feature 'Not logged user' do
|
||||
scenario 'can not see comments forms' do
|
||||
feature "Not logged user" do
|
||||
scenario "can not see comments forms" do
|
||||
create(:comment, commentable: poll)
|
||||
visit poll_path(poll)
|
||||
|
||||
expect(page).to have_content 'You must Sign in or Sign up to leave a comment'
|
||||
within('#comments') do
|
||||
expect(page).not_to have_content 'Write a comment'
|
||||
expect(page).not_to have_content 'Reply'
|
||||
expect(page).to have_content "You must Sign in or Sign up to leave a comment"
|
||||
within("#comments") do
|
||||
expect(page).not_to have_content "Write a comment"
|
||||
expect(page).not_to have_content "Reply"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Create', :js do
|
||||
scenario "Create", :js do
|
||||
login_as(user)
|
||||
visit poll_path(poll)
|
||||
|
||||
fill_in "comment-body-poll_#{poll.id}", with: 'Have you thought about...?'
|
||||
click_button 'Publish comment'
|
||||
fill_in "comment-body-poll_#{poll.id}", with: "Have you thought about...?"
|
||||
click_button "Publish comment"
|
||||
|
||||
within "#comments" do
|
||||
expect(page).to have_content 'Have you thought about...?'
|
||||
expect(page).to have_content "Have you thought about...?"
|
||||
end
|
||||
|
||||
within "#tab-comments-label" do
|
||||
expect(page).to have_content 'Comments (1)'
|
||||
expect(page).to have_content "Comments (1)"
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Errors on create', :js do
|
||||
scenario "Errors on create", :js do
|
||||
login_as(user)
|
||||
visit poll_path(poll)
|
||||
|
||||
click_button 'Publish comment'
|
||||
click_button "Publish comment"
|
||||
|
||||
expect(page).to have_content "Can't be blank"
|
||||
end
|
||||
|
||||
scenario 'Reply', :js do
|
||||
citizen = create(:user, username: 'Ana')
|
||||
manuela = create(:user, username: 'Manuela')
|
||||
scenario "Reply", :js do
|
||||
citizen = create(:user, username: "Ana")
|
||||
manuela = create(:user, username: "Manuela")
|
||||
comment = create(:comment, commentable: poll, user: citizen)
|
||||
|
||||
login_as(manuela)
|
||||
@@ -204,18 +204,18 @@ feature 'Commenting polls' do
|
||||
click_link "Reply"
|
||||
|
||||
within "#js-comment-form-comment_#{comment.id}" do
|
||||
fill_in "comment-body-comment_#{comment.id}", with: 'It will be done next week.'
|
||||
click_button 'Publish reply'
|
||||
fill_in "comment-body-comment_#{comment.id}", with: "It will be done next week."
|
||||
click_button "Publish reply"
|
||||
end
|
||||
|
||||
within "#comment_#{comment.id}" do
|
||||
expect(page).to have_content 'It will be done next week.'
|
||||
expect(page).to have_content "It will be done next week."
|
||||
end
|
||||
|
||||
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}", visible: true)
|
||||
end
|
||||
|
||||
scenario 'Errors on reply', :js do
|
||||
scenario "Errors on reply", :js do
|
||||
comment = create(:comment, commentable: poll, user: user)
|
||||
|
||||
login_as(user)
|
||||
@@ -224,7 +224,7 @@ feature 'Commenting polls' do
|
||||
click_link "Reply"
|
||||
|
||||
within "#js-comment-form-comment_#{comment.id}" do
|
||||
click_button 'Publish reply'
|
||||
click_button "Publish reply"
|
||||
expect(page).to have_content "Can't be blank"
|
||||
end
|
||||
|
||||
@@ -302,8 +302,8 @@ feature 'Commenting polls' do
|
||||
|
||||
visit poll_path(poll)
|
||||
within "#comment_#{comment.id}" do
|
||||
expect(page).to have_content('User deleted')
|
||||
expect(page).to have_content('this should be visible')
|
||||
expect(page).to have_content("User deleted")
|
||||
expect(page).to have_content("this should be visible")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -345,7 +345,7 @@ feature 'Commenting polls' do
|
||||
within "#js-comment-form-comment_#{comment.id}" do
|
||||
fill_in "comment-body-comment_#{comment.id}", with: "I am moderating!"
|
||||
check "comment-as-moderator-comment_#{comment.id}"
|
||||
click_button 'Publish reply'
|
||||
click_button "Publish reply"
|
||||
end
|
||||
|
||||
within "#comment_#{comment.id}" do
|
||||
@@ -407,7 +407,7 @@ feature 'Commenting polls' do
|
||||
within "#js-comment-form-comment_#{comment.id}" do
|
||||
fill_in "comment-body-comment_#{comment.id}", with: "Top of the world!"
|
||||
check "comment-as-administrator-comment_#{comment.id}"
|
||||
click_button 'Publish reply'
|
||||
click_button "Publish reply"
|
||||
end
|
||||
|
||||
within "#comment_#{comment.id}" do
|
||||
@@ -432,7 +432,7 @@ feature 'Commenting polls' do
|
||||
end
|
||||
end
|
||||
|
||||
feature 'Voting comments' do
|
||||
feature "Voting comments" do
|
||||
|
||||
background do
|
||||
@manuela = create(:user, verified_at: Time.current)
|
||||
@@ -443,7 +443,7 @@ feature 'Commenting polls' do
|
||||
login_as(@manuela)
|
||||
end
|
||||
|
||||
scenario 'Show' do
|
||||
scenario "Show" do
|
||||
create(:vote, voter: @manuela, votable: @comment, vote_flag: true)
|
||||
create(:vote, voter: @pablo, votable: @comment, vote_flag: false)
|
||||
|
||||
@@ -462,7 +462,7 @@ feature 'Commenting polls' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Create', :js do
|
||||
scenario "Create", :js do
|
||||
visit poll_path(@poll)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
@@ -480,23 +480,23 @@ feature 'Commenting polls' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Update', :js do
|
||||
scenario "Update", :js do
|
||||
visit poll_path(@poll)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
find('.in_favor a').click
|
||||
find(".in_favor a").click
|
||||
|
||||
within('.in_favor') do
|
||||
within(".in_favor") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
find('.against a').click
|
||||
find(".against a").click
|
||||
|
||||
within('.in_favor') do
|
||||
within(".in_favor") do
|
||||
expect(page).to have_content "0"
|
||||
end
|
||||
|
||||
within('.against') do
|
||||
within(".against") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
@@ -504,18 +504,18 @@ feature 'Commenting polls' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Trying to vote multiple times', :js do
|
||||
scenario "Trying to vote multiple times", :js do
|
||||
visit poll_path(@poll)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
find('.in_favor a').click
|
||||
find('.in_favor a').click
|
||||
find(".in_favor a").click
|
||||
find(".in_favor a").click
|
||||
|
||||
within('.in_favor') do
|
||||
within(".in_favor") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
within('.against') do
|
||||
within(".against") do
|
||||
expect(page).to have_content "0"
|
||||
end
|
||||
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
include ActionView::Helpers::DateHelper
|
||||
|
||||
feature 'Commenting proposals' do
|
||||
feature "Commenting proposals" do
|
||||
let(:user) { create :user }
|
||||
let(:proposal) { create :proposal }
|
||||
|
||||
scenario 'Index' do
|
||||
scenario "Index" do
|
||||
3.times { create(:comment, commentable: proposal) }
|
||||
|
||||
visit proposal_path(proposal)
|
||||
|
||||
expect(page).to have_css('.comment', count: 3)
|
||||
expect(page).to have_css(".comment", count: 3)
|
||||
|
||||
comment = Comment.last
|
||||
within first('.comment') do
|
||||
within first(".comment") do
|
||||
expect(page).to have_content comment.user.name
|
||||
expect(page).to have_content I18n.l(comment.created_at, format: :datetime)
|
||||
expect(page).to have_content comment.body
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Show' do
|
||||
scenario "Show" do
|
||||
parent_comment = create(:comment, commentable: proposal)
|
||||
first_child = create(:comment, commentable: proposal, parent: parent_comment)
|
||||
second_child = create(:comment, commentable: proposal, parent: parent_comment)
|
||||
@@ -38,33 +38,33 @@ feature 'Commenting proposals' do
|
||||
expect(page).to have_selector("ul#comment_#{second_child.id}>li", count: 1)
|
||||
end
|
||||
|
||||
scenario 'Collapsable comments', :js do
|
||||
scenario "Collapsable comments", :js do
|
||||
parent_comment = create(:comment, body: "Main comment", commentable: proposal)
|
||||
child_comment = create(:comment, body: "First subcomment", commentable: proposal, parent: parent_comment)
|
||||
grandchild_comment = create(:comment, body: "Last subcomment", commentable: proposal, parent: child_comment)
|
||||
|
||||
visit proposal_path(proposal)
|
||||
|
||||
expect(page).to have_css('.comment', count: 3)
|
||||
expect(page).to have_css(".comment", count: 3)
|
||||
|
||||
find("#comment_#{child_comment.id}_children_arrow").click
|
||||
|
||||
expect(page).to have_css('.comment', count: 2)
|
||||
expect(page).to have_css(".comment", count: 2)
|
||||
expect(page).not_to have_content grandchild_comment.body
|
||||
|
||||
find("#comment_#{child_comment.id}_children_arrow").click
|
||||
|
||||
expect(page).to have_css('.comment', count: 3)
|
||||
expect(page).to have_css(".comment", count: 3)
|
||||
expect(page).to have_content grandchild_comment.body
|
||||
|
||||
find("#comment_#{parent_comment.id}_children_arrow").click
|
||||
|
||||
expect(page).to have_css('.comment', count: 1)
|
||||
expect(page).to have_css(".comment", count: 1)
|
||||
expect(page).not_to have_content child_comment.body
|
||||
expect(page).not_to have_content grandchild_comment.body
|
||||
end
|
||||
|
||||
scenario 'Comment order' do
|
||||
scenario "Comment order" do
|
||||
c1 = create(:comment, :with_confidence_score, commentable: proposal, cached_votes_up: 100,
|
||||
cached_votes_total: 120, created_at: Time.current - 2)
|
||||
c2 = create(:comment, :with_confidence_score, commentable: proposal, cached_votes_up: 10,
|
||||
@@ -88,7 +88,7 @@ feature 'Commenting proposals' do
|
||||
expect(c2.body).to appear_before(c3.body)
|
||||
end
|
||||
|
||||
scenario 'Creation date works differently in roots and in child comments, when sorting by confidence_score' do
|
||||
scenario "Creation date works differently in roots and in child comments, when sorting by confidence_score" do
|
||||
old_root = create(:comment, commentable: proposal, created_at: Time.current - 10)
|
||||
new_root = create(:comment, commentable: proposal, created_at: Time.current)
|
||||
old_child = create(:comment, commentable: proposal, parent_id: new_root.id, created_at: Time.current - 10)
|
||||
@@ -110,39 +110,39 @@ feature 'Commenting proposals' do
|
||||
expect(old_child.body).to appear_before(new_child.body)
|
||||
end
|
||||
|
||||
scenario 'Turns links into html links' do
|
||||
create :comment, commentable: proposal, body: 'Built with http://rubyonrails.org/'
|
||||
scenario "Turns links into html links" do
|
||||
create :comment, commentable: proposal, body: "Built with http://rubyonrails.org/"
|
||||
|
||||
visit proposal_path(proposal)
|
||||
|
||||
within first('.comment') do
|
||||
expect(page).to have_content 'Built with http://rubyonrails.org/'
|
||||
expect(page).to have_link('http://rubyonrails.org/', href: 'http://rubyonrails.org/')
|
||||
expect(find_link('http://rubyonrails.org/')[:rel]).to eq('nofollow')
|
||||
expect(find_link('http://rubyonrails.org/')[:target]).to eq('_blank')
|
||||
within first(".comment") do
|
||||
expect(page).to have_content "Built with http://rubyonrails.org/"
|
||||
expect(page).to have_link("http://rubyonrails.org/", href: "http://rubyonrails.org/")
|
||||
expect(find_link("http://rubyonrails.org/")[:rel]).to eq("nofollow")
|
||||
expect(find_link("http://rubyonrails.org/")[:target]).to eq("_blank")
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Sanitizes comment body for security' do
|
||||
scenario "Sanitizes comment body for security" do
|
||||
create :comment, commentable: proposal,
|
||||
body: "<script>alert('hola')</script> <a href=\"javascript:alert('sorpresa!')\">click me<a/> http://www.url.com"
|
||||
|
||||
visit proposal_path(proposal)
|
||||
|
||||
within first('.comment') do
|
||||
within first(".comment") do
|
||||
expect(page).to have_content "click me http://www.url.com"
|
||||
expect(page).to have_link('http://www.url.com', href: 'http://www.url.com')
|
||||
expect(page).not_to have_link('click me')
|
||||
expect(page).to have_link("http://www.url.com", href: "http://www.url.com")
|
||||
expect(page).not_to have_link("click me")
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Paginated comments' do
|
||||
scenario "Paginated comments" do
|
||||
per_page = 10
|
||||
(per_page + 2).times { create(:comment, commentable: proposal)}
|
||||
|
||||
visit proposal_path(proposal)
|
||||
|
||||
expect(page).to have_css('.comment', count: per_page)
|
||||
expect(page).to have_css(".comment", count: per_page)
|
||||
within("ul.pagination") do
|
||||
expect(page).to have_content("1")
|
||||
expect(page).to have_content("2")
|
||||
@@ -150,50 +150,50 @@ feature 'Commenting proposals' do
|
||||
click_link "Next", exact: false
|
||||
end
|
||||
|
||||
expect(page).to have_css('.comment', count: 2)
|
||||
expect(page).to have_css(".comment", count: 2)
|
||||
end
|
||||
|
||||
feature 'Not logged user' do
|
||||
scenario 'can not see comments forms' do
|
||||
feature "Not logged user" do
|
||||
scenario "can not see comments forms" do
|
||||
create(:comment, commentable: proposal)
|
||||
visit proposal_path(proposal)
|
||||
|
||||
expect(page).to have_content 'You must Sign in or Sign up to leave a comment'
|
||||
within('#comments') do
|
||||
expect(page).not_to have_content 'Write a comment'
|
||||
expect(page).not_to have_content 'Reply'
|
||||
expect(page).to have_content "You must Sign in or Sign up to leave a comment"
|
||||
within("#comments") do
|
||||
expect(page).not_to have_content "Write a comment"
|
||||
expect(page).not_to have_content "Reply"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Create', :js do
|
||||
scenario "Create", :js do
|
||||
login_as(user)
|
||||
visit proposal_path(proposal)
|
||||
|
||||
fill_in "comment-body-proposal_#{proposal.id}", with: 'Have you thought about...?'
|
||||
click_button 'Publish comment'
|
||||
fill_in "comment-body-proposal_#{proposal.id}", with: "Have you thought about...?"
|
||||
click_button "Publish comment"
|
||||
|
||||
within "#comments" do
|
||||
expect(page).to have_content 'Have you thought about...?'
|
||||
expect(page).to have_content "Have you thought about...?"
|
||||
end
|
||||
|
||||
within "#tab-comments-label" do
|
||||
expect(page).to have_content 'Comments (1)'
|
||||
expect(page).to have_content "Comments (1)"
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Errors on create', :js do
|
||||
scenario "Errors on create", :js do
|
||||
login_as(user)
|
||||
visit proposal_path(proposal)
|
||||
|
||||
click_button 'Publish comment'
|
||||
click_button "Publish comment"
|
||||
|
||||
expect(page).to have_content "Can't be blank"
|
||||
end
|
||||
|
||||
scenario 'Reply', :js do
|
||||
citizen = create(:user, username: 'Ana')
|
||||
manuela = create(:user, username: 'Manuela')
|
||||
scenario "Reply", :js do
|
||||
citizen = create(:user, username: "Ana")
|
||||
manuela = create(:user, username: "Manuela")
|
||||
comment = create(:comment, commentable: proposal, user: citizen)
|
||||
|
||||
login_as(manuela)
|
||||
@@ -202,18 +202,18 @@ feature 'Commenting proposals' do
|
||||
click_link "Reply"
|
||||
|
||||
within "#js-comment-form-comment_#{comment.id}" do
|
||||
fill_in "comment-body-comment_#{comment.id}", with: 'It will be done next week.'
|
||||
click_button 'Publish reply'
|
||||
fill_in "comment-body-comment_#{comment.id}", with: "It will be done next week."
|
||||
click_button "Publish reply"
|
||||
end
|
||||
|
||||
within "#comment_#{comment.id}" do
|
||||
expect(page).to have_content 'It will be done next week.'
|
||||
expect(page).to have_content "It will be done next week."
|
||||
end
|
||||
|
||||
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}", visible: true)
|
||||
end
|
||||
|
||||
scenario 'Errors on reply', :js do
|
||||
scenario "Errors on reply", :js do
|
||||
comment = create(:comment, commentable: proposal, user: user)
|
||||
|
||||
login_as(user)
|
||||
@@ -222,7 +222,7 @@ feature 'Commenting proposals' do
|
||||
click_link "Reply"
|
||||
|
||||
within "#js-comment-form-comment_#{comment.id}" do
|
||||
click_button 'Publish reply'
|
||||
click_button "Publish reply"
|
||||
expect(page).to have_content "Can't be blank"
|
||||
end
|
||||
|
||||
@@ -294,8 +294,8 @@ feature 'Commenting proposals' do
|
||||
|
||||
visit proposal_path(proposal)
|
||||
within "#comment_#{comment.id}" do
|
||||
expect(page).to have_content('User deleted')
|
||||
expect(page).to have_content('this should be visible')
|
||||
expect(page).to have_content("User deleted")
|
||||
expect(page).to have_content("this should be visible")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -332,7 +332,7 @@ feature 'Commenting proposals' do
|
||||
within "#js-comment-form-comment_#{comment.id}" do
|
||||
fill_in "comment-body-comment_#{comment.id}", with: "I am moderating!"
|
||||
check "comment-as-moderator-comment_#{comment.id}"
|
||||
click_button 'Publish reply'
|
||||
click_button "Publish reply"
|
||||
end
|
||||
|
||||
within "#comment_#{comment.id}" do
|
||||
@@ -388,7 +388,7 @@ feature 'Commenting proposals' do
|
||||
within "#js-comment-form-comment_#{comment.id}" do
|
||||
fill_in "comment-body-comment_#{comment.id}", with: "Top of the world!"
|
||||
check "comment-as-administrator-comment_#{comment.id}"
|
||||
click_button 'Publish reply'
|
||||
click_button "Publish reply"
|
||||
end
|
||||
|
||||
within "#comment_#{comment.id}" do
|
||||
@@ -411,7 +411,7 @@ feature 'Commenting proposals' do
|
||||
end
|
||||
end
|
||||
|
||||
feature 'Voting comments' do
|
||||
feature "Voting comments" do
|
||||
|
||||
background do
|
||||
@manuela = create(:user, verified_at: Time.current)
|
||||
@@ -422,7 +422,7 @@ feature 'Commenting proposals' do
|
||||
login_as(@manuela)
|
||||
end
|
||||
|
||||
scenario 'Show' do
|
||||
scenario "Show" do
|
||||
create(:vote, voter: @manuela, votable: @comment, vote_flag: true)
|
||||
create(:vote, voter: @pablo, votable: @comment, vote_flag: false)
|
||||
|
||||
@@ -441,7 +441,7 @@ feature 'Commenting proposals' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Create', :js do
|
||||
scenario "Create", :js do
|
||||
visit proposal_path(@proposal)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
@@ -459,23 +459,23 @@ feature 'Commenting proposals' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Update', :js do
|
||||
scenario "Update", :js do
|
||||
visit proposal_path(@proposal)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
find('.in_favor a').click
|
||||
find(".in_favor a").click
|
||||
|
||||
within('.in_favor') do
|
||||
within(".in_favor") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
find('.against a').click
|
||||
find(".against a").click
|
||||
|
||||
within('.in_favor') do
|
||||
within(".in_favor") do
|
||||
expect(page).to have_content "0"
|
||||
end
|
||||
|
||||
within('.against') do
|
||||
within(".against") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
@@ -483,18 +483,18 @@ feature 'Commenting proposals' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Trying to vote multiple times', :js do
|
||||
scenario "Trying to vote multiple times", :js do
|
||||
visit proposal_path(@proposal)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
find('.in_favor a').click
|
||||
find('.in_favor a').click
|
||||
find(".in_favor a").click
|
||||
find(".in_favor a").click
|
||||
|
||||
within('.in_favor') do
|
||||
within(".in_favor") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
within('.against') do
|
||||
within(".against") do
|
||||
expect(page).to have_content "0"
|
||||
end
|
||||
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
include ActionView::Helpers::DateHelper
|
||||
|
||||
feature 'Commenting topics from proposals' do
|
||||
feature "Commenting topics from proposals" do
|
||||
let(:user) { create :user }
|
||||
let(:proposal) { create :proposal }
|
||||
|
||||
scenario 'Index' do
|
||||
scenario "Index" do
|
||||
community = proposal.community
|
||||
topic = create(:topic, community: community)
|
||||
create_list(:comment, 3, commentable: topic)
|
||||
|
||||
visit community_topic_path(community, topic)
|
||||
|
||||
expect(page).to have_css('.comment', count: 3)
|
||||
expect(page).to have_css(".comment", count: 3)
|
||||
|
||||
comment = Comment.last
|
||||
within first('.comment') do
|
||||
within first(".comment") do
|
||||
expect(page).to have_content comment.user.name
|
||||
expect(page).to have_content I18n.l(comment.created_at, format: :datetime)
|
||||
expect(page).to have_content comment.body
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Show' do
|
||||
scenario "Show" do
|
||||
community = proposal.community
|
||||
topic = create(:topic, community: community)
|
||||
parent_comment = create(:comment, commentable: topic)
|
||||
@@ -39,7 +39,7 @@ feature 'Commenting topics from proposals' do
|
||||
expect(page).to have_link "Go back to #{topic.title}", href: community_topic_path(community, topic)
|
||||
end
|
||||
|
||||
scenario 'Collapsable comments', :js do
|
||||
scenario "Collapsable comments", :js do
|
||||
community = proposal.community
|
||||
topic = create(:topic, community: community)
|
||||
parent_comment = create(:comment, body: "Main comment", commentable: topic)
|
||||
@@ -48,26 +48,26 @@ feature 'Commenting topics from proposals' do
|
||||
|
||||
visit community_topic_path(community, topic)
|
||||
|
||||
expect(page).to have_css('.comment', count: 3)
|
||||
expect(page).to have_css(".comment", count: 3)
|
||||
|
||||
find("#comment_#{child_comment.id}_children_arrow").click
|
||||
|
||||
expect(page).to have_css('.comment', count: 2)
|
||||
expect(page).to have_css(".comment", count: 2)
|
||||
expect(page).not_to have_content grandchild_comment.body
|
||||
|
||||
find("#comment_#{child_comment.id}_children_arrow").click
|
||||
|
||||
expect(page).to have_css('.comment', count: 3)
|
||||
expect(page).to have_css(".comment", count: 3)
|
||||
expect(page).to have_content grandchild_comment.body
|
||||
|
||||
find("#comment_#{parent_comment.id}_children_arrow").click
|
||||
|
||||
expect(page).to have_css('.comment', count: 1)
|
||||
expect(page).to have_css(".comment", count: 1)
|
||||
expect(page).not_to have_content child_comment.body
|
||||
expect(page).not_to have_content grandchild_comment.body
|
||||
end
|
||||
|
||||
scenario 'Comment order' do
|
||||
scenario "Comment order" do
|
||||
community = proposal.community
|
||||
topic = create(:topic, community: community)
|
||||
c1 = create(:comment, :with_confidence_score, commentable: topic, cached_votes_up: 100,
|
||||
@@ -93,7 +93,7 @@ feature 'Commenting topics from proposals' do
|
||||
expect(c2.body).to appear_before(c3.body)
|
||||
end
|
||||
|
||||
scenario 'Creation date works differently in roots and in child comments, when sorting by confidence_score' do
|
||||
scenario "Creation date works differently in roots and in child comments, when sorting by confidence_score" do
|
||||
community = proposal.community
|
||||
topic = create(:topic, community: community)
|
||||
old_root = create(:comment, commentable: topic, created_at: Time.current - 10)
|
||||
@@ -117,22 +117,22 @@ feature 'Commenting topics from proposals' do
|
||||
expect(old_child.body).to appear_before(new_child.body)
|
||||
end
|
||||
|
||||
scenario 'Turns links into html links' do
|
||||
scenario "Turns links into html links" do
|
||||
community = proposal.community
|
||||
topic = create(:topic, community: community)
|
||||
create :comment, commentable: topic, body: 'Built with http://rubyonrails.org/'
|
||||
create :comment, commentable: topic, body: "Built with http://rubyonrails.org/"
|
||||
|
||||
visit community_topic_path(community, topic)
|
||||
|
||||
within first('.comment') do
|
||||
expect(page).to have_content 'Built with http://rubyonrails.org/'
|
||||
expect(page).to have_link('http://rubyonrails.org/', href: 'http://rubyonrails.org/')
|
||||
expect(find_link('http://rubyonrails.org/')[:rel]).to eq('nofollow')
|
||||
expect(find_link('http://rubyonrails.org/')[:target]).to eq('_blank')
|
||||
within first(".comment") do
|
||||
expect(page).to have_content "Built with http://rubyonrails.org/"
|
||||
expect(page).to have_link("http://rubyonrails.org/", href: "http://rubyonrails.org/")
|
||||
expect(find_link("http://rubyonrails.org/")[:rel]).to eq("nofollow")
|
||||
expect(find_link("http://rubyonrails.org/")[:target]).to eq("_blank")
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Sanitizes comment body for security' do
|
||||
scenario "Sanitizes comment body for security" do
|
||||
community = proposal.community
|
||||
topic = create(:topic, community: community)
|
||||
create :comment, commentable: topic,
|
||||
@@ -140,14 +140,14 @@ feature 'Commenting topics from proposals' do
|
||||
|
||||
visit community_topic_path(community, topic)
|
||||
|
||||
within first('.comment') do
|
||||
within first(".comment") do
|
||||
expect(page).to have_content "click me http://www.url.com"
|
||||
expect(page).to have_link('http://www.url.com', href: 'http://www.url.com')
|
||||
expect(page).not_to have_link('click me')
|
||||
expect(page).to have_link("http://www.url.com", href: "http://www.url.com")
|
||||
expect(page).not_to have_link("click me")
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Paginated comments' do
|
||||
scenario "Paginated comments" do
|
||||
community = proposal.community
|
||||
topic = create(:topic, community: community)
|
||||
per_page = 10
|
||||
@@ -155,7 +155,7 @@ feature 'Commenting topics from proposals' do
|
||||
|
||||
visit community_topic_path(community, topic)
|
||||
|
||||
expect(page).to have_css('.comment', count: per_page)
|
||||
expect(page).to have_css(".comment", count: per_page)
|
||||
within("ul.pagination") do
|
||||
expect(page).to have_content("1")
|
||||
expect(page).to have_content("2")
|
||||
@@ -163,59 +163,59 @@ feature 'Commenting topics from proposals' do
|
||||
click_link "Next", exact: false
|
||||
end
|
||||
|
||||
expect(page).to have_css('.comment', count: 2)
|
||||
expect(page).to have_css(".comment", count: 2)
|
||||
end
|
||||
|
||||
feature 'Not logged user' do
|
||||
scenario 'can not see comments forms' do
|
||||
feature "Not logged user" do
|
||||
scenario "can not see comments forms" do
|
||||
community = proposal.community
|
||||
topic = create(:topic, community: community)
|
||||
create(:comment, commentable: topic)
|
||||
|
||||
visit community_topic_path(community, topic)
|
||||
|
||||
expect(page).to have_content 'You must Sign in or Sign up to leave a comment'
|
||||
within('#comments') do
|
||||
expect(page).not_to have_content 'Write a comment'
|
||||
expect(page).not_to have_content 'Reply'
|
||||
expect(page).to have_content "You must Sign in or Sign up to leave a comment"
|
||||
within("#comments") do
|
||||
expect(page).not_to have_content "Write a comment"
|
||||
expect(page).not_to have_content "Reply"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Create', :js do
|
||||
scenario "Create", :js do
|
||||
login_as(user)
|
||||
community = proposal.community
|
||||
topic = create(:topic, community: community)
|
||||
visit community_topic_path(community, topic)
|
||||
|
||||
fill_in "comment-body-topic_#{topic.id}", with: 'Have you thought about...?'
|
||||
click_button 'Publish comment'
|
||||
fill_in "comment-body-topic_#{topic.id}", with: "Have you thought about...?"
|
||||
click_button "Publish comment"
|
||||
|
||||
within "#comments" do
|
||||
expect(page).to have_content 'Have you thought about...?'
|
||||
expect(page).to have_content "Have you thought about...?"
|
||||
end
|
||||
|
||||
within "#tab-comments-label" do
|
||||
expect(page).to have_content 'Comments (1)'
|
||||
expect(page).to have_content "Comments (1)"
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Errors on create', :js do
|
||||
scenario "Errors on create", :js do
|
||||
login_as(user)
|
||||
community = proposal.community
|
||||
topic = create(:topic, community: community)
|
||||
visit community_topic_path(community, topic)
|
||||
|
||||
click_button 'Publish comment'
|
||||
click_button "Publish comment"
|
||||
|
||||
expect(page).to have_content "Can't be blank"
|
||||
end
|
||||
|
||||
scenario 'Reply', :js do
|
||||
scenario "Reply", :js do
|
||||
community = proposal.community
|
||||
topic = create(:topic, community: community)
|
||||
citizen = create(:user, username: 'Ana')
|
||||
manuela = create(:user, username: 'Manuela')
|
||||
citizen = create(:user, username: "Ana")
|
||||
manuela = create(:user, username: "Manuela")
|
||||
comment = create(:comment, commentable: topic, user: citizen)
|
||||
|
||||
login_as(manuela)
|
||||
@@ -224,18 +224,18 @@ feature 'Commenting topics from proposals' do
|
||||
click_link "Reply"
|
||||
|
||||
within "#js-comment-form-comment_#{comment.id}" do
|
||||
fill_in "comment-body-comment_#{comment.id}", with: 'It will be done next week.'
|
||||
click_button 'Publish reply'
|
||||
fill_in "comment-body-comment_#{comment.id}", with: "It will be done next week."
|
||||
click_button "Publish reply"
|
||||
end
|
||||
|
||||
within "#comment_#{comment.id}" do
|
||||
expect(page).to have_content 'It will be done next week.'
|
||||
expect(page).to have_content "It will be done next week."
|
||||
end
|
||||
|
||||
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}", visible: true)
|
||||
end
|
||||
|
||||
scenario 'Errors on reply', :js do
|
||||
scenario "Errors on reply", :js do
|
||||
community = proposal.community
|
||||
topic = create(:topic, community: community)
|
||||
comment = create(:comment, commentable: topic, user: user)
|
||||
@@ -246,7 +246,7 @@ feature 'Commenting topics from proposals' do
|
||||
click_link "Reply"
|
||||
|
||||
within "#js-comment-form-comment_#{comment.id}" do
|
||||
click_button 'Publish reply'
|
||||
click_button "Publish reply"
|
||||
expect(page).to have_content "Can't be blank"
|
||||
end
|
||||
|
||||
@@ -304,7 +304,7 @@ feature 'Commenting topics from proposals' do
|
||||
end
|
||||
|
||||
scenario "Flagging turbolinks sanity check", :js do
|
||||
Setting['feature.community'] = true
|
||||
Setting["feature.community"] = true
|
||||
|
||||
community = proposal.community
|
||||
topic = create(:topic, community: community, title: "Should we change the world?")
|
||||
@@ -319,7 +319,7 @@ feature 'Commenting topics from proposals' do
|
||||
expect(page).to have_selector("#flag-comment-#{comment.id}")
|
||||
end
|
||||
|
||||
Setting['feature.community'] = nil
|
||||
Setting["feature.community"] = nil
|
||||
end
|
||||
|
||||
scenario "Erasing a comment's author" do
|
||||
@@ -331,8 +331,8 @@ feature 'Commenting topics from proposals' do
|
||||
visit community_topic_path(community, topic)
|
||||
|
||||
within "#comment_#{comment.id}" do
|
||||
expect(page).to have_content('User deleted')
|
||||
expect(page).to have_content('this should be visible')
|
||||
expect(page).to have_content("User deleted")
|
||||
expect(page).to have_content("this should be visible")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -373,7 +373,7 @@ feature 'Commenting topics from proposals' do
|
||||
within "#js-comment-form-comment_#{comment.id}" do
|
||||
fill_in "comment-body-comment_#{comment.id}", with: "I am moderating!"
|
||||
check "comment-as-moderator-comment_#{comment.id}"
|
||||
click_button 'Publish reply'
|
||||
click_button "Publish reply"
|
||||
end
|
||||
|
||||
within "#comment_#{comment.id}" do
|
||||
@@ -435,7 +435,7 @@ feature 'Commenting topics from proposals' do
|
||||
within "#js-comment-form-comment_#{comment.id}" do
|
||||
fill_in "comment-body-comment_#{comment.id}", with: "Top of the world!"
|
||||
check "comment-as-administrator-comment_#{comment.id}"
|
||||
click_button 'Publish reply'
|
||||
click_button "Publish reply"
|
||||
end
|
||||
|
||||
within "#comment_#{comment.id}" do
|
||||
@@ -460,7 +460,7 @@ feature 'Commenting topics from proposals' do
|
||||
end
|
||||
end
|
||||
|
||||
feature 'Voting comments' do
|
||||
feature "Voting comments" do
|
||||
|
||||
background do
|
||||
@manuela = create(:user, verified_at: Time.current)
|
||||
@@ -472,7 +472,7 @@ feature 'Commenting topics from proposals' do
|
||||
login_as(@manuela)
|
||||
end
|
||||
|
||||
scenario 'Show' do
|
||||
scenario "Show" do
|
||||
create(:vote, voter: @manuela, votable: @comment, vote_flag: true)
|
||||
create(:vote, voter: @pablo, votable: @comment, vote_flag: false)
|
||||
|
||||
@@ -491,7 +491,7 @@ feature 'Commenting topics from proposals' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Create', :js do
|
||||
scenario "Create", :js do
|
||||
visit community_topic_path(@proposal.community, @topic)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
@@ -509,23 +509,23 @@ feature 'Commenting topics from proposals' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Update', :js do
|
||||
scenario "Update", :js do
|
||||
visit community_topic_path(@proposal.community, @topic)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
find('.in_favor a').click
|
||||
find(".in_favor a").click
|
||||
|
||||
within('.in_favor') do
|
||||
within(".in_favor") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
find('.against a').click
|
||||
find(".against a").click
|
||||
|
||||
within('.in_favor') do
|
||||
within(".in_favor") do
|
||||
expect(page).to have_content "0"
|
||||
end
|
||||
|
||||
within('.against') do
|
||||
within(".against") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
@@ -533,18 +533,18 @@ feature 'Commenting topics from proposals' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Trying to vote multiple times', :js do
|
||||
scenario "Trying to vote multiple times", :js do
|
||||
visit community_topic_path(@proposal.community, @topic)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
find('.in_favor a').click
|
||||
find('.in_favor a').click
|
||||
find(".in_favor a").click
|
||||
find(".in_favor a").click
|
||||
|
||||
within('.in_favor') do
|
||||
within(".in_favor") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
within('.against') do
|
||||
within(".against") do
|
||||
expect(page).to have_content "0"
|
||||
end
|
||||
|
||||
@@ -555,28 +555,28 @@ feature 'Commenting topics from proposals' do
|
||||
|
||||
end
|
||||
|
||||
feature 'Commenting topics from budget investments' do
|
||||
feature "Commenting topics from budget investments" do
|
||||
let(:user) { create :user }
|
||||
let(:investment) { create :budget_investment }
|
||||
|
||||
scenario 'Index' do
|
||||
scenario "Index" do
|
||||
community = investment.community
|
||||
topic = create(:topic, community: community)
|
||||
create_list(:comment, 3, commentable: topic)
|
||||
|
||||
visit community_topic_path(community, topic)
|
||||
|
||||
expect(page).to have_css('.comment', count: 3)
|
||||
expect(page).to have_css(".comment", count: 3)
|
||||
|
||||
comment = Comment.last
|
||||
within first('.comment') do
|
||||
within first(".comment") do
|
||||
expect(page).to have_content comment.user.name
|
||||
expect(page).to have_content I18n.l(comment.created_at, format: :datetime)
|
||||
expect(page).to have_content comment.body
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Show' do
|
||||
scenario "Show" do
|
||||
community = investment.community
|
||||
topic = create(:topic, community: community)
|
||||
parent_comment = create(:comment, commentable: topic)
|
||||
@@ -593,7 +593,7 @@ feature 'Commenting topics from budget investments' do
|
||||
expect(page).to have_link "Go back to #{topic.title}", href: community_topic_path(community, topic)
|
||||
end
|
||||
|
||||
scenario 'Collapsable comments', :js do
|
||||
scenario "Collapsable comments", :js do
|
||||
community = investment.community
|
||||
topic = create(:topic, community: community)
|
||||
parent_comment = create(:comment, body: "Main comment", commentable: topic)
|
||||
@@ -602,26 +602,26 @@ feature 'Commenting topics from budget investments' do
|
||||
|
||||
visit community_topic_path(community, topic)
|
||||
|
||||
expect(page).to have_css('.comment', count: 3)
|
||||
expect(page).to have_css(".comment", count: 3)
|
||||
|
||||
find("#comment_#{child_comment.id}_children_arrow").click
|
||||
|
||||
expect(page).to have_css('.comment', count: 2)
|
||||
expect(page).to have_css(".comment", count: 2)
|
||||
expect(page).not_to have_content grandchild_comment.body
|
||||
|
||||
find("#comment_#{child_comment.id}_children_arrow").click
|
||||
|
||||
expect(page).to have_css('.comment', count: 3)
|
||||
expect(page).to have_css(".comment", count: 3)
|
||||
expect(page).to have_content grandchild_comment.body
|
||||
|
||||
find("#comment_#{parent_comment.id}_children_arrow").click
|
||||
|
||||
expect(page).to have_css('.comment', count: 1)
|
||||
expect(page).to have_css(".comment", count: 1)
|
||||
expect(page).not_to have_content child_comment.body
|
||||
expect(page).not_to have_content grandchild_comment.body
|
||||
end
|
||||
|
||||
scenario 'Comment order' do
|
||||
scenario "Comment order" do
|
||||
community = investment.community
|
||||
topic = create(:topic, community: community)
|
||||
c1 = create(:comment, :with_confidence_score, commentable: topic, cached_votes_up: 100,
|
||||
@@ -647,7 +647,7 @@ feature 'Commenting topics from budget investments' do
|
||||
expect(c2.body).to appear_before(c3.body)
|
||||
end
|
||||
|
||||
scenario 'Creation date works differently in roots and in child comments, when sorting by confidence_score' do
|
||||
scenario "Creation date works differently in roots and in child comments, when sorting by confidence_score" do
|
||||
community = investment.community
|
||||
topic = create(:topic, community: community)
|
||||
old_root = create(:comment, commentable: topic, created_at: Time.current - 10)
|
||||
@@ -671,22 +671,22 @@ feature 'Commenting topics from budget investments' do
|
||||
expect(old_child.body).to appear_before(new_child.body)
|
||||
end
|
||||
|
||||
scenario 'Turns links into html links' do
|
||||
scenario "Turns links into html links" do
|
||||
community = investment.community
|
||||
topic = create(:topic, community: community)
|
||||
create :comment, commentable: topic, body: 'Built with http://rubyonrails.org/'
|
||||
create :comment, commentable: topic, body: "Built with http://rubyonrails.org/"
|
||||
|
||||
visit community_topic_path(community, topic)
|
||||
|
||||
within first('.comment') do
|
||||
expect(page).to have_content 'Built with http://rubyonrails.org/'
|
||||
expect(page).to have_link('http://rubyonrails.org/', href: 'http://rubyonrails.org/')
|
||||
expect(find_link('http://rubyonrails.org/')[:rel]).to eq('nofollow')
|
||||
expect(find_link('http://rubyonrails.org/')[:target]).to eq('_blank')
|
||||
within first(".comment") do
|
||||
expect(page).to have_content "Built with http://rubyonrails.org/"
|
||||
expect(page).to have_link("http://rubyonrails.org/", href: "http://rubyonrails.org/")
|
||||
expect(find_link("http://rubyonrails.org/")[:rel]).to eq("nofollow")
|
||||
expect(find_link("http://rubyonrails.org/")[:target]).to eq("_blank")
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Sanitizes comment body for security' do
|
||||
scenario "Sanitizes comment body for security" do
|
||||
community = investment.community
|
||||
topic = create(:topic, community: community)
|
||||
create :comment, commentable: topic,
|
||||
@@ -694,14 +694,14 @@ feature 'Commenting topics from budget investments' do
|
||||
|
||||
visit community_topic_path(community, topic)
|
||||
|
||||
within first('.comment') do
|
||||
within first(".comment") do
|
||||
expect(page).to have_content "click me http://www.url.com"
|
||||
expect(page).to have_link('http://www.url.com', href: 'http://www.url.com')
|
||||
expect(page).not_to have_link('click me')
|
||||
expect(page).to have_link("http://www.url.com", href: "http://www.url.com")
|
||||
expect(page).not_to have_link("click me")
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Paginated comments' do
|
||||
scenario "Paginated comments" do
|
||||
community = investment.community
|
||||
topic = create(:topic, community: community)
|
||||
per_page = 10
|
||||
@@ -709,7 +709,7 @@ feature 'Commenting topics from budget investments' do
|
||||
|
||||
visit community_topic_path(community, topic)
|
||||
|
||||
expect(page).to have_css('.comment', count: per_page)
|
||||
expect(page).to have_css(".comment", count: per_page)
|
||||
within("ul.pagination") do
|
||||
expect(page).to have_content("1")
|
||||
expect(page).to have_content("2")
|
||||
@@ -717,59 +717,59 @@ feature 'Commenting topics from budget investments' do
|
||||
click_link "Next", exact: false
|
||||
end
|
||||
|
||||
expect(page).to have_css('.comment', count: 2)
|
||||
expect(page).to have_css(".comment", count: 2)
|
||||
end
|
||||
|
||||
feature 'Not logged user' do
|
||||
scenario 'can not see comments forms' do
|
||||
feature "Not logged user" do
|
||||
scenario "can not see comments forms" do
|
||||
community = investment.community
|
||||
topic = create(:topic, community: community)
|
||||
create(:comment, commentable: topic)
|
||||
|
||||
visit community_topic_path(community, topic)
|
||||
|
||||
expect(page).to have_content 'You must Sign in or Sign up to leave a comment'
|
||||
within('#comments') do
|
||||
expect(page).not_to have_content 'Write a comment'
|
||||
expect(page).not_to have_content 'Reply'
|
||||
expect(page).to have_content "You must Sign in or Sign up to leave a comment"
|
||||
within("#comments") do
|
||||
expect(page).not_to have_content "Write a comment"
|
||||
expect(page).not_to have_content "Reply"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Create', :js do
|
||||
scenario "Create", :js do
|
||||
login_as(user)
|
||||
community = investment.community
|
||||
topic = create(:topic, community: community)
|
||||
visit community_topic_path(community, topic)
|
||||
|
||||
fill_in "comment-body-topic_#{topic.id}", with: 'Have you thought about...?'
|
||||
click_button 'Publish comment'
|
||||
fill_in "comment-body-topic_#{topic.id}", with: "Have you thought about...?"
|
||||
click_button "Publish comment"
|
||||
|
||||
within "#comments" do
|
||||
expect(page).to have_content 'Have you thought about...?'
|
||||
expect(page).to have_content "Have you thought about...?"
|
||||
end
|
||||
|
||||
within "#tab-comments-label" do
|
||||
expect(page).to have_content 'Comments (1)'
|
||||
expect(page).to have_content "Comments (1)"
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Errors on create', :js do
|
||||
scenario "Errors on create", :js do
|
||||
login_as(user)
|
||||
community = investment.community
|
||||
topic = create(:topic, community: community)
|
||||
visit community_topic_path(community, topic)
|
||||
|
||||
click_button 'Publish comment'
|
||||
click_button "Publish comment"
|
||||
|
||||
expect(page).to have_content "Can't be blank"
|
||||
end
|
||||
|
||||
scenario 'Reply', :js do
|
||||
scenario "Reply", :js do
|
||||
community = investment.community
|
||||
topic = create(:topic, community: community)
|
||||
citizen = create(:user, username: 'Ana')
|
||||
manuela = create(:user, username: 'Manuela')
|
||||
citizen = create(:user, username: "Ana")
|
||||
manuela = create(:user, username: "Manuela")
|
||||
comment = create(:comment, commentable: topic, user: citizen)
|
||||
|
||||
login_as(manuela)
|
||||
@@ -778,18 +778,18 @@ feature 'Commenting topics from budget investments' do
|
||||
click_link "Reply"
|
||||
|
||||
within "#js-comment-form-comment_#{comment.id}" do
|
||||
fill_in "comment-body-comment_#{comment.id}", with: 'It will be done next week.'
|
||||
click_button 'Publish reply'
|
||||
fill_in "comment-body-comment_#{comment.id}", with: "It will be done next week."
|
||||
click_button "Publish reply"
|
||||
end
|
||||
|
||||
within "#comment_#{comment.id}" do
|
||||
expect(page).to have_content 'It will be done next week.'
|
||||
expect(page).to have_content "It will be done next week."
|
||||
end
|
||||
|
||||
expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}", visible: true)
|
||||
end
|
||||
|
||||
scenario 'Errors on reply', :js do
|
||||
scenario "Errors on reply", :js do
|
||||
community = investment.community
|
||||
topic = create(:topic, community: community)
|
||||
comment = create(:comment, commentable: topic, user: user)
|
||||
@@ -800,7 +800,7 @@ feature 'Commenting topics from budget investments' do
|
||||
click_link "Reply"
|
||||
|
||||
within "#js-comment-form-comment_#{comment.id}" do
|
||||
click_button 'Publish reply'
|
||||
click_button "Publish reply"
|
||||
expect(page).to have_content "Can't be blank"
|
||||
end
|
||||
|
||||
@@ -858,7 +858,7 @@ feature 'Commenting topics from budget investments' do
|
||||
end
|
||||
|
||||
scenario "Flagging turbolinks sanity check", :js do
|
||||
Setting['feature.community'] = true
|
||||
Setting["feature.community"] = true
|
||||
|
||||
community = investment.community
|
||||
topic = create(:topic, community: community, title: "Should we change the world?")
|
||||
@@ -873,7 +873,7 @@ feature 'Commenting topics from budget investments' do
|
||||
expect(page).to have_selector("#flag-comment-#{comment.id}")
|
||||
end
|
||||
|
||||
Setting['feature.community'] = nil
|
||||
Setting["feature.community"] = nil
|
||||
end
|
||||
|
||||
scenario "Erasing a comment's author" do
|
||||
@@ -885,8 +885,8 @@ feature 'Commenting topics from budget investments' do
|
||||
visit community_topic_path(community, topic)
|
||||
|
||||
within "#comment_#{comment.id}" do
|
||||
expect(page).to have_content('User deleted')
|
||||
expect(page).to have_content('this should be visible')
|
||||
expect(page).to have_content("User deleted")
|
||||
expect(page).to have_content("this should be visible")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -927,7 +927,7 @@ feature 'Commenting topics from budget investments' do
|
||||
within "#js-comment-form-comment_#{comment.id}" do
|
||||
fill_in "comment-body-comment_#{comment.id}", with: "I am moderating!"
|
||||
check "comment-as-moderator-comment_#{comment.id}"
|
||||
click_button 'Publish reply'
|
||||
click_button "Publish reply"
|
||||
end
|
||||
|
||||
within "#comment_#{comment.id}" do
|
||||
@@ -989,7 +989,7 @@ feature 'Commenting topics from budget investments' do
|
||||
within "#js-comment-form-comment_#{comment.id}" do
|
||||
fill_in "comment-body-comment_#{comment.id}", with: "Top of the world!"
|
||||
check "comment-as-administrator-comment_#{comment.id}"
|
||||
click_button 'Publish reply'
|
||||
click_button "Publish reply"
|
||||
end
|
||||
|
||||
within "#comment_#{comment.id}" do
|
||||
@@ -1014,7 +1014,7 @@ feature 'Commenting topics from budget investments' do
|
||||
end
|
||||
end
|
||||
|
||||
feature 'Voting comments' do
|
||||
feature "Voting comments" do
|
||||
|
||||
background do
|
||||
@manuela = create(:user, verified_at: Time.current)
|
||||
@@ -1026,7 +1026,7 @@ feature 'Commenting topics from budget investments' do
|
||||
login_as(@manuela)
|
||||
end
|
||||
|
||||
scenario 'Show' do
|
||||
scenario "Show" do
|
||||
create(:vote, voter: @manuela, votable: @comment, vote_flag: true)
|
||||
create(:vote, voter: @pablo, votable: @comment, vote_flag: false)
|
||||
|
||||
@@ -1045,7 +1045,7 @@ feature 'Commenting topics from budget investments' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Create', :js do
|
||||
scenario "Create", :js do
|
||||
visit community_topic_path(@investment.community, @topic)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
@@ -1063,23 +1063,23 @@ feature 'Commenting topics from budget investments' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Update', :js do
|
||||
scenario "Update", :js do
|
||||
visit community_topic_path(@investment.community, @topic)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
find('.in_favor a').click
|
||||
find(".in_favor a").click
|
||||
|
||||
within('.in_favor') do
|
||||
within(".in_favor") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
find('.against a').click
|
||||
find(".against a").click
|
||||
|
||||
within('.in_favor') do
|
||||
within(".in_favor") do
|
||||
expect(page).to have_content "0"
|
||||
end
|
||||
|
||||
within('.against') do
|
||||
within(".against") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
@@ -1087,18 +1087,18 @@ feature 'Commenting topics from budget investments' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Trying to vote multiple times', :js do
|
||||
scenario "Trying to vote multiple times", :js do
|
||||
visit community_topic_path(@investment.community, @topic)
|
||||
|
||||
within("#comment_#{@comment.id}_votes") do
|
||||
find('.in_favor a').click
|
||||
find('.in_favor a').click
|
||||
find(".in_favor a").click
|
||||
find(".in_favor a").click
|
||||
|
||||
within('.in_favor') do
|
||||
within(".in_favor") do
|
||||
expect(page).to have_content "1"
|
||||
end
|
||||
|
||||
within('.against') do
|
||||
within(".against") do
|
||||
expect(page).to have_content "0"
|
||||
end
|
||||
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Communities' do
|
||||
feature "Communities" do
|
||||
|
||||
background do
|
||||
Setting['feature.community'] = true
|
||||
Setting["feature.community"] = true
|
||||
end
|
||||
|
||||
after do
|
||||
Setting['feature.community'] = nil
|
||||
Setting["feature.community"] = nil
|
||||
end
|
||||
|
||||
context 'Show' do
|
||||
context "Show" do
|
||||
|
||||
scenario 'Should display default content' do
|
||||
scenario "Should display default content" do
|
||||
proposal = create(:proposal)
|
||||
community = proposal.community
|
||||
user = create(:user)
|
||||
@@ -26,7 +26,7 @@ feature 'Communities' do
|
||||
expect(page).to have_link("Create topic", href: new_community_topic_path(community))
|
||||
end
|
||||
|
||||
scenario 'Should display without_topics_text and participants when there are not topics' do
|
||||
scenario "Should display without_topics_text and participants when there are not topics" do
|
||||
proposal = create(:proposal)
|
||||
community = proposal.community
|
||||
|
||||
@@ -36,7 +36,7 @@ feature 'Communities' do
|
||||
expect(page).to have_content "Participants (1)"
|
||||
end
|
||||
|
||||
scenario 'Should display order selector and topic content when there are topics' do
|
||||
scenario "Should display order selector and topic content when there are topics" do
|
||||
proposal = create(:proposal)
|
||||
community = proposal.community
|
||||
topic = create(:topic, community: community)
|
||||
@@ -90,7 +90,7 @@ feature 'Communities' do
|
||||
expect(topic2.title).to appear_before(topic1.title)
|
||||
end
|
||||
|
||||
scenario 'Should display topic edit button on topic show when author is logged' do
|
||||
scenario "Should display topic edit button on topic show when author is logged" do
|
||||
proposal = create(:proposal)
|
||||
community = proposal.community
|
||||
user = create(:user)
|
||||
@@ -105,7 +105,7 @@ feature 'Communities' do
|
||||
expect(page).not_to have_link("Edit topic", href: edit_community_topic_path(community, topic2))
|
||||
end
|
||||
|
||||
scenario 'Should display participant when there is topics' do
|
||||
scenario "Should display participant when there is topics" do
|
||||
proposal = create(:proposal)
|
||||
community = proposal.community
|
||||
topic = create(:topic, community: community)
|
||||
@@ -119,7 +119,7 @@ feature 'Communities' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Should display participants when there are topics and comments' do
|
||||
scenario "Should display participants when there are topics and comments" do
|
||||
proposal = create(:proposal)
|
||||
community = proposal.community
|
||||
topic = create(:topic, community: community)
|
||||
@@ -135,8 +135,8 @@ feature 'Communities' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Should redirect root path when communities are disabled' do
|
||||
Setting['feature.community'] = nil
|
||||
scenario "Should redirect root path when communities are disabled" do
|
||||
Setting["feature.community"] = nil
|
||||
proposal = create(:proposal)
|
||||
community = proposal.community
|
||||
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
# coding: utf-8
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Debates' do
|
||||
feature "Debates" do
|
||||
|
||||
scenario 'Disabled with a feature flag' do
|
||||
Setting['feature.debates'] = nil
|
||||
scenario "Disabled with a feature flag" do
|
||||
Setting["feature.debates"] = nil
|
||||
expect{ visit debates_path }.to raise_exception(FeatureFlags::FeatureDisabled)
|
||||
Setting['feature.debates'] = true
|
||||
Setting["feature.debates"] = true
|
||||
end
|
||||
|
||||
context "Concerns" do
|
||||
it_behaves_like 'notifiable in-app', Debate
|
||||
it_behaves_like 'relationable', Debate
|
||||
it_behaves_like "notifiable in-app", Debate
|
||||
it_behaves_like "relationable", Debate
|
||||
end
|
||||
|
||||
scenario 'Index' do
|
||||
scenario "Index" do
|
||||
debates = [create(:debate), create(:debate), create(:debate)]
|
||||
|
||||
visit debates_path
|
||||
|
||||
expect(page).to have_selector('#debates .debate', count: 3)
|
||||
expect(page).to have_selector("#debates .debate", count: 3)
|
||||
debates.each do |debate|
|
||||
within('#debates') do
|
||||
within("#debates") do
|
||||
expect(page).to have_content debate.title
|
||||
expect(page).to have_content debate.description
|
||||
expect(page).to have_css("a[href='#{debate_path(debate)}']", text: debate.title)
|
||||
@@ -29,13 +29,13 @@ feature 'Debates' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Paginated Index' do
|
||||
scenario "Paginated Index" do
|
||||
per_page = Kaminari.config.default_per_page
|
||||
(per_page + 2).times { create(:debate) }
|
||||
|
||||
visit debates_path
|
||||
|
||||
expect(page).to have_selector('#debates .debate', count: per_page)
|
||||
expect(page).to have_selector("#debates .debate", count: per_page)
|
||||
|
||||
within("ul.pagination") do
|
||||
expect(page).to have_content("1")
|
||||
@@ -44,38 +44,38 @@ feature 'Debates' do
|
||||
click_link "Next", exact: false
|
||||
end
|
||||
|
||||
expect(page).to have_selector('#debates .debate', count: 2)
|
||||
expect(page).to have_selector("#debates .debate", count: 2)
|
||||
end
|
||||
|
||||
scenario 'Index view mode' do
|
||||
scenario "Index view mode" do
|
||||
debates = [create(:debate), create(:debate), create(:debate)]
|
||||
|
||||
visit debates_path
|
||||
|
||||
click_button 'View mode'
|
||||
click_button "View mode"
|
||||
|
||||
click_link 'List'
|
||||
click_link "List"
|
||||
|
||||
debates.each do |debate|
|
||||
within('#debates') do
|
||||
within("#debates") do
|
||||
expect(page).to have_link debate.title
|
||||
expect(page).not_to have_content debate.description
|
||||
end
|
||||
end
|
||||
|
||||
click_button 'View mode'
|
||||
click_button "View mode"
|
||||
|
||||
click_link 'Cards'
|
||||
click_link "Cards"
|
||||
|
||||
debates.each do |debate|
|
||||
within('#debates') do
|
||||
within("#debates") do
|
||||
expect(page).to have_link debate.title
|
||||
expect(page).to have_content debate.description
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Show' do
|
||||
scenario "Show" do
|
||||
debate = create(:debate)
|
||||
|
||||
visit debate_path(debate)
|
||||
@@ -87,13 +87,13 @@ feature 'Debates' do
|
||||
expect(page).to have_selector(avatar(debate.author.name))
|
||||
expect(page.html).to include "<title>#{debate.title}</title>"
|
||||
|
||||
within('.social-share-button') do
|
||||
expect(page.all('a').count).to be(4) # Twitter, Facebook, Google+, Telegram
|
||||
within(".social-share-button") do
|
||||
expect(page.all("a").count).to be(4) # Twitter, Facebook, Google+, Telegram
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Show: "Back" link directs to previous page' do
|
||||
debate = create(:debate, title: 'Test Debate 1')
|
||||
scenario "Show: 'Back' link directs to previous page" do
|
||||
debate = create(:debate, title: "Test Debate 1")
|
||||
|
||||
visit debates_path(order: :hot_score, page: 1)
|
||||
|
||||
@@ -101,13 +101,13 @@ feature 'Debates' do
|
||||
click_link debate.title
|
||||
end
|
||||
|
||||
link_text = find_link('Go back')[:href]
|
||||
link_text = find_link("Go back")[:href]
|
||||
|
||||
expect(link_text).to include(debates_path(order: :hot_score, page: 1))
|
||||
end
|
||||
|
||||
context "Show" do
|
||||
scenario 'When path matches the friendly url' do
|
||||
scenario "When path matches the friendly url" do
|
||||
debate = create(:debate)
|
||||
|
||||
right_path = debate_path(debate)
|
||||
@@ -116,7 +116,7 @@ feature 'Debates' do
|
||||
expect(page).to have_current_path(right_path)
|
||||
end
|
||||
|
||||
scenario 'When path does not match the friendly url' do
|
||||
scenario "When path does not match the friendly url" do
|
||||
debate = create(:debate)
|
||||
|
||||
right_path = debate_path(debate)
|
||||
@@ -165,128 +165,128 @@ feature 'Debates' do
|
||||
expect(page).to have_content("-6 votes")
|
||||
end
|
||||
|
||||
scenario 'Create' do
|
||||
scenario "Create" do
|
||||
author = create(:user)
|
||||
login_as(author)
|
||||
|
||||
visit new_debate_path
|
||||
fill_in 'debate_title', with: 'A title for a debate'
|
||||
fill_in 'debate_description', with: 'This is very important because...'
|
||||
check 'debate_terms_of_service'
|
||||
fill_in "debate_title", with: "A title for a debate"
|
||||
fill_in "debate_description", with: "This is very important because..."
|
||||
check "debate_terms_of_service"
|
||||
|
||||
click_button 'Start a debate'
|
||||
click_button "Start a debate"
|
||||
|
||||
expect(page).to have_content 'A title for a debate'
|
||||
expect(page).to have_content 'Debate created successfully.'
|
||||
expect(page).to have_content 'This is very important because...'
|
||||
expect(page).to have_content "A title for a debate"
|
||||
expect(page).to have_content "Debate created successfully."
|
||||
expect(page).to have_content "This is very important because..."
|
||||
expect(page).to have_content author.name
|
||||
expect(page).to have_content I18n.l(Debate.last.created_at.to_date)
|
||||
end
|
||||
|
||||
scenario 'Create with invisible_captcha honeypot field' do
|
||||
scenario "Create with invisible_captcha honeypot field" do
|
||||
author = create(:user)
|
||||
login_as(author)
|
||||
|
||||
visit new_debate_path
|
||||
fill_in 'debate_title', with: 'I am a bot'
|
||||
fill_in 'debate_subtitle', with: 'This is a honeypot field'
|
||||
fill_in 'debate_description', with: 'This is the description'
|
||||
check 'debate_terms_of_service'
|
||||
fill_in "debate_title", with: "I am a bot"
|
||||
fill_in "debate_subtitle", with: "This is a honeypot field"
|
||||
fill_in "debate_description", with: "This is the description"
|
||||
check "debate_terms_of_service"
|
||||
|
||||
click_button 'Start a debate'
|
||||
click_button "Start a debate"
|
||||
|
||||
expect(page.status_code).to eq(200)
|
||||
expect(page.html).to be_empty
|
||||
expect(page).to have_current_path(debates_path)
|
||||
end
|
||||
|
||||
scenario 'Create debate too fast' do
|
||||
scenario "Create debate too fast" do
|
||||
allow(InvisibleCaptcha).to receive(:timestamp_threshold).and_return(Float::INFINITY)
|
||||
|
||||
author = create(:user)
|
||||
login_as(author)
|
||||
|
||||
visit new_debate_path
|
||||
fill_in 'debate_title', with: 'I am a bot'
|
||||
fill_in 'debate_description', with: 'This is the description'
|
||||
check 'debate_terms_of_service'
|
||||
fill_in "debate_title", with: "I am a bot"
|
||||
fill_in "debate_description", with: "This is the description"
|
||||
check "debate_terms_of_service"
|
||||
|
||||
click_button 'Start a debate'
|
||||
click_button "Start a debate"
|
||||
|
||||
expect(page).to have_content 'Sorry, that was too quick! Please resubmit'
|
||||
expect(page).to have_content "Sorry, that was too quick! Please resubmit"
|
||||
|
||||
expect(page).to have_current_path(new_debate_path)
|
||||
end
|
||||
|
||||
scenario 'Errors on create' do
|
||||
scenario "Errors on create" do
|
||||
author = create(:user)
|
||||
login_as(author)
|
||||
|
||||
visit new_debate_path
|
||||
click_button 'Start a debate'
|
||||
click_button "Start a debate"
|
||||
expect(page).to have_content error_message
|
||||
end
|
||||
|
||||
scenario 'JS injection is prevented but safe html is respected' do
|
||||
scenario "JS injection is prevented but safe html is respected" do
|
||||
author = create(:user)
|
||||
login_as(author)
|
||||
|
||||
visit new_debate_path
|
||||
fill_in 'debate_title', with: 'Testing an attack'
|
||||
fill_in 'debate_description', with: '<p>This is <script>alert("an attack");</script></p>'
|
||||
check 'debate_terms_of_service'
|
||||
fill_in "debate_title", with: "Testing an attack"
|
||||
fill_in "debate_description", with: "<p>This is <script>alert('an attack');</script></p>"
|
||||
check "debate_terms_of_service"
|
||||
|
||||
click_button 'Start a debate'
|
||||
click_button "Start a debate"
|
||||
|
||||
expect(page).to have_content 'Debate created successfully.'
|
||||
expect(page).to have_content 'Testing an attack'
|
||||
expect(page.html).to include '<p>This is alert("an attack");</p>'
|
||||
expect(page.html).not_to include '<script>alert("an attack");</script>'
|
||||
expect(page.html).not_to include '<p>This is'
|
||||
expect(page).to have_content "Debate created successfully."
|
||||
expect(page).to have_content "Testing an attack"
|
||||
expect(page.html).to include "<p>This is alert('an attack');</p>"
|
||||
expect(page.html).not_to include "<script>alert('an attack');</script>"
|
||||
expect(page.html).not_to include "<p>This is"
|
||||
end
|
||||
|
||||
scenario 'Autolinking is applied to description' do
|
||||
scenario "Autolinking is applied to description" do
|
||||
author = create(:user)
|
||||
login_as(author)
|
||||
|
||||
visit new_debate_path
|
||||
fill_in 'debate_title', with: 'Testing auto link'
|
||||
fill_in 'debate_description', with: '<p>This is a link www.example.org</p>'
|
||||
check 'debate_terms_of_service'
|
||||
fill_in "debate_title", with: "Testing auto link"
|
||||
fill_in "debate_description", with: "<p>This is a link www.example.org</p>"
|
||||
check "debate_terms_of_service"
|
||||
|
||||
click_button 'Start a debate'
|
||||
click_button "Start a debate"
|
||||
|
||||
expect(page).to have_content 'Debate created successfully.'
|
||||
expect(page).to have_content 'Testing auto link'
|
||||
expect(page).to have_link('www.example.org', href: 'http://www.example.org')
|
||||
expect(page).to have_content "Debate created successfully."
|
||||
expect(page).to have_content "Testing auto link"
|
||||
expect(page).to have_link("www.example.org", href: "http://www.example.org")
|
||||
end
|
||||
|
||||
scenario 'JS injection is prevented but autolinking is respected' do
|
||||
scenario "JS injection is prevented but autolinking is respected" do
|
||||
author = create(:user)
|
||||
js_injection_string = "<script>alert('hey')</script> <a href=\"javascript:alert('surprise!')\">click me<a/> http://example.org"
|
||||
login_as(author)
|
||||
|
||||
visit new_debate_path
|
||||
fill_in 'debate_title', with: 'Testing auto link'
|
||||
fill_in 'debate_description', with: js_injection_string
|
||||
check 'debate_terms_of_service'
|
||||
fill_in "debate_title", with: "Testing auto link"
|
||||
fill_in "debate_description", with: js_injection_string
|
||||
check "debate_terms_of_service"
|
||||
|
||||
click_button 'Start a debate'
|
||||
click_button "Start a debate"
|
||||
|
||||
expect(page).to have_content 'Debate created successfully.'
|
||||
expect(page).to have_content 'Testing auto link'
|
||||
expect(page).to have_link('http://example.org', href: 'http://example.org')
|
||||
expect(page).not_to have_link('click me')
|
||||
expect(page).to have_content "Debate created successfully."
|
||||
expect(page).to have_content "Testing auto link"
|
||||
expect(page).to have_link("http://example.org", href: "http://example.org")
|
||||
expect(page).not_to have_link("click me")
|
||||
expect(page.html).not_to include "<script>alert('hey')</script>"
|
||||
|
||||
click_link 'Edit'
|
||||
click_link "Edit"
|
||||
|
||||
expect(page).to have_current_path(edit_debate_path(Debate.last))
|
||||
expect(page).not_to have_link('click me')
|
||||
expect(page).not_to have_link("click me")
|
||||
expect(page.html).not_to include "<script>alert('hey')</script>"
|
||||
end
|
||||
|
||||
scenario 'Update should not be posible if logged user is not the author' do
|
||||
scenario "Update should not be posible if logged user is not the author" do
|
||||
debate = create(:debate)
|
||||
expect(debate).to be_editable
|
||||
login_as(create(:user))
|
||||
@@ -297,7 +297,7 @@ feature 'Debates' do
|
||||
expect(page).to have_content "You do not have permission to carry out the action 'edit' on debate."
|
||||
end
|
||||
|
||||
scenario 'Update should not be posible if debate is not editable' do
|
||||
scenario "Update should not be posible if debate is not editable" do
|
||||
debate = create(:debate)
|
||||
Setting["max_votes_for_debate_edit"] = 2
|
||||
3.times { create(:vote, votable: debate) }
|
||||
@@ -309,18 +309,18 @@ feature 'Debates' do
|
||||
|
||||
expect(page).not_to have_current_path(edit_debate_path(debate))
|
||||
expect(page).to have_current_path(root_path)
|
||||
expect(page).to have_content 'You do not have permission to'
|
||||
expect(page).to have_content "You do not have permission to"
|
||||
end
|
||||
|
||||
scenario 'Update should be posible for the author of an editable debate' do
|
||||
scenario "Update should be posible for the author of an editable debate" do
|
||||
debate = create(:debate)
|
||||
login_as(debate.author)
|
||||
|
||||
visit edit_debate_path(debate)
|
||||
expect(page).to have_current_path(edit_debate_path(debate))
|
||||
|
||||
fill_in 'debate_title', with: "End child poverty"
|
||||
fill_in 'debate_description', with: "Let's do something to end child poverty"
|
||||
fill_in "debate_title", with: "End child poverty"
|
||||
fill_in "debate_description", with: "Let's do something to end child poverty"
|
||||
|
||||
click_button "Save changes"
|
||||
|
||||
@@ -329,12 +329,12 @@ feature 'Debates' do
|
||||
expect(page).to have_content "Let's do something to end child poverty"
|
||||
end
|
||||
|
||||
scenario 'Errors on update' do
|
||||
scenario "Errors on update" do
|
||||
debate = create(:debate)
|
||||
login_as(debate.author)
|
||||
|
||||
visit edit_debate_path(debate)
|
||||
fill_in 'debate_title', with: ""
|
||||
fill_in "debate_title", with: ""
|
||||
click_button "Save changes"
|
||||
|
||||
expect(page).to have_content error_message
|
||||
@@ -375,14 +375,14 @@ feature 'Debates' do
|
||||
expect(Flag.flagged?(user, debate)).not_to be
|
||||
end
|
||||
|
||||
feature 'Debate index order filters' do
|
||||
feature "Debate index order filters" do
|
||||
|
||||
scenario 'Default order is hot_score', :js do
|
||||
best_debate = create(:debate, title: 'Best')
|
||||
scenario "Default order is hot_score", :js do
|
||||
best_debate = create(:debate, title: "Best")
|
||||
best_debate.update_column(:hot_score, 10)
|
||||
worst_debate = create(:debate, title: 'Worst')
|
||||
worst_debate = create(:debate, title: "Worst")
|
||||
worst_debate.update_column(:hot_score, 2)
|
||||
medium_debate = create(:debate, title: 'Medium')
|
||||
medium_debate = create(:debate, title: "Medium")
|
||||
medium_debate.update_column(:hot_score, 5)
|
||||
|
||||
visit debates_path
|
||||
@@ -391,160 +391,160 @@ feature 'Debates' do
|
||||
expect(medium_debate.title).to appear_before(worst_debate.title)
|
||||
end
|
||||
|
||||
scenario 'Debates are ordered by confidence_score', :js do
|
||||
best_debate = create(:debate, title: 'Best')
|
||||
scenario "Debates are ordered by confidence_score", :js do
|
||||
best_debate = create(:debate, title: "Best")
|
||||
best_debate.update_column(:confidence_score, 10)
|
||||
worst_debate = create(:debate, title: 'Worst')
|
||||
worst_debate = create(:debate, title: "Worst")
|
||||
worst_debate.update_column(:confidence_score, 2)
|
||||
medium_debate = create(:debate, title: 'Medium')
|
||||
medium_debate = create(:debate, title: "Medium")
|
||||
medium_debate.update_column(:confidence_score, 5)
|
||||
|
||||
visit debates_path
|
||||
click_link 'highest rated'
|
||||
click_link "highest rated"
|
||||
|
||||
expect(page).to have_selector('a.is-active', text: 'highest rated')
|
||||
expect(page).to have_selector("a.is-active", text: "highest rated")
|
||||
|
||||
within '#debates' do
|
||||
within "#debates" do
|
||||
expect(best_debate.title).to appear_before(medium_debate.title)
|
||||
expect(medium_debate.title).to appear_before(worst_debate.title)
|
||||
end
|
||||
|
||||
expect(current_url).to include('order=confidence_score')
|
||||
expect(current_url).to include('page=1')
|
||||
expect(current_url).to include("order=confidence_score")
|
||||
expect(current_url).to include("page=1")
|
||||
end
|
||||
|
||||
scenario 'Debates are ordered by newest', :js do
|
||||
best_debate = create(:debate, title: 'Best', created_at: Time.current)
|
||||
medium_debate = create(:debate, title: 'Medium', created_at: Time.current - 1.hour)
|
||||
worst_debate = create(:debate, title: 'Worst', created_at: Time.current - 1.day)
|
||||
scenario "Debates are ordered by newest", :js do
|
||||
best_debate = create(:debate, title: "Best", created_at: Time.current)
|
||||
medium_debate = create(:debate, title: "Medium", created_at: Time.current - 1.hour)
|
||||
worst_debate = create(:debate, title: "Worst", created_at: Time.current - 1.day)
|
||||
|
||||
visit debates_path
|
||||
click_link 'newest'
|
||||
click_link "newest"
|
||||
|
||||
expect(page).to have_selector('a.is-active', text: 'newest')
|
||||
expect(page).to have_selector("a.is-active", text: "newest")
|
||||
|
||||
within '#debates' do
|
||||
within "#debates" do
|
||||
expect(best_debate.title).to appear_before(medium_debate.title)
|
||||
expect(medium_debate.title).to appear_before(worst_debate.title)
|
||||
end
|
||||
|
||||
expect(current_url).to include('order=created_at')
|
||||
expect(current_url).to include('page=1')
|
||||
expect(current_url).to include("order=created_at")
|
||||
expect(current_url).to include("page=1")
|
||||
end
|
||||
|
||||
context 'Recommendations' do
|
||||
context "Recommendations" do
|
||||
|
||||
let!(:best_debate) { create(:debate, title: 'Best', cached_votes_total: 10, tag_list: 'Sport') }
|
||||
let!(:medium_debate) { create(:debate, title: 'Medium', cached_votes_total: 5, tag_list: 'Sport') }
|
||||
let!(:worst_debate) { create(:debate, title: 'Worst', cached_votes_total: 1, tag_list: 'Sport') }
|
||||
let!(:best_debate) { create(:debate, title: "Best", cached_votes_total: 10, tag_list: "Sport") }
|
||||
let!(:medium_debate) { create(:debate, title: "Medium", cached_votes_total: 5, tag_list: "Sport") }
|
||||
let!(:worst_debate) { create(:debate, title: "Worst", cached_votes_total: 1, tag_list: "Sport") }
|
||||
|
||||
background do
|
||||
Setting['feature.user.recommendations'] = true
|
||||
Setting['feature.user.recommendations_on_debates'] = true
|
||||
Setting["feature.user.recommendations"] = true
|
||||
Setting["feature.user.recommendations_on_debates"] = true
|
||||
end
|
||||
|
||||
after do
|
||||
Setting['feature.user.recommendations'] = nil
|
||||
Setting['feature.user.recommendations_on_debates'] = nil
|
||||
Setting["feature.user.recommendations"] = nil
|
||||
Setting["feature.user.recommendations_on_debates"] = nil
|
||||
end
|
||||
|
||||
scenario "can't be sorted if there's no logged user" do
|
||||
visit debates_path
|
||||
expect(page).not_to have_selector('a', text: 'recommendations')
|
||||
expect(page).not_to have_selector("a", text: "recommendations")
|
||||
end
|
||||
|
||||
scenario 'are shown on index header when account setting is enabled' do
|
||||
scenario "are shown on index header when account setting is enabled" do
|
||||
user = create(:user)
|
||||
proposal = create(:proposal, tag_list: 'Sport')
|
||||
proposal = create(:proposal, tag_list: "Sport")
|
||||
create(:follow, followable: proposal, user: user)
|
||||
|
||||
login_as(user)
|
||||
visit debates_path
|
||||
|
||||
expect(page).to have_css('.recommendation', count: 3)
|
||||
expect(page).to have_link 'Best'
|
||||
expect(page).to have_link 'Medium'
|
||||
expect(page).to have_link 'Worst'
|
||||
expect(page).to have_link 'See more recommendations'
|
||||
expect(page).to have_css(".recommendation", count: 3)
|
||||
expect(page).to have_link "Best"
|
||||
expect(page).to have_link "Medium"
|
||||
expect(page).to have_link "Worst"
|
||||
expect(page).to have_link "See more recommendations"
|
||||
end
|
||||
|
||||
scenario 'should display text when there are no results' do
|
||||
scenario "should display text when there are no results" do
|
||||
user = create(:user)
|
||||
proposal = create(:proposal, tag_list: 'Distinct_to_sport')
|
||||
proposal = create(:proposal, tag_list: "Distinct_to_sport")
|
||||
create(:follow, followable: proposal, user: user)
|
||||
|
||||
login_as(user)
|
||||
visit debates_path
|
||||
|
||||
click_link 'recommendations'
|
||||
click_link "recommendations"
|
||||
|
||||
expect(page).to have_content 'There are no debates related to your interests'
|
||||
expect(page).to have_content "There are no debates related to your interests"
|
||||
end
|
||||
|
||||
scenario 'should display text when user has no related interests' do
|
||||
scenario "should display text when user has no related interests" do
|
||||
user = create(:user)
|
||||
|
||||
login_as(user)
|
||||
visit debates_path
|
||||
|
||||
click_link 'recommendations'
|
||||
click_link "recommendations"
|
||||
|
||||
expect(page).to have_content 'Follow proposals so we can give you recommendations'
|
||||
expect(page).to have_content "Follow proposals so we can give you recommendations"
|
||||
end
|
||||
|
||||
scenario "can be sorted when there's a logged user" do
|
||||
user = create(:user)
|
||||
proposal = create(:proposal, tag_list: 'Sport')
|
||||
proposal = create(:proposal, tag_list: "Sport")
|
||||
create(:follow, followable: proposal, user: user)
|
||||
|
||||
login_as(user)
|
||||
visit debates_path
|
||||
|
||||
click_link 'recommendations'
|
||||
click_link "recommendations"
|
||||
|
||||
expect(page).to have_selector('a.is-active', text: 'recommendations')
|
||||
expect(page).to have_selector("a.is-active", text: "recommendations")
|
||||
|
||||
within '#debates' do
|
||||
within "#debates" do
|
||||
expect(best_debate.title).to appear_before(medium_debate.title)
|
||||
expect(medium_debate.title).to appear_before(worst_debate.title)
|
||||
end
|
||||
|
||||
expect(current_url).to include('order=recommendations')
|
||||
expect(current_url).to include('page=1')
|
||||
expect(current_url).to include("order=recommendations")
|
||||
expect(current_url).to include("page=1")
|
||||
end
|
||||
|
||||
scenario 'are not shown if account setting is disabled' do
|
||||
scenario "are not shown if account setting is disabled" do
|
||||
user = create(:user, recommended_debates: false)
|
||||
proposal = create(:proposal, tag_list: 'Sport')
|
||||
proposal = create(:proposal, tag_list: "Sport")
|
||||
create(:follow, followable: proposal, user: user)
|
||||
|
||||
login_as(user)
|
||||
visit debates_path
|
||||
|
||||
expect(page).not_to have_css('.recommendation', count: 3)
|
||||
expect(page).not_to have_link('recommendations')
|
||||
expect(page).not_to have_css(".recommendation", count: 3)
|
||||
expect(page).not_to have_link("recommendations")
|
||||
end
|
||||
|
||||
scenario 'are automatically disabled when dismissed from index', :js do
|
||||
scenario "are automatically disabled when dismissed from index", :js do
|
||||
user = create(:user)
|
||||
proposal = create(:proposal, tag_list: 'Sport')
|
||||
proposal = create(:proposal, tag_list: "Sport")
|
||||
create(:follow, followable: proposal, user: user)
|
||||
|
||||
login_as(user)
|
||||
visit debates_path
|
||||
|
||||
within("#recommendations") do
|
||||
expect(page).to have_content('Best')
|
||||
expect(page).to have_content('Worst')
|
||||
expect(page).to have_content('Medium')
|
||||
expect(page).to have_css('.recommendation', count: 3)
|
||||
expect(page).to have_content("Best")
|
||||
expect(page).to have_content("Worst")
|
||||
expect(page).to have_content("Medium")
|
||||
expect(page).to have_css(".recommendation", count: 3)
|
||||
|
||||
accept_confirm { click_link 'Hide recommendations' }
|
||||
accept_confirm { click_link "Hide recommendations" }
|
||||
end
|
||||
|
||||
expect(page).not_to have_link('recommendations')
|
||||
expect(page).not_to have_css('.recommendation', count: 3)
|
||||
expect(page).to have_content('Recommendations for debates are now disabled for this account')
|
||||
expect(page).not_to have_link("recommendations")
|
||||
expect(page).not_to have_css(".recommendation", count: 3)
|
||||
expect(page).to have_content("Recommendations for debates are now disabled for this account")
|
||||
|
||||
user.reload
|
||||
|
||||
@@ -560,7 +560,7 @@ feature 'Debates' do
|
||||
|
||||
context "Basic search" do
|
||||
|
||||
scenario 'Search by text' do
|
||||
scenario "Search by text" do
|
||||
debate1 = create(:debate, title: "Get Schwifty")
|
||||
debate2 = create(:debate, title: "Schwifty Hello")
|
||||
debate3 = create(:debate, title: "Do not show me")
|
||||
@@ -573,7 +573,7 @@ feature 'Debates' do
|
||||
end
|
||||
|
||||
within("#debates") do
|
||||
expect(page).to have_css('.debate', count: 2)
|
||||
expect(page).to have_css(".debate", count: 2)
|
||||
|
||||
expect(page).to have_content(debate1.title)
|
||||
expect(page).to have_content(debate2.title)
|
||||
@@ -629,7 +629,7 @@ feature 'Debates' do
|
||||
visit debates_path
|
||||
|
||||
click_link "Advanced search"
|
||||
select Setting['official_level_1_name'], from: "advanced_search_official_level"
|
||||
select Setting["official_level_1_name"], from: "advanced_search_official_level"
|
||||
click_button "Filter"
|
||||
|
||||
expect(page).to have_content("There are 2 debates")
|
||||
@@ -652,7 +652,7 @@ feature 'Debates' do
|
||||
visit debates_path
|
||||
|
||||
click_link "Advanced search"
|
||||
select Setting['official_level_2_name'], from: "advanced_search_official_level"
|
||||
select Setting["official_level_2_name"], from: "advanced_search_official_level"
|
||||
click_button "Filter"
|
||||
|
||||
expect(page).to have_content("There are 2 debates")
|
||||
@@ -675,7 +675,7 @@ feature 'Debates' do
|
||||
visit debates_path
|
||||
|
||||
click_link "Advanced search"
|
||||
select Setting['official_level_3_name'], from: "advanced_search_official_level"
|
||||
select Setting["official_level_3_name"], from: "advanced_search_official_level"
|
||||
click_button "Filter"
|
||||
|
||||
expect(page).to have_content("There are 2 debates")
|
||||
@@ -698,7 +698,7 @@ feature 'Debates' do
|
||||
visit debates_path
|
||||
|
||||
click_link "Advanced search"
|
||||
select Setting['official_level_4_name'], from: "advanced_search_official_level"
|
||||
select Setting["official_level_4_name"], from: "advanced_search_official_level"
|
||||
click_button "Filter"
|
||||
|
||||
expect(page).to have_content("There are 2 debates")
|
||||
@@ -721,7 +721,7 @@ feature 'Debates' do
|
||||
visit debates_path
|
||||
|
||||
click_link "Advanced search"
|
||||
select Setting['official_level_5_name'], from: "advanced_search_official_level"
|
||||
select Setting["official_level_5_name"], from: "advanced_search_official_level"
|
||||
click_button "Filter"
|
||||
|
||||
expect(page).to have_content("There are 2 debates")
|
||||
@@ -751,7 +751,7 @@ feature 'Debates' do
|
||||
click_button "Filter"
|
||||
|
||||
within("#debates") do
|
||||
expect(page).to have_css('.debate', count: 2)
|
||||
expect(page).to have_css(".debate", count: 2)
|
||||
|
||||
expect(page).to have_content(debate1.title)
|
||||
expect(page).to have_content(debate2.title)
|
||||
@@ -771,7 +771,7 @@ feature 'Debates' do
|
||||
click_button "Filter"
|
||||
|
||||
within("#debates") do
|
||||
expect(page).to have_css('.debate', count: 2)
|
||||
expect(page).to have_css(".debate", count: 2)
|
||||
|
||||
expect(page).to have_content(debate1.title)
|
||||
expect(page).to have_content(debate2.title)
|
||||
@@ -791,7 +791,7 @@ feature 'Debates' do
|
||||
click_button "Filter"
|
||||
|
||||
within("#debates") do
|
||||
expect(page).to have_css('.debate', count: 2)
|
||||
expect(page).to have_css(".debate", count: 2)
|
||||
|
||||
expect(page).to have_content(debate1.title)
|
||||
expect(page).to have_content(debate2.title)
|
||||
@@ -811,7 +811,7 @@ feature 'Debates' do
|
||||
click_button "Filter"
|
||||
|
||||
within("#debates") do
|
||||
expect(page).to have_css('.debate', count: 2)
|
||||
expect(page).to have_css(".debate", count: 2)
|
||||
|
||||
expect(page).to have_content(debate1.title)
|
||||
expect(page).to have_content(debate2.title)
|
||||
@@ -835,7 +835,7 @@ feature 'Debates' do
|
||||
click_button "Filter"
|
||||
|
||||
within("#debates") do
|
||||
expect(page).to have_css('.debate', count: 2)
|
||||
expect(page).to have_css(".debate", count: 2)
|
||||
|
||||
expect(page).to have_content(debate1.title)
|
||||
expect(page).to have_content(debate2.title)
|
||||
@@ -857,7 +857,7 @@ feature 'Debates' do
|
||||
click_button "Filter"
|
||||
|
||||
within("#debates") do
|
||||
expect(page).to have_css('.debate', count: 3)
|
||||
expect(page).to have_css(".debate", count: 3)
|
||||
|
||||
expect(page).to have_content(debate1.title)
|
||||
expect(page).to have_content(debate2.title)
|
||||
@@ -877,13 +877,13 @@ feature 'Debates' do
|
||||
|
||||
click_link "Advanced search"
|
||||
fill_in "Write the text", with: "Schwifty"
|
||||
select Setting['official_level_1_name'], from: "advanced_search_official_level"
|
||||
select Setting["official_level_1_name"], from: "advanced_search_official_level"
|
||||
select "Last 24 hours", from: "js-advanced-search-date-min"
|
||||
|
||||
click_button "Filter"
|
||||
|
||||
within("#debates") do
|
||||
expect(page).to have_css('.debate', count: 1)
|
||||
expect(page).to have_css(".debate", count: 1)
|
||||
expect(page).to have_content(debate1.title)
|
||||
end
|
||||
end
|
||||
@@ -893,15 +893,15 @@ feature 'Debates' do
|
||||
click_link "Advanced search"
|
||||
|
||||
fill_in "Write the text", with: "Schwifty"
|
||||
select Setting['official_level_1_name'], from: "advanced_search_official_level"
|
||||
select Setting["official_level_1_name"], from: "advanced_search_official_level"
|
||||
select "Last 24 hours", from: "js-advanced-search-date-min"
|
||||
|
||||
click_button "Filter"
|
||||
|
||||
within "#js-advanced-search" do
|
||||
expect(page).to have_selector("input[name='search'][value='Schwifty']")
|
||||
expect(page).to have_select('advanced_search[official_level]', selected: Setting['official_level_1_name'])
|
||||
expect(page).to have_select('advanced_search[date_min]', selected: 'Last 24 hours')
|
||||
expect(page).to have_select("advanced_search[official_level]", selected: Setting["official_level_1_name"])
|
||||
expect(page).to have_select("advanced_search[date_min]", selected: "Last 24 hours")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -910,14 +910,14 @@ feature 'Debates' do
|
||||
click_link "Advanced search"
|
||||
|
||||
select "Customized", from: "js-advanced-search-date-min"
|
||||
fill_in "advanced_search_date_min", with: 7.days.ago.strftime('%d/%m/%Y')
|
||||
fill_in "advanced_search_date_max", with: 1.day.ago.strftime('%d/%m/%Y')
|
||||
fill_in "advanced_search_date_min", with: 7.days.ago.strftime("%d/%m/%Y")
|
||||
fill_in "advanced_search_date_max", with: 1.day.ago.strftime("%d/%m/%Y")
|
||||
click_button "Filter"
|
||||
|
||||
within "#js-advanced-search" do
|
||||
expect(page).to have_select('advanced_search[date_min]', selected: 'Customized')
|
||||
expect(page).to have_selector("input[name='advanced_search[date_min]'][value*='#{7.days.ago.strftime('%d/%m/%Y')}']")
|
||||
expect(page).to have_selector("input[name='advanced_search[date_max]'][value*='#{1.day.ago.strftime('%d/%m/%Y')}']")
|
||||
expect(page).to have_select("advanced_search[date_min]", selected: "Customized")
|
||||
expect(page).to have_selector("input[name='advanced_search[date_min]'][value*='#{7.days.ago.strftime("%d/%m/%Y")}']")
|
||||
expect(page).to have_selector("input[name='advanced_search[date_max]'][value*='#{1.day.ago.strftime("%d/%m/%Y")}']")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -951,7 +951,7 @@ feature 'Debates' do
|
||||
visit debates_path
|
||||
fill_in "search", with: "Show you got"
|
||||
click_button "Search"
|
||||
click_link 'newest'
|
||||
click_link "newest"
|
||||
expect(page).to have_selector("a.is-active", text: "newest")
|
||||
|
||||
within("#debates") do
|
||||
@@ -963,8 +963,8 @@ feature 'Debates' do
|
||||
end
|
||||
|
||||
scenario "Reorder by recommendations results maintaing search" do
|
||||
Setting['feature.user.recommendations'] = true
|
||||
Setting['feature.user.recommendations_on_debates'] = true
|
||||
Setting["feature.user.recommendations"] = true
|
||||
Setting["feature.user.recommendations_on_debates"] = true
|
||||
|
||||
user = create(:user, recommended_debates: true)
|
||||
login_as(user)
|
||||
@@ -979,7 +979,7 @@ feature 'Debates' do
|
||||
visit debates_path
|
||||
fill_in "search", with: "Show you got"
|
||||
click_button "Search"
|
||||
click_link 'recommendations'
|
||||
click_link "recommendations"
|
||||
expect(page).to have_selector("a.is-active", text: "recommendations")
|
||||
|
||||
within("#debates") do
|
||||
@@ -989,11 +989,11 @@ feature 'Debates' do
|
||||
expect(page).not_to have_content "Do not display"
|
||||
end
|
||||
|
||||
Setting['feature.user.recommendations'] = nil
|
||||
Setting['feature.user.recommendations_on_debates'] = nil
|
||||
Setting["feature.user.recommendations"] = nil
|
||||
Setting["feature.user.recommendations_on_debates"] = nil
|
||||
end
|
||||
|
||||
scenario 'After a search do not show featured debates' do
|
||||
scenario "After a search do not show featured debates" do
|
||||
featured_debates = create_featured_debates
|
||||
debate = create(:debate, title: "Abcdefghi")
|
||||
|
||||
@@ -1003,13 +1003,13 @@ feature 'Debates' do
|
||||
click_button "Search"
|
||||
end
|
||||
|
||||
expect(page).not_to have_selector('#debates .debate-featured')
|
||||
expect(page).not_to have_selector('#featured-debates')
|
||||
expect(page).not_to have_selector("#debates .debate-featured")
|
||||
expect(page).not_to have_selector("#featured-debates")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
scenario 'Conflictive' do
|
||||
scenario "Conflictive" do
|
||||
good_debate = create(:debate)
|
||||
conflictive_debate = create(:debate, :conflictive)
|
||||
|
||||
@@ -1020,16 +1020,16 @@ feature 'Debates' do
|
||||
expect(page).not_to have_content "This debate has been flagged as inappropriate by several users."
|
||||
end
|
||||
|
||||
scenario 'Erased author' do
|
||||
scenario "Erased author" do
|
||||
user = create(:user)
|
||||
debate = create(:debate, author: user)
|
||||
user.erase
|
||||
|
||||
visit debates_path
|
||||
expect(page).to have_content('User deleted')
|
||||
expect(page).to have_content("User deleted")
|
||||
|
||||
visit debate_path(debate)
|
||||
expect(page).to have_content('User deleted')
|
||||
expect(page).to have_content("User deleted")
|
||||
end
|
||||
|
||||
context "Filter" do
|
||||
@@ -1055,7 +1055,7 @@ feature 'Debates' do
|
||||
end
|
||||
|
||||
within("#debates") do
|
||||
expect(page).to have_css('.debate', count: 2)
|
||||
expect(page).to have_css(".debate", count: 2)
|
||||
expect(page).to have_content(@debate1.title)
|
||||
expect(page).to have_content(@debate2.title)
|
||||
expect(page).not_to have_content(@debate3.title)
|
||||
@@ -1070,7 +1070,7 @@ feature 'Debates' do
|
||||
click_link "California"
|
||||
end
|
||||
within("#debates") do
|
||||
expect(page).to have_css('.debate', count: 2)
|
||||
expect(page).to have_css(".debate", count: 2)
|
||||
expect(page).to have_content(@debate1.title)
|
||||
expect(page).to have_content(@debate2.title)
|
||||
expect(page).not_to have_content(@debate3.title)
|
||||
@@ -1085,7 +1085,7 @@ feature 'Debates' do
|
||||
end
|
||||
|
||||
within("#debates") do
|
||||
expect(page).to have_css('.debate', count: 2)
|
||||
expect(page).to have_css(".debate", count: 2)
|
||||
expect(page).to have_content(@debate1.title)
|
||||
expect(page).to have_content(@debate2.title)
|
||||
expect(page).not_to have_content(@debate3.title)
|
||||
@@ -1095,8 +1095,8 @@ feature 'Debates' do
|
||||
end
|
||||
end
|
||||
|
||||
context 'Suggesting debates' do
|
||||
scenario 'Shows up to 5 suggestions', :js do
|
||||
context "Suggesting debates" do
|
||||
scenario "Shows up to 5 suggestions", :js do
|
||||
author = create(:user)
|
||||
login_as(author)
|
||||
|
||||
@@ -1105,19 +1105,19 @@ feature 'Debates' do
|
||||
debate3 = create(:debate, title: "Third debate has 3 votes", cached_votes_up: 3)
|
||||
debate4 = create(:debate, title: "This one has 4 votes", description: "This is the fourth debate", cached_votes_up: 4)
|
||||
debate5 = create(:debate, title: "Fifth debate has 5 votes", cached_votes_up: 5)
|
||||
debate6 = create(:debate, title: "Sixth debate has 6 votes", description: 'This is the sixth debate', cached_votes_up: 6)
|
||||
debate7 = create(:debate, title: "This has seven votes, and is not suggest", description: 'This is the seven', cached_votes_up: 7)
|
||||
debate6 = create(:debate, title: "Sixth debate has 6 votes", description: "This is the sixth debate", cached_votes_up: 6)
|
||||
debate7 = create(:debate, title: "This has seven votes, and is not suggest", description: "This is the seven", cached_votes_up: 7)
|
||||
|
||||
visit new_debate_path
|
||||
fill_in 'debate_title', with: 'debate'
|
||||
fill_in "debate_title", with: "debate"
|
||||
check "debate_terms_of_service"
|
||||
|
||||
within('div#js-suggest') do
|
||||
within("div#js-suggest") do
|
||||
expect(page).to have_content "You are seeing 5 of 6 debates containing the term 'debate'"
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'No found suggestions', :js do
|
||||
scenario "No found suggestions", :js do
|
||||
author = create(:user)
|
||||
login_as(author)
|
||||
|
||||
@@ -1125,49 +1125,49 @@ feature 'Debates' do
|
||||
debate2 = create(:debate, title: "Second debate has 2 votes", cached_votes_up: 2)
|
||||
|
||||
visit new_debate_path
|
||||
fill_in 'debate_title', with: 'proposal'
|
||||
fill_in "debate_title", with: "proposal"
|
||||
check "debate_terms_of_service"
|
||||
|
||||
within('div#js-suggest') do
|
||||
expect(page).not_to have_content 'You are seeing'
|
||||
within("div#js-suggest") do
|
||||
expect(page).not_to have_content "You are seeing"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Mark/Unmark a debate as featured' do
|
||||
scenario "Mark/Unmark a debate as featured" do
|
||||
admin = create(:administrator)
|
||||
login_as(admin.user)
|
||||
|
||||
debate = create(:debate)
|
||||
|
||||
visit debates_path
|
||||
within('#debates') do
|
||||
expect(page).not_to have_content 'Featured'
|
||||
within("#debates") do
|
||||
expect(page).not_to have_content "Featured"
|
||||
end
|
||||
|
||||
click_link debate.title
|
||||
|
||||
click_link 'Featured'
|
||||
click_link "Featured"
|
||||
|
||||
visit debates_path
|
||||
|
||||
within('#debates') do
|
||||
expect(page).to have_content 'Featured'
|
||||
within("#debates") do
|
||||
expect(page).to have_content "Featured"
|
||||
end
|
||||
|
||||
within('#featured-debates') do
|
||||
within("#featured-debates") do
|
||||
expect(page).to have_content debate.title
|
||||
end
|
||||
|
||||
visit debate_path(debate)
|
||||
click_link 'Unmark featured'
|
||||
click_link "Unmark featured"
|
||||
|
||||
within('#debates') do
|
||||
expect(page).not_to have_content 'Featured'
|
||||
within("#debates") do
|
||||
expect(page).not_to have_content "Featured"
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Index include featured debates' do
|
||||
scenario "Index include featured debates" do
|
||||
admin = create(:administrator)
|
||||
login_as(admin.user)
|
||||
|
||||
@@ -1175,12 +1175,12 @@ feature 'Debates' do
|
||||
debate2 = create(:debate)
|
||||
|
||||
visit debates_path
|
||||
within('#debates') do
|
||||
within("#debates") do
|
||||
expect(page).to have_content("Featured")
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Index do not show featured debates if none is marked as featured' do
|
||||
scenario "Index do not show featured debates if none is marked as featured" do
|
||||
admin = create(:administrator)
|
||||
login_as(admin.user)
|
||||
|
||||
@@ -1188,7 +1188,7 @@ feature 'Debates' do
|
||||
debate2 = create(:debate)
|
||||
|
||||
visit debates_path
|
||||
within('#debates') do
|
||||
within("#debates") do
|
||||
expect(page).not_to have_content("Featured")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Direct messages' do
|
||||
feature "Direct messages" do
|
||||
|
||||
background do
|
||||
Setting[:direct_message_max_per_day] = 3
|
||||
@@ -17,8 +17,8 @@ feature 'Direct messages' do
|
||||
|
||||
expect(page).to have_content "Send private message to #{receiver.name}"
|
||||
|
||||
fill_in 'direct_message_title', with: "Hey!"
|
||||
fill_in 'direct_message_body', with: "How are you doing?"
|
||||
fill_in "direct_message_title", with: "Hey!"
|
||||
fill_in "direct_message_body", with: "How are you doing?"
|
||||
click_button "Send message"
|
||||
|
||||
expect(page).to have_content "You message has been sent successfully."
|
||||
@@ -109,8 +109,8 @@ feature 'Direct messages' do
|
||||
|
||||
expect(page).to have_content "Send private message to #{receiver.name}"
|
||||
|
||||
fill_in 'direct_message_title', with: "Hey!"
|
||||
fill_in 'direct_message_body', with: "How are you doing?"
|
||||
fill_in "direct_message_title", with: "Hey!"
|
||||
fill_in "direct_message_body", with: "How are you doing?"
|
||||
click_button "Send message"
|
||||
|
||||
expect(page).to have_content "You have reached the maximum number of private messages per day"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Emails' do
|
||||
feature "Emails" do
|
||||
|
||||
background do
|
||||
reset_mailer
|
||||
@@ -28,8 +28,8 @@ feature 'Emails' do
|
||||
sign_up
|
||||
|
||||
email = open_last_email
|
||||
expect(email).to have_subject('Confirmation instructions')
|
||||
expect(email).to deliver_to('manuela@consul.dev')
|
||||
expect(email).to have_subject("Confirmation instructions")
|
||||
expect(email).to deliver_to("manuela@consul.dev")
|
||||
expect(email).to have_body_text(user_confirmation_path)
|
||||
end
|
||||
|
||||
@@ -37,185 +37,185 @@ feature 'Emails' do
|
||||
reset_password
|
||||
|
||||
email = open_last_email
|
||||
expect(email).to have_subject('Instructions for resetting your password')
|
||||
expect(email).to deliver_to('manuela@consul.dev')
|
||||
expect(email).to have_subject("Instructions for resetting your password")
|
||||
expect(email).to deliver_to("manuela@consul.dev")
|
||||
expect(email).to have_body_text(edit_user_password_path)
|
||||
end
|
||||
|
||||
context 'Proposal comments' do
|
||||
context "Proposal comments" do
|
||||
let(:user) { create(:user, email_on_comment: true) }
|
||||
let(:proposal) { create(:proposal, author: user) }
|
||||
|
||||
scenario 'Send email on proposal comment' do
|
||||
scenario "Send email on proposal comment" do
|
||||
comment_on(proposal)
|
||||
|
||||
email = open_last_email
|
||||
expect(email).to have_subject('Someone has commented on your citizen proposal')
|
||||
expect(email).to have_subject("Someone has commented on your citizen proposal")
|
||||
expect(email).to deliver_to(proposal.author)
|
||||
expect(email).to have_body_text(proposal_path(proposal))
|
||||
expect(email).to have_body_text('To stop receiving these emails change your settings in')
|
||||
expect(email).to have_body_text("To stop receiving these emails change your settings in")
|
||||
expect(email).to have_body_text(account_path)
|
||||
end
|
||||
|
||||
scenario 'Do not send email about own proposal comments' do
|
||||
scenario "Do not send email about own proposal comments" do
|
||||
comment_on(proposal, user)
|
||||
expect { open_last_email }.to raise_error('No email has been sent!')
|
||||
expect { open_last_email }.to raise_error("No email has been sent!")
|
||||
end
|
||||
|
||||
scenario 'Do not send email about proposal comment unless set in preferences' do
|
||||
scenario "Do not send email about proposal comment unless set in preferences" do
|
||||
user.update(email_on_comment: false)
|
||||
comment_on(proposal)
|
||||
expect { open_last_email }.to raise_error('No email has been sent!')
|
||||
expect { open_last_email }.to raise_error("No email has been sent!")
|
||||
end
|
||||
end
|
||||
|
||||
context 'Debate comments' do
|
||||
context "Debate comments" do
|
||||
let(:user) { create(:user, email_on_comment: true) }
|
||||
let(:debate) { create(:debate, author: user) }
|
||||
|
||||
scenario 'Send email on debate comment' do
|
||||
scenario "Send email on debate comment" do
|
||||
comment_on(debate)
|
||||
|
||||
email = open_last_email
|
||||
expect(email).to have_subject('Someone has commented on your debate')
|
||||
expect(email).to have_subject("Someone has commented on your debate")
|
||||
expect(email).to deliver_to(debate.author)
|
||||
expect(email).to have_body_text(debate_path(debate))
|
||||
expect(email).to have_body_text('To stop receiving these emails change your settings in')
|
||||
expect(email).to have_body_text("To stop receiving these emails change your settings in")
|
||||
expect(email).to have_body_text(account_path)
|
||||
end
|
||||
|
||||
scenario 'Do not send email about own debate comments' do
|
||||
scenario "Do not send email about own debate comments" do
|
||||
comment_on(debate, user)
|
||||
expect { open_last_email }.to raise_error('No email has been sent!')
|
||||
expect { open_last_email }.to raise_error("No email has been sent!")
|
||||
end
|
||||
|
||||
scenario 'Do not send email about debate comment unless set in preferences' do
|
||||
scenario "Do not send email about debate comment unless set in preferences" do
|
||||
user.update(email_on_comment: false)
|
||||
comment_on(debate)
|
||||
expect { open_last_email }.to raise_error('No email has been sent!')
|
||||
expect { open_last_email }.to raise_error("No email has been sent!")
|
||||
end
|
||||
end
|
||||
|
||||
context 'Budget investments comments' do
|
||||
context "Budget investments comments" do
|
||||
let(:user) { create(:user, email_on_comment: true) }
|
||||
let(:investment) { create(:budget_investment, author: user, budget: create(:budget)) }
|
||||
|
||||
scenario 'Send email on budget investment comment' do
|
||||
scenario "Send email on budget investment comment" do
|
||||
comment_on(investment)
|
||||
|
||||
email = open_last_email
|
||||
expect(email).to have_subject('Someone has commented on your investment')
|
||||
expect(email).to have_subject("Someone has commented on your investment")
|
||||
expect(email).to deliver_to(investment.author)
|
||||
expect(email).to have_body_text(budget_investment_path(investment, budget_id: investment.budget_id))
|
||||
expect(email).to have_body_text('To stop receiving these emails change your settings in')
|
||||
expect(email).to have_body_text("To stop receiving these emails change your settings in")
|
||||
expect(email).to have_body_text(account_path)
|
||||
end
|
||||
|
||||
scenario 'Do not send email about own budget investments comments' do
|
||||
scenario "Do not send email about own budget investments comments" do
|
||||
comment_on(investment, user)
|
||||
expect { open_last_email }.to raise_error('No email has been sent!')
|
||||
expect { open_last_email }.to raise_error("No email has been sent!")
|
||||
end
|
||||
|
||||
scenario 'Do not send email about budget investment comment unless set in preferences' do
|
||||
scenario "Do not send email about budget investment comment unless set in preferences" do
|
||||
user.update(email_on_comment: false)
|
||||
comment_on(investment)
|
||||
expect { open_last_email }.to raise_error('No email has been sent!')
|
||||
expect { open_last_email }.to raise_error("No email has been sent!")
|
||||
end
|
||||
end
|
||||
|
||||
context 'Topic comments' do
|
||||
context "Topic comments" do
|
||||
let(:user) { create(:user, email_on_comment: true) }
|
||||
let(:proposal) { create(:proposal) }
|
||||
let(:topic) { create(:topic, author: user, community: proposal.community) }
|
||||
|
||||
scenario 'Send email on topic comment' do
|
||||
scenario "Send email on topic comment" do
|
||||
comment_on(topic)
|
||||
|
||||
email = open_last_email
|
||||
expect(email).to have_subject('Someone has commented on your topic')
|
||||
expect(email).to have_subject("Someone has commented on your topic")
|
||||
expect(email).to deliver_to(topic.author)
|
||||
expect(email).to have_body_text(community_topic_path(topic, community_id: topic.community_id))
|
||||
expect(email).to have_body_text('To stop receiving these emails change your settings in')
|
||||
expect(email).to have_body_text("To stop receiving these emails change your settings in")
|
||||
expect(email).to have_body_text(account_path)
|
||||
end
|
||||
|
||||
scenario 'Do not send email about own topic comments' do
|
||||
scenario "Do not send email about own topic comments" do
|
||||
comment_on(topic, user)
|
||||
expect { open_last_email }.to raise_error('No email has been sent!')
|
||||
expect { open_last_email }.to raise_error("No email has been sent!")
|
||||
end
|
||||
|
||||
scenario 'Do not send email about topic comment unless set in preferences' do
|
||||
scenario "Do not send email about topic comment unless set in preferences" do
|
||||
user.update(email_on_comment: false)
|
||||
comment_on(topic)
|
||||
expect { open_last_email }.to raise_error('No email has been sent!')
|
||||
expect { open_last_email }.to raise_error("No email has been sent!")
|
||||
end
|
||||
end
|
||||
|
||||
context 'Poll comments' do
|
||||
context "Poll comments" do
|
||||
let(:user) { create(:user, email_on_comment: true) }
|
||||
let(:poll) { create(:poll, author: user) }
|
||||
|
||||
scenario 'Send email on poll comment' do
|
||||
scenario "Send email on poll comment" do
|
||||
comment_on(poll)
|
||||
|
||||
email = open_last_email
|
||||
expect(email).to have_subject('Someone has commented on your poll')
|
||||
expect(email).to have_subject("Someone has commented on your poll")
|
||||
expect(email).to deliver_to(poll.author)
|
||||
expect(email).to have_body_text(poll_path(poll))
|
||||
expect(email).to have_body_text('To stop receiving these emails change your settings in')
|
||||
expect(email).to have_body_text("To stop receiving these emails change your settings in")
|
||||
expect(email).to have_body_text(account_path)
|
||||
end
|
||||
|
||||
scenario 'Do not send email about own poll comments' do
|
||||
scenario "Do not send email about own poll comments" do
|
||||
comment_on(poll, user)
|
||||
expect { open_last_email }.to raise_error('No email has been sent!')
|
||||
expect { open_last_email }.to raise_error("No email has been sent!")
|
||||
end
|
||||
|
||||
scenario 'Do not send email about poll question comment unless set in preferences' do
|
||||
scenario "Do not send email about poll question comment unless set in preferences" do
|
||||
user.update(email_on_comment: false)
|
||||
comment_on(poll)
|
||||
expect { open_last_email }.to raise_error('No email has been sent!')
|
||||
expect { open_last_email }.to raise_error("No email has been sent!")
|
||||
end
|
||||
end
|
||||
|
||||
context 'Comment replies' do
|
||||
context "Comment replies" do
|
||||
let(:user) { create(:user, email_on_comment_reply: true) }
|
||||
|
||||
scenario 'Send email on comment reply', :js do
|
||||
scenario "Send email on comment reply", :js do
|
||||
reply_to(user)
|
||||
|
||||
email = open_last_email
|
||||
expect(email).to have_subject('Someone has responded to your comment')
|
||||
expect(email).to have_subject("Someone has responded to your comment")
|
||||
expect(email).to deliver_to(user)
|
||||
expect(email).not_to have_body_text(debate_path(Comment.first.commentable))
|
||||
expect(email).to have_body_text(comment_path(Comment.last))
|
||||
expect(email).to have_body_text('To stop receiving these emails change your settings in')
|
||||
expect(email).to have_body_text("To stop receiving these emails change your settings in")
|
||||
expect(email).to have_body_text(account_path)
|
||||
end
|
||||
|
||||
scenario 'Do not send email about own replies to own comments', :js do
|
||||
scenario "Do not send email about own replies to own comments", :js do
|
||||
reply_to(user, user)
|
||||
expect { open_last_email }.to raise_error('No email has been sent!')
|
||||
expect { open_last_email }.to raise_error("No email has been sent!")
|
||||
end
|
||||
|
||||
scenario 'Do not send email about comment reply unless set in preferences', :js do
|
||||
scenario "Do not send email about comment reply unless set in preferences", :js do
|
||||
user.update(email_on_comment_reply: false)
|
||||
reply_to(user)
|
||||
expect { open_last_email }.to raise_error('No email has been sent!')
|
||||
expect { open_last_email }.to raise_error("No email has been sent!")
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Email depending on user's locale" do
|
||||
visit root_path(locale: :es)
|
||||
|
||||
click_link 'Registrarse'
|
||||
click_link "Registrarse"
|
||||
fill_in_signup_form
|
||||
click_button 'Registrarse'
|
||||
click_button "Registrarse"
|
||||
|
||||
email = open_last_email
|
||||
expect(email).to deliver_to('manuela@consul.dev')
|
||||
expect(email).to deliver_to("manuela@consul.dev")
|
||||
expect(email).to have_body_text(user_confirmation_path)
|
||||
expect(email).to have_subject('Instrucciones de confirmación')
|
||||
expect(email).to have_subject("Instrucciones de confirmación")
|
||||
end
|
||||
|
||||
scenario "Email on unfeasible spending proposal" do
|
||||
@@ -230,10 +230,10 @@ feature 'Emails' do
|
||||
login_as(valuator.user)
|
||||
visit edit_valuation_spending_proposal_path(spending_proposal)
|
||||
|
||||
choose 'spending_proposal_feasible_false'
|
||||
fill_in 'spending_proposal_feasible_explanation', with: 'This is not legal as stated in Article 34.9'
|
||||
check 'spending_proposal_valuation_finished'
|
||||
click_button 'Save changes'
|
||||
choose "spending_proposal_feasible_false"
|
||||
fill_in "spending_proposal_feasible_explanation", with: "This is not legal as stated in Article 34.9"
|
||||
check "spending_proposal_valuation_finished"
|
||||
click_button "Save changes"
|
||||
|
||||
expect(page).to have_content "Dossier updated"
|
||||
spending_proposal.reload
|
||||
@@ -312,16 +312,16 @@ feature 'Emails' do
|
||||
expect(email).to have_body_text(notification1.notifiable.body)
|
||||
expect(email).to have_body_text(proposal1.author.name)
|
||||
|
||||
expect(email).to have_body_text(/#{proposal_path(proposal1, anchor: 'tab-notifications')}/)
|
||||
expect(email).to have_body_text(/#{proposal_path(proposal1, anchor: 'comments')}/)
|
||||
expect(email).to have_body_text(/#{proposal_path(proposal1, anchor: 'social-share')}/)
|
||||
expect(email).to have_body_text(/#{proposal_path(proposal1, anchor: "tab-notifications")}/)
|
||||
expect(email).to have_body_text(/#{proposal_path(proposal1, anchor: "comments")}/)
|
||||
expect(email).to have_body_text(/#{proposal_path(proposal1, anchor: "social-share")}/)
|
||||
|
||||
expect(email).to have_body_text(proposal2.title)
|
||||
expect(email).to have_body_text(notification2.notifiable.title)
|
||||
expect(email).to have_body_text(notification2.notifiable.body)
|
||||
expect(email).to have_body_text(/#{proposal_path(proposal2, anchor: 'tab-notifications')}/)
|
||||
expect(email).to have_body_text(/#{proposal_path(proposal2, anchor: 'comments')}/)
|
||||
expect(email).to have_body_text(/#{proposal_path(proposal2, anchor: 'social-share')}/)
|
||||
expect(email).to have_body_text(/#{proposal_path(proposal2, anchor: "tab-notifications")}/)
|
||||
expect(email).to have_body_text(/#{proposal_path(proposal2, anchor: "comments")}/)
|
||||
expect(email).to have_body_text(/#{proposal_path(proposal2, anchor: "social-share")}/)
|
||||
expect(email).to have_body_text(proposal2.author.name)
|
||||
|
||||
expect(email).not_to have_body_text(proposal3.title)
|
||||
@@ -392,13 +392,13 @@ feature 'Emails' do
|
||||
login_as(author)
|
||||
visit new_budget_investment_path(budget_id: budget.id)
|
||||
|
||||
select heading.name, from: 'budget_investment_heading_id'
|
||||
fill_in 'budget_investment_title', with: 'Build a hospital'
|
||||
fill_in 'budget_investment_description', with: 'We have lots of people that require medical attention'
|
||||
check 'budget_investment_terms_of_service'
|
||||
select heading.name, from: "budget_investment_heading_id"
|
||||
fill_in "budget_investment_title", with: "Build a hospital"
|
||||
fill_in "budget_investment_description", with: "We have lots of people that require medical attention"
|
||||
check "budget_investment_terms_of_service"
|
||||
|
||||
click_button 'Create Investment'
|
||||
expect(page).to have_content 'Investment created successfully'
|
||||
click_button "Create Investment"
|
||||
expect(page).to have_content "Investment created successfully"
|
||||
|
||||
email = open_last_email
|
||||
investment = Budget::Investment.last
|
||||
@@ -412,7 +412,7 @@ feature 'Emails' do
|
||||
end
|
||||
|
||||
scenario "Unfeasible investment" do
|
||||
budget.update(phase: 'valuating')
|
||||
budget.update(phase: "valuating")
|
||||
investment = create(:budget_investment, author: author, budget: budget, heading: heading)
|
||||
|
||||
valuator = create(:valuator)
|
||||
@@ -421,10 +421,10 @@ feature 'Emails' do
|
||||
login_as(valuator.user)
|
||||
visit edit_valuation_budget_budget_investment_path(budget, investment)
|
||||
|
||||
choose 'budget_investment_feasibility_unfeasible'
|
||||
fill_in 'budget_investment_unfeasibility_explanation', with: 'This is not legal as stated in Article 34.9'
|
||||
find_field('budget_investment[valuation_finished]').click
|
||||
click_button 'Save changes'
|
||||
choose "budget_investment_feasibility_unfeasible"
|
||||
fill_in "budget_investment_unfeasibility_explanation", with: "This is not legal as stated in Article 34.9"
|
||||
find_field("budget_investment[valuation_finished]").click
|
||||
click_button "Save changes"
|
||||
|
||||
expect(page).to have_content "Dossier updated"
|
||||
investment.reload
|
||||
@@ -495,20 +495,20 @@ feature 'Emails' do
|
||||
click_link "Reply"
|
||||
|
||||
within "#js-comment-form-comment_#{comment.id}" do
|
||||
fill_in "comment-body-comment_#{comment.id}", with: 'It will be done next week.'
|
||||
click_button 'Publish reply'
|
||||
fill_in "comment-body-comment_#{comment.id}", with: "It will be done next week."
|
||||
click_button "Publish reply"
|
||||
end
|
||||
|
||||
within "#comment_#{comment.id}" do
|
||||
expect(page).to have_content 'It will be done next week.'
|
||||
expect(page).to have_content "It will be done next week."
|
||||
end
|
||||
|
||||
email = open_last_email
|
||||
expect(email).to have_subject('Someone has responded to your comment')
|
||||
expect(email).to have_subject("Someone has responded to your comment")
|
||||
expect(email).to deliver_to(user1)
|
||||
expect(email).not_to have_body_text(poll_path(poll))
|
||||
expect(email).to have_body_text(comment_path(Comment.last))
|
||||
expect(email).to have_body_text('To stop receiving these emails change your settings in')
|
||||
expect(email).to have_body_text("To stop receiving these emails change your settings in")
|
||||
expect(email).to have_body_text(account_path)
|
||||
end
|
||||
|
||||
@@ -530,7 +530,7 @@ feature 'Emails' do
|
||||
login_as(admin.user)
|
||||
|
||||
visit new_admin_newsletter_path
|
||||
fill_in_newsletter_form(segment_recipient: 'Proposal authors')
|
||||
fill_in_newsletter_form(segment_recipient: "Proposal authors")
|
||||
click_button "Create Newsletter"
|
||||
|
||||
expect(page).to have_content "Newsletter created successfully"
|
||||
@@ -543,9 +543,9 @@ feature 'Emails' do
|
||||
expect(unread_emails_for(user_without_newsletter_in_segment.email).count).to eq 0
|
||||
|
||||
email = open_last_email
|
||||
expect(email).to have_subject('This is a different subject')
|
||||
expect(email).to deliver_from('no-reply@consul.dev')
|
||||
expect(email.body.encoded).to include('This is a different body')
|
||||
expect(email).to have_subject("This is a different subject")
|
||||
expect(email).to deliver_from("no-reply@consul.dev")
|
||||
expect(email.body.encoded).to include("This is a different body")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Help page' do
|
||||
feature "Help page" do
|
||||
|
||||
context 'Index' do
|
||||
context "Index" do
|
||||
|
||||
scenario 'Help menu and page is visible if feature is enabled' do
|
||||
Setting['feature.help_page'] = true
|
||||
scenario "Help menu and page is visible if feature is enabled" do
|
||||
Setting["feature.help_page"] = true
|
||||
|
||||
visit root_path
|
||||
|
||||
expect(page).to have_link 'Help'
|
||||
expect(page).to have_link "Help"
|
||||
|
||||
within('#navigation_bar') do
|
||||
click_link 'Help'
|
||||
within("#navigation_bar") do
|
||||
click_link "Help"
|
||||
end
|
||||
|
||||
expect(page).to have_content('CONSUL is a platform for citizen participation')
|
||||
expect(page).to have_content("CONSUL is a platform for citizen participation")
|
||||
end
|
||||
|
||||
scenario 'Help menu and page is hidden if feature is disabled' do
|
||||
Setting['feature.help_page'] = nil
|
||||
scenario "Help menu and page is hidden if feature is disabled" do
|
||||
Setting["feature.help_page"] = nil
|
||||
|
||||
visit root_path
|
||||
|
||||
expect(page).not_to have_link 'Help'
|
||||
expect(page).not_to have_link "Help"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature "Home" do
|
||||
|
||||
context "For not logged users" do
|
||||
|
||||
scenario 'Welcome message' do
|
||||
scenario "Welcome message" do
|
||||
visit root_path
|
||||
|
||||
expect(page).to have_content "CONSUL"
|
||||
end
|
||||
|
||||
scenario 'Not display recommended section' do
|
||||
scenario "Not display recommended section" do
|
||||
debate = create(:debate)
|
||||
|
||||
visit root_path
|
||||
@@ -25,7 +25,7 @@ feature "Home" do
|
||||
feature "Recommended" do
|
||||
|
||||
background do
|
||||
Setting['feature.user.recommendations'] = true
|
||||
Setting["feature.user.recommendations"] = true
|
||||
user = create(:user)
|
||||
proposal = create(:proposal, tag_list: "Sport")
|
||||
create(:follow, followable: proposal, user: user)
|
||||
@@ -33,25 +33,25 @@ feature "Home" do
|
||||
end
|
||||
|
||||
after do
|
||||
Setting['feature.user.recommendations'] = nil
|
||||
Setting["feature.user.recommendations"] = nil
|
||||
end
|
||||
|
||||
scenario 'Display recommended section when feature flag recommended is active' do
|
||||
scenario "Display recommended section when feature flag recommended is active" do
|
||||
debate = create(:debate, tag_list: "Sport")
|
||||
visit root_path
|
||||
expect(page).to have_content "Recommendations that may interest you"
|
||||
end
|
||||
|
||||
scenario 'Not display recommended section when feature flag recommended is not active' do
|
||||
scenario "Not display recommended section when feature flag recommended is not active" do
|
||||
debate = create(:debate, tag_list: "Sport")
|
||||
Setting['feature.user.recommendations'] = false
|
||||
Setting["feature.user.recommendations"] = false
|
||||
|
||||
visit root_path
|
||||
|
||||
expect(page).not_to have_content "Recommendations that may interest you"
|
||||
end
|
||||
|
||||
scenario 'Display debates' do
|
||||
scenario "Display debates" do
|
||||
debate = create(:debate, tag_list: "Sport")
|
||||
|
||||
visit root_path
|
||||
@@ -60,13 +60,13 @@ feature "Home" do
|
||||
expect(page).to have_content debate.description
|
||||
end
|
||||
|
||||
scenario 'Display all recommended debates link' do
|
||||
scenario "Display all recommended debates link" do
|
||||
debate = create(:debate, tag_list: "Sport")
|
||||
visit root_path
|
||||
expect(page).to have_link("All recommended debates", href: debates_path(order: "recommendations"))
|
||||
end
|
||||
|
||||
scenario 'Display proposal' do
|
||||
scenario "Display proposal" do
|
||||
proposal = create(:proposal, tag_list: "Sport")
|
||||
|
||||
visit root_path
|
||||
@@ -75,35 +75,35 @@ feature "Home" do
|
||||
expect(page).to have_content proposal.description
|
||||
end
|
||||
|
||||
scenario 'Display all recommended proposals link' do
|
||||
scenario "Display all recommended proposals link" do
|
||||
debate = create(:proposal, tag_list: "Sport")
|
||||
visit root_path
|
||||
expect(page).to have_link("All recommended proposals", href: proposals_path(order: "recommendations"))
|
||||
end
|
||||
|
||||
scenario 'Display orbit carrousel' do
|
||||
scenario "Display orbit carrousel" do
|
||||
create_list(:debate, 3, tag_list: "Sport")
|
||||
|
||||
visit root_path
|
||||
|
||||
expect(page).to have_selector('li[data-slide="0"]')
|
||||
expect(page).to have_selector('li[data-slide="1"]', visible: false)
|
||||
expect(page).to have_selector('li[data-slide="2"]', visible: false)
|
||||
expect(page).to have_selector("li[data-slide='0']")
|
||||
expect(page).to have_selector("li[data-slide='1']", visible: false)
|
||||
expect(page).to have_selector("li[data-slide='2']", visible: false)
|
||||
end
|
||||
|
||||
scenario 'Display recommended show when click on carousel' do
|
||||
scenario "Display recommended show when click on carousel" do
|
||||
debate = create(:debate, tag_list: "Sport")
|
||||
|
||||
visit root_path
|
||||
|
||||
within('#section_recommended') do
|
||||
within("#section_recommended") do
|
||||
click_on debate.title
|
||||
end
|
||||
|
||||
expect(page).to have_current_path(debate_path(debate))
|
||||
end
|
||||
|
||||
scenario 'Do not display recommended section when there are not debates and proposals' do
|
||||
scenario "Do not display recommended section when there are not debates and proposals" do
|
||||
visit root_path
|
||||
expect(page).not_to have_content "Recommendations that may interest you"
|
||||
end
|
||||
@@ -111,32 +111,32 @@ feature "Home" do
|
||||
|
||||
end
|
||||
|
||||
feature 'IE alert' do
|
||||
scenario 'IE visitors are presented with an alert until they close it', :page_driver do
|
||||
feature "IE alert" do
|
||||
scenario "IE visitors are presented with an alert until they close it", :page_driver do
|
||||
# Selenium API does not include page request/response inspection methods
|
||||
# so we must use Capybara::RackTest driver to set the browser's headers
|
||||
Capybara.current_session.driver.header(
|
||||
'User-Agent',
|
||||
'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)'
|
||||
"User-Agent",
|
||||
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)"
|
||||
)
|
||||
|
||||
visit root_path
|
||||
expect(page).to have_xpath(ie_alert_box_xpath, visible: false)
|
||||
expect(page.driver.request.cookies['ie_alert_closed']).to be_nil
|
||||
expect(page.driver.request.cookies["ie_alert_closed"]).to be_nil
|
||||
|
||||
# faking close button, since a normal find and click
|
||||
# will not work as the element is inside a HTML conditional comment
|
||||
page.driver.browser.set_cookie('ie_alert_closed=true')
|
||||
page.driver.browser.set_cookie("ie_alert_closed=true")
|
||||
|
||||
visit root_path
|
||||
expect(page).not_to have_xpath(ie_alert_box_xpath, visible: false)
|
||||
expect(page.driver.request.cookies['ie_alert_closed']).to eq('true')
|
||||
expect(page.driver.request.cookies["ie_alert_closed"]).to eq("true")
|
||||
end
|
||||
|
||||
scenario 'non-IE visitors are not bothered with IE alerts', :page_driver do
|
||||
scenario "non-IE visitors are not bothered with IE alerts", :page_driver do
|
||||
visit root_path
|
||||
expect(page).not_to have_xpath(ie_alert_box_xpath, visible: false)
|
||||
expect(page.driver.request.cookies['ie_alert_closed']).to be_nil
|
||||
expect(page.driver.request.cookies["ie_alert_closed"]).to be_nil
|
||||
end
|
||||
|
||||
def ie_alert_box_xpath
|
||||
@@ -144,7 +144,7 @@ feature "Home" do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'if there are cards, the "featured" title will render' do
|
||||
scenario "if there are cards, the 'featured' title will render" do
|
||||
card = create(:widget_card,
|
||||
title: "Card text",
|
||||
description: "Card description",
|
||||
@@ -157,7 +157,7 @@ feature "Home" do
|
||||
expect(page).to have_css(".title", text: "Featured")
|
||||
end
|
||||
|
||||
scenario 'if there are no cards, the "featured" title will not render' do
|
||||
scenario "if there are no cards, the 'featured' title will not render" do
|
||||
visit root_path
|
||||
|
||||
expect(page).not_to have_css(".title", text: "Featured")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Legislation Draft Versions' do
|
||||
feature "Legislation Draft Versions" do
|
||||
let(:user) { create(:user) }
|
||||
let(:administrator) do
|
||||
create(:administrator, user: user)
|
||||
@@ -23,7 +23,7 @@ feature 'Legislation Draft Versions' do
|
||||
|
||||
expect(page).to have_content("Body of the first version")
|
||||
|
||||
within('select#draft_version_id') do
|
||||
within("select#draft_version_id") do
|
||||
expect(page).to have_content("Version 1")
|
||||
expect(page).to have_content("Version 2")
|
||||
expect(page).not_to have_content("Version 3")
|
||||
@@ -37,7 +37,7 @@ feature 'Legislation Draft Versions' do
|
||||
|
||||
expect(page).to have_content("Body of the third version")
|
||||
|
||||
within('select#draft_version_id') do
|
||||
within("select#draft_version_id") do
|
||||
expect(page).to have_content("Version 1")
|
||||
expect(page).to have_content("Version 2")
|
||||
expect(page).to have_content("Version 3 *")
|
||||
@@ -97,7 +97,7 @@ feature 'Legislation Draft Versions' do
|
||||
|
||||
expect(page).to have_content("Changes for first version")
|
||||
|
||||
within('select#draft_version_id') do
|
||||
within("select#draft_version_id") do
|
||||
expect(page).to have_content("Version 1")
|
||||
expect(page).to have_content("Version 2")
|
||||
expect(page).not_to have_content("Version 3")
|
||||
@@ -111,7 +111,7 @@ feature 'Legislation Draft Versions' do
|
||||
|
||||
expect(page).to have_content("Changes for third version")
|
||||
|
||||
within('select#draft_version_id') do
|
||||
within("select#draft_version_id") do
|
||||
expect(page).to have_content("Version 1")
|
||||
expect(page).to have_content("Version 2")
|
||||
expect(page).to have_content("Version 3 *")
|
||||
@@ -140,12 +140,12 @@ feature 'Legislation Draft Versions' do
|
||||
end
|
||||
end
|
||||
|
||||
context 'Annotations', :js do
|
||||
context "Annotations", :js do
|
||||
let(:user) { create(:user) }
|
||||
|
||||
background { login_as user }
|
||||
|
||||
scenario 'Visit as anonymous' do
|
||||
scenario "Visit as anonymous" do
|
||||
logout
|
||||
draft_version = create(:legislation_draft_version, :published)
|
||||
|
||||
@@ -153,11 +153,11 @@ feature 'Legislation Draft Versions' do
|
||||
|
||||
page.find(:css, ".legislation-annotatable").double_click
|
||||
page.find(:css, ".annotator-adder button").click
|
||||
expect(page).not_to have_css('#legislation_annotation_text')
|
||||
expect(page).not_to have_css("#legislation_annotation_text")
|
||||
expect(page).to have_content "You must Sign in or Sign up to leave a comment."
|
||||
end
|
||||
|
||||
scenario 'Create' do
|
||||
scenario "Create" do
|
||||
draft_version = create(:legislation_draft_version, :published)
|
||||
|
||||
visit legislation_process_draft_version_path(draft_version.process, draft_version)
|
||||
@@ -167,7 +167,7 @@ feature 'Legislation Draft Versions' do
|
||||
page.click_button "Publish Comment"
|
||||
expect(page).to have_content "Comment can't be blank"
|
||||
|
||||
fill_in 'legislation_annotation_text', with: 'this is my annotation'
|
||||
fill_in "legislation_annotation_text", with: "this is my annotation"
|
||||
page.click_button "Publish Comment"
|
||||
|
||||
expect(page).to have_css ".annotator-hl"
|
||||
@@ -181,7 +181,7 @@ feature 'Legislation Draft Versions' do
|
||||
expect(page).to have_content "this is my annotation"
|
||||
end
|
||||
|
||||
scenario 'View annotations and comments' do
|
||||
scenario "View annotations and comments" do
|
||||
draft_version = create(:legislation_draft_version, :published)
|
||||
annotation1 = create(:legislation_annotation, draft_version: draft_version, text: "my annotation",
|
||||
ranges: [{"start" => "/p[1]", "startOffset" => 5, "end" => "/p[1]", "endOffset" => 10}])
|
||||
@@ -224,7 +224,7 @@ feature 'Legislation Draft Versions' do
|
||||
|
||||
background { login_as user }
|
||||
|
||||
scenario 'View annotations and comments in an included range' do
|
||||
scenario "View annotations and comments in an included range" do
|
||||
draft_version = create(:legislation_draft_version, :published)
|
||||
annotation1 = create(:legislation_annotation, draft_version: draft_version, text: "my annotation",
|
||||
ranges: [{"start" => "/p[1]", "startOffset" => 1, "end" => "/p[1]", "endOffset" => 5}])
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
feature 'Legislation' do
|
||||
feature "Legislation" do
|
||||
|
||||
let!(:administrator) { create(:administrator).user }
|
||||
|
||||
@@ -24,7 +24,7 @@ feature 'Legislation' do
|
||||
end
|
||||
end
|
||||
|
||||
context 'processes home page' do
|
||||
context "processes home page" do
|
||||
|
||||
scenario "No processes to be listed" do
|
||||
visit legislation_processes_path
|
||||
@@ -34,7 +34,7 @@ feature 'Legislation' do
|
||||
expect(page).to have_text "There aren't past processes"
|
||||
end
|
||||
|
||||
scenario 'Processes can be listed' do
|
||||
scenario "Processes can be listed" do
|
||||
processes = create_list(:legislation_process, 3)
|
||||
|
||||
visit legislation_processes_path
|
||||
@@ -55,7 +55,7 @@ feature 'Legislation' do
|
||||
expect("Process 2").to appear_before("Process 1")
|
||||
end
|
||||
|
||||
scenario 'Participation phases are displayed only if there is a phase enabled' do
|
||||
scenario "Participation phases are displayed only if there is a phase enabled" do
|
||||
process = create(:legislation_process, :empty)
|
||||
process_debate = create(:legislation_process)
|
||||
|
||||
@@ -68,7 +68,7 @@ feature 'Legislation' do
|
||||
expect(page).to have_content("Participation phases")
|
||||
end
|
||||
|
||||
scenario 'Participation phases are displayed on current locale' do
|
||||
scenario "Participation phases are displayed on current locale" do
|
||||
process = create(:legislation_process, proposals_phase_start_date: Date.new(2018, 01, 01),
|
||||
proposals_phase_end_date: Date.new(2018, 12, 01))
|
||||
|
||||
@@ -85,19 +85,19 @@ feature 'Legislation' do
|
||||
expect(page).to have_content("01 ene 2018 - 01 dic 2018")
|
||||
end
|
||||
|
||||
scenario 'Filtering processes' do
|
||||
scenario "Filtering processes" do
|
||||
create(:legislation_process, title: "Process open")
|
||||
create(:legislation_process, :past, title: "Process past")
|
||||
create(:legislation_process, :in_draft_phase, title: "Process in draft phase")
|
||||
|
||||
visit legislation_processes_path
|
||||
expect(page).to have_content('Process open')
|
||||
expect(page).not_to have_content('Process past')
|
||||
expect(page).not_to have_content('Process in draft phase')
|
||||
expect(page).to have_content("Process open")
|
||||
expect(page).not_to have_content("Process past")
|
||||
expect(page).not_to have_content("Process in draft phase")
|
||||
|
||||
visit legislation_processes_path(filter: 'past')
|
||||
expect(page).not_to have_content('Process open')
|
||||
expect(page).to have_content('Process past')
|
||||
visit legislation_processes_path(filter: "past")
|
||||
expect(page).not_to have_content("Process open")
|
||||
expect(page).to have_content("Process past")
|
||||
end
|
||||
|
||||
context "not published processes" do
|
||||
@@ -110,33 +110,33 @@ feature 'Legislation' do
|
||||
|
||||
it "aren't listed" do
|
||||
visit legislation_processes_path
|
||||
expect(page).not_to have_content('not published')
|
||||
expect(page).to have_content('published')
|
||||
expect(page).not_to have_content("not published")
|
||||
expect(page).to have_content("published")
|
||||
|
||||
login_as(administrator)
|
||||
visit legislation_processes_path
|
||||
expect(page).not_to have_content('not published')
|
||||
expect(page).to have_content('published')
|
||||
expect(page).not_to have_content("not published")
|
||||
expect(page).to have_content("published")
|
||||
end
|
||||
|
||||
it "aren't listed with past filter" do
|
||||
visit legislation_processes_path(filter: 'past')
|
||||
expect(page).not_to have_content('not published')
|
||||
expect(page).to have_content('past published')
|
||||
visit legislation_processes_path(filter: "past")
|
||||
expect(page).not_to have_content("not published")
|
||||
expect(page).to have_content("past published")
|
||||
|
||||
login_as(administrator)
|
||||
visit legislation_processes_path(filter: 'past')
|
||||
expect(page).not_to have_content('not published')
|
||||
expect(page).to have_content('past published')
|
||||
visit legislation_processes_path(filter: "past")
|
||||
expect(page).not_to have_content("not published")
|
||||
expect(page).to have_content("past published")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'process page' do
|
||||
context "process page" do
|
||||
context "show" do
|
||||
include_examples "not published permissions", :legislation_process_path
|
||||
|
||||
scenario 'show view has document present on all phases' do
|
||||
scenario "show view has document present on all phases" do
|
||||
process = create(:legislation_process)
|
||||
document = create(:document, documentable: process)
|
||||
phases = ["Debate", "Proposals", "Comments"]
|
||||
@@ -145,14 +145,14 @@ feature 'Legislation' do
|
||||
|
||||
phases.each do |phase|
|
||||
within(".legislation-process-list") do
|
||||
find('li', :text => "#{phase}").click_link
|
||||
find("li", :text => "#{phase}").click_link
|
||||
end
|
||||
|
||||
expect(page).to have_content(document.title)
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'show draft publication and final result publication dates' do
|
||||
scenario "show draft publication and final result publication dates" do
|
||||
process = create(:legislation_process, draft_publication_date: Date.new(2019, 01, 10),
|
||||
result_publication_date: Date.new(2019, 01, 20))
|
||||
|
||||
@@ -166,7 +166,7 @@ feature 'Legislation' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'do not show draft publication and final result publication dates if are empty' do
|
||||
scenario "do not show draft publication and final result publication dates if are empty" do
|
||||
process = create(:legislation_process, :empty)
|
||||
|
||||
visit legislation_process_path(process)
|
||||
@@ -177,7 +177,7 @@ feature 'Legislation' do
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'show additional info button' do
|
||||
scenario "show additional info button" do
|
||||
process = create(:legislation_process, additional_info: "Text for additional info of the process")
|
||||
|
||||
visit legislation_process_path(process)
|
||||
@@ -186,7 +186,7 @@ feature 'Legislation' do
|
||||
expect(page).to have_content("Text for additional info of the process")
|
||||
end
|
||||
|
||||
scenario 'do not show additional info button if it is empty' do
|
||||
scenario "do not show additional info button if it is empty" do
|
||||
process = create(:legislation_process)
|
||||
|
||||
visit legislation_process_path(process)
|
||||
@@ -203,10 +203,10 @@ feature 'Legislation' do
|
||||
end
|
||||
end
|
||||
|
||||
context 'homepage' do
|
||||
scenario 'enabled' do
|
||||
context "homepage" do
|
||||
scenario "enabled" do
|
||||
process = create(:legislation_process, homepage_enabled: true,
|
||||
homepage: 'This is the process homepage',
|
||||
homepage: "This is the process homepage",
|
||||
debate_start_date: Date.current + 1.day,
|
||||
debate_end_date: Date.current + 2.days)
|
||||
|
||||
@@ -220,9 +220,9 @@ feature 'Legislation' do
|
||||
expect(page).not_to have_content("Participate in the debate")
|
||||
end
|
||||
|
||||
scenario 'disabled', :with_frozen_time do
|
||||
scenario "disabled", :with_frozen_time do
|
||||
process = create(:legislation_process, homepage_enabled: false,
|
||||
homepage: 'This is the process homepage',
|
||||
homepage: "This is the process homepage",
|
||||
debate_start_date: Date.current + 1.day,
|
||||
debate_end_date: Date.current + 2.days)
|
||||
|
||||
@@ -237,8 +237,8 @@ feature 'Legislation' do
|
||||
end
|
||||
end
|
||||
|
||||
context 'debate phase' do
|
||||
scenario 'not open', :with_frozen_time do
|
||||
context "debate phase" do
|
||||
scenario "not open", :with_frozen_time do
|
||||
process = create(:legislation_process, debate_start_date: Date.current + 1.day, debate_end_date: Date.current + 2.days)
|
||||
|
||||
visit legislation_process_path(process)
|
||||
@@ -247,7 +247,7 @@ feature 'Legislation' do
|
||||
expect(page).not_to have_content("Participate in the debate")
|
||||
end
|
||||
|
||||
scenario 'open without questions' do
|
||||
scenario "open without questions" do
|
||||
process = create(:legislation_process, debate_start_date: Date.current - 1.day, debate_end_date: Date.current + 2.days)
|
||||
|
||||
visit legislation_process_path(process)
|
||||
@@ -256,7 +256,7 @@ feature 'Legislation' do
|
||||
expect(page).not_to have_content("This phase is not open yet")
|
||||
end
|
||||
|
||||
scenario 'open with questions' do
|
||||
scenario "open with questions" do
|
||||
process = create(:legislation_process, debate_start_date: Date.current - 1.day, debate_end_date: Date.current + 2.days)
|
||||
create(:legislation_question, process: process, title: "Question 1")
|
||||
create(:legislation_question, process: process, title: "Question 2")
|
||||
@@ -272,8 +272,8 @@ feature 'Legislation' do
|
||||
include_examples "not published permissions", :debate_legislation_process_path
|
||||
end
|
||||
|
||||
context 'draft publication phase' do
|
||||
scenario 'not open', :with_frozen_time do
|
||||
context "draft publication phase" do
|
||||
scenario "not open", :with_frozen_time do
|
||||
process = create(:legislation_process, draft_publication_date: Date.current + 1.day)
|
||||
|
||||
visit draft_publication_legislation_process_path(process)
|
||||
@@ -281,7 +281,7 @@ feature 'Legislation' do
|
||||
expect(page).to have_content("This phase is not open yet")
|
||||
end
|
||||
|
||||
scenario 'open' do
|
||||
scenario "open" do
|
||||
process = create(:legislation_process, draft_publication_date: Date.current)
|
||||
|
||||
visit draft_publication_legislation_process_path(process)
|
||||
@@ -292,8 +292,8 @@ feature 'Legislation' do
|
||||
include_examples "not published permissions", :draft_publication_legislation_process_path
|
||||
end
|
||||
|
||||
context 'allegations phase' do
|
||||
scenario 'not open', :with_frozen_time do
|
||||
context "allegations phase" do
|
||||
scenario "not open", :with_frozen_time do
|
||||
process = create(:legislation_process, allegations_start_date: Date.current + 1.day, allegations_end_date: Date.current + 2.days)
|
||||
|
||||
visit allegations_legislation_process_path(process)
|
||||
@@ -301,7 +301,7 @@ feature 'Legislation' do
|
||||
expect(page).to have_content("This phase is not open yet")
|
||||
end
|
||||
|
||||
scenario 'open' do
|
||||
scenario "open" do
|
||||
process = create(:legislation_process, allegations_start_date: Date.current - 1.day, allegations_end_date: Date.current + 2.days)
|
||||
|
||||
visit allegations_legislation_process_path(process)
|
||||
@@ -312,8 +312,8 @@ feature 'Legislation' do
|
||||
include_examples "not published permissions", :allegations_legislation_process_path
|
||||
end
|
||||
|
||||
context 'final version publication phase' do
|
||||
scenario 'not open', :with_frozen_time do
|
||||
context "final version publication phase" do
|
||||
scenario "not open", :with_frozen_time do
|
||||
process = create(:legislation_process, result_publication_date: Date.current + 1.day)
|
||||
|
||||
visit result_publication_legislation_process_path(process)
|
||||
@@ -321,7 +321,7 @@ feature 'Legislation' do
|
||||
expect(page).to have_content("This phase is not open yet")
|
||||
end
|
||||
|
||||
scenario 'open' do
|
||||
scenario "open" do
|
||||
process = create(:legislation_process, result_publication_date: Date.current)
|
||||
|
||||
visit result_publication_legislation_process_path(process)
|
||||
@@ -332,8 +332,8 @@ feature 'Legislation' do
|
||||
include_examples "not published permissions", :result_publication_legislation_process_path
|
||||
end
|
||||
|
||||
context 'proposals phase' do
|
||||
scenario 'not open', :with_frozen_time do
|
||||
context "proposals phase" do
|
||||
scenario "not open", :with_frozen_time do
|
||||
process = create(:legislation_process, :upcoming_proposals_phase)
|
||||
|
||||
visit legislation_process_proposals_path(process)
|
||||
@@ -341,7 +341,7 @@ feature 'Legislation' do
|
||||
expect(page).to have_content("This phase is not open yet")
|
||||
end
|
||||
|
||||
scenario 'open' do
|
||||
scenario "open" do
|
||||
process = create(:legislation_process, :in_proposals_phase)
|
||||
|
||||
visit legislation_process_proposals_path(process)
|
||||
@@ -349,7 +349,7 @@ feature 'Legislation' do
|
||||
expect(page).to have_content("There are no proposals")
|
||||
end
|
||||
|
||||
scenario 'create proposal button redirects to register path if user is not logged in' do
|
||||
scenario "create proposal button redirects to register path if user is not logged in" do
|
||||
process = create(:legislation_process, :in_proposals_phase)
|
||||
|
||||
visit legislation_process_proposals_path(process)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
require 'sessions_helper'
|
||||
require "rails_helper"
|
||||
require "sessions_helper"
|
||||
|
||||
feature 'Legislation Proposals' do
|
||||
feature "Legislation Proposals" do
|
||||
|
||||
let(:user) { create(:user) }
|
||||
let(:user2) { create(:user) }
|
||||
@@ -9,14 +9,14 @@ feature 'Legislation Proposals' do
|
||||
let(:proposal) { create(:legislation_proposal) }
|
||||
|
||||
context "Concerns" do
|
||||
it_behaves_like 'notifiable in-app', Legislation::Proposal
|
||||
it_behaves_like "notifiable in-app", Legislation::Proposal
|
||||
end
|
||||
|
||||
scenario "Only one menu element has 'active' CSS selector" do
|
||||
visit legislation_process_proposal_path(proposal.process, proposal)
|
||||
|
||||
within('#navigation_bar') do
|
||||
expect(page).to have_css('.is-active', count: 1)
|
||||
within("#navigation_bar") do
|
||||
expect(page).to have_css(".is-active", count: 1)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -81,43 +81,43 @@ feature 'Legislation Proposals' do
|
||||
end
|
||||
end
|
||||
|
||||
context 'Selected filter' do
|
||||
scenario 'apperars even if there are not any selected poposals' do
|
||||
context "Selected filter" do
|
||||
scenario "apperars even if there are not any selected poposals" do
|
||||
create(:legislation_proposal, legislation_process_id: process.id)
|
||||
|
||||
visit legislation_process_proposals_path(process)
|
||||
|
||||
expect(page).to have_content('Selected')
|
||||
expect(page).to have_content("Selected")
|
||||
end
|
||||
|
||||
scenario 'defaults to winners if there are selected proposals' do
|
||||
scenario "defaults to winners if there are selected proposals" do
|
||||
create(:legislation_proposal, legislation_process_id: process.id)
|
||||
create(:legislation_proposal, legislation_process_id: process.id, selected: true)
|
||||
|
||||
visit legislation_process_proposals_path(process)
|
||||
|
||||
expect(page).to have_link('Random')
|
||||
expect(page).not_to have_link('Selected')
|
||||
expect(page).to have_content('Selected')
|
||||
expect(page).to have_link("Random")
|
||||
expect(page).not_to have_link("Selected")
|
||||
expect(page).to have_content("Selected")
|
||||
end
|
||||
|
||||
scenario 'defaults to random if the current process does not have selected proposals' do
|
||||
scenario "defaults to random if the current process does not have selected proposals" do
|
||||
create(:legislation_proposal, legislation_process_id: process.id)
|
||||
create(:legislation_proposal, selected: true)
|
||||
|
||||
visit legislation_process_proposals_path(process)
|
||||
|
||||
expect(page).to have_link('Selected')
|
||||
expect(page).not_to have_link('Random')
|
||||
expect(page).to have_content('Random')
|
||||
expect(page).to have_link("Selected")
|
||||
expect(page).not_to have_link("Random")
|
||||
expect(page).to have_content("Random")
|
||||
end
|
||||
|
||||
scenario 'filters correctly' do
|
||||
scenario "filters correctly" do
|
||||
proposal1 = create(:legislation_proposal, legislation_process_id: process.id)
|
||||
proposal2 = create(:legislation_proposal, legislation_process_id: process.id, selected: true)
|
||||
|
||||
visit legislation_process_proposals_path(process, filter: "random")
|
||||
click_link 'Selected'
|
||||
click_link "Selected"
|
||||
|
||||
expect(page).to have_css("div#legislation_proposal_#{proposal2.id}")
|
||||
expect(page).not_to have_css("div#legislation_proposal_#{proposal1.id}")
|
||||
@@ -135,14 +135,14 @@ feature 'Legislation Proposals' do
|
||||
|
||||
visit new_legislation_process_proposal_path(process)
|
||||
|
||||
fill_in 'Proposal title', with: 'Legislation proposal with image'
|
||||
fill_in 'Proposal summary', with: 'Including an image on a legislation proposal'
|
||||
imageable_attach_new_file(create(:image), Rails.root.join('spec/fixtures/files/clippy.jpg'))
|
||||
check 'legislation_proposal_terms_of_service'
|
||||
click_button 'Create proposal'
|
||||
fill_in "Proposal title", with: "Legislation proposal with image"
|
||||
fill_in "Proposal summary", with: "Including an image on a legislation proposal"
|
||||
imageable_attach_new_file(create(:image), Rails.root.join("spec/fixtures/files/clippy.jpg"))
|
||||
check "legislation_proposal_terms_of_service"
|
||||
click_button "Create proposal"
|
||||
|
||||
expect(page).to have_content 'Legislation proposal with image'
|
||||
expect(page).to have_content 'Including an image on a legislation proposal'
|
||||
expect(page).to have_content "Legislation proposal with image"
|
||||
expect(page).to have_content "Including an image on a legislation proposal"
|
||||
expect(page).to have_css("img[alt='#{Legislation::Proposal.last.image.title}']")
|
||||
end
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user