diff --git a/spec/controllers/admin/api/stats_controller_spec.rb b/spec/controllers/admin/api/stats_controller_spec.rb index 29cb36724..2db94c7d3 100644 --- a/spec/controllers/admin/api/stats_controller_spec.rb +++ b/spec/controllers/admin/api/stats_controller_spec.rb @@ -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) diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index 53212032e..025ec4e39 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe ApplicationController do diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb index 047e76e85..c267f3814 100644 --- a/spec/controllers/comments_controller_spec.rb +++ b/spec/controllers/comments_controller_spec.rb @@ -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 diff --git a/spec/controllers/concerns/has_filters_spec.rb b/spec/controllers/concerns/has_filters_spec.rb index d0bfdf1e7..ac4854db8 100644 --- a/spec/controllers/concerns/has_filters_spec.rb +++ b/spec/controllers/concerns/has_filters_spec.rb @@ -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 diff --git a/spec/controllers/concerns/has_orders_spec.rb b/spec/controllers/concerns/has_orders_spec.rb index b94cc2dba..d4240b29d 100644 --- a/spec/controllers/concerns/has_orders_spec.rb +++ b/spec/controllers/concerns/has_orders_spec.rb @@ -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 diff --git a/spec/controllers/debates_controller_spec.rb b/spec/controllers/debates_controller_spec.rb index 64d1fa597..7f89a75ae 100644 --- a/spec/controllers/debates_controller_spec.rb +++ b/spec/controllers/debates_controller_spec.rb @@ -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 diff --git a/spec/controllers/graphql_controller_spec.rb b/spec/controllers/graphql_controller_spec.rb index 0f15da038..46d1d69df 100644 --- a/spec/controllers/graphql_controller_spec.rb +++ b/spec/controllers/graphql_controller_spec.rb @@ -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 diff --git a/spec/controllers/installation_controller_spec.rb b/spec/controllers/installation_controller_spec.rb index 5341271b7..722bfa538 100644 --- a/spec/controllers/installation_controller_spec.rb +++ b/spec/controllers/installation_controller_spec.rb @@ -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 diff --git a/spec/controllers/legislation/annotations_controller_spec.rb b/spec/controllers/legislation/annotations_controller_spec.rb index 80335a209..d7847d9fa 100644 --- a/spec/controllers/legislation/annotations_controller_spec.rb +++ b/spec/controllers/legislation/annotations_controller_spec.rb @@ -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) diff --git a/spec/controllers/legislation/answers_controller_spec.rb b/spec/controllers/legislation/answers_controller_spec.rb index 466a90eb8..b5ef6dd96 100644 --- a/spec/controllers/legislation/answers_controller_spec.rb +++ b/spec/controllers/legislation/answers_controller_spec.rb @@ -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) diff --git a/spec/controllers/management/base_controller_spec.rb b/spec/controllers/management/base_controller_spec.rb index 60b4678f8..751466e7b 100644 --- a/spec/controllers/management/base_controller_spec.rb +++ b/spec/controllers/management/base_controller_spec.rb @@ -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" diff --git a/spec/controllers/management/sessions_controller_spec.rb b/spec/controllers/management/sessions_controller_spec.rb index 25d0afc6b..7356169ad 100644 --- a/spec/controllers/management/sessions_controller_spec.rb +++ b/spec/controllers/management/sessions_controller_spec.rb @@ -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" diff --git a/spec/controllers/management/users_controller_spec.rb b/spec/controllers/management/users_controller_spec.rb index d30e5f27c..3b89920b9 100644 --- a/spec/controllers/management/users_controller_spec.rb +++ b/spec/controllers/management/users_controller_spec.rb @@ -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" diff --git a/spec/controllers/pages_controller_spec.rb b/spec/controllers/pages_controller_spec.rb index 239afb468..1069652ff 100644 --- a/spec/controllers/pages_controller_spec.rb +++ b/spec/controllers/pages_controller_spec.rb @@ -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 diff --git a/spec/controllers/users/registrations_controller_spec.rb b/spec/controllers/users/registrations_controller_spec.rb index b8454678c..82269703e 100644 --- a/spec/controllers/users/registrations_controller_spec.rb +++ b/spec/controllers/users/registrations_controller_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Users::RegistrationsController do diff --git a/spec/customization_engine_spec.rb b/spec/customization_engine_spec.rb index be005562b..d8a22cc37 100644 --- a/spec/customization_engine_spec.rb +++ b/spec/customization_engine_spec.rb @@ -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) diff --git a/spec/factories/administration.rb b/spec/factories/administration.rb index 17c9660aa..24704dfaa 100644 --- a/spec/factories/administration.rb +++ b/spec/factories/administration.rb @@ -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 diff --git a/spec/factories/debates.rb b/spec/factories/debates.rb index c657ccadb..41ca081c0 100644 --- a/spec/factories/debates.rb +++ b/spec/factories/debates.rb @@ -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 diff --git a/spec/factories/legislations.rb b/spec/factories/legislations.rb index 77b14f65a..204bc67e1 100644 --- a/spec/factories/legislations.rb +++ b/spec/factories/legislations.rb @@ -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 diff --git a/spec/factories/polls.rb b/spec/factories/polls.rb index 07649d693..280da6c4d 100644 --- a/spec/factories/polls.rb +++ b/spec/factories/polls.rb @@ -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 diff --git a/spec/factories/proposals.rb b/spec/factories/proposals.rb index d65d5afb3..9bf42ab6e 100644 --- a/spec/factories/proposals.rb +++ b/spec/factories/proposals.rb @@ -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 diff --git a/spec/factories/users.rb b/spec/factories/users.rb index f80e78bf8..c4a70a94b 100644 --- a/spec/factories/users.rb +++ b/spec/factories/users.rb @@ -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 diff --git a/spec/factories/verifications.rb b/spec/factories/verifications.rb index e81e21ed5..e750d8027 100644 --- a/spec/factories/verifications.rb +++ b/spec/factories/verifications.rb @@ -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 diff --git a/spec/features/account_spec.rb b/spec/features/account_spec.rb index a82f32495..1902ede45 100644 --- a/spec/features/account_spec.rb +++ b/spec/features/account_spec.rb @@ -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 diff --git a/spec/features/admin/activity_spec.rb b/spec/features/admin/activity_spec.rb index 6f9270ffe..7e8813af5 100644 --- a/spec/features/admin/activity_spec.rb +++ b/spec/features/admin/activity_spec.rb @@ -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 diff --git a/spec/features/admin/admin_notifications_spec.rb b/spec/features/admin/admin_notifications_spec.rb index a37790b63..19910172d 100644 --- a/spec/features/admin/admin_notifications_spec.rb +++ b/spec/features/admin/admin_notifications_spec.rb @@ -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") diff --git a/spec/features/admin/administrators_spec.rb b/spec/features/admin/administrators_spec.rb index 2e793e545..c69d217da 100644 --- a/spec/features/admin/administrators_spec.rb +++ b/spec/features/admin/administrators_spec.rb @@ -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 diff --git a/spec/features/admin/banners_spec.rb b/spec/features/admin/banners_spec.rb index 9c581e03b..1c86fde16 100644 --- a/spec/features/admin/banners_spec.rb +++ b/spec/features/admin/banners_spec.rb @@ -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 diff --git a/spec/features/admin/budget_groups_spec.rb b/spec/features/admin/budget_groups_spec.rb index a1bb01bcf..4c89abaeb 100644 --- a/spec/features/admin/budget_groups_spec.rb +++ b/spec/features/admin/budget_groups_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" feature "Admin budget groups" do diff --git a/spec/features/admin/budget_headings_spec.rb b/spec/features/admin/budget_headings_spec.rb index 4eda9fcb9..2c918b6da 100644 --- a/spec/features/admin/budget_headings_spec.rb +++ b/spec/features/admin/budget_headings_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" feature "Admin budget headings" do diff --git a/spec/features/admin/budget_investment_milestones_spec.rb b/spec/features/admin/budget_investment_milestones_spec.rb index eae9786ca..091285951 100644 --- a/spec/features/admin/budget_investment_milestones_spec.rb +++ b/spec/features/admin/budget_investment_milestones_spec.rb @@ -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", diff --git a/spec/features/admin/budget_phases_spec.rb b/spec/features/admin/budget_phases_spec.rb index b647b4a79..b19cafdcd 100644 --- a/spec/features/admin/budget_phases_spec.rb +++ b/spec/features/admin/budget_phases_spec.rb @@ -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) diff --git a/spec/features/admin/comments_spec.rb b/spec/features/admin/comments_spec.rb index b06b575c5..0c4994e31 100644 --- a/spec/features/admin/comments_spec.rb +++ b/spec/features/admin/comments_spec.rb @@ -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 \ No newline at end of file diff --git a/spec/features/admin/debates_spec.rb b/spec/features/admin/debates_spec.rb index 012a57570..874707eac 100644 --- a/spec/features/admin/debates_spec.rb +++ b/spec/features/admin/debates_spec.rb @@ -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 diff --git a/spec/features/admin/emails/emails_download_spec.rb b/spec/features/admin/emails/emails_download_spec.rb index 8a92337b0..13aad88a7 100644 --- a/spec/features/admin/emails/emails_download_spec.rb +++ b/spec/features/admin/emails/emails_download_spec.rb @@ -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 diff --git a/spec/features/admin/emails/newsletters_spec.rb b/spec/features/admin/emails/newsletters_spec.rb index 102620245..7356ed978 100644 --- a/spec/features/admin/emails/newsletters_spec.rb +++ b/spec/features/admin/emails/newsletters_spec.rb @@ -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") diff --git a/spec/features/admin/feature_flags_spec.rb b/spec/features/admin/feature_flags_spec.rb index 89d20d052..181a8a34c 100644 --- a/spec/features/admin/feature_flags_spec.rb +++ b/spec/features/admin/feature_flags_spec.rb @@ -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 diff --git a/spec/features/admin/geozones_spec.rb b/spec/features/admin/geozones_spec.rb index 44f9b0d03..9fadded83 100644 --- a/spec/features/admin/geozones_spec.rb +++ b/spec/features/admin/geozones_spec.rb @@ -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 diff --git a/spec/features/admin/hidden_budget_investments_spec.rb b/spec/features/admin/hidden_budget_investments_spec.rb index 2b001830b..592f04144 100644 --- a/spec/features/admin/hidden_budget_investments_spec.rb +++ b/spec/features/admin/hidden_budget_investments_spec.rb @@ -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 diff --git a/spec/features/admin/hidden_proposals_spec.rb b/spec/features/admin/hidden_proposals_spec.rb index 3b55d98a0..71a290ecb 100644 --- a/spec/features/admin/hidden_proposals_spec.rb +++ b/spec/features/admin/hidden_proposals_spec.rb @@ -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 diff --git a/spec/features/admin/hidden_users_spec.rb b/spec/features/admin/hidden_users_spec.rb index 121e52b69..8061277c3 100644 --- a/spec/features/admin/hidden_users_spec.rb +++ b/spec/features/admin/hidden_users_spec.rb @@ -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 diff --git a/spec/features/admin/homepage/homepage_spec.rb b/spec/features/admin/homepage/homepage_spec.rb index babd4814e..c62353283 100644 --- a/spec/features/admin/homepage/homepage_spec.rb +++ b/spec/features/admin/homepage/homepage_spec.rb @@ -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 diff --git a/spec/features/admin/legislation/draft_versions_spec.rb b/spec/features/admin/legislation/draft_versions_spec.rb index 8aac1d201..2de2345d6 100644 --- a/spec/features/admin/legislation/draft_versions_spec.rb +++ b/spec/features/admin/legislation/draft_versions_spec.rb @@ -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 diff --git a/spec/features/admin/legislation/processes_spec.rb b/spec/features/admin/legislation/processes_spec.rb index bfeeece69..dde769291 100644 --- a/spec/features/admin/legislation/processes_spec.rb +++ b/spec/features/admin/legislation/processes_spec.rb @@ -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 diff --git a/spec/features/admin/legislation/proposals_spec.rb b/spec/features/admin/legislation/proposals_spec.rb index f25bd2af1..8ace1da76 100644 --- a/spec/features/admin/legislation/proposals_spec.rb +++ b/spec/features/admin/legislation/proposals_spec.rb @@ -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 diff --git a/spec/features/admin/legislation/questions_spec.rb b/spec/features/admin/legislation/questions_spec.rb index adff3c3eb..f90a59ecc 100644 --- a/spec/features/admin/legislation/questions_spec.rb +++ b/spec/features/admin/legislation/questions_spec.rb @@ -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 diff --git a/spec/features/admin/managers_spec.rb b/spec/features/admin/managers_spec.rb index 24baafca6..915ebe34f 100644 --- a/spec/features/admin/managers_spec.rb +++ b/spec/features/admin/managers_spec.rb @@ -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 diff --git a/spec/features/admin/milestone_statuses_spec.rb b/spec/features/admin/milestone_statuses_spec.rb index e928ce453..56442db54 100644 --- a/spec/features/admin/milestone_statuses_spec.rb +++ b/spec/features/admin/milestone_statuses_spec.rb @@ -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 diff --git a/spec/features/admin/moderators_spec.rb b/spec/features/admin/moderators_spec.rb index aa45f7011..733a45b90 100644 --- a/spec/features/admin/moderators_spec.rb +++ b/spec/features/admin/moderators_spec.rb @@ -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 diff --git a/spec/features/admin/officials_spec.rb b/spec/features/admin/officials_spec.rb index 151beaeca..719822b92 100644 --- a/spec/features/admin/officials_spec.rb +++ b/spec/features/admin/officials_spec.rb @@ -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 diff --git a/spec/features/admin/organizations_spec.rb b/spec/features/admin/organizations_spec.rb index 9f4e2a546..061967328 100644 --- a/spec/features/admin/organizations_spec.rb +++ b/spec/features/admin/organizations_spec.rb @@ -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 diff --git a/spec/features/admin/poll/booth_assigments_spec.rb b/spec/features/admin/poll/booth_assigments_spec.rb index d93ac10c8..19e109f0b 100644 --- a/spec/features/admin/poll/booth_assigments_spec.rb +++ b/spec/features/admin/poll/booth_assigments_spec.rb @@ -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 diff --git a/spec/features/admin/poll/booths_spec.rb b/spec/features/admin/poll/booths_spec.rb index 7ca347649..592bb7c34 100644 --- a/spec/features/admin/poll/booths_spec.rb +++ b/spec/features/admin/poll/booths_spec.rb @@ -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 diff --git a/spec/features/admin/poll/officer_assignments_spec.rb b/spec/features/admin/poll/officer_assignments_spec.rb index d95fc8aa5..d58f1331a 100644 --- a/spec/features/admin/poll/officer_assignments_spec.rb +++ b/spec/features/admin/poll/officer_assignments_spec.rb @@ -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 diff --git a/spec/features/admin/poll/officers_spec.rb b/spec/features/admin/poll/officers_spec.rb index cfa0ff1ae..4fd3f0d96 100644 --- a/spec/features/admin/poll/officers_spec.rb +++ b/spec/features/admin/poll/officers_spec.rb @@ -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 \ No newline at end of file diff --git a/spec/features/admin/poll/questions/answers/answers_spec.rb b/spec/features/admin/poll/questions/answers/answers_spec.rb index 4e3965f01..410147e0f 100644 --- a/spec/features/admin/poll/questions/answers/answers_spec.rb +++ b/spec/features/admin/poll/questions/answers/answers_spec.rb @@ -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) diff --git a/spec/features/admin/poll/questions/answers/images/images_spec.rb b/spec/features/admin/poll/questions/answers/images/images_spec.rb index eb18e17fd..2e62250e1 100644 --- a/spec/features/admin/poll/questions/answers/images/images_spec.rb +++ b/spec/features/admin/poll/questions/answers/images/images_spec.rb @@ -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}']") diff --git a/spec/features/admin/poll/questions/answers/videos/videos_spec.rb b/spec/features/admin/poll/questions/answers/videos/videos_spec.rb index 35d07f454..e11f3b9e4 100644 --- a/spec/features/admin/poll/questions/answers/videos/videos_spec.rb +++ b/spec/features/admin/poll/questions/answers/videos/videos_spec.rb @@ -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" diff --git a/spec/features/admin/poll/questions_spec.rb b/spec/features/admin/poll/questions_spec.rb index 779a6b7d5..29083b99b 100644 --- a/spec/features/admin/poll/questions_spec.rb +++ b/spec/features/admin/poll/questions_spec.rb @@ -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 diff --git a/spec/features/admin/poll/shifts_spec.rb b/spec/features/admin/poll/shifts_spec.rb index f70b01ec5..35efc2927 100644 --- a/spec/features/admin/poll/shifts_spec.rb +++ b/spec/features/admin/poll/shifts_spec.rb @@ -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 diff --git a/spec/features/admin/proposal_notifications_spec.rb b/spec/features/admin/proposal_notifications_spec.rb index 62f4bf340..6bf60709c 100644 --- a/spec/features/admin/proposal_notifications_spec.rb +++ b/spec/features/admin/proposal_notifications_spec.rb @@ -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 diff --git a/spec/features/admin/settings_spec.rb b/spec/features/admin/settings_spec.rb index 7a98155bc..954365d89 100644 --- a/spec/features/admin/settings_spec.rb +++ b/spec/features/admin/settings_spec.rb @@ -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 diff --git a/spec/features/admin/signature_sheets_spec.rb b/spec/features/admin/signature_sheets_spec.rb index 126e899db..edaa42336 100644 --- a/spec/features/admin/signature_sheets_spec.rb +++ b/spec/features/admin/signature_sheets_spec.rb @@ -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, diff --git a/spec/features/admin/site_customization/content_blocks_spec.rb b/spec/features/admin/site_customization/content_blocks_spec.rb index f54189049..c2e5e519a 100644 --- a/spec/features/admin/site_customization/content_blocks_spec.rb +++ b/spec/features/admin/site_customization/content_blocks_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" feature "Admin custom content blocks" do diff --git a/spec/features/admin/site_customization/images_spec.rb b/spec/features/admin/site_customization/images_spec.rb index d2f23d34e..419ea5a5a 100644 --- a/spec/features/admin/site_customization/images_spec.rb +++ b/spec/features/admin/site_customization/images_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" feature "Admin custom images" do diff --git a/spec/features/admin/site_customization/information_texts_spec.rb b/spec/features/admin/site_customization/information_texts_spec.rb index 83e4edb9a..9d20dfa54 100644 --- a/spec/features/admin/site_customization/information_texts_spec.rb +++ b/spec/features/admin/site_customization/information_texts_spec.rb @@ -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 diff --git a/spec/features/admin/site_customization/pages_spec.rb b/spec/features/admin/site_customization/pages_spec.rb index 098710ede..65502a470 100644 --- a/spec/features/admin/site_customization/pages_spec.rb +++ b/spec/features/admin/site_customization/pages_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" feature "Admin custom pages" do diff --git a/spec/features/admin/stats_spec.rb b/spec/features/admin/stats_spec.rb index 24df9b3bc..1e3cb5087 100644 --- a/spec/features/admin/stats_spec.rb +++ b/spec/features/admin/stats_spec.rb @@ -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 diff --git a/spec/features/admin/system_emails_spec.rb b/spec/features/admin/system_emails_spec.rb index 239e6183a..fb0eb374c 100644 --- a/spec/features/admin/system_emails_spec.rb +++ b/spec/features/admin/system_emails_spec.rb @@ -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) diff --git a/spec/features/admin/tags_spec.rb b/spec/features/admin/tags_spec.rb index e22637675..5580ad7b7 100644 --- a/spec/features/admin/tags_spec.rb +++ b/spec/features/admin/tags_spec.rb @@ -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 diff --git a/spec/features/admin/users_spec.rb b/spec/features/admin/users_spec.rb index f6f14772f..7972f7c16 100644 --- a/spec/features/admin/users_spec.rb +++ b/spec/features/admin/users_spec.rb @@ -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 diff --git a/spec/features/admin/valuator_groups_spec.rb b/spec/features/admin/valuator_groups_spec.rb index 47c94b475..9cf86bc50 100644 --- a/spec/features/admin/valuator_groups_spec.rb +++ b/spec/features/admin/valuator_groups_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" feature "Valuator groups" do diff --git a/spec/features/admin/valuators_spec.rb b/spec/features/admin/valuators_spec.rb index ba6792b49..c80e44fcc 100644 --- a/spec/features/admin/valuators_spec.rb +++ b/spec/features/admin/valuators_spec.rb @@ -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 diff --git a/spec/features/admin/verifications_spec.rb b/spec/features/admin/verifications_spec.rb index 94218426d..0d09eaaf0 100644 --- a/spec/features/admin/verifications_spec.rb +++ b/spec/features/admin/verifications_spec.rb @@ -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 diff --git a/spec/features/admin_spec.rb b/spec/features/admin_spec.rb index 82130cda4..f7808d601 100644 --- a/spec/features/admin_spec.rb +++ b/spec/features/admin_spec.rb @@ -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 diff --git a/spec/features/banners_spec.rb b/spec/features/banners_spec.rb index 0e5e5ea6a..b45cdcaba 100644 --- a/spec/features/banners_spec.rb +++ b/spec/features/banners_spec.rb @@ -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 diff --git a/spec/features/budget_polls/officing_spec.rb b/spec/features/budget_polls/officing_spec.rb index 81dd3b533..7f77b5caa 100644 --- a/spec/features/budget_polls/officing_spec.rb +++ b/spec/features/budget_polls/officing_spec.rb @@ -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) @@ -36,4 +36,4 @@ feature 'Budget Poll Officing' do expect(page).not_to have_content("Total recounts and results") end -end \ No newline at end of file +end diff --git a/spec/features/budgets/ballots_spec.rb b/spec/features/budgets/ballots_spec.rb index 5d93cee85..4398ab07f 100644 --- a/spec/features/budgets/ballots_spec.rb +++ b/spec/features/budgets/ballots_spec.rb @@ -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) diff --git a/spec/features/budgets/executions_spec.rb b/spec/features/budgets/executions_spec.rb index 53d0ef6b6..e25dd5a49 100644 --- a/spec/features/budgets/executions_spec.rb +++ b/spec/features/budgets/executions_spec.rb @@ -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 diff --git a/spec/features/budgets/investments_spec.rb b/spec/features/budgets/investments_spec.rb index a0d02bc37..b95f65e72 100644 --- a/spec/features/budgets/investments_spec.rb +++ b/spec/features/budgets/investments_spec.rb @@ -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) diff --git a/spec/features/budgets/results_spec.rb b/spec/features/budgets/results_spec.rb index 31c00a0a1..a2585e150 100644 --- a/spec/features/budgets/results_spec.rb +++ b/spec/features/budgets/results_spec.rb @@ -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" diff --git a/spec/features/campaigns_spec.rb b/spec/features/campaigns_spec.rb index 9a8935fc1..681cd33c1 100644 --- a/spec/features/campaigns_spec.rb +++ b/spec/features/campaigns_spec.rb @@ -1,6 +1,6 @@ -require 'rails_helper' +require "rails_helper" -feature 'Email campaigns' do +feature "Email campaigns" do background do @campaign1 = create(:campaign) diff --git a/spec/features/ckeditor_spec.rb b/spec/features/ckeditor_spec.rb index 7f5edc6e8..469df5001 100644 --- a/spec/features/ckeditor_spec.rb +++ b/spec/features/ckeditor_spec.rb @@ -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 diff --git a/spec/features/comments/budget_investments_spec.rb b/spec/features/comments/budget_investments_spec.rb index bf30bace6..c3a3e3193 100644 --- a/spec/features/comments/budget_investments_spec.rb +++ b/spec/features/comments/budget_investments_spec.rb @@ -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: " click me 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 diff --git a/spec/features/comments/budget_investments_valuation_spec.rb b/spec/features/comments/budget_investments_valuation_spec.rb index 746edc18e..b17cd1b47 100644 --- a/spec/features/comments/budget_investments_valuation_spec.rb +++ b/spec/features/comments/budget_investments_valuation_spec.rb @@ -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 = " "\ "click me 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 diff --git a/spec/features/comments/debates_spec.rb b/spec/features/comments/debates_spec.rb index a6015620b..d42844c51 100644 --- a/spec/features/comments/debates_spec.rb +++ b/spec/features/comments/debates_spec.rb @@ -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: " click me 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 diff --git a/spec/features/comments/legislation_annotations_spec.rb b/spec/features/comments/legislation_annotations_spec.rb index cb86b203f..cfeda9a9a 100644 --- a/spec/features/comments/legislation_annotations_spec.rb +++ b/spec/features/comments/legislation_annotations_spec.rb @@ -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: " click me 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) diff --git a/spec/features/comments/legislation_questions_spec.rb b/spec/features/comments/legislation_questions_spec.rb index f9de25023..db707a626 100644 --- a/spec/features/comments/legislation_questions_spec.rb +++ b/spec/features/comments/legislation_questions_spec.rb @@ -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: " click me 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 diff --git a/spec/features/comments/polls_spec.rb b/spec/features/comments/polls_spec.rb index 5e4bb51ef..7d7e63f98 100644 --- a/spec/features/comments/polls_spec.rb +++ b/spec/features/comments/polls_spec.rb @@ -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: " click me 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 diff --git a/spec/features/comments/proposals_spec.rb b/spec/features/comments/proposals_spec.rb index 2b067f556..07c2cf1f7 100644 --- a/spec/features/comments/proposals_spec.rb +++ b/spec/features/comments/proposals_spec.rb @@ -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: " click me 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 diff --git a/spec/features/comments/topics_spec.rb b/spec/features/comments/topics_spec.rb index d2e052035..5fe47e50b 100644 --- a/spec/features/comments/topics_spec.rb +++ b/spec/features/comments/topics_spec.rb @@ -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 diff --git a/spec/features/communities_spec.rb b/spec/features/communities_spec.rb index 0b9fa2c01..1c54aa681 100644 --- a/spec/features/communities_spec.rb +++ b/spec/features/communities_spec.rb @@ -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 diff --git a/spec/features/debates_spec.rb b/spec/features/debates_spec.rb index 1cd490276..8282ab265 100644 --- a/spec/features/debates_spec.rb +++ b/spec/features/debates_spec.rb @@ -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 "#{debate.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: '

This is

' - check 'debate_terms_of_service' + fill_in "debate_title", with: "Testing an attack" + fill_in "debate_description", with: "

This is

" + 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 '

This is alert("an attack");

' - expect(page.html).not_to include '' - 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 "

This is alert('an attack');

" + expect(page.html).not_to include "" + 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: '

This is a link www.example.org

' - check 'debate_terms_of_service' + fill_in "debate_title", with: "Testing auto link" + fill_in "debate_description", with: "

This is a link www.example.org

" + 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 = "
click me 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 "" - 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 "" 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 diff --git a/spec/features/direct_messages_spec.rb b/spec/features/direct_messages_spec.rb index d2ebccd87..1b1704087 100644 --- a/spec/features/direct_messages_spec.rb +++ b/spec/features/direct_messages_spec.rb @@ -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" diff --git a/spec/features/emails_spec.rb b/spec/features/emails_spec.rb index 573930ccb..ff71ec6d5 100644 --- a/spec/features/emails_spec.rb +++ b/spec/features/emails_spec.rb @@ -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 diff --git a/spec/features/help_page_spec.rb b/spec/features/help_page_spec.rb index 14f6746d1..2efe7aa9f 100644 --- a/spec/features/help_page_spec.rb +++ b/spec/features/help_page_spec.rb @@ -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 diff --git a/spec/features/home_spec.rb b/spec/features/home_spec.rb index 1d60684fd..08186c217 100644 --- a/spec/features/home_spec.rb +++ b/spec/features/home_spec.rb @@ -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") diff --git a/spec/features/legislation/draft_versions_spec.rb b/spec/features/legislation/draft_versions_spec.rb index 2336aef04..fccdc3900 100644 --- a/spec/features/legislation/draft_versions_spec.rb +++ b/spec/features/legislation/draft_versions_spec.rb @@ -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}]) diff --git a/spec/features/legislation/processes_spec.rb b/spec/features/legislation/processes_spec.rb index e20e7eebc..fca4fdcaf 100644 --- a/spec/features/legislation/processes_spec.rb +++ b/spec/features/legislation/processes_spec.rb @@ -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) diff --git a/spec/features/legislation/proposals_spec.rb b/spec/features/legislation/proposals_spec.rb index ce2862981..c2d516c92 100644 --- a/spec/features/legislation/proposals_spec.rb +++ b/spec/features/legislation/proposals_spec.rb @@ -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 diff --git a/spec/features/legislation/questions_spec.rb b/spec/features/legislation/questions_spec.rb index d871d120b..8cb46a020 100644 --- a/spec/features/legislation/questions_spec.rb +++ b/spec/features/legislation/questions_spec.rb @@ -1,7 +1,7 @@ -require 'rails_helper' +require "rails_helper" -feature 'Legislation' do - context 'process debate page' do +feature "Legislation" do + context "process debate page" do before do @process = create(:legislation_process, debate_start_date: Date.current - 3.days, debate_end_date: Date.current + 2.days) create(:legislation_question, process: @process, title: "Question 1") @@ -9,7 +9,7 @@ feature 'Legislation' do create(:legislation_question, process: @process, title: "Question 3") end - scenario 'shows question list' do + scenario "shows question list" do visit legislation_process_path(@process) expect(page).to have_content("Participate in the debate") @@ -34,14 +34,14 @@ feature 'Legislation' do expect(page).not_to have_content("Next question") end - scenario 'shows question page' do + scenario "shows question page" do visit legislation_process_question_path(@process, @process.questions.first) expect(page).to have_content("Question 1") expect(page).to have_content("Open answers (0)") end - scenario 'shows next question link in question page' do + scenario "shows next question link in question page" do visit legislation_process_question_path(@process, @process.questions.first) expect(page).to have_content("Question 1") @@ -58,7 +58,7 @@ feature 'Legislation' do expect(page).not_to have_content("Next question") end - scenario 'answer question' do + scenario "answer question" do question = @process.questions.first create(:legislation_question_option, question: question, value: "Yes") create(:legislation_question_option, question: question, value: "No") @@ -88,7 +88,7 @@ feature 'Legislation' do expect(option.reload.answers_count).to eq(1) end - scenario 'cannot answer question when phase not open' do + scenario "cannot answer question when phase not open" do @process.update_attribute(:debate_end_date, Date.current - 1.day) question = @process.questions.first create(:legislation_question_option, question: question, value: "Yes") diff --git a/spec/features/localization_spec.rb b/spec/features/localization_spec.rb index 756af38cd..7094b0394 100644 --- a/spec/features/localization_spec.rb +++ b/spec/features/localization_spec.rb @@ -1,44 +1,44 @@ -require 'rails_helper' +require "rails_helper" -feature 'Localization' do +feature "Localization" do - scenario 'Wrong locale' do + scenario "Wrong locale" do Globalize.with_locale(:es) do - create(:widget_card, title: 'Bienvenido a CONSUL', - description: 'Software libre para la participación ciudadana.', - link_text: 'Más información', - link_url: 'http://consulproject.org/', + create(:widget_card, title: "Bienvenido a CONSUL", + description: "Software libre para la participación ciudadana.", + link_text: "Más información", + link_url: "http://consulproject.org/", header: true) end visit root_path(locale: :es) visit root_path(locale: :klingon) - expect(page).to have_text('Bienvenido a CONSUL') + expect(page).to have_text("Bienvenido a CONSUL") end - scenario 'Available locales appear in the locale switcher' do - visit '/' + scenario "Available locales appear in the locale switcher" do + visit "/" - within('.locale-form .js-location-changer') do - expect(page).to have_content 'Español' - expect(page).to have_content 'English' + within(".locale-form .js-location-changer") do + expect(page).to have_content "Español" + expect(page).to have_content "English" end end - scenario 'The current locale is selected' do - visit '/' - expect(page).to have_select('locale-switcher', selected: 'English') + scenario "The current locale is selected" do + visit "/" + expect(page).to have_select("locale-switcher", selected: "English") end - scenario 'Changing the locale', :js do - visit '/' - expect(page).to have_content('Language') + scenario "Changing the locale", :js do + visit "/" + expect(page).to have_content("Language") - select('Español', from: 'locale-switcher') - expect(page).to have_content('Idioma') - expect(page).not_to have_content('Language') - expect(page).to have_select('locale-switcher', selected: 'Español') + select("Español", from: "locale-switcher") + expect(page).to have_content("Idioma") + expect(page).not_to have_content("Language") + expect(page).to have_select("locale-switcher", selected: "Español") end context "Only one locale" do @@ -50,9 +50,9 @@ feature 'Localization' do after { I18n.reload! } scenario "Locale switcher not present" do - visit '/' - expect(page).not_to have_content('Language') - expect(page).not_to have_css('div.locale') + visit "/" + expect(page).not_to have_content("Language") + expect(page).not_to have_css("div.locale") end end @@ -73,11 +73,11 @@ feature 'Localization' do I18n.locale = I18n.default_locale end - scenario 'Available locales without language translation display locale key' do - visit '/' + scenario "Available locales without language translation display locale key" do + visit "/" - within('.locale-form .js-location-changer') do - expect(page).to have_content 'wl' + within(".locale-form .js-location-changer") do + expect(page).to have_content "wl" end end diff --git a/spec/features/management/account_spec.rb b/spec/features/management/account_spec.rb index 50e8e9ae4..9e65781d5 100644 --- a/spec/features/management/account_spec.rb +++ b/spec/features/management/account_spec.rb @@ -1,6 +1,6 @@ -require 'rails_helper' +require "rails_helper" -feature 'Account' do +feature "Account" do background do login_as_manager @@ -12,12 +12,12 @@ feature 'Account' do visit management_root_path - click_link 'Reset password via email' + click_link "Reset password via email" expect(page).to have_content "No verified user logged in yet" end - scenario 'Delete a user account', :js do + scenario "Delete a user account", :js do user = create(:user, :level_two) login_managed_user(user) @@ -36,15 +36,15 @@ feature 'Account' do login_managed_user(user) visit management_root_path - click_link 'Reset password via email' + click_link "Reset password via email" - click_link 'Send reset password email' + click_link "Send reset password email" - expect(page).to have_content 'Email correctly sent.' + expect(page).to have_content "Email correctly sent." email = ActionMailer::Base.deliveries.last - expect(email).to have_text 'Change your password' + expect(email).to have_text "Change your password" end scenario "Manager changes the password by hand (writen by them)" do @@ -52,19 +52,19 @@ feature 'Account' do login_managed_user(user) visit management_root_path - click_link 'Reset password manually' + click_link "Reset password manually" find(:css, "input[id$='user_password']").set("new_password") - click_button 'Save password' + click_button "Save password" - expect(page).to have_content 'Password reseted successfully' + expect(page).to have_content "Password reseted successfully" logout - login_through_form_with_email_and_password(user.email, 'new_password') + login_through_form_with_email_and_password(user.email, "new_password") - expect(page).to have_content 'You have been signed in successfully.' + expect(page).to have_content "You have been signed in successfully." end scenario "Manager generates random password", :js do @@ -72,20 +72,20 @@ feature 'Account' do login_managed_user(user) visit management_root_path - click_link 'Reset password manually' - click_link 'Generate random password' + click_link "Reset password manually" + click_link "Generate random password" - new_password = find_field('user_password').value + new_password = find_field("user_password").value - click_button 'Save password' + click_button "Save password" - expect(page).to have_content 'Password reseted successfully' + expect(page).to have_content "Password reseted successfully" logout login_through_form_with_email_and_password(user.username, new_password) - expect(page).to have_content 'You have been signed in successfully.' + expect(page).to have_content "You have been signed in successfully." end scenario "The password is printed", :js do @@ -93,15 +93,15 @@ feature 'Account' do login_managed_user(user) visit management_root_path - click_link 'Reset password manually' + click_link "Reset password manually" find(:css, "input[id$='user_password']").set("another_new_password") - click_button 'Save password' + click_button "Save password" - expect(page).to have_content 'Password reseted successfully' - expect(page).to have_css("a[href='javascript:window.print();']", text: 'Print password') - expect(page).to have_css("div.for-print-only", text: 'another_new_password', visible: false) + expect(page).to have_content "Password reseted successfully" + expect(page).to have_css("a[href='javascript:window.print();']", text: "Print password") + expect(page).to have_css("div.for-print-only", text: "another_new_password", visible: false) end end diff --git a/spec/features/management/document_verifications_spec.rb b/spec/features/management/document_verifications_spec.rb index f9e2c20cc..b02cbfbfc 100644 --- a/spec/features/management/document_verifications_spec.rb +++ b/spec/features/management/document_verifications_spec.rb @@ -1,75 +1,75 @@ -require 'rails_helper' +require "rails_helper" -feature 'DocumentVerifications' do +feature "DocumentVerifications" do background do login_as_manager end - scenario 'Verifying a level 3 user shows an "already verified" page' do + scenario "Verifying a level 3 user shows an 'already verified' page" do user = create(:user, :level_three) visit management_document_verifications_path - fill_in 'document_verification_document_number', with: user.document_number - click_button 'Check document' + fill_in "document_verification_document_number", with: user.document_number + click_button "Check document" expect(page).to have_content "already verified" end - scenario 'Verifying a level 2 user displays the verification form' do + scenario "Verifying a level 2 user displays the verification form" do user = create(:user, :level_two) visit management_document_verifications_path - fill_in 'document_verification_document_number', with: user.document_number - click_button 'Check document' + fill_in "document_verification_document_number", with: user.document_number + click_button "Check document" expect(page).to have_content "Vote proposals" - click_button 'Verify' + click_button "Verify" expect(page).to have_content "already verified" expect(user.reload).to be_level_three_verified end - scenario 'Verifying a user which does not exist and is not in the census shows an error' do + scenario "Verifying a user which does not exist and is not in the census shows an error" do expect_any_instance_of(Verification::Management::Document).to receive(:in_census?).and_return(false) visit management_document_verifications_path - fill_in 'document_verification_document_number', with: "inexisting" - click_button 'Check document' + fill_in "document_verification_document_number", with: "inexisting" + click_button "Check document" expect(page).to have_content "This document is not registered" end - scenario 'Verifying a user which does exists in the census but not in the db redirects allows sending an email' do + scenario "Verifying a user which does exists in the census but not in the db redirects allows sending an email" do visit management_document_verifications_path - fill_in 'document_verification_document_number', with: '12345678Z' - click_button 'Check document' + fill_in "document_verification_document_number", with: "12345678Z" + click_button "Check document" expect(page).to have_content "Please introduce the email used on the account" end - scenario 'Document number is format-standarized' do + scenario "Document number is format-standarized" do visit management_document_verifications_path - fill_in 'document_verification_document_number', with: '12345 - h' - click_button 'Check document' + fill_in "document_verification_document_number", with: "12345 - h" + click_button "Check document" expect(page).to have_content "Document number: 12345H" end - scenario 'User age is checked' do + scenario "User age is checked" do expect_any_instance_of(Verification::Management::Document).to receive(:under_age?).and_return(true) visit management_document_verifications_path - fill_in 'document_verification_document_number', with: '12345678Z' - click_button 'Check document' + fill_in "document_verification_document_number", with: "12345678Z" + click_button "Check document" expect(page).to have_content "You don't have the required age to verify your account." end -end \ No newline at end of file +end diff --git a/spec/features/management/email_verifications_spec.rb b/spec/features/management/email_verifications_spec.rb index 56997f140..79f86bfc0 100644 --- a/spec/features/management/email_verifications_spec.rb +++ b/spec/features/management/email_verifications_spec.rb @@ -1,20 +1,20 @@ -require 'rails_helper' +require "rails_helper" -feature 'EmailVerifications' do +feature "EmailVerifications" do - scenario 'Verifying a level 1 user via email' do + scenario "Verifying a level 1 user via email" do login_as_manager user = create(:user) visit management_document_verifications_path - fill_in 'document_verification_document_number', with: '12345678Z' - click_button 'Check document' + fill_in "document_verification_document_number", with: "12345678Z" + click_button "Check document" expect(page).to have_content "Please introduce the email used on the account" - fill_in 'email_verification_email', with: user.email - click_button 'Send verification email' + fill_in "email_verification_email", with: user.email + click_button "Send verification email" expect(page).to have_content("In order to completely verify this user, it is necessary that the user clicks on a link") @@ -30,7 +30,7 @@ feature 'EmailVerifications' do expect(page).not_to have_link "Verify my account" expect(page).to have_content "Account verified" - expect(user.reload.document_number).to eq('12345678Z') + expect(user.reload.document_number).to eq("12345678Z") expect(user).to be_level_three_verified end diff --git a/spec/features/management/localization_spec.rb b/spec/features/management/localization_spec.rb index dacff366e..d55a67168 100644 --- a/spec/features/management/localization_spec.rb +++ b/spec/features/management/localization_spec.rb @@ -1,48 +1,48 @@ -require 'rails_helper' +require "rails_helper" -feature 'Localization' do +feature "Localization" do background do login_as_manager end - scenario 'Wrong locale' do + scenario "Wrong locale" do visit management_root_path(locale: :es) visit management_root_path(locale: :klingon) - expect(page).to have_text('Gestión') + expect(page).to have_text("Gestión") end - scenario 'Available locales appear in the locale switcher' do + scenario "Available locales appear in the locale switcher" do visit management_root_path - within('.locale-form .js-location-changer') do - expect(page).to have_content 'Español' - expect(page).to have_content 'English' + within(".locale-form .js-location-changer") do + expect(page).to have_content "Español" + expect(page).to have_content "English" end end - scenario 'The current locale is selected' do + scenario "The current locale is selected" do visit management_root_path - expect(page).to have_select('locale-switcher', selected: 'English') - expect(page).to have_text('Management') + expect(page).to have_select("locale-switcher", selected: "English") + expect(page).to have_text("Management") end - scenario 'Changing the locale', :js do + scenario "Changing the locale", :js do visit management_root_path - expect(page).to have_content('Language') + expect(page).to have_content("Language") - select('Español', from: 'locale-switcher') - expect(page).to have_content('Idioma') - expect(page).not_to have_content('Language') - expect(page).to have_select('locale-switcher', selected: 'Español') + select("Español", from: "locale-switcher") + expect(page).to have_content("Idioma") + expect(page).not_to have_content("Language") + expect(page).to have_select("locale-switcher", selected: "Español") end - scenario 'Locale switcher not present if only one locale' do + scenario "Locale switcher not present if only one locale" do allow(I18n).to receive(:available_locales).and_return([:en]) visit management_root_path - expect(page).not_to have_content('Language') - expect(page).not_to have_css('div.locale') + expect(page).not_to have_content("Language") + expect(page).not_to have_css("div.locale") end end diff --git a/spec/features/management/managed_users_spec.rb b/spec/features/management/managed_users_spec.rb index dfd638b6c..360c28caa 100644 --- a/spec/features/management/managed_users_spec.rb +++ b/spec/features/management/managed_users_spec.rb @@ -1,6 +1,6 @@ -require 'rails_helper' +require "rails_helper" -feature 'Managed User' do +feature "Managed User" do background do login_as_manager @@ -17,8 +17,8 @@ feature 'Managed User' do user = create(:user, :level_three) visit management_document_verifications_path - fill_in 'document_verification_document_number', with: user.document_number - click_button 'Check document' + fill_in "document_verification_document_number", with: user.document_number + click_button "Check document" expect(page).to have_content "already verified" @@ -34,12 +34,12 @@ feature 'Managed User' do user = create(:user, :level_two) visit management_document_verifications_path - fill_in 'document_verification_document_number', with: user.document_number - click_button 'Check document' + fill_in "document_verification_document_number", with: user.document_number + click_button "Check document" expect(page).to have_content "Vote proposals" - click_button 'Verify' + click_button "Verify" expect(page).to have_content "already verified" @@ -57,8 +57,8 @@ feature 'Managed User' do user = create(:user) visit management_document_verifications_path - fill_in 'document_verification_document_number', with: '12345678Z' - click_button 'Check document' + fill_in "document_verification_document_number", with: "12345678Z" + click_button "Check document" within(".account-info") do expect(page).not_to have_content "Identified as" @@ -71,8 +71,8 @@ feature 'Managed User' do expect(page).to have_content "Please introduce the email used on the account" - fill_in 'email_verification_email', with: user.email - click_button 'Send verification email' + fill_in "email_verification_email", with: user.email + click_button "Send verification email" expect(page).to have_content("In order to completely verify this user, it is necessary that the user clicks on a link") @@ -88,17 +88,17 @@ feature 'Managed User' do login_as_manager visit management_document_verifications_path - fill_in 'document_verification_document_number', with: '12345678Z' - click_button 'Check document' + fill_in "document_verification_document_number", with: "12345678Z" + click_button "Check document" expect(page).to have_content "Please introduce the email used on the account" - click_link 'Create a new account' + click_link "Create a new account" - fill_in 'user_username', with: 'pepe' - fill_in 'user_email', with: 'pepe@gmail.com' + fill_in "user_username", with: "pepe" + fill_in "user_email", with: "pepe@gmail.com" - click_button 'Create user' + click_button "Create user" expect(page).to have_content "We have sent an email" expect(page).not_to have_content "Autogenerated password is" @@ -116,17 +116,17 @@ feature 'Managed User' do login_as_manager visit management_document_verifications_path - fill_in 'document_verification_document_number', with: '12345678Z' - click_button 'Check document' + fill_in "document_verification_document_number", with: "12345678Z" + click_button "Check document" expect(page).to have_content "Please introduce the email used on the account" - click_link 'Create a new account' + click_link "Create a new account" - fill_in 'user_username', with: 'peppa' - fill_in 'user_email', with: '' + fill_in "user_username", with: "peppa" + fill_in "user_email", with: "" - click_button 'Create user' + click_button "Create user" expect(page).not_to have_content "We have sent an email" expect(page).to have_content "Autogenerated password is" @@ -144,8 +144,8 @@ feature 'Managed User' do user = create(:user, :level_three) visit management_document_verifications_path - fill_in 'document_verification_document_number', with: user.document_number - click_button 'Check document' + fill_in "document_verification_document_number", with: user.document_number + click_button "Check document" expect(page).to have_content "already verified" diff --git a/spec/features/management/proposals_spec.rb b/spec/features/management/proposals_spec.rb index ca33e3399..03519d02d 100644 --- a/spec/features/management/proposals_spec.rb +++ b/spec/features/management/proposals_spec.rb @@ -1,6 +1,6 @@ -require 'rails_helper' +require "rails_helper" -feature 'Proposals' do +feature "Proposals" do background do login_as_manager @@ -8,7 +8,7 @@ feature 'Proposals' do context "Create" do - scenario 'Creating proposals on behalf of someone' do + scenario "Creating proposals on behalf of someone" do user = create(:user, :level_two) login_managed_user(user) @@ -21,24 +21,24 @@ feature 'Proposals' do expect(page).to have_content user.document_number.to_s end - fill_in 'proposal_title', with: 'Help refugees' - fill_in 'proposal_question', with: '¿Would you like to give assistance to war refugees?' - fill_in 'proposal_summary', with: 'In summary, what we want is...' - fill_in 'proposal_description', with: 'This is very important because...' - fill_in 'proposal_external_url', with: 'http://rescue.org/refugees' - fill_in 'proposal_video_url', with: 'https://www.youtube.com/watch?v=yRYFKcMa_Ek' - check 'proposal_terms_of_service' + fill_in "proposal_title", with: "Help refugees" + fill_in "proposal_question", with: "¿Would you like to give assistance to war refugees?" + fill_in "proposal_summary", with: "In summary, what we want is..." + fill_in "proposal_description", with: "This is very important because..." + fill_in "proposal_external_url", with: "http://rescue.org/refugees" + fill_in "proposal_video_url", with: "https://www.youtube.com/watch?v=yRYFKcMa_Ek" + check "proposal_terms_of_service" - click_button 'Create proposal' + click_button "Create proposal" - expect(page).to have_content 'Proposal created successfully.' + expect(page).to have_content "Proposal created successfully." - expect(page).to have_content 'Help refugees' - expect(page).to have_content '¿Would you like to give assistance to war refugees?' - expect(page).to have_content 'In summary, what we want is...' - expect(page).to have_content 'This is very important because...' - expect(page).to have_content 'http://rescue.org/refugees' - expect(page).to have_content 'https://www.youtube.com/watch?v=yRYFKcMa_Ek' + expect(page).to have_content "Help refugees" + expect(page).to have_content "¿Would you like to give assistance to war refugees?" + expect(page).to have_content "In summary, what we want is..." + expect(page).to have_content "This is very important because..." + expect(page).to have_content "http://rescue.org/refugees" + expect(page).to have_content "https://www.youtube.com/watch?v=yRYFKcMa_Ek" expect(page).to have_content user.name expect(page).to have_content I18n.l(Proposal.last.created_at.to_date) @@ -56,7 +56,7 @@ feature 'Proposals' do end context "Show" do - scenario 'When path matches the friendly url' do + scenario "When path matches the friendly url" do proposal = create(:proposal) user = create(:user, :level_two) @@ -68,7 +68,7 @@ feature 'Proposals' 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 proposal = create(:proposal) user = create(:user, :level_two) @@ -98,7 +98,7 @@ feature 'Proposals' do expect(page).to have_current_path(management_proposals_path, ignore_query: true) within(".proposals-list") do - expect(page).to have_css('.proposal', count: 1) + expect(page).to have_css(".proposal", count: 1) expect(page).to have_content(proposal1.title) expect(page).to have_content(proposal1.summary) expect(page).not_to have_content(proposal2.title) @@ -125,7 +125,7 @@ feature 'Proposals' do end within(".proposals-list") do - expect(page).to have_css('.proposal', count: 2) + expect(page).to have_css(".proposal", count: 2) expect(page).to have_css("a[href='#{management_proposal_path(proposal1)}']", text: proposal1.title) expect(page).to have_content(proposal1.summary) expect(page).to have_css("a[href='#{management_proposal_path(proposal2)}']", text: proposal2.title) @@ -137,14 +137,14 @@ feature 'Proposals' do let!(:proposal) { create(:proposal) } - scenario 'Voting proposals on behalf of someone in index view', :js do + scenario "Voting proposals on behalf of someone in index view", :js do user = create(:user, :level_two) login_managed_user(user) click_link "Support proposals" within(".proposals-list") do - click_link('Support') + click_link("Support") expect(page).to have_content "1 support" expect(page).to have_content "You have already supported this proposal. Share it!" end @@ -152,7 +152,7 @@ feature 'Proposals' do expect(page).to have_current_path(management_proposals_path) end - scenario 'Voting proposals on behalf of someone in show view', :js do + scenario "Voting proposals on behalf of someone in show view", :js do user = create(:user, :level_two) login_managed_user(user) @@ -160,7 +160,7 @@ feature 'Proposals' do within(".proposals-list") { click_link proposal.title } expect(page).to have_content proposal.code - within("#proposal_#{proposal.id}_votes") { click_link('Support') } + within("#proposal_#{proposal.id}_votes") { click_link("Support") } expect(page).to have_content "1 support" expect(page).to have_content "You have already supported this proposal. Share it!" @@ -179,21 +179,21 @@ feature 'Proposals' do context "Printing" do - scenario 'Printing proposals' do + scenario "Printing proposals" do 6.times { create(:proposal) } click_link "Print proposals" - expect(page).to have_css('.proposal', count: 5) - expect(page).to have_css("a[href='javascript:window.print();']", text: 'Print') + expect(page).to have_css(".proposal", count: 5) + expect(page).to have_css("a[href='javascript:window.print();']", text: "Print") end scenario "Filtering proposals to be printed", :js do - worst_proposal = create(:proposal, title: 'Worst proposal') + worst_proposal = create(:proposal, title: "Worst proposal") worst_proposal.update_column(:confidence_score, 2) - best_proposal = create(:proposal, title: 'Best proposal') + best_proposal = create(:proposal, title: "Best proposal") best_proposal.update_column(:confidence_score, 10) - medium_proposal = create(:proposal, title: 'Medium proposal') + medium_proposal = create(:proposal, title: "Medium proposal") medium_proposal.update_column(:confidence_score, 5) user = create(:user, :level_two) @@ -201,19 +201,19 @@ feature 'Proposals' do click_link "Print proposals" - expect(page).to have_selector('.js-order-selector[data-order="confidence_score"]') + expect(page).to have_selector(".js-order-selector[data-order='confidence_score']") within(".proposals-list") do expect(best_proposal.title).to appear_before(medium_proposal.title) expect(medium_proposal.title).to appear_before(worst_proposal.title) end - select 'newest', from: 'order-selector' + select "newest", from: "order-selector" - expect(page).to have_selector('.js-order-selector[data-order="created_at"]') + expect(page).to have_selector(".js-order-selector[data-order='created_at']") - 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") within(".proposals-list") do expect(medium_proposal.title).to appear_before(best_proposal.title) diff --git a/spec/features/management/users_spec.rb b/spec/features/management/users_spec.rb index 5cba5411c..38891eb14 100644 --- a/spec/features/management/users_spec.rb +++ b/spec/features/management/users_spec.rb @@ -1,30 +1,30 @@ -require 'rails_helper' +require "rails_helper" -feature 'Users' do +feature "Users" do background do login_as_manager end - scenario 'Create a level 3 user with email from scratch' do + scenario "Create a level 3 user with email from scratch" do visit management_document_verifications_path - fill_in 'document_verification_document_number', with: '12345678Z' - click_button 'Check document' + fill_in "document_verification_document_number", with: "12345678Z" + click_button "Check document" expect(page).to have_content "Please introduce the email used on the account" - click_link 'Create a new account' + click_link "Create a new account" - fill_in 'user_username', with: 'pepe' - fill_in 'user_email', with: 'pepe@gmail.com' - select_date '31-December-1980', from: 'user_date_of_birth' + fill_in "user_username", with: "pepe" + fill_in "user_email", with: "pepe@gmail.com" + select_date "31-December-1980", from: "user_date_of_birth" - click_button 'Create user' + click_button "Create user" expect(page).to have_content "We have sent an email" expect(page).not_to have_content "Autogenerated password is" - user = User.find_by(email: 'pepe@gmail.com') + user = User.find_by(email: "pepe@gmail.com") expect(user).to be_level_three_verified expect(user).to be_residence_verified @@ -36,35 +36,35 @@ feature 'Users' do expect(page).to have_content "Confirming the account with email" - fill_in 'user_password', with: '12345678' - fill_in 'user_password_confirmation', with: '12345678' + fill_in "user_password", with: "12345678" + fill_in "user_password_confirmation", with: "12345678" - click_button 'Confirm' + click_button "Confirm" expect(user.reload).to be_confirmed expect(page).to have_content "Your account has been confirmed." end - scenario 'Create a level 3 user without email from scratch' do + scenario "Create a level 3 user without email from scratch" do visit management_document_verifications_path - fill_in 'document_verification_document_number', with: '12345678Z' - click_button 'Check document' + fill_in "document_verification_document_number", with: "12345678Z" + click_button "Check document" expect(page).to have_content "Please introduce the email used on the account" - click_link 'Create a new account' + click_link "Create a new account" - fill_in 'user_username', with: 'Kelly Sue' - fill_in 'user_email', with: '' - select_date '31-December-1980', from: 'user_date_of_birth' + fill_in "user_username", with: "Kelly Sue" + fill_in "user_email", with: "" + select_date "31-December-1980", from: "user_date_of_birth" - click_button 'Create user' + click_button "Create user" expect(page).not_to have_content "We have sent an email" expect(page).to have_content "Autogenerated password is" - user = User.find_by(username: 'Kelly Sue') + user = User.find_by(username: "Kelly Sue") expect(user).to be_level_three_verified expect(user).to be_residence_verified @@ -72,12 +72,12 @@ feature 'Users' do expect(user.date_of_birth).to have_content Date.new(1980, 12, 31) end - scenario 'Delete a level 2 user account from document verification page', :js do + scenario "Delete a level 2 user account from document verification page", :js do level_2_user = create(:user, :level_two, document_number: "12345678Z") visit management_document_verifications_path - fill_in 'document_verification_document_number', with: '12345678Z' - click_button 'Check document' + fill_in "document_verification_document_number", with: "12345678Z" + click_button "Check document" expect(page).not_to have_content "This user account is already verified." expect(page).to have_content "This user can participate in the website with the following permissions" @@ -90,8 +90,8 @@ feature 'Users' do expect(level_2_user.reload.erase_reason).to eq "Deleted by manager: manager_user_#{Manager.last.user_id}" visit management_document_verifications_path - fill_in 'document_verification_document_number', with: '12345678Z' - click_button 'Check document' + fill_in "document_verification_document_number", with: "12345678Z" + click_button "Check document" expect(page).to have_content "no user account associated to it" end diff --git a/spec/features/management_spec.rb b/spec/features/management_spec.rb index eb3630c5a..8fd95dcba 100644 --- a/spec/features/management_spec.rb +++ b/spec/features/management_spec.rb @@ -1,6 +1,6 @@ -require 'rails_helper' +require "rails_helper" -feature 'Management' do +feature "Management" do let(:user) { create(:user) } scenario "Should show admin menu if logged user is admin" do diff --git a/spec/features/moderation/budget_investments_spec.rb b/spec/features/moderation/budget_investments_spec.rb index 7cb4f5020..83191120e 100644 --- a/spec/features/moderation/budget_investments_spec.rb +++ b/spec/features/moderation/budget_investments_spec.rb @@ -1,32 +1,32 @@ -require 'rails_helper' +require "rails_helper" -feature 'Moderate budget investments' do +feature "Moderate budget investments" do let(:budget) { create(:budget) } - let(:group) { create(:budget_group, name: 'Culture', budget: budget) } - let(:heading) { create(:budget_heading, name: 'More libraries', price: 666666, group: group) } + let(:group) { create(:budget_group, name: "Culture", budget: budget) } + let(:heading) { create(:budget_heading, name: "More libraries", price: 666666, group: group) } background do @mod = create(:moderator) @investment = create(:budget_investment, heading: heading, author: create(:user)) end - scenario 'Disabled with a feature flag' do - Setting['feature.budgets'] = nil + scenario "Disabled with a feature flag" do + Setting["feature.budgets"] = nil login_as(@mod.user) expect{ visit moderation_budget_investments_path }.to raise_exception(FeatureFlags::FeatureDisabled) - Setting['feature.budgets'] = true + Setting["feature.budgets"] = true end - scenario 'Hiding an investment', :js do + scenario "Hiding an investment", :js do login_as(@mod.user) visit budget_investment_path(budget, @investment) - accept_confirm { click_link 'Hide' } + accept_confirm { click_link "Hide" } - expect(page).to have_css('.faded', count: 2) + expect(page).to have_css(".faded", count: 2) visit budget_investments_path(budget.id, heading_id: heading.id) @@ -37,7 +37,7 @@ feature 'Moderate budget investments' do login_as(@mod.user) visit budget_investment_path(budget, @investment) - accept_confirm { click_link 'Hide author' } + accept_confirm { click_link "Hide author" } expect(page).to have_current_path(debates_path) @@ -46,32 +46,32 @@ feature 'Moderate budget investments' do expect(page).not_to have_content(@investment.title) end - scenario 'Can not hide own investment' do + scenario "Can not hide own investment" do @investment.update(author: @mod.user) login_as(@mod.user) visit budget_investment_path(budget, @investment) within "#budget_investment_#{@investment.id}" do - expect(page).not_to have_link('Hide') - expect(page).not_to have_link('Hide author') + expect(page).not_to have_link("Hide") + expect(page).not_to have_link("Hide author") end end - feature '/moderation/ screen' do + feature "/moderation/ screen" do background do login_as(@mod.user) end - feature 'moderate in bulk' do - feature 'When an investment has been selected for moderation' do + feature "moderate in bulk" do + feature "When an investment has been selected for moderation" do background do visit moderation_budget_investments_path - within('.menu.simple') do - click_link 'All' + within(".menu.simple") do + click_link "All" end within("#investment_#{@investment.id}") do @@ -81,8 +81,8 @@ feature 'Moderate budget investments' do expect(page).not_to have_css("investment#{@investment.id}") end - scenario 'Hide the investment' do - click_button 'Hide budget investments' + scenario "Hide the investment" do + click_button "Hide budget investments" expect(page).not_to have_css("investment_#{@investment.id}") @investment.reload @@ -90,8 +90,8 @@ feature 'Moderate budget investments' do expect(@investment.author).not_to be_hidden end - scenario 'Block the author' do - click_button 'Block authors' + scenario "Block the author" do + click_button "Block authors" expect(page).not_to have_css("investment_#{@investment.id}") @investment.reload @@ -99,8 +99,8 @@ feature 'Moderate budget investments' do expect(@investment.author).to be_hidden end - scenario 'Ignore the investment' do - click_button 'Mark as viewed' + scenario "Ignore the investment" do + click_button "Mark as viewed" expect(page).not_to have_css("investment_#{@investment.id}") @investment.reload @@ -111,132 +111,132 @@ feature 'Moderate budget investments' do end end - scenario 'select all/none', :js do + scenario "select all/none", :js do create_list(:budget_investment, 2, heading: heading, author: create(:user)) visit moderation_budget_investments_path - within('.js-check') { click_on 'All' } + within(".js-check") { click_on "All" } - expect(all('input[type=checkbox]')).to all(be_checked) + expect(all("input[type=checkbox]")).to all(be_checked) - within('.js-check') { click_on 'None' } + within(".js-check") { click_on "None" } - all('input[type=checkbox]').each do |checkbox| + all("input[type=checkbox]").each do |checkbox| expect(checkbox).not_to be_checked end end - scenario 'remembering page, filter and order' do + scenario "remembering page, filter and order" do create_list(:budget_investment, 52, heading: heading, author: create(:user)) - visit moderation_budget_investments_path(filter: 'all', page: '2', order: 'created_at') + visit moderation_budget_investments_path(filter: "all", page: "2", order: "created_at") - click_button 'Mark as viewed' + click_button "Mark as viewed" - expect(page).to have_selector('.js-order-selector[data-order="created_at"]') + expect(page).to have_selector(".js-order-selector[data-order='created_at']") - expect(current_url).to include('filter=all') - expect(current_url).to include('page=2') - expect(current_url).to include('order=created_at') + expect(current_url).to include("filter=all") + expect(current_url).to include("page=2") + expect(current_url).to include("order=created_at") end end - scenario 'Current filter is properly highlighted' do + scenario "Current filter is properly highlighted" do visit moderation_budget_investments_path - expect(page).not_to have_link('Pending') - expect(page).to have_link('All') - expect(page).to have_link('Marked as viewed') + expect(page).not_to have_link("Pending") + expect(page).to have_link("All") + expect(page).to have_link("Marked as viewed") - visit moderation_budget_investments_path(filter: 'all') + visit moderation_budget_investments_path(filter: "all") - within('.menu.simple') do - expect(page).not_to have_link('All') - expect(page).to have_link('Pending') - expect(page).to have_link('Marked as viewed') + within(".menu.simple") do + expect(page).not_to have_link("All") + expect(page).to have_link("Pending") + expect(page).to have_link("Marked as viewed") end - visit moderation_budget_investments_path(filter: 'pending_flag_review') + visit moderation_budget_investments_path(filter: "pending_flag_review") - within('.menu.simple') do - expect(page).to have_link('All') - expect(page).not_to have_link('Pending') - expect(page).to have_link('Marked as viewed') + within(".menu.simple") do + expect(page).to have_link("All") + expect(page).not_to have_link("Pending") + expect(page).to have_link("Marked as viewed") end - visit moderation_budget_investments_path(filter: 'with_ignored_flag') + visit moderation_budget_investments_path(filter: "with_ignored_flag") - within('.menu.simple') do - expect(page).to have_link('All') - expect(page).to have_link('Pending') - expect(page).not_to have_link('Marked as viewed') + within(".menu.simple") do + expect(page).to have_link("All") + expect(page).to have_link("Pending") + expect(page).not_to have_link("Marked as viewed") end end - scenario 'Filtering investments' do - create(:budget_investment, heading: heading, title: 'Books investment') - create(:budget_investment, :flagged, heading: heading, title: 'Non-selected investment') - create(:budget_investment, :hidden, heading: heading, title: 'Hidden investment') - create(:budget_investment, :flagged, :with_ignored_flag, heading: heading, title: 'Ignored investment') + scenario "Filtering investments" do + create(:budget_investment, heading: heading, title: "Books investment") + create(:budget_investment, :flagged, heading: heading, title: "Non-selected investment") + create(:budget_investment, :hidden, heading: heading, title: "Hidden investment") + create(:budget_investment, :flagged, :with_ignored_flag, heading: heading, title: "Ignored investment") - visit moderation_budget_investments_path(filter: 'all') + visit moderation_budget_investments_path(filter: "all") - expect(page).to have_content('Books investment') - expect(page).to have_content('Non-selected investment') - expect(page).not_to have_content('Hidden investment') - expect(page).to have_content('Ignored investment') + expect(page).to have_content("Books investment") + expect(page).to have_content("Non-selected investment") + expect(page).not_to have_content("Hidden investment") + expect(page).to have_content("Ignored investment") - visit moderation_budget_investments_path(filter: 'pending_flag_review') + visit moderation_budget_investments_path(filter: "pending_flag_review") - expect(page).not_to have_content('Books investment') - expect(page).to have_content('Non-selected investment') - expect(page).not_to have_content('Hidden investment') - expect(page).not_to have_content('Ignored investment') + expect(page).not_to have_content("Books investment") + expect(page).to have_content("Non-selected investment") + expect(page).not_to have_content("Hidden investment") + expect(page).not_to have_content("Ignored investment") - visit moderation_budget_investments_path(filter: 'with_ignored_flag') + visit moderation_budget_investments_path(filter: "with_ignored_flag") - expect(page).not_to have_content('Books investment') - expect(page).not_to have_content('Non-selected investment') - expect(page).not_to have_content('Hidden investment') - expect(page).to have_content('Ignored investment') + expect(page).not_to have_content("Books investment") + expect(page).not_to have_content("Non-selected investment") + expect(page).not_to have_content("Hidden investment") + expect(page).to have_content("Ignored investment") end - scenario 'sorting investments' do + scenario "sorting investments" do flagged_investment = create(:budget_investment, heading: heading, - title: 'Flagged investment', + title: "Flagged investment", created_at: Time.current - 1.day, flags_count: 5 ) flagged_new_investment = create(:budget_investment, heading: heading, - title: 'Flagged new investment', + title: "Flagged new investment", created_at: Time.current - 12.hours, flags_count: 3 ) latest_investment = create(:budget_investment, heading: heading, - title: 'Latest investment', + title: "Latest investment", created_at: Time.current ) - visit moderation_budget_investments_path(order: 'created_at') + visit moderation_budget_investments_path(order: "created_at") expect(flagged_new_investment.title).to appear_before(flagged_investment.title) - visit moderation_budget_investments_path(order: 'flags') + visit moderation_budget_investments_path(order: "flags") expect(flagged_investment.title).to appear_before(flagged_new_investment.title) - visit moderation_budget_investments_path(filter: 'all', order: 'created_at') + visit moderation_budget_investments_path(filter: "all", order: "created_at") expect(latest_investment.title).to appear_before(flagged_new_investment.title) expect(flagged_new_investment.title).to appear_before(flagged_investment.title) - visit moderation_budget_investments_path(filter: 'all', order: 'flags') + visit moderation_budget_investments_path(filter: "all", order: "flags") expect(flagged_investment.title).to appear_before(flagged_new_investment.title) expect(flagged_new_investment.title).to appear_before(latest_investment.title) diff --git a/spec/features/moderation/comments_spec.rb b/spec/features/moderation/comments_spec.rb index f939a611b..2a0c65b6d 100644 --- a/spec/features/moderation/comments_spec.rb +++ b/spec/features/moderation/comments_spec.rb @@ -1,8 +1,8 @@ -require 'rails_helper' +require "rails_helper" -feature 'Moderate comments' do +feature "Moderate comments" do - scenario 'Hide', :js do + scenario "Hide", :js do citizen = create(:user) moderator = create(:moderator) @@ -12,19 +12,19 @@ feature 'Moderate comments' do visit debate_path(comment.commentable) within("#comment_#{comment.id}") do - accept_confirm { click_link 'Hide' } - expect(page).to have_css('.comment .faded') + accept_confirm { click_link "Hide" } + expect(page).to have_css(".comment .faded") end login_as(citizen) visit debate_path(comment.commentable) - expect(page).to have_css('.comment', count: 1) - expect(page).not_to have_content('This comment has been deleted') - expect(page).not_to have_content('SPAM') + expect(page).to have_css(".comment", count: 1) + expect(page).not_to have_content("This comment has been deleted") + expect(page).not_to have_content("SPAM") end - scenario 'Can not hide own comment' do + scenario "Can not hide own comment" do moderator = create(:moderator) comment = create(:comment, user: moderator.user) @@ -32,8 +32,8 @@ feature 'Moderate comments' do visit debate_path(comment.commentable) within("#comment_#{comment.id}") do - expect(page).not_to have_link('Hide') - expect(page).not_to have_link('Block author') + expect(page).not_to have_link("Hide") + expect(page).not_to have_link("Block author") end end @@ -63,19 +63,19 @@ feature 'Moderate comments' do expect(page).to have_content("This is SPAM comment on proposal") end - feature '/moderation/ screen' do + feature "/moderation/ screen" do background do moderator = create(:moderator) login_as(moderator.user) end - feature 'moderate in bulk' do + feature "moderate in bulk" do feature "When a comment has been selected for moderation" do background do @comment = create(:comment) visit moderation_comments_path - within('.menu.simple') do + within(".menu.simple") do click_link "All" end @@ -86,21 +86,21 @@ feature 'Moderate comments' do expect(page).not_to have_css("comment_#{@comment.id}") end - scenario 'Hide the comment' do + scenario "Hide the comment" do click_on "Hide comments" expect(page).not_to have_css("comment_#{@comment.id}") expect(@comment.reload).to be_hidden expect(@comment.user).not_to be_hidden end - scenario 'Block the user' do + scenario "Block the user" do click_on "Block authors" expect(page).not_to have_css("comment_#{@comment.id}") expect(@comment.reload).to be_hidden expect(@comment.user).to be_hidden end - scenario 'Ignore the comment' do + scenario "Ignore the comment" do click_on "Mark as viewed" expect(page).not_to have_css("comment_#{@comment.id}") expect(@comment.reload).to be_ignored_flag @@ -114,13 +114,13 @@ feature 'Moderate comments' do visit moderation_comments_path - within('.js-check') { click_on 'All' } + within(".js-check") { click_on "All" } - expect(all('input[type=checkbox]')).to all(be_checked) + expect(all("input[type=checkbox]")).to all(be_checked) - within('.js-check') { click_on 'None' } + within(".js-check") { click_on "None" } - all('input[type=checkbox]').each do |checkbox| + all("input[type=checkbox]").each do |checkbox| expect(checkbox).not_to be_checked end end @@ -128,43 +128,43 @@ feature 'Moderate comments' do scenario "remembering page, filter and order" do create_list(:comment, 52) - visit moderation_comments_path(filter: 'all', page: '2', order: 'newest') + visit moderation_comments_path(filter: "all", page: "2", order: "newest") click_on "Mark as viewed" - expect(page).to have_selector('.js-order-selector[data-order="newest"]') + expect(page).to have_selector(".js-order-selector[data-order='newest']") - expect(current_url).to include('filter=all') - expect(current_url).to include('page=2') - expect(current_url).to include('order=newest') + expect(current_url).to include("filter=all") + expect(current_url).to include("page=2") + expect(current_url).to include("order=newest") end end scenario "Current filter is properly highlighted" do visit moderation_comments_path - expect(page).not_to have_link('Pending') - expect(page).to have_link('All') - expect(page).to have_link('Marked as viewed') + expect(page).not_to have_link("Pending") + expect(page).to have_link("All") + expect(page).to have_link("Marked as viewed") - visit moderation_comments_path(filter: 'all') - within('.menu.simple') do - expect(page).not_to have_link('All') - expect(page).to have_link('Pending') - expect(page).to have_link('Marked as viewed') + visit moderation_comments_path(filter: "all") + within(".menu.simple") do + expect(page).not_to have_link("All") + expect(page).to have_link("Pending") + expect(page).to have_link("Marked as viewed") end - visit moderation_comments_path(filter: 'pending_flag_review') - within('.menu.simple') do - expect(page).to have_link('All') - expect(page).not_to have_link('Pending') - expect(page).to have_link('Marked as viewed') + visit moderation_comments_path(filter: "pending_flag_review") + within(".menu.simple") do + expect(page).to have_link("All") + expect(page).not_to have_link("Pending") + expect(page).to have_link("Marked as viewed") end - visit moderation_comments_path(filter: 'with_ignored_flag') - within('.menu.simple') do - expect(page).to have_link('All') - expect(page).to have_link('Pending') - expect(page).not_to have_link('Marked as viewed') + visit moderation_comments_path(filter: "with_ignored_flag") + within(".menu.simple") do + expect(page).to have_link("All") + expect(page).to have_link("Pending") + expect(page).not_to have_link("Marked as viewed") end end @@ -174,23 +174,23 @@ feature 'Moderate comments' do create(:comment, :hidden, body: "Hidden comment") create(:comment, :flagged, :with_ignored_flag, body: "Ignored comment") - visit moderation_comments_path(filter: 'all') - expect(page).to have_content('Regular comment') - expect(page).to have_content('Pending comment') - expect(page).not_to have_content('Hidden comment') - expect(page).to have_content('Ignored comment') + visit moderation_comments_path(filter: "all") + expect(page).to have_content("Regular comment") + expect(page).to have_content("Pending comment") + expect(page).not_to have_content("Hidden comment") + expect(page).to have_content("Ignored comment") - visit moderation_comments_path(filter: 'pending_flag_review') - expect(page).not_to have_content('Regular comment') - expect(page).to have_content('Pending comment') - expect(page).not_to have_content('Hidden comment') - expect(page).not_to have_content('Ignored comment') + visit moderation_comments_path(filter: "pending_flag_review") + expect(page).not_to have_content("Regular comment") + expect(page).to have_content("Pending comment") + expect(page).not_to have_content("Hidden comment") + expect(page).not_to have_content("Ignored comment") - visit moderation_comments_path(filter: 'with_ignored_flag') - expect(page).not_to have_content('Regular comment') - expect(page).not_to have_content('Pending comment') - expect(page).not_to have_content('Hidden comment') - expect(page).to have_content('Ignored comment') + visit moderation_comments_path(filter: "with_ignored_flag") + expect(page).not_to have_content("Regular comment") + expect(page).not_to have_content("Pending comment") + expect(page).not_to have_content("Hidden comment") + expect(page).to have_content("Ignored comment") end scenario "sorting comments" do @@ -198,20 +198,20 @@ feature 'Moderate comments' do flagged_new_comment = create(:comment, body: "Flagged new comment", created_at: Time.current - 12.hours, flags_count: 3) newer_comment = create(:comment, body: "Newer comment", created_at: Time.current) - visit moderation_comments_path(order: 'newest') + visit moderation_comments_path(order: "newest") expect(flagged_new_comment.body).to appear_before(flagged_comment.body) - visit moderation_comments_path(order: 'flags') + visit moderation_comments_path(order: "flags") expect(flagged_comment.body).to appear_before(flagged_new_comment.body) - visit moderation_comments_path(filter: 'all', order: 'newest') + visit moderation_comments_path(filter: "all", order: "newest") expect(newer_comment.body).to appear_before(flagged_new_comment.body) expect(flagged_new_comment.body).to appear_before(flagged_comment.body) - visit moderation_comments_path(filter: 'all', order: 'flags') + visit moderation_comments_path(filter: "all", order: "flags") expect(flagged_comment.body).to appear_before(flagged_new_comment.body) expect(flagged_new_comment.body).to appear_before(newer_comment.body) diff --git a/spec/features/moderation/debates_spec.rb b/spec/features/moderation/debates_spec.rb index d37d41ce5..df55f5cd5 100644 --- a/spec/features/moderation/debates_spec.rb +++ b/spec/features/moderation/debates_spec.rb @@ -1,18 +1,18 @@ -require 'rails_helper' +require "rails_helper" -feature 'Moderate debates' do +feature "Moderate debates" do - scenario 'Disabled with a feature flag' do - Setting['feature.debates'] = nil + scenario "Disabled with a feature flag" do + Setting["feature.debates"] = nil moderator = create(:moderator) login_as(moderator.user) expect{ visit moderation_debates_path }.to raise_exception(FeatureFlags::FeatureDisabled) - Setting['feature.debates'] = true + Setting["feature.debates"] = true end - scenario 'Hide', :js do + scenario "Hide", :js do citizen = create(:user) moderator = create(:moderator) @@ -22,7 +22,7 @@ feature 'Moderate debates' do visit debate_path(debate) within("#debate_#{debate.id}") do - accept_confirm { click_link 'Hide' } + accept_confirm { click_link "Hide" } end expect(find("div#debate_#{debate.id}.faded")).to have_text debate.title @@ -30,10 +30,10 @@ feature 'Moderate debates' do login_as(citizen) visit debates_path - expect(page).to have_css('.debate', count: 0) + expect(page).to have_css(".debate", count: 0) end - scenario 'Can not hide own debate' do + scenario "Can not hide own debate" do moderator = create(:moderator) debate = create(:debate, author: moderator.user) @@ -41,24 +41,24 @@ feature 'Moderate debates' do visit debate_path(debate) within("#debate_#{debate.id}") do - expect(page).not_to have_link('Hide') - expect(page).not_to have_link('Block author') + expect(page).not_to have_link("Hide") + expect(page).not_to have_link("Block author") end end - feature '/moderation/ screen' do + feature "/moderation/ screen" do background do moderator = create(:moderator) login_as(moderator.user) end - feature 'moderate in bulk' do + feature "moderate in bulk" do feature "When a debate has been selected for moderation" do background do @debate = create(:debate) visit moderation_debates_path - within('.menu.simple') do + within(".menu.simple") do click_link "All" end @@ -69,21 +69,21 @@ feature 'Moderate debates' do expect(page).not_to have_css("debate_#{@debate.id}") end - scenario 'Hide the debate' do + scenario "Hide the debate" do click_on "Hide debates" expect(page).not_to have_css("debate_#{@debate.id}") expect(@debate.reload).to be_hidden expect(@debate.author).not_to be_hidden end - scenario 'Block the author' do + scenario "Block the author" do click_on "Block authors" expect(page).not_to have_css("debate_#{@debate.id}") expect(@debate.reload).to be_hidden expect(@debate.author).to be_hidden end - scenario 'Ignore the debate' do + scenario "Ignore the debate" do click_on "Mark as viewed" expect(page).not_to have_css("debate_#{@debate.id}") expect(@debate.reload).to be_ignored_flag @@ -97,13 +97,13 @@ feature 'Moderate debates' do visit moderation_debates_path - within('.js-check') { click_on 'All' } + within(".js-check") { click_on "All" } - expect(all('input[type=checkbox]')).to all(be_checked) + expect(all("input[type=checkbox]")).to all(be_checked) - within('.js-check') { click_on 'None' } + within(".js-check") { click_on "None" } - all('input[type=checkbox]').each do |checkbox| + all("input[type=checkbox]").each do |checkbox| expect(checkbox).not_to be_checked end end @@ -111,43 +111,43 @@ feature 'Moderate debates' do scenario "remembering page, filter and order" do create_list(:debate, 52) - visit moderation_debates_path(filter: 'all', page: '2', order: 'created_at') + visit moderation_debates_path(filter: "all", page: "2", order: "created_at") click_on "Mark as viewed" - expect(page).to have_selector('.js-order-selector[data-order="created_at"]') + expect(page).to have_selector(".js-order-selector[data-order='created_at']") - expect(current_url).to include('filter=all') - expect(current_url).to include('page=2') - expect(current_url).to include('order=created_at') + expect(current_url).to include("filter=all") + expect(current_url).to include("page=2") + expect(current_url).to include("order=created_at") end end scenario "Current filter is properly highlighted" do visit moderation_debates_path - expect(page).not_to have_link('Pending') - expect(page).to have_link('All') - expect(page).to have_link('Marked as viewed') + expect(page).not_to have_link("Pending") + expect(page).to have_link("All") + expect(page).to have_link("Marked as viewed") - visit moderation_debates_path(filter: 'all') - within('.menu.simple') do - expect(page).not_to have_link('All') - expect(page).to have_link('Pending') - expect(page).to have_link('Marked as viewed') + visit moderation_debates_path(filter: "all") + within(".menu.simple") do + expect(page).not_to have_link("All") + expect(page).to have_link("Pending") + expect(page).to have_link("Marked as viewed") end - visit moderation_debates_path(filter: 'pending_flag_review') - within('.menu.simple') do - expect(page).to have_link('All') - expect(page).not_to have_link('Pending') - expect(page).to have_link('Marked as viewed') + visit moderation_debates_path(filter: "pending_flag_review") + within(".menu.simple") do + expect(page).to have_link("All") + expect(page).not_to have_link("Pending") + expect(page).to have_link("Marked as viewed") end - visit moderation_debates_path(filter: 'with_ignored_flag') - within('.menu.simple') do - expect(page).to have_link('All') - expect(page).to have_link('Pending') - expect(page).not_to have_link('Marked as viewed') + visit moderation_debates_path(filter: "with_ignored_flag") + within(".menu.simple") do + expect(page).to have_link("All") + expect(page).to have_link("Pending") + expect(page).not_to have_link("Marked as viewed") end end @@ -157,23 +157,23 @@ feature 'Moderate debates' do create(:debate, :hidden, title: "Hidden debate") create(:debate, :flagged, :with_ignored_flag, title: "Ignored debate") - visit moderation_debates_path(filter: 'all') - expect(page).to have_content('Regular debate') - expect(page).to have_content('Pending debate') - expect(page).not_to have_content('Hidden debate') - expect(page).to have_content('Ignored debate') + visit moderation_debates_path(filter: "all") + expect(page).to have_content("Regular debate") + expect(page).to have_content("Pending debate") + expect(page).not_to have_content("Hidden debate") + expect(page).to have_content("Ignored debate") - visit moderation_debates_path(filter: 'pending_flag_review') - expect(page).not_to have_content('Regular debate') - expect(page).to have_content('Pending debate') - expect(page).not_to have_content('Hidden debate') - expect(page).not_to have_content('Ignored debate') + visit moderation_debates_path(filter: "pending_flag_review") + expect(page).not_to have_content("Regular debate") + expect(page).to have_content("Pending debate") + expect(page).not_to have_content("Hidden debate") + expect(page).not_to have_content("Ignored debate") - visit moderation_debates_path(filter: 'with_ignored_flag') - expect(page).not_to have_content('Regular debate') - expect(page).not_to have_content('Pending debate') - expect(page).not_to have_content('Hidden debate') - expect(page).to have_content('Ignored debate') + visit moderation_debates_path(filter: "with_ignored_flag") + expect(page).not_to have_content("Regular debate") + expect(page).not_to have_content("Pending debate") + expect(page).not_to have_content("Hidden debate") + expect(page).to have_content("Ignored debate") end scenario "sorting debates" do @@ -181,20 +181,20 @@ feature 'Moderate debates' do flagged_new_debate = create(:debate, title: "Flagged new debate", created_at: Time.current - 12.hours, flags_count: 3) newer_debate = create(:debate, title: "Newer debate", created_at: Time.current) - visit moderation_debates_path(order: 'created_at') + visit moderation_debates_path(order: "created_at") expect(flagged_new_debate.title).to appear_before(flagged_debate.title) - visit moderation_debates_path(order: 'flags') + visit moderation_debates_path(order: "flags") expect(flagged_debate.title).to appear_before(flagged_new_debate.title) - visit moderation_debates_path(filter: 'all', order: 'created_at') + visit moderation_debates_path(filter: "all", order: "created_at") expect(newer_debate.title).to appear_before(flagged_new_debate.title) expect(flagged_new_debate.title).to appear_before(flagged_debate.title) - visit moderation_debates_path(filter: 'all', order: 'flags') + visit moderation_debates_path(filter: "all", order: "flags") expect(flagged_debate.title).to appear_before(flagged_new_debate.title) expect(flagged_new_debate.title).to appear_before(newer_debate.title) diff --git a/spec/features/moderation/proposal_notifications_spec.rb b/spec/features/moderation/proposal_notifications_spec.rb index 396173190..c6d6252d7 100644 --- a/spec/features/moderation/proposal_notifications_spec.rb +++ b/spec/features/moderation/proposal_notifications_spec.rb @@ -1,8 +1,8 @@ -require 'rails_helper' +require "rails_helper" -feature 'Moderate proposal notifications' do +feature "Moderate proposal notifications" do - scenario 'Hide', :js do + scenario "Hide", :js do citizen = create(:user) proposal = create(:proposal) proposal_notification = create(:proposal_notification, proposal: proposal, created_at: Date.current - 4.days) @@ -13,7 +13,7 @@ feature 'Moderate proposal notifications' do click_link "Notifications (1)" within("#proposal_notification_#{proposal_notification.id}") do - accept_confirm { click_link 'Hide' } + accept_confirm { click_link "Hide" } end expect(page).to have_css("#proposal_notification_#{proposal_notification.id}.faded") @@ -25,7 +25,7 @@ feature 'Moderate proposal notifications' do expect(page).to have_content "Notifications (0)" end - scenario 'Can not hide own proposal notification' do + scenario "Can not hide own proposal notification" do moderator = create(:moderator) proposal = create(:proposal, author: moderator.user) proposal_notification = create(:proposal_notification, proposal: proposal, created_at: Date.current - 4.days) @@ -34,25 +34,25 @@ feature 'Moderate proposal notifications' do visit proposal_path(proposal) within("#proposal_notification_#{proposal_notification.id}") do - expect(page).not_to have_link('Hide') - expect(page).not_to have_link('Block author') + expect(page).not_to have_link("Hide") + expect(page).not_to have_link("Block author") end end - feature '/moderation/ screen' do + feature "/moderation/ screen" do background do moderator = create(:moderator) login_as(moderator.user) end - feature 'moderate in bulk' do + feature "moderate in bulk" do feature "When a proposal has been selected for moderation" do background do proposal = create(:proposal) @proposal_notification = create(:proposal_notification, proposal: proposal, created_at: Date.current - 4.days) visit moderation_proposal_notifications_path - within('.menu.simple') do + within(".menu.simple") do click_link "All" end @@ -61,14 +61,14 @@ feature 'Moderate proposal notifications' do end end - scenario 'Hide the proposal' do + scenario "Hide the proposal" do click_on "Hide proposals" expect(page).not_to have_css("#proposal_notification_#{@proposal_notification.id}") expect(@proposal_notification.reload).to be_hidden expect(@proposal_notification.author).not_to be_hidden end - scenario 'Block the author' do + scenario "Block the author" do author = create(:user) @proposal_notification.update(author: author) click_on "Block authors" @@ -77,7 +77,7 @@ feature 'Moderate proposal notifications' do expect(author.reload).to be_hidden end - scenario 'Ignore the proposal' do + scenario "Ignore the proposal" do click_button "Mark as viewed" expect(@proposal_notification.reload).to be_ignored @@ -91,13 +91,13 @@ feature 'Moderate proposal notifications' do visit moderation_proposal_notifications_path - within('.js-check') { click_on 'All' } + within(".js-check") { click_on "All" } - expect(all('input[type=checkbox]')).to all(be_checked) + expect(all("input[type=checkbox]")).to all(be_checked) - within('.js-check') { click_on 'None' } + within(".js-check") { click_on "None" } - all('input[type=checkbox]').each do |checkbox| + all("input[type=checkbox]").each do |checkbox| expect(checkbox).not_to be_checked end end @@ -105,43 +105,43 @@ feature 'Moderate proposal notifications' do scenario "remembering page, filter and order" do create_list(:proposal, 52) - visit moderation_proposal_notifications_path(filter: 'all', page: '2', order: 'created_at') + visit moderation_proposal_notifications_path(filter: "all", page: "2", order: "created_at") click_button "Mark as viewed" - expect(page).to have_selector('.js-order-selector[data-order="created_at"]') + expect(page).to have_selector(".js-order-selector[data-order='created_at']") - expect(current_url).to include('filter=all') - expect(current_url).to include('page=2') - expect(current_url).to include('order=created_at') + expect(current_url).to include("filter=all") + expect(current_url).to include("page=2") + expect(current_url).to include("order=created_at") end end scenario "Current filter is properly highlighted" do visit moderation_proposal_notifications_path - expect(page).not_to have_link('Pending review') - expect(page).to have_link('All') - expect(page).to have_link('Mark as viewed') + expect(page).not_to have_link("Pending review") + expect(page).to have_link("All") + expect(page).to have_link("Mark as viewed") - visit moderation_proposal_notifications_path(filter: 'all') - within('.menu.simple') do - expect(page).not_to have_link('All') - expect(page).to have_link('Pending review') - expect(page).to have_link('Mark as viewed') + visit moderation_proposal_notifications_path(filter: "all") + within(".menu.simple") do + expect(page).not_to have_link("All") + expect(page).to have_link("Pending review") + expect(page).to have_link("Mark as viewed") end - visit moderation_proposal_notifications_path(filter: 'pending_review') - within('.menu.simple') do - expect(page).to have_link('All') - expect(page).not_to have_link('Pending review') - expect(page).to have_link('Mark as viewed') + visit moderation_proposal_notifications_path(filter: "pending_review") + within(".menu.simple") do + expect(page).to have_link("All") + expect(page).not_to have_link("Pending review") + expect(page).to have_link("Mark as viewed") end - visit moderation_proposal_notifications_path(filter: 'ignored') - within('.menu.simple') do - expect(page).to have_link('All') - expect(page).to have_link('Pending review') - expect(page).not_to have_link('Marked as viewed') + visit moderation_proposal_notifications_path(filter: "ignored") + within(".menu.simple") do + expect(page).to have_link("All") + expect(page).to have_link("Pending review") + expect(page).not_to have_link("Marked as viewed") end end @@ -152,23 +152,23 @@ feature 'Moderate proposal notifications' do create(:proposal_notification, :hidden, title: "Hidden proposal", proposal: proposal) create(:proposal_notification, :moderated, :ignored, title: "Ignored proposal", proposal: proposal) - visit moderation_proposal_notifications_path(filter: 'all') - expect(page).to have_content('Regular proposal') - expect(page).to have_content('Pending proposal') - expect(page).not_to have_content('Hidden proposal') - expect(page).to have_content('Ignored proposal') + visit moderation_proposal_notifications_path(filter: "all") + expect(page).to have_content("Regular proposal") + expect(page).to have_content("Pending proposal") + expect(page).not_to have_content("Hidden proposal") + expect(page).to have_content("Ignored proposal") - visit moderation_proposal_notifications_path(filter: 'pending_review') - expect(page).not_to have_content('Regular proposal') - expect(page).to have_content('Pending proposal') - expect(page).not_to have_content('Hidden proposal') - expect(page).not_to have_content('Ignored proposal') + visit moderation_proposal_notifications_path(filter: "pending_review") + expect(page).not_to have_content("Regular proposal") + expect(page).to have_content("Pending proposal") + expect(page).not_to have_content("Hidden proposal") + expect(page).not_to have_content("Ignored proposal") - visit moderation_proposal_notifications_path(filter: 'ignored') - expect(page).not_to have_content('Regular proposal') - expect(page).not_to have_content('Pending proposal') - expect(page).not_to have_content('Hidden proposal') - expect(page).to have_content('Ignored proposal') + visit moderation_proposal_notifications_path(filter: "ignored") + expect(page).not_to have_content("Regular proposal") + expect(page).not_to have_content("Pending proposal") + expect(page).not_to have_content("Hidden proposal") + expect(page).to have_content("Ignored proposal") end scenario "sorting proposal notifications" do @@ -177,11 +177,11 @@ feature 'Moderate proposal notifications' do newer_notification = create(:proposal_notification, title: "Newer notification", created_at: Time.current) old_moderated_notification = create(:proposal_notification, :moderated, title: "Older notification", created_at: Time.current - 2.days) - visit moderation_proposal_notifications_path(filter: 'all', order: 'created_at') + visit moderation_proposal_notifications_path(filter: "all", order: "created_at") expect(moderated_new_notification.title).to appear_before(moderated_notification.title) - visit moderation_proposal_notifications_path(filter: 'all', order: 'moderated') + visit moderation_proposal_notifications_path(filter: "all", order: "moderated") expect(old_moderated_notification.title).to appear_before(newer_notification.title) end diff --git a/spec/features/moderation/proposals_spec.rb b/spec/features/moderation/proposals_spec.rb index d73c34e73..6dad35f57 100644 --- a/spec/features/moderation/proposals_spec.rb +++ b/spec/features/moderation/proposals_spec.rb @@ -1,18 +1,18 @@ -require 'rails_helper' +require "rails_helper" -feature 'Moderate proposals' do +feature "Moderate proposals" do - scenario 'Disabled with a feature flag' do - Setting['feature.proposals'] = nil + scenario "Disabled with a feature flag" do + Setting["feature.proposals"] = nil moderator = create(:moderator) login_as(moderator.user) expect{ visit moderation_proposals_path }.to raise_exception(FeatureFlags::FeatureDisabled) - Setting['feature.proposals'] = true + Setting["feature.proposals"] = true end - scenario 'Hide', :js do + scenario "Hide", :js do citizen = create(:user) proposal = create(:proposal) moderator = create(:moderator) @@ -21,7 +21,7 @@ feature 'Moderate proposals' do visit proposal_path(proposal) within("#proposal_#{proposal.id}") do - accept_confirm { click_link 'Hide' } + accept_confirm { click_link "Hide" } end expect(page).to have_css("#proposal_#{proposal.id}.faded") @@ -29,10 +29,10 @@ feature 'Moderate proposals' do login_as(citizen) visit proposals_path - expect(page).to have_css('.proposal', count: 0) + expect(page).to have_css(".proposal", count: 0) end - scenario 'Can not hide own proposal' do + scenario "Can not hide own proposal" do moderator = create(:moderator) proposal = create(:proposal, author: moderator.user) @@ -40,24 +40,24 @@ feature 'Moderate proposals' do visit proposal_path(proposal) within("#proposal_#{proposal.id}") do - expect(page).not_to have_link('Hide') - expect(page).not_to have_link('Block author') + expect(page).not_to have_link("Hide") + expect(page).not_to have_link("Block author") end end - feature '/moderation/ screen' do + feature "/moderation/ screen" do background do moderator = create(:moderator) login_as(moderator.user) end - feature 'moderate in bulk' do + feature "moderate in bulk" do feature "When a proposal has been selected for moderation" do background do @proposal = create(:proposal) visit moderation_proposals_path - within('.menu.simple') do + within(".menu.simple") do click_link "All" end @@ -68,21 +68,21 @@ feature 'Moderate proposals' do expect(page).not_to have_css("proposal_#{@proposal.id}") end - scenario 'Hide the proposal' do + scenario "Hide the proposal" do click_on "Hide proposals" expect(page).not_to have_css("proposal_#{@proposal.id}") expect(@proposal.reload).to be_hidden expect(@proposal.author).not_to be_hidden end - scenario 'Block the author' do + scenario "Block the author" do click_on "Block authors" expect(page).not_to have_css("proposal_#{@proposal.id}") expect(@proposal.reload).to be_hidden expect(@proposal.author).to be_hidden end - scenario 'Ignore the proposal' do + scenario "Ignore the proposal" do click_button "Mark as viewed" expect(page).not_to have_css("proposal_#{@proposal.id}") expect(@proposal.reload).to be_ignored_flag @@ -96,13 +96,13 @@ feature 'Moderate proposals' do visit moderation_proposals_path - within('.js-check') { click_on 'All' } + within(".js-check") { click_on "All" } - expect(all('input[type=checkbox]')).to all(be_checked) + expect(all("input[type=checkbox]")).to all(be_checked) - within('.js-check') { click_on 'None' } + within(".js-check") { click_on "None" } - all('input[type=checkbox]').each do |checkbox| + all("input[type=checkbox]").each do |checkbox| expect(checkbox).not_to be_checked end end @@ -110,43 +110,43 @@ feature 'Moderate proposals' do scenario "remembering page, filter and order" do create_list(:proposal, 52) - visit moderation_proposals_path(filter: 'all', page: '2', order: 'created_at') + visit moderation_proposals_path(filter: "all", page: "2", order: "created_at") click_button "Mark as viewed" - expect(page).to have_selector('.js-order-selector[data-order="created_at"]') + expect(page).to have_selector(".js-order-selector[data-order='created_at']") - expect(current_url).to include('filter=all') - expect(current_url).to include('page=2') - expect(current_url).to include('order=created_at') + expect(current_url).to include("filter=all") + expect(current_url).to include("page=2") + expect(current_url).to include("order=created_at") end end scenario "Current filter is properly highlighted" do visit moderation_proposals_path - expect(page).not_to have_link('Pending') - expect(page).to have_link('All') - expect(page).to have_link('Mark as viewed') + expect(page).not_to have_link("Pending") + expect(page).to have_link("All") + expect(page).to have_link("Mark as viewed") - visit moderation_proposals_path(filter: 'all') - within('.menu.simple') do - expect(page).not_to have_link('All') - expect(page).to have_link('Pending review') - expect(page).to have_link('Mark as viewed') + visit moderation_proposals_path(filter: "all") + within(".menu.simple") do + expect(page).not_to have_link("All") + expect(page).to have_link("Pending review") + expect(page).to have_link("Mark as viewed") end - visit moderation_proposals_path(filter: 'pending_flag_review') - within('.menu.simple') do - expect(page).to have_link('All') - expect(page).not_to have_link('Pending') - expect(page).to have_link('Mark as viewed') + visit moderation_proposals_path(filter: "pending_flag_review") + within(".menu.simple") do + expect(page).to have_link("All") + expect(page).not_to have_link("Pending") + expect(page).to have_link("Mark as viewed") end - visit moderation_proposals_path(filter: 'with_ignored_flag') - within('.menu.simple') do - expect(page).to have_link('All') - expect(page).to have_link('Pending review') - expect(page).not_to have_link('Marked as viewed') + visit moderation_proposals_path(filter: "with_ignored_flag") + within(".menu.simple") do + expect(page).to have_link("All") + expect(page).to have_link("Pending review") + expect(page).not_to have_link("Marked as viewed") end end @@ -156,23 +156,23 @@ feature 'Moderate proposals' do create(:proposal, :hidden, title: "Hidden proposal") create(:proposal, :flagged, :with_ignored_flag, title: "Ignored proposal") - visit moderation_proposals_path(filter: 'all') - expect(page).to have_content('Regular proposal') - expect(page).to have_content('Pending proposal') - expect(page).not_to have_content('Hidden proposal') - expect(page).to have_content('Ignored proposal') + visit moderation_proposals_path(filter: "all") + expect(page).to have_content("Regular proposal") + expect(page).to have_content("Pending proposal") + expect(page).not_to have_content("Hidden proposal") + expect(page).to have_content("Ignored proposal") - visit moderation_proposals_path(filter: 'pending_flag_review') - expect(page).not_to have_content('Regular proposal') - expect(page).to have_content('Pending proposal') - expect(page).not_to have_content('Hidden proposal') - expect(page).not_to have_content('Ignored proposal') + visit moderation_proposals_path(filter: "pending_flag_review") + expect(page).not_to have_content("Regular proposal") + expect(page).to have_content("Pending proposal") + expect(page).not_to have_content("Hidden proposal") + expect(page).not_to have_content("Ignored proposal") - visit moderation_proposals_path(filter: 'with_ignored_flag') - expect(page).not_to have_content('Regular proposal') - expect(page).not_to have_content('Pending proposal') - expect(page).not_to have_content('Hidden proposal') - expect(page).to have_content('Ignored proposal') + visit moderation_proposals_path(filter: "with_ignored_flag") + expect(page).not_to have_content("Regular proposal") + expect(page).not_to have_content("Pending proposal") + expect(page).not_to have_content("Hidden proposal") + expect(page).to have_content("Ignored proposal") end scenario "sorting proposals" do @@ -180,20 +180,20 @@ feature 'Moderate proposals' do flagged_new_proposal = create(:proposal, title: "Flagged new proposal", created_at: Time.current - 12.hours, flags_count: 3) newer_proposal = create(:proposal, title: "Newer proposal", created_at: Time.current) - visit moderation_proposals_path(order: 'created_at') + visit moderation_proposals_path(order: "created_at") expect(flagged_new_proposal.title).to appear_before(flagged_proposal.title) - visit moderation_proposals_path(order: 'flags') + visit moderation_proposals_path(order: "flags") expect(flagged_proposal.title).to appear_before(flagged_new_proposal.title) - visit moderation_proposals_path(filter: 'all', order: 'created_at') + visit moderation_proposals_path(filter: "all", order: "created_at") expect(newer_proposal.title).to appear_before(flagged_new_proposal.title) expect(flagged_new_proposal.title).to appear_before(flagged_proposal.title) - visit moderation_proposals_path(filter: 'all', order: 'flags') + visit moderation_proposals_path(filter: "all", order: "flags") expect(flagged_proposal.title).to appear_before(flagged_new_proposal.title) expect(flagged_new_proposal.title).to appear_before(newer_proposal.title) diff --git a/spec/features/moderation/users_spec.rb b/spec/features/moderation/users_spec.rb index 697b11d34..b2c6e37d9 100644 --- a/spec/features/moderation/users_spec.rb +++ b/spec/features/moderation/users_spec.rb @@ -1,15 +1,15 @@ -require 'rails_helper' +require "rails_helper" -feature 'Moderate users' do +feature "Moderate users" do - scenario 'Hide' do + scenario "Hide" do citizen = create(:user) moderator = create(:moderator) debate1 = create(:debate, author: citizen) debate2 = create(:debate, author: citizen) debate3 = create(:debate) - comment3 = create(:comment, user: citizen, commentable: debate3, body: 'SPAMMER') + comment3 = create(:comment, user: citizen, commentable: debate3, body: "SPAMMER") login_as(moderator.user) visit debates_path @@ -25,7 +25,7 @@ feature 'Moderate users' do visit debate_path(debate1) within("#debate_#{debate1.id}") do - click_link 'Hide author' + click_link "Hide author" end expect(page).to have_current_path(debates_path) @@ -41,17 +41,17 @@ feature 'Moderate users' do visit root_path - click_link 'Sign in' - fill_in 'user_login', with: citizen.email - fill_in 'user_password', with: citizen.password - click_button 'Enter' + click_link "Sign in" + fill_in "user_login", with: citizen.email + fill_in "user_password", with: citizen.password + click_button "Enter" - expect(page).to have_content 'Invalid login or password' + expect(page).to have_content "Invalid login or password" expect(page).to have_current_path(new_user_session_path) end - scenario 'Search and ban users' do - citizen = create(:user, username: 'Wanda Maximoff') + scenario "Search and ban users" do + citizen = create(:user, username: "Wanda Maximoff") moderator = create(:moderator) login_as(moderator.user) @@ -59,13 +59,13 @@ feature 'Moderate users' do visit moderation_users_path expect(page).not_to have_content citizen.name - fill_in 'name_or_email', with: 'Wanda' - click_button 'Search' + fill_in "name_or_email", with: "Wanda" + click_button "Search" within("#moderation_users") do expect(page).to have_content citizen.name expect(page).not_to have_content "Blocked" - click_link 'Block' + click_link "Block" end within("#moderation_users") do diff --git a/spec/features/moderation_spec.rb b/spec/features/moderation_spec.rb index 785c15580..455a98fa1 100644 --- a/spec/features/moderation_spec.rb +++ b/spec/features/moderation_spec.rb @@ -1,9 +1,9 @@ -require 'rails_helper' +require "rails_helper" -feature 'Moderation' do +feature "Moderation" do let(:user) { create(:user) } - scenario 'Access as regular user is not authorized' do + scenario "Access as regular user is not authorized" do login_as(user) visit root_path @@ -15,7 +15,7 @@ feature 'Moderation' 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) @@ -29,7 +29,7 @@ feature 'Moderation' 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) @@ -43,7 +43,7 @@ feature 'Moderation' 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) @@ -57,7 +57,7 @@ feature 'Moderation' do expect(page).to have_content "You do not have permission to access this page" end - scenario 'Access as a moderator is authorized' do + scenario "Access as a moderator is authorized" do create(:moderator, user: user) login_as(user) @@ -70,7 +70,7 @@ feature 'Moderation' do expect(page).not_to have_content "You do not have permission to access this page" end - scenario 'Access as an administrator is authorized' do + scenario "Access as an administrator is authorized" do create(:administrator, user: user) login_as(user) @@ -88,32 +88,32 @@ feature 'Moderation' do login_as(user) visit root_path - expect(page).to have_link('Moderation') - expect(page).not_to have_link('Administration') - expect(page).not_to have_link('Valuation') + expect(page).to have_link("Moderation") + expect(page).not_to have_link("Administration") + expect(page).not_to have_link("Valuation") end - context 'Moderation dashboard' do + context "Moderation dashboard" do background do - Setting['org_name'] = 'OrgName' + Setting["org_name"] = "OrgName" end after do - Setting['org_name'] = 'CONSUL' + Setting["org_name"] = "CONSUL" end - scenario 'Contains correct elements' do + scenario "Contains correct elements" do create(:moderator, user: user) login_as(user) visit root_path - click_link 'Moderation' + click_link "Moderation" - expect(page).to have_link('Go back to OrgName') + expect(page).to have_link("Go back to OrgName") expect(page).to have_current_path(moderation_root_path) - expect(page).to have_css('#moderation_menu') - expect(page).not_to have_css('#admin_menu') - expect(page).not_to have_css('#valuation_menu') + expect(page).to have_css("#moderation_menu") + expect(page).not_to have_css("#admin_menu") + expect(page).not_to have_css("#valuation_menu") end end end diff --git a/spec/features/notifications_spec.rb b/spec/features/notifications_spec.rb index d492f1f07..1702bf943 100644 --- a/spec/features/notifications_spec.rb +++ b/spec/features/notifications_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" feature "Notifications" do @@ -133,15 +133,15 @@ feature "Notifications" do create(:notification, notifiable: create(:poll_question), user: user) click_notifications_icon - expect(page).to have_content('This resource is not available anymore.', count: 2) + expect(page).to have_content("This resource is not available anymore.", count: 2) end context "Admin Notifications" do let(:admin_notification) do - create(:admin_notification, title: 'Notification title', - body: 'Notification body', - link: 'https://www.external.link.dev/', - segment_recipient: 'all_users') + create(:admin_notification, title: "Notification title", + body: "Notification body", + link: "https://www.external.link.dev/", + segment_recipient: "all_users") end let!(:notification) do @@ -154,30 +154,30 @@ feature "Notifications" do scenario "With external link" do visit notifications_path - expect(page).to have_content('Notification title') - expect(page).to have_content('Notification body') + expect(page).to have_content("Notification title") + expect(page).to have_content("Notification body") first("#notification_#{notification.id} a").click - expect(page.current_url).to eq('https://www.external.link.dev/') + expect(page.current_url).to eq("https://www.external.link.dev/") end scenario "With internal link" do - admin_notification.update_attributes(link: '/stats') + admin_notification.update_attributes(link: "/stats") visit notifications_path - expect(page).to have_content('Notification title') - expect(page).to have_content('Notification body') + expect(page).to have_content("Notification title") + expect(page).to have_content("Notification body") first("#notification_#{notification.id} a").click - expect(page).to have_current_path('/stats') + expect(page).to have_current_path("/stats") end scenario "Without a link" do - admin_notification.update_attributes(link: '/stats') + admin_notification.update_attributes(link: "/stats") visit notifications_path - expect(page).to have_content('Notification title') - expect(page).to have_content('Notification body') + expect(page).to have_content("Notification title") + expect(page).to have_content("Notification body") expect(page).not_to have_link(notification_path(notification), visible: false) end end @@ -242,7 +242,7 @@ feature "Notifications" do def users_without_notifications User.all.select { |user| user.notifications.not_emailed - .where(notifiable_type: 'ProposalNotification').blank? } + .where(notifiable_type: "ProposalNotification").blank? } end end diff --git a/spec/features/official_positions_spec.rb b/spec/features/official_positions_spec.rb index f8e53ea2c..8eeda2038 100644 --- a/spec/features/official_positions_spec.rb +++ b/spec/features/official_positions_spec.rb @@ -1,6 +1,6 @@ -require 'rails_helper' +require "rails_helper" -feature 'Official positions' do +feature "Official positions" do context "Badge" do diff --git a/spec/features/officing/residence_spec.rb b/spec/features/officing/residence_spec.rb index 034d47420..9f07eb8ce 100644 --- a/spec/features/officing/residence_spec.rb +++ b/spec/features/officing/residence_spec.rb @@ -1,6 +1,6 @@ -require 'rails_helper' +require "rails_helper" -feature 'Residence', :with_frozen_time do +feature "Residence", :with_frozen_time do let(:officer) { create(:poll_officer) } feature "Officers without assignments" do @@ -34,13 +34,13 @@ feature 'Residence', :with_frozen_time do click_link "Validate document" end - select 'DNI', from: 'residence_document_type' - fill_in 'residence_document_number', with: "12345678Z" - fill_in 'residence_year_of_birth', with: '1980' + select "DNI", from: "residence_document_type" + fill_in "residence_document_number", with: "12345678Z" + fill_in "residence_year_of_birth", with: "1980" - click_button 'Validate document' + click_button "Validate document" - expect(page).to have_content 'Document verified with Census' + expect(page).to have_content "Document verified with Census" end scenario "Error on verify" do @@ -61,13 +61,13 @@ feature 'Residence', :with_frozen_time do click_link "Validate document" end - select 'DNI', from: 'residence_document_type' - fill_in 'residence_document_number', with: "9999999A" - fill_in 'residence_year_of_birth', with: '1980' + select "DNI", from: "residence_document_type" + fill_in "residence_document_number", with: "9999999A" + fill_in "residence_year_of_birth", with: "1980" - click_button 'Validate document' + click_button "Validate document" - expect(page).to have_content 'The Census was unable to verify this document' + expect(page).to have_content "The Census was unable to verify this document" officer.reload fcc = FailedCensusCall.last @@ -82,13 +82,13 @@ feature 'Residence', :with_frozen_time do click_link "Validate document" end - select 'DNI', from: 'residence_document_type' - fill_in 'residence_document_number', with: "12345678Z" - fill_in 'residence_year_of_birth', with: '1981' + select "DNI", from: "residence_document_type" + fill_in "residence_document_number", with: "12345678Z" + fill_in "residence_year_of_birth", with: "1981" - click_button 'Validate document' + click_button "Validate document" - expect(page).to have_content 'The Census was unable to verify this document' + expect(page).to have_content "The Census was unable to verify this document" end end diff --git a/spec/features/officing/results_spec.rb b/spec/features/officing/results_spec.rb index eccffef4b..56a0aa4d8 100644 --- a/spec/features/officing/results_spec.rb +++ b/spec/features/officing/results_spec.rb @@ -1,6 +1,6 @@ -require 'rails_helper' +require "rails_helper" -feature 'Officing Results', :with_frozen_time do +feature "Officing Results", :with_frozen_time do background do @poll_officer = create(:poll_officer) @@ -8,16 +8,16 @@ feature 'Officing Results', :with_frozen_time do @poll = @officer_assignment.booth_assignment.poll @poll.update(ends_at: 1.day.ago) @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) login_as(@poll_officer.user) end - scenario 'Only polls where user is officer for results are accessible' do + scenario "Only polls where user is officer for results are accessible" do regular_officer_assignment_1 = create(:poll_officer_assignment, officer: @poll_officer) regular_officer_assignment_2 = create(:poll_officer_assignment, officer: @poll_officer) @@ -27,11 +27,11 @@ feature 'Officing Results', :with_frozen_time do not_allowed_poll_3 = regular_officer_assignment_2.booth_assignment.poll visit root_path - click_link 'Polling officers' + click_link "Polling officers" - expect(page).to have_content('Poll officing') - within('#side_menu') do - click_link 'Total recounts and results' + expect(page).to have_content("Poll officing") + within("#side_menu") do + click_link "Total recounts and results" end expect(page).not_to have_content(not_allowed_poll_1.name) @@ -40,47 +40,47 @@ feature 'Officing Results', :with_frozen_time do expect(page).to have_content(@poll.name) visit new_officing_poll_result_path(not_allowed_poll_1) - expect(page).to have_content('You are not allowed to add results for this poll') + expect(page).to have_content("You are not allowed to add results for this poll") end - scenario 'Add results' do + scenario "Add results" do visit officing_root_path - within('#side_menu') do - click_link 'Total recounts and results' + within("#side_menu") do + click_link "Total recounts and results" end within("#poll_#{@poll.id}") do expect(page).to have_content(@poll.name) - click_link 'Add results' + click_link "Add results" end - expect(page).not_to have_content('Your results') + expect(page).not_to have_content("Your results") booth_name = @officer_assignment.booth_assignment.booth.name - select booth_name, from: 'officer_assignment_id' + select booth_name, from: "officer_assignment_id" - fill_in "questions[#{@question_1.id}][0]", with: '100' - fill_in "questions[#{@question_1.id}][1]", with: '200' + fill_in "questions[#{@question_1.id}][0]", with: "100" + fill_in "questions[#{@question_1.id}][1]", with: "200" - fill_in "questions[#{@question_2.id}][0]", with: '333' - fill_in "questions[#{@question_2.id}][1]", with: '444' + fill_in "questions[#{@question_2.id}][0]", with: "333" + fill_in "questions[#{@question_2.id}][1]", with: "444" - fill_in "whites", with: '66' - fill_in "nulls", with: '77' - fill_in "total", with: '88' + fill_in "whites", with: "66" + fill_in "nulls", with: "77" + fill_in "total", with: "88" - click_button 'Save' + click_button "Save" - expect(page).to have_content('Your results') + expect(page).to have_content("Your results") - within("#results_#{@officer_assignment.booth_assignment_id}_#{Date.current.strftime('%Y%m%d')}") do + within("#results_#{@officer_assignment.booth_assignment_id}_#{Date.current.strftime("%Y%m%d")}") do expect(page).to have_content(I18n.l(Date.current, format: :long)) expect(page).to have_content(booth_name) end end - scenario 'Edit result' do + scenario "Edit result" do partial_result = create(:poll_partial_result, officer_assignment: @officer_assignment, booth_assignment: @officer_assignment.booth_assignment, @@ -92,36 +92,36 @@ feature 'Officing Results', :with_frozen_time do visit officing_poll_results_path(@poll, date: I18n.l(partial_result.date), booth_assignment_id: partial_result.booth_assignment_id) - within("#question_#{@question_1.id}_0_result") { expect(page).to have_content('7777') } + within("#question_#{@question_1.id}_0_result") { expect(page).to have_content("7777") } visit new_officing_poll_result_path(@poll) booth_name = partial_result.booth_assignment.booth.name - select booth_name, from: 'officer_assignment_id' + select booth_name, from: "officer_assignment_id" - fill_in "questions[#{@question_1.id}][0]", with: '5555' - fill_in "questions[#{@question_1.id}][1]", with: '200' - fill_in "whites", with: '6' - fill_in "nulls", with: '7' - fill_in "total", with: '8' + fill_in "questions[#{@question_1.id}][0]", with: "5555" + fill_in "questions[#{@question_1.id}][1]", with: "200" + fill_in "whites", with: "6" + fill_in "nulls", with: "7" + fill_in "total", with: "8" - click_button 'Save' + click_button "Save" - within("#results_#{partial_result.booth_assignment_id}_#{partial_result.date.strftime('%Y%m%d')}") do + within("#results_#{partial_result.booth_assignment_id}_#{partial_result.date.strftime("%Y%m%d")}") do expect(page).to have_content(I18n.l(partial_result.date, format: :long)) expect(page).to have_content(partial_result.booth_assignment.booth.name) click_link "See results" end - expect(page).not_to have_content('7777') - within("#white_results") { expect(page).to have_content('6') } - within("#null_results") { expect(page).to have_content('7') } - within("#total_results") { expect(page).to have_content('8') } - within("#question_#{@question_1.id}_0_result") { expect(page).to have_content('5555') } - within("#question_#{@question_1.id}_1_result") { expect(page).to have_content('200') } + expect(page).not_to have_content("7777") + within("#white_results") { expect(page).to have_content("6") } + within("#null_results") { expect(page).to have_content("7") } + within("#total_results") { expect(page).to have_content("8") } + within("#question_#{@question_1.id}_0_result") { expect(page).to have_content("5555") } + within("#question_#{@question_1.id}_1_result") { expect(page).to have_content("200") } end - scenario 'Index lists all questions and answers' do + scenario "Index lists all questions and answers" do partial_result = create(:poll_partial_result, officer_assignment: @officer_assignment, booth_assignment: @officer_assignment.booth_assignment, @@ -153,9 +153,9 @@ feature 'Officing Results', :with_frozen_time do within("#question_#{@question_2.id}_#{i}_result") { expect(page).to have_content(answer.title) } 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 end diff --git a/spec/features/officing/voters_spec.rb b/spec/features/officing/voters_spec.rb index a9d37526b..067520d27 100644 --- a/spec/features/officing/voters_spec.rb +++ b/spec/features/officing/voters_spec.rb @@ -1,6 +1,6 @@ -require 'rails_helper' +require "rails_helper" -feature 'Voters' do +feature "Voters" do let(:poll) { create(:poll, :current) } let(:booth) { create(:poll_booth) } diff --git a/spec/features/officing_spec.rb b/spec/features/officing_spec.rb index d5e410afb..0d865b13f 100644 --- a/spec/features/officing_spec.rb +++ b/spec/features/officing_spec.rb @@ -1,10 +1,10 @@ -require 'rails_helper' -require 'sessions_helper' +require "rails_helper" +require "sessions_helper" -feature 'Poll Officing' do +feature "Poll Officing" do let(:user) { create(:user) } - scenario 'Access as regular user is not authorized' do + scenario "Access as regular user is not authorized" do login_as(user) visit root_path @@ -16,7 +16,7 @@ feature 'Poll Officing' 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 root_path @@ -29,7 +29,7 @@ feature 'Poll Officing' 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 root_path @@ -42,7 +42,7 @@ feature 'Poll Officing' do expect(page).to have_content "You do not have permission to access this page" end - scenario 'Access as a valuator is not authorized' do + scenario "Access as a valuator is not authorized" do create(:valuator, user: user) login_as(user) visit root_path @@ -55,7 +55,7 @@ feature 'Poll Officing' do expect(page).to have_content "You do not have permission to access this page" end - scenario 'Access as an administrator is not authorized' do + scenario "Access as an administrator is not authorized" do create(:administrator, user: user) create(:poll) login_as(user) @@ -69,7 +69,7 @@ feature 'Poll Officing' do expect(page).to have_content "You do not have permission to access this page" end - scenario 'Access as an administrator with poll officer role is authorized' do + scenario "Access as an administrator with poll officer role is authorized" do create(:administrator, user: user) create(:poll_officer, user: user) create(:poll) @@ -83,7 +83,7 @@ feature 'Poll Officing' do expect(page).not_to have_content "You do not have permission to access this page" end - scenario 'Access as an poll officer is authorized' do + scenario "Access as an poll officer is authorized" do create(:poll_officer, user: user) create(:poll) login_as(user) @@ -102,27 +102,27 @@ feature 'Poll Officing' do visit root_path expect(page).to have_link("Polling officers") - expect(page).not_to have_link('Valuation') - expect(page).not_to have_link('Administration') - expect(page).not_to have_link('Moderation') + expect(page).not_to have_link("Valuation") + expect(page).not_to have_link("Administration") + expect(page).not_to have_link("Moderation") end - scenario 'Officing dashboard' do + scenario "Officing dashboard" do create(:poll_officer, user: user) create(:poll) login_as(user) visit root_path - click_link 'Polling officers' + click_link "Polling officers" expect(page).to have_current_path(officing_root_path) - expect(page).to have_css('#officing_menu') - expect(page).not_to have_css('#valuation_menu') - expect(page).not_to have_css('#admin_menu') - expect(page).not_to have_css('#moderation_menu') + expect(page).to have_css("#officing_menu") + expect(page).not_to have_css("#valuation_menu") + expect(page).not_to have_css("#admin_menu") + expect(page).not_to have_css("#moderation_menu") end - scenario 'Officing dashboard available for multiple sessions', :js, :with_frozen_time do + scenario "Officing dashboard available for multiple sessions", :js, :with_frozen_time do poll = create(:poll) booth = create(:poll_booth) booth_assignment = create(:poll_booth_assignment, poll: poll, booth: booth) @@ -152,16 +152,16 @@ feature 'Poll Officing' do expect(page).to have_content("Here you can validate user documents and store voting results") visit new_officing_residence_path - expect(page).to have_selector('#residence_document_type') + expect(page).to have_selector("#residence_document_type") - select 'DNI', from: 'residence_document_type' - fill_in 'residence_document_number', with: "12345678Z" - fill_in 'residence_year_of_birth', with: '1980' - click_button 'Validate document' - expect(page).to have_content 'Document verified with Census' + select "DNI", from: "residence_document_type" + fill_in "residence_document_number", with: "12345678Z" + fill_in "residence_year_of_birth", with: "1980" + click_button "Validate document" + expect(page).to have_content "Document verified with Census" click_button "Confirm vote" expect(page).to have_content "Vote introduced!" - expect(Poll::Voter.where(document_number: '12345678Z', poll_id: poll, origin: 'booth', officer_id: officer1).count).to be(1) + expect(Poll::Voter.where(document_number: "12345678Z", poll_id: poll, origin: "booth", officer_id: officer1).count).to be(1) visit final_officing_polls_path expect(page).to have_content("Polls ready for final recounting") @@ -171,16 +171,16 @@ feature 'Poll Officing' do expect(page).to have_content("Here you can validate user documents and store voting results") visit new_officing_residence_path - expect(page).to have_selector('#residence_document_type') + expect(page).to have_selector("#residence_document_type") - select 'DNI', from: 'residence_document_type' - fill_in 'residence_document_number', with: "12345678Y" - fill_in 'residence_year_of_birth', with: '1980' - click_button 'Validate document' - expect(page).to have_content 'Document verified with Census' + select "DNI", from: "residence_document_type" + fill_in "residence_document_number", with: "12345678Y" + fill_in "residence_year_of_birth", with: "1980" + click_button "Validate document" + expect(page).to have_content "Document verified with Census" click_button "Confirm vote" expect(page).to have_content "Vote introduced!" - expect(Poll::Voter.where(document_number: '12345678Y', poll_id: poll, origin: 'booth', officer_id: officer2).count).to be(1) + expect(Poll::Voter.where(document_number: "12345678Y", poll_id: poll, origin: "booth", officer_id: officer2).count).to be(1) visit final_officing_polls_path expect(page).to have_content("Polls ready for final recounting") diff --git a/spec/features/organizations_spec.rb b/spec/features/organizations_spec.rb index e2183bf25..c68df84e4 100644 --- a/spec/features/organizations_spec.rb +++ b/spec/features/organizations_spec.rb @@ -1,72 +1,72 @@ -require 'rails_helper' +require "rails_helper" -feature 'Organizations' do +feature "Organizations" do - scenario 'Organizations can be created' do - user = User.organizations.where(email: 'green@peace.com').first + scenario "Organizations can be created" do + user = User.organizations.where(email: "green@peace.com").first expect(user).not_to be visit new_organization_registration_path - fill_in 'user_organization_attributes_name', with: 'Greenpeace' - fill_in 'user_organization_attributes_responsible_name', with: 'Dorothy Stowe' - fill_in 'user_email', with: 'green@peace.com' - fill_in 'user_password', with: 'greenpeace' - fill_in 'user_password_confirmation', with: 'greenpeace' - check 'user_terms_of_service' + fill_in "user_organization_attributes_name", with: "Greenpeace" + fill_in "user_organization_attributes_responsible_name", with: "Dorothy Stowe" + fill_in "user_email", with: "green@peace.com" + fill_in "user_password", with: "greenpeace" + fill_in "user_password_confirmation", with: "greenpeace" + check "user_terms_of_service" - click_button 'Register' + click_button "Register" - user = User.organizations.where(email: 'green@peace.com').first + user = User.organizations.where(email: "green@peace.com").first expect(user).to be expect(user).to be_organization expect(user.organization).not_to be_verified end - scenario 'Create with invisible_captcha honeypot field' do + scenario "Create with invisible_captcha honeypot field" do visit new_organization_registration_path - fill_in 'user_organization_attributes_name', with: 'robot' - fill_in 'user_address', with: 'This is the honeypot field' - fill_in 'user_organization_attributes_responsible_name', with: 'Robots are more responsible than humans' - fill_in 'user_email', with: 'robot@robot.com' - fill_in 'user_password', with: 'destroyallhumans' - fill_in 'user_password_confirmation', with: 'destroyallhumans' + fill_in "user_organization_attributes_name", with: "robot" + fill_in "user_address", with: "This is the honeypot field" + fill_in "user_organization_attributes_responsible_name", with: "Robots are more responsible than humans" + fill_in "user_email", with: "robot@robot.com" + fill_in "user_password", with: "destroyallhumans" + fill_in "user_password_confirmation", with: "destroyallhumans" - check 'user_terms_of_service' + check "user_terms_of_service" - click_button 'Register' + click_button "Register" expect(page.status_code).to eq(200) expect(page.html).to be_empty expect(page).to have_current_path(organization_registration_path) end - scenario 'Create organization too fast' do + scenario "Create organization too fast" do allow(InvisibleCaptcha).to receive(:timestamp_threshold).and_return(Float::INFINITY) visit new_organization_registration_path - fill_in 'user_organization_attributes_name', with: 'robot' - fill_in 'user_organization_attributes_responsible_name', with: 'Robots are more responsible than humans' - fill_in 'user_email', with: 'robot@robot.com' - fill_in 'user_password', with: 'destroyallhumans' - fill_in 'user_password_confirmation', with: 'destroyallhumans' + fill_in "user_organization_attributes_name", with: "robot" + fill_in "user_organization_attributes_responsible_name", with: "Robots are more responsible than humans" + fill_in "user_email", with: "robot@robot.com" + fill_in "user_password", with: "destroyallhumans" + fill_in "user_password_confirmation", with: "destroyallhumans" - click_button 'Register' + click_button "Register" - 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_organization_registration_path) end - scenario 'Errors on create' do + scenario "Errors on create" do visit new_organization_registration_path - click_button 'Register' + click_button "Register" expect(page).to have_content error_message end - scenario 'Shared links' do + scenario "Shared links" do # visit new_user_registration_path # expect(page).to have_link "Sign up as an organization / collective" diff --git a/spec/features/polls/answers_spec.rb b/spec/features/polls/answers_spec.rb index 89bdfeb5d..cc028fde0 100644 --- a/spec/features/polls/answers_spec.rb +++ b/spec/features/polls/answers_spec.rb @@ -1,6 +1,6 @@ -require 'rails_helper' +require "rails_helper" -feature 'Answers' do +feature "Answers" do let(:question) { create(:poll_question) } let(:admin) { create(:administrator) } @@ -38,7 +38,7 @@ feature 'Answers' do expect(page).to have_content "Adding more trees, creating a play area..." end - scenario 'Add video to answer' do + scenario "Add video to answer" do answer1 = create(:poll_question_answer, question: question) answer2 = create(:poll_question_answer, question: question) diff --git a/spec/features/polls/polls_spec.rb b/spec/features/polls/polls_spec.rb index a1485c132..70ad7ca5a 100644 --- a/spec/features/polls/polls_spec.rb +++ b/spec/features/polls/polls_spec.rb @@ -1,16 +1,16 @@ -require 'rails_helper' +require "rails_helper" -feature 'Polls' do +feature "Polls" do context "Concerns" do - it_behaves_like 'notifiable in-app', Poll + it_behaves_like "notifiable in-app", Poll end - context '#index' do + context "#index" do - scenario 'Polls can be listed' do + scenario "Polls can be listed" do visit polls_path - expect(page).to have_content('There are no open votings') + expect(page).to have_content("There are no open votings") polls = create_list(:poll, 3) create(:image, imageable: polls[0]) @@ -26,29 +26,29 @@ feature 'Polls' do end end - scenario 'Filtering polls' do + scenario "Filtering polls" do create(:poll, name: "Current poll") create(:poll, :expired, name: "Expired poll") visit polls_path - expect(page).to have_content('Current poll') - expect(page).to have_link('Participate in this poll') - expect(page).not_to have_content('Expired poll') + expect(page).to have_content("Current poll") + expect(page).to have_link("Participate in this poll") + expect(page).not_to have_content("Expired poll") - visit polls_path(filter: 'expired') - expect(page).not_to have_content('Current poll') - expect(page).to have_content('Expired poll') - expect(page).to have_link('Poll ended') + visit polls_path(filter: "expired") + expect(page).not_to have_content("Current poll") + expect(page).to have_content("Expired poll") + expect(page).to have_link("Poll ended") end scenario "Current filter is properly highlighted" do visit polls_path - expect(page).not_to have_link('Open') - expect(page).to have_link('Expired') + expect(page).not_to have_link("Open") + expect(page).to have_link("Expired") - visit polls_path(filter: 'expired') - expect(page).to have_link('Open') - expect(page).not_to have_link('Expired') + visit polls_path(filter: "expired") + expect(page).to have_link("Open") + expect(page).not_to have_link("Expired") end scenario "Displays icon correctly", :js do @@ -78,9 +78,9 @@ feature 'Polls' do poll_with_question = create(:poll) question = create(:poll_question, poll: poll_with_question) - answer1 = create(:poll_question_answer, question: question, title: 'Yes') - answer2 = create(:poll_question_answer, question: question, title: 'No') - vote_for_poll_via_web(poll_with_question, question, 'Yes') + answer1 = create(:poll_question_answer, question: question, title: "Yes") + answer2 = create(:poll_question_answer, question: question, title: "No") + vote_for_poll_via_web(poll_with_question, question, "Yes") visit polls_path @@ -105,13 +105,13 @@ feature 'Polls' do end end - context 'Show' do + context "Show" do let(:geozone) { create(:geozone) } let(:poll) { create(:poll, summary: "Summary", description: "Description") } - scenario 'Show answers with videos' do + scenario "Show answers with videos" do question = create(:poll_question, poll: poll) - answer = create(:poll_question_answer, question: question, title: 'Chewbacca') + answer = create(:poll_question_answer, question: question, title: "Chewbacca") video = create(:poll_answer_video, answer: answer, title: "Awesome project video", url: "https://www.youtube.com/watch?v=123") visit poll_path(poll) @@ -119,7 +119,7 @@ feature 'Polls' do expect(page).to have_link("Awesome project video", href: "https://www.youtube.com/watch?v=123") end - scenario 'Lists questions from proposals as well as regular ones' do + scenario "Lists questions from proposals as well as regular ones" do normal_question = create(:poll_question, poll: poll) proposal_question = create(:poll_question, poll: poll, proposal: create(:proposal)) @@ -134,8 +134,8 @@ feature 'Polls' do scenario "Question answers appear in the given order" do question = create(:poll_question, poll: poll) - answer1 = create(:poll_question_answer, title: 'First', question: question, given_order: 2) - answer2 = create(:poll_question_answer, title: 'Second', question: question, given_order: 1) + answer1 = create(:poll_question_answer, title: "First", question: question, given_order: 2) + answer2 = create(:poll_question_answer, title: "Second", question: question, given_order: 1) visit poll_path(poll) @@ -146,219 +146,219 @@ feature 'Polls' do scenario "More info answers appear in the given order" do question = create(:poll_question, poll: poll) - answer1 = create(:poll_question_answer, title: 'First', question: question, given_order: 2) - answer2 = create(:poll_question_answer, title: 'Second', question: question, given_order: 1) + answer1 = create(:poll_question_answer, title: "First", question: question, given_order: 2) + answer2 = create(:poll_question_answer, title: "Second", question: question, given_order: 1) visit poll_path(poll) - within('div.poll-more-info-answers') do + within("div.poll-more-info-answers") do expect(page.body.index(answer1.title)).to be < page.body.index(answer2.title) end end - scenario 'Non-logged in users' do + scenario "Non-logged in users" do question = create(:poll_question, poll: poll) - answer1 = create(:poll_question_answer, question: question, title: 'Han Solo') - answer2 = create(:poll_question_answer, question: question, title: 'Chewbacca') + answer1 = create(:poll_question_answer, question: question, title: "Han Solo") + answer2 = create(:poll_question_answer, question: question, title: "Chewbacca") visit poll_path(poll) - expect(page).to have_content('You must Sign in or Sign up to participate') - expect(page).to have_link('Han Solo', href: new_user_session_path) - expect(page).to have_link('Chewbacca', href: new_user_session_path) + expect(page).to have_content("You must Sign in or Sign up to participate") + expect(page).to have_link("Han Solo", href: new_user_session_path) + expect(page).to have_link("Chewbacca", href: new_user_session_path) end - scenario 'Level 1 users' do + scenario "Level 1 users" do visit polls_path - expect(page).not_to have_selector('.already-answer') + expect(page).not_to have_selector(".already-answer") poll.update(geozone_restricted: true) poll.geozones << geozone question = create(:poll_question, poll: poll) - answer1 = create(:poll_question_answer, question: question, title: 'Han Solo') - answer2 = create(:poll_question_answer, question: question, title: 'Chewbacca') + answer1 = create(:poll_question_answer, question: question, title: "Han Solo") + answer2 = create(:poll_question_answer, question: question, title: "Chewbacca") login_as(create(:user, geozone: geozone)) visit poll_path(poll) - expect(page).to have_content('You must verify your account in order to answer') + expect(page).to have_content("You must verify your account in order to answer") - expect(page).to have_link('Han Solo', href: verification_path) - expect(page).to have_link('Chewbacca', href: verification_path) + expect(page).to have_link("Han Solo", href: verification_path) + expect(page).to have_link("Chewbacca", href: verification_path) end - scenario 'Level 2 users in an expired poll' do + scenario "Level 2 users in an expired poll" do expired_poll = create(:poll, :expired, geozone_restricted: true) expired_poll.geozones << geozone question = create(:poll_question, poll: expired_poll) - answer1 = create(:poll_question_answer, question: question, title: 'Luke') - answer2 = create(:poll_question_answer, question: question, title: 'Leia') + answer1 = create(:poll_question_answer, question: question, title: "Luke") + answer2 = create(:poll_question_answer, question: question, title: "Leia") login_as(create(:user, :level_two, geozone: geozone)) visit poll_path(expired_poll) - expect(page).to have_content('Luke') - expect(page).to have_content('Leia') - expect(page).not_to have_link('Luke') - expect(page).not_to have_link('Leia') + expect(page).to have_content("Luke") + expect(page).to have_content("Leia") + expect(page).not_to have_link("Luke") + expect(page).not_to have_link("Leia") - expect(page).to have_content('This poll has finished') + expect(page).to have_content("This poll has finished") end - scenario 'Level 2 users in a poll with questions for a geozone which is not theirs' do + scenario "Level 2 users in a poll with questions for a geozone which is not theirs" do poll.update(geozone_restricted: true) poll.geozones << create(:geozone) question = create(:poll_question, poll: poll) - answer1 = create(:poll_question_answer, question: question, title: 'Vader') - answer2 = create(:poll_question_answer, question: question, title: 'Palpatine') + answer1 = create(:poll_question_answer, question: question, title: "Vader") + answer2 = create(:poll_question_answer, question: question, title: "Palpatine") login_as(create(:user, :level_two)) visit poll_path(poll) - expect(page).to have_content('Vader') - expect(page).to have_content('Palpatine') - expect(page).not_to have_link('Vader') - expect(page).not_to have_link('Palpatine') + expect(page).to have_content("Vader") + expect(page).to have_content("Palpatine") + expect(page).not_to have_link("Vader") + expect(page).not_to have_link("Palpatine") end - scenario 'Level 2 users reading a same-geozone poll' do + scenario "Level 2 users reading a same-geozone poll" do poll.update(geozone_restricted: true) poll.geozones << geozone question = create(:poll_question, poll: poll) - answer1 = create(:poll_question_answer, question: question, title: 'Han Solo') - answer2 = create(:poll_question_answer, question: question, title: 'Chewbacca') + answer1 = create(:poll_question_answer, question: question, title: "Han Solo") + answer2 = create(:poll_question_answer, question: question, title: "Chewbacca") login_as(create(:user, :level_two, geozone: geozone)) visit poll_path(poll) - expect(page).to have_link('Han Solo') - expect(page).to have_link('Chewbacca') + expect(page).to have_link("Han Solo") + expect(page).to have_link("Chewbacca") end - scenario 'Level 2 users reading a all-geozones poll' do + scenario "Level 2 users reading a all-geozones poll" do question = create(:poll_question, poll: poll) - answer1 = create(:poll_question_answer, question: question, title: 'Han Solo') - answer2 = create(:poll_question_answer, question: question, title: 'Chewbacca') + answer1 = create(:poll_question_answer, question: question, title: "Han Solo") + answer2 = create(:poll_question_answer, question: question, title: "Chewbacca") login_as(create(:user, :level_two)) visit poll_path(poll) - expect(page).to have_link('Han Solo') - expect(page).to have_link('Chewbacca') + expect(page).to have_link("Han Solo") + expect(page).to have_link("Chewbacca") end - scenario 'Level 2 users who have already answered' do + scenario "Level 2 users who have already answered" do question = create(:poll_question, poll: poll) - answer1 = create(:poll_question_answer, question: question, title: 'Han Solo') - answer2 = create(:poll_question_answer, question: question, title: 'Chewbacca') + answer1 = create(:poll_question_answer, question: question, title: "Han Solo") + answer2 = create(:poll_question_answer, question: question, title: "Chewbacca") user = create(:user, :level_two) - create(:poll_answer, question: question, author: user, answer: 'Chewbacca') + create(:poll_answer, question: question, author: user, answer: "Chewbacca") login_as user visit poll_path(poll) - expect(page).to have_link('Han Solo') - expect(page).to have_link('Chewbacca') + expect(page).to have_link("Han Solo") + expect(page).to have_link("Chewbacca") end - scenario 'Level 2 users answering', :js do + scenario "Level 2 users answering", :js do poll.update(geozone_restricted: true) poll.geozones << geozone question = create(:poll_question, poll: poll) - answer1 = create(:poll_question_answer, question: question, title: 'Han Solo') - answer2 = create(:poll_question_answer, question: question, title: 'Chewbacca') + answer1 = create(:poll_question_answer, question: question, title: "Han Solo") + answer2 = create(:poll_question_answer, question: question, title: "Chewbacca") user = create(:user, :level_two, geozone: geozone) login_as user visit poll_path(poll) - click_link 'Han Solo' + click_link "Han Solo" - expect(page).not_to have_link('Han Solo') - expect(page).to have_link('Chewbacca') + expect(page).not_to have_link("Han Solo") + expect(page).to have_link("Chewbacca") end - scenario 'Level 2 users changing answer', :js do + scenario "Level 2 users changing answer", :js do poll.update(geozone_restricted: true) poll.geozones << geozone question = create(:poll_question, poll: poll) - answer1 = create(:poll_question_answer, question: question, title: 'Han Solo') - answer2 = create(:poll_question_answer, question: question, title: 'Chewbacca') + answer1 = create(:poll_question_answer, question: question, title: "Han Solo") + answer2 = create(:poll_question_answer, question: question, title: "Chewbacca") user = create(:user, :level_two, geozone: geozone) login_as user visit poll_path(poll) - click_link 'Han Solo' + click_link "Han Solo" - expect(page).not_to have_link('Han Solo') - expect(page).to have_link('Chewbacca') + expect(page).not_to have_link("Han Solo") + expect(page).to have_link("Chewbacca") - click_link 'Chewbacca' + click_link "Chewbacca" - expect(page).not_to have_link('Chewbacca') - expect(page).to have_link('Han Solo') + expect(page).not_to have_link("Chewbacca") + expect(page).to have_link("Han Solo") end - scenario 'Level 2 votes, signs out, signs in, votes again', :js do + scenario "Level 2 votes, signs out, signs in, votes again", :js do poll.update(geozone_restricted: true) poll.geozones << geozone question = create(:poll_question, poll: poll) - answer1 = create(:poll_question_answer, question: question, title: 'Han Solo') - answer2 = create(:poll_question_answer, question: question, title: 'Chewbacca') + answer1 = create(:poll_question_answer, question: question, title: "Han Solo") + answer2 = create(:poll_question_answer, question: question, title: "Chewbacca") user = create(:user, :level_two, geozone: geozone) login_as user visit poll_path(poll) - click_link 'Han Solo' + click_link "Han Solo" - expect(page).not_to have_link('Han Solo') - expect(page).to have_link('Chewbacca') + expect(page).not_to have_link("Han Solo") + expect(page).to have_link("Chewbacca") click_link "Sign out" login_as user visit poll_path(poll) - click_link 'Han Solo' + click_link "Han Solo" - expect(page).not_to have_link('Han Solo') - expect(page).to have_link('Chewbacca') + expect(page).not_to have_link("Han Solo") + expect(page).to have_link("Chewbacca") click_link "Sign out" login_as user visit poll_path(poll) - click_link 'Chewbacca' + click_link "Chewbacca" - expect(page).not_to have_link('Chewbacca') - expect(page).to have_link('Han Solo') + expect(page).not_to have_link("Chewbacca") + expect(page).to have_link("Han Solo") end end - context 'Booth & Website', :with_frozen_time do + context "Booth & Website", :with_frozen_time do let(:poll) { create(:poll, summary: "Summary", description: "Description") } let(:booth) { create(:poll_booth) } let(:officer) { create(:poll_officer) } - scenario 'Already voted on booth cannot vote on website', :js do + scenario "Already voted on booth cannot vote on website", :js do create(:poll_shift, officer: officer, booth: booth, date: Date.current, task: :vote_collection) booth_assignment = create(:poll_booth_assignment, poll: poll, booth: booth) create(:poll_officer_assignment, officer: officer, booth_assignment: booth_assignment, date: Date.current) question = create(:poll_question, poll: poll) - create(:poll_question_answer, question: question, title: 'Han Solo') - create(:poll_question_answer, question: question, title: 'Chewbacca') + create(:poll_question_answer, question: question, title: "Han Solo") + create(:poll_question_answer, question: question, title: "Chewbacca") user = create(:user, :level_two, :in_census) login_as(officer.user) @@ -376,11 +376,11 @@ feature 'Polls' do expect(page).to have_content "You have already participated in a physical booth. You can not participate again." within("#poll_question_#{question.id}_answers") do - expect(page).to have_content('Han Solo') - expect(page).to have_content('Chewbacca') + expect(page).to have_content("Han Solo") + expect(page).to have_content("Chewbacca") - expect(page).not_to have_link('Han Solo') - expect(page).not_to have_link('Chewbacca') + expect(page).not_to have_link("Han Solo") + expect(page).not_to have_link("Chewbacca") end end diff --git a/spec/features/polls/questions_spec.rb b/spec/features/polls/questions_spec.rb index 9e7efeedc..4af4f9785 100644 --- a/spec/features/polls/questions_spec.rb +++ b/spec/features/polls/questions_spec.rb @@ -1,8 +1,8 @@ -require 'rails_helper' +require "rails_helper" -feature 'Poll Questions' do +feature "Poll Questions" do - scenario 'Lists questions from proposals before regular questions' do + scenario "Lists questions from proposals before regular questions" do poll = create(:poll) normal_question = create(:poll_question, poll: poll) proposal_question = create(:poll_question, proposal: create(:proposal), poll: poll) diff --git a/spec/features/polls/results_spec.rb b/spec/features/polls/results_spec.rb index 0dfb93f1a..99236849a 100644 --- a/spec/features/polls/results_spec.rb +++ b/spec/features/polls/results_spec.rb @@ -1,36 +1,36 @@ -require 'rails_helper' +require "rails_helper" -feature 'Poll Results' do - scenario 'List each Poll question', :js do +feature "Poll Results" do + scenario "List each Poll question", :js do user1 = create(:user, :level_two) user2 = create(:user, :level_two) user3 = create(:user, :level_two) poll = create(:poll, results_enabled: true) question1 = create(:poll_question, poll: poll) - answer1 = create(:poll_question_answer, question: question1, title: 'Yes') - answer2 = create(:poll_question_answer, question: question1, title: 'No') + answer1 = create(:poll_question_answer, question: question1, title: "Yes") + answer2 = create(:poll_question_answer, question: question1, title: "No") question2 = create(:poll_question, poll: poll) - answer3 = create(:poll_question_answer, question: question2, title: 'Blue') - answer4 = create(:poll_question_answer, question: question2, title: 'Green') - answer5 = create(:poll_question_answer, question: question2, title: 'Yellow') + answer3 = create(:poll_question_answer, question: question2, title: "Blue") + answer4 = create(:poll_question_answer, question: question2, title: "Green") + answer5 = create(:poll_question_answer, question: question2, title: "Yellow") login_as user1 - vote_for_poll_via_web(poll, question1, 'Yes') - vote_for_poll_via_web(poll, question2, 'Blue') + vote_for_poll_via_web(poll, question1, "Yes") + vote_for_poll_via_web(poll, question2, "Blue") expect(Poll::Voter.count).to eq(1) logout login_as user2 - vote_for_poll_via_web(poll, question1, 'Yes') - vote_for_poll_via_web(poll, question2, 'Green') + vote_for_poll_via_web(poll, question1, "Yes") + vote_for_poll_via_web(poll, question2, "Green") expect(Poll::Voter.count).to eq(2) logout login_as user3 - vote_for_poll_via_web(poll, question1, 'No') - vote_for_poll_via_web(poll, question2, 'Yellow') + vote_for_poll_via_web(poll, question1, "No") + vote_for_poll_via_web(poll, question2, "Yellow") expect(Poll::Voter.count).to eq(3) logout diff --git a/spec/features/polls/voter_spec.rb b/spec/features/polls/voter_spec.rb index f7f1b58c8..ae0022302 100644 --- a/spec/features/polls/voter_spec.rb +++ b/spec/features/polls/voter_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" feature "Voter" do @@ -8,8 +8,8 @@ feature "Voter" do let(:question) { create(:poll_question, poll: poll) } let(:booth) { create(:poll_booth) } let(:officer) { create(:poll_officer) } - let!(:answer_yes) { create(:poll_question_answer, question: question, title: 'Yes') } - let!(:answer_no) { create(:poll_question_answer, question: question, title: 'No') } + let!(:answer_yes) { create(:poll_question_answer, question: question, title: "Yes") } + let!(:answer_no) { create(:poll_question_answer, question: question, title: "No") } background do create(:geozone, :in_census) @@ -30,7 +30,7 @@ feature "Voter" do end expect(page).to have_css(".js-token-message", visible: true) - token = find(:css, ".js-question-answer")[:href].gsub(/.+?(?=token)/, '').gsub('token=', '') + token = find(:css, ".js-question-answer")[:href].gsub(/.+?(?=token)/, "").gsub("token=", "") expect(page).to have_content "You can write down this vote identifier, to check your vote on the final results: #{token}" @@ -53,7 +53,7 @@ feature "Voter" do expect(page).not_to have_content("You have already participated in this poll. If you vote again it will be overwritten") end - scenario 'Voting in booth', :js do + scenario "Voting in booth", :js do user = create(:user, :in_census) login_through_form_as_officer(officer.user) @@ -64,13 +64,13 @@ feature "Voter" do expect(page).to have_content poll.name within("#poll_#{poll.id}") do - click_button('Confirm vote') - expect(page).not_to have_button('Confirm vote') - expect(page).to have_content('Vote introduced!') + click_button("Confirm vote") + expect(page).not_to have_button("Confirm vote") + expect(page).to have_content("Vote introduced!") end expect(Poll::Voter.count).to eq(1) - expect(Poll::Voter.first.origin).to eq('booth') + expect(Poll::Voter.first.origin).to eq("booth") end context "Trying to vote the same poll in booth and web" do @@ -116,7 +116,7 @@ feature "Voter" do visit poll_path(poll) - expect(page).not_to have_selector('.js-token-message') + expect(page).not_to have_selector(".js-token-message") expect(page).to have_content "You have already participated in this poll. If you vote again it will be overwritten." within("#poll_question_#{question.id}_answers") do @@ -152,7 +152,7 @@ feature "Voter" do login_as user visit account_path - click_link 'Verify my account' + click_link "Verify my account" verify_residence confirm_phone(user) diff --git a/spec/features/proposal_ballots_spec.rb b/spec/features/proposal_ballots_spec.rb index 1ec99d3d0..d67585a7c 100644 --- a/spec/features/proposal_ballots_spec.rb +++ b/spec/features/proposal_ballots_spec.rb @@ -1,9 +1,9 @@ # coding: utf-8 -require 'rails_helper' +require "rails_helper" -feature 'Proposal ballots' do +feature "Proposal ballots" do - scenario 'Successful proposals do not show support buttons in index' do + scenario "Successful proposals do not show support buttons in index" do successful_proposals = create_successful_proposals visit proposals_path @@ -15,7 +15,7 @@ feature 'Proposal ballots' do end end - scenario 'Successful proposals do not show support buttons in show' do + scenario "Successful proposals do not show support buttons in show" do successful_proposals = create_successful_proposals successful_proposals.each do |proposal| diff --git a/spec/features/proposal_notifications_spec.rb b/spec/features/proposal_notifications_spec.rb index b3a61eaff..3fff6c6c9 100644 --- a/spec/features/proposal_notifications_spec.rb +++ b/spec/features/proposal_notifications_spec.rb @@ -1,6 +1,6 @@ -require 'rails_helper' +require "rails_helper" -feature 'Proposal Notifications' do +feature "Proposal Notifications" do scenario "Send a notification" do author = create(:user) @@ -15,8 +15,8 @@ feature 'Proposal Notifications' do click_link "Send notification" end - fill_in 'proposal_notification_title', with: "Thank you for supporting my proposal" - fill_in 'proposal_notification_body', with: "Please share it with others so we can make it happen!" + fill_in "proposal_notification_title", with: "Thank you for supporting my proposal" + fill_in "proposal_notification_body", with: "Please share it with others so we can make it happen!" click_button "Send message" expect(page).to have_content "Your message has been sent correctly." @@ -116,7 +116,7 @@ feature 'Proposal Notifications' do expect(page).to have_content "This message will be sent to 7 people and it will "\ "be visible in the proposal's page" expect(page).to have_link("the proposal's page", href: proposal_path(proposal, - anchor: 'comments')) + anchor: "comments")) end scenario "Message about receivers (Followers)" do @@ -131,7 +131,7 @@ feature 'Proposal Notifications' do expect(page).to have_content "This message will be sent to 7 people and it will "\ "be visible in the proposal's page" expect(page).to have_link("the proposal's page", href: proposal_path(proposal, - anchor: 'comments')) + anchor: "comments")) end scenario "Message about receivers (Disctinct Followers and Voters)" do @@ -147,7 +147,7 @@ feature 'Proposal Notifications' do expect(page).to have_content "This message will be sent to 14 people and it will "\ "be visible in the proposal's page" expect(page).to have_link("the proposal's page", href: proposal_path(proposal, - anchor: 'comments')) + anchor: "comments")) end scenario "Message about receivers (Same Followers and Voters)" do @@ -164,7 +164,7 @@ feature 'Proposal Notifications' do expect(page).to have_content "This message will be sent to 1 people and it will "\ "be visible in the proposal's page" expect(page).to have_link("the proposal's page", href: proposal_path(proposal, - anchor: 'comments')) + anchor: "comments")) end context "Permissions" do @@ -222,8 +222,8 @@ feature 'Proposal Notifications' do visit new_proposal_notification_path(proposal_id: proposal.id) - fill_in 'proposal_notification_title', with: "Thank you for supporting my proposal" - fill_in 'proposal_notification_body', with: "Please share it with others so we can make it happen!" + fill_in "proposal_notification_title", with: "Thank you for supporting my proposal" + fill_in "proposal_notification_body", with: "Please share it with others so we can make it happen!" click_button "Send message" expect(page).to have_content "Your message has been sent correctly." @@ -279,8 +279,8 @@ feature 'Proposal Notifications' do visit new_proposal_notification_path(proposal_id: proposal.id) - fill_in 'proposal_notification_title', with: "Thank you for supporting my proposal" - fill_in 'proposal_notification_body', with: "Please share it with others so we can make it happen!" + fill_in "proposal_notification_title", with: "Thank you for supporting my proposal" + fill_in "proposal_notification_body", with: "Please share it with others so we can make it happen!" click_button "Send message" expect(page).to have_content "Your message has been sent correctly." @@ -329,8 +329,8 @@ feature 'Proposal Notifications' do visit new_proposal_notification_path(proposal_id: proposal.id) - fill_in 'proposal_notification_title', with: "Thank you for supporting my proposal" - fill_in 'proposal_notification_body', with: "Please share it with others so we can make it happen!" + fill_in "proposal_notification_title", with: "Thank you for supporting my proposal" + fill_in "proposal_notification_body", with: "Please share it with others so we can make it happen!" click_button "Send message" expect(page).to have_content "Your message has been sent correctly." diff --git a/spec/features/proposals_spec.rb b/spec/features/proposals_spec.rb index e36d9c6cd..033b80fbc 100644 --- a/spec/features/proposals_spec.rb +++ b/spec/features/proposals_spec.rb @@ -1,52 +1,52 @@ # coding: utf-8 -require 'rails_helper' +require "rails_helper" -feature 'Proposals' do +feature "Proposals" do it_behaves_like "milestoneable", :proposal, "proposal_path" - scenario 'Disabled with a feature flag' do - Setting['feature.proposals'] = nil + scenario "Disabled with a feature flag" do + Setting["feature.proposals"] = nil expect{ visit proposals_path }.to raise_exception(FeatureFlags::FeatureDisabled) - Setting['feature.proposals'] = true + Setting["feature.proposals"] = true end context "Concerns" do - it_behaves_like 'notifiable in-app', Proposal - it_behaves_like 'relationable', Proposal + it_behaves_like "notifiable in-app", Proposal + it_behaves_like "relationable", Proposal end - context 'Index' do + context "Index" do before do - Setting['feature.allow_images'] = true - Setting['feature.featured_proposals'] = true - Setting['featured_proposals_number'] = 3 + Setting["feature.allow_images"] = true + Setting["feature.featured_proposals"] = true + Setting["featured_proposals_number"] = 3 end after do - Setting['feature.allow_images'] = nil + Setting["feature.allow_images"] = nil end - scenario 'Lists featured and regular proposals' do + scenario "Lists featured and regular proposals" do featured_proposals = create_featured_proposals proposals = [create(:proposal), create(:proposal), create(:proposal)] visit proposals_path - expect(page).to have_selector('#proposals .proposal-featured', count: 3) + expect(page).to have_selector("#proposals .proposal-featured", count: 3) featured_proposals.each do |featured_proposal| - within('#featured-proposals') do + within("#featured-proposals") do expect(page).to have_content featured_proposal.title expect(page).to have_css("a[href='#{proposal_path(featured_proposal)}']") end end - expect(page).to have_selector('#proposals .proposal', count: 3) + expect(page).to have_selector("#proposals .proposal", count: 3) proposals.each do |proposal| - within('#proposals') do + within("#proposals") do expect(page).to have_content proposal.title expect(page).to have_content proposal.summary expect(page).to have_css("a[href='#{proposal_path(proposal)}']", text: proposal.title) @@ -54,55 +54,55 @@ feature 'Proposals' do end end - scenario 'Index view mode' do + scenario "Index view mode" do featured_proposals = create_featured_proposals proposals = [create(:proposal), create(:proposal), create(:proposal)] visit proposals_path - click_button 'View mode' + click_button "View mode" - click_link 'List' + click_link "List" proposals.each do |proposal| - within('#proposals') do + within("#proposals") do expect(page).to have_link proposal.title expect(page).not_to have_content proposal.summary end end - click_button 'View mode' + click_button "View mode" - click_link 'Cards' + click_link "Cards" proposals.each do |proposal| - within('#proposals') do + within("#proposals") do expect(page).to have_link proposal.title expect(page).to have_content proposal.summary end end end - scenario 'Pagination' do + scenario "Pagination" do per_page = Kaminari.config.default_per_page (per_page + 5).times { create(:proposal) } visit proposals_path - expect(page).to have_selector('#proposals .proposal', count: per_page) + expect(page).to have_selector("#proposals .proposal", count: per_page) within("ul.pagination") do expect(page).to have_content("1") - expect(page).to have_link('2', href: 'http://www.example.com/proposals?page=2') + expect(page).to have_link("2", href: "http://www.example.com/proposals?page=2") expect(page).not_to have_content("3") click_link "Next", exact: false end - expect(page).to have_selector('#proposals .proposal-featured', count: 3) - expect(page).to have_selector('#proposals .proposal', count: 2) + expect(page).to have_selector("#proposals .proposal-featured", count: 3) + expect(page).to have_selector("#proposals .proposal", count: 2) end - scenario 'Index should show proposal descriptive image only when is defined' do + scenario "Index should show proposal descriptive image only when is defined" do featured_proposals = create_featured_proposals proposal = create(:proposal) proposal_with_image = create(:proposal) @@ -119,7 +119,7 @@ feature 'Proposals' do end end - scenario 'Show' do + scenario "Show" do proposal = create(:proposal) visit proposal_path(proposal) @@ -136,13 +136,13 @@ feature 'Proposals' do expect(page).not_to have_selector ".js-flag-actions" expect(page).not_to have_selector ".js-follow" - 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 context "Show" do - scenario 'When path matches the friendly url' do + scenario "When path matches the friendly url" do proposal = create(:proposal) right_path = proposal_path(proposal) @@ -151,7 +151,7 @@ feature 'Proposals' 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 proposal = create(:proposal) right_path = proposal_path(proposal) @@ -162,18 +162,18 @@ feature 'Proposals' do expect(page).to have_current_path(right_path) end - scenario 'Can access the community' do - Setting['feature.community'] = true + scenario "Can access the community" do + Setting["feature.community"] = true proposal = create(:proposal) visit proposal_path(proposal) expect(page).to have_content "Access the community" - Setting['feature.community'] = false + Setting["feature.community"] = false end - scenario 'Can not access the community' do - Setting['feature.community'] = false + scenario "Can not access the community" do + Setting["feature.community"] = false proposal = create(:proposal) visit proposal_path(proposal) @@ -187,14 +187,14 @@ feature 'Proposals' do proposal = create(:proposal, video_url: "http://www.youtube.com/watch?v=a7UFm6ErMPU") visit proposal_path(proposal) expect(page).to have_selector("div[id='js-embedded-video']") - expect(page.html).to include 'https://www.youtube.com/embed/a7UFm6ErMPU' + expect(page.html).to include "https://www.youtube.com/embed/a7UFm6ErMPU" end scenario "Show Vimeo video" do proposal = create(:proposal, video_url: "https://vimeo.com/7232823") visit proposal_path(proposal) expect(page).to have_selector("div[id='js-embedded-video']") - expect(page.html).to include 'https://player.vimeo.com/video/7232823' + expect(page.html).to include "https://player.vimeo.com/video/7232823" end scenario "Dont show video" do @@ -205,254 +205,254 @@ feature 'Proposals' do end end - scenario 'Social Media Cards' do + scenario "Social Media Cards" do proposal = create(:proposal) visit proposal_path(proposal) - expect(page).to have_css "meta[name='twitter:title'][content=\"#{proposal.title}\"]", visible: false - expect(page).to have_css "meta[property='og:title'][content=\"#{proposal.title}\"]", visible: false + expect(page).to have_css "meta[name='twitter:title'][content=\'#{proposal.title}\']", visible: false + expect(page).to have_css "meta[property='og:title'][content=\'#{proposal.title}\']", visible: false end - scenario 'Create' do + scenario "Create" do author = create(:user) login_as(author) visit new_proposal_path - fill_in 'proposal_title', with: 'Help refugees' - fill_in 'proposal_question', with: '¿Would you like to give assistance to war refugees?' - fill_in 'proposal_summary', with: 'In summary, what we want is...' - fill_in 'proposal_description', with: 'This is very important because...' - fill_in 'proposal_external_url', with: 'http://rescue.org/refugees' - fill_in 'proposal_video_url', with: 'https://www.youtube.com/watch?v=yPQfcG-eimk' - fill_in 'proposal_responsible_name', with: 'Isabel Garcia' - fill_in 'proposal_tag_list', with: 'Refugees, Solidarity' - check 'proposal_terms_of_service' + fill_in "proposal_title", with: "Help refugees" + fill_in "proposal_question", with: "¿Would you like to give assistance to war refugees?" + fill_in "proposal_summary", with: "In summary, what we want is..." + fill_in "proposal_description", with: "This is very important because..." + fill_in "proposal_external_url", with: "http://rescue.org/refugees" + fill_in "proposal_video_url", with: "https://www.youtube.com/watch?v=yPQfcG-eimk" + fill_in "proposal_responsible_name", with: "Isabel Garcia" + fill_in "proposal_tag_list", with: "Refugees, Solidarity" + check "proposal_terms_of_service" - click_button 'Create proposal' + click_button "Create proposal" - expect(page).to have_content 'Proposal created successfully.' - expect(page).to have_content 'Help refugees' - expect(page).not_to have_content 'You can also see more information about improving your campaign' + expect(page).to have_content "Proposal created successfully." + expect(page).to have_content "Help refugees" + expect(page).not_to have_content "You can also see more information about improving your campaign" - click_link 'Not now, go to my proposal' + click_link "Not now, go to my proposal" - expect(page).to have_content 'Help refugees' - expect(page).to have_content '¿Would you like to give assistance to war refugees?' - expect(page).to have_content 'In summary, what we want is...' - expect(page).to have_content 'This is very important because...' - expect(page).to have_content 'http://rescue.org/refugees' - expect(page).to have_content 'https://www.youtube.com/watch?v=yPQfcG-eimk' + expect(page).to have_content "Help refugees" + expect(page).to have_content "¿Would you like to give assistance to war refugees?" + expect(page).to have_content "In summary, what we want is..." + expect(page).to have_content "This is very important because..." + expect(page).to have_content "http://rescue.org/refugees" + expect(page).to have_content "https://www.youtube.com/watch?v=yPQfcG-eimk" expect(page).to have_content author.name - expect(page).to have_content 'Refugees' - expect(page).to have_content 'Solidarity' + expect(page).to have_content "Refugees" + expect(page).to have_content "Solidarity" expect(page).to have_content I18n.l(Proposal.last.created_at.to_date) end - scenario 'Create with proposal improvement info link' do - Setting['proposal_improvement_path'] = '/more-information/proposal-improvement' + scenario "Create with proposal improvement info link" do + Setting["proposal_improvement_path"] = "/more-information/proposal-improvement" author = create(:user) login_as(author) visit new_proposal_path - fill_in 'proposal_title', with: 'Help refugees' - fill_in 'proposal_question', with: '¿Would you like to give assistance to war refugees?' - fill_in 'proposal_summary', with: 'In summary, what we want is...' - fill_in 'proposal_description', with: 'This is very important because...' - fill_in 'proposal_external_url', with: 'http://rescue.org/refugees' - fill_in 'proposal_video_url', with: 'https://www.youtube.com/watch?v=yPQfcG-eimk' - fill_in 'proposal_responsible_name', with: 'Isabel Garcia' - fill_in 'proposal_tag_list', with: 'Refugees, Solidarity' - check 'proposal_terms_of_service' + fill_in "proposal_title", with: "Help refugees" + fill_in "proposal_question", with: "¿Would you like to give assistance to war refugees?" + fill_in "proposal_summary", with: "In summary, what we want is..." + fill_in "proposal_description", with: "This is very important because..." + fill_in "proposal_external_url", with: "http://rescue.org/refugees" + fill_in "proposal_video_url", with: "https://www.youtube.com/watch?v=yPQfcG-eimk" + fill_in "proposal_responsible_name", with: "Isabel Garcia" + fill_in "proposal_tag_list", with: "Refugees, Solidarity" + check "proposal_terms_of_service" - click_button 'Create proposal' + click_button "Create proposal" - expect(page).to have_content 'Proposal created successfully.' - expect(page).to have_content 'Improve your campaign and get more supports' + expect(page).to have_content "Proposal created successfully." + expect(page).to have_content "Improve your campaign and get more supports" - click_link 'Not now, go to my proposal' + click_link "Not now, go to my proposal" - expect(page).to have_content 'Help refugees' + expect(page).to have_content "Help refugees" - Setting['proposal_improvement_path'] = nil + Setting["proposal_improvement_path"] = nil 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_proposal_path - fill_in 'proposal_title', with: 'I am a bot' - fill_in 'proposal_subtitle', with: 'This is the honeypot field' - fill_in 'proposal_question', with: 'This is a question' - fill_in 'proposal_summary', with: 'This is the summary' - fill_in 'proposal_description', with: 'This is the description' - fill_in 'proposal_external_url', with: 'http://google.com/robots.txt' - fill_in 'proposal_responsible_name', with: 'Some other robot' - check 'proposal_terms_of_service' + fill_in "proposal_title", with: "I am a bot" + fill_in "proposal_subtitle", with: "This is the honeypot field" + fill_in "proposal_question", with: "This is a question" + fill_in "proposal_summary", with: "This is the summary" + fill_in "proposal_description", with: "This is the description" + fill_in "proposal_external_url", with: "http://google.com/robots.txt" + fill_in "proposal_responsible_name", with: "Some other robot" + check "proposal_terms_of_service" - click_button 'Create proposal' + click_button "Create proposal" expect(page.status_code).to eq(200) expect(page.html).to be_empty expect(page).to have_current_path(proposals_path) end - scenario 'Create proposal too fast' do + scenario "Create proposal too fast" do allow(InvisibleCaptcha).to receive(:timestamp_threshold).and_return(Float::INFINITY) author = create(:user) login_as(author) visit new_proposal_path - fill_in 'proposal_title', with: 'I am a bot' - fill_in 'proposal_question', with: 'This is a question' - fill_in 'proposal_summary', with: 'This is the summary' - fill_in 'proposal_description', with: 'This is the description' - fill_in 'proposal_external_url', with: 'http://google.com/robots.txt' - fill_in 'proposal_responsible_name', with: 'Some other robot' - check 'proposal_terms_of_service' + fill_in "proposal_title", with: "I am a bot" + fill_in "proposal_question", with: "This is a question" + fill_in "proposal_summary", with: "This is the summary" + fill_in "proposal_description", with: "This is the description" + fill_in "proposal_external_url", with: "http://google.com/robots.txt" + fill_in "proposal_responsible_name", with: "Some other robot" + check "proposal_terms_of_service" - click_button 'Create proposal' + click_button "Create proposal" - 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_proposal_path) end - scenario 'Responsible name is stored for anonymous users' do + scenario "Responsible name is stored for anonymous users" do author = create(:user) login_as(author) visit new_proposal_path - fill_in 'proposal_title', with: 'Help refugees' - fill_in 'proposal_question', with: '¿Would you like to give assistance to war refugees?' - fill_in 'proposal_summary', with: 'In summary, what we want is...' - fill_in 'proposal_description', with: 'This is very important because...' - fill_in 'proposal_external_url', with: 'http://rescue.org/refugees' - fill_in 'proposal_responsible_name', with: 'Isabel Garcia' - fill_in 'proposal_responsible_name', with: 'Isabel Garcia' - check 'proposal_terms_of_service' + fill_in "proposal_title", with: "Help refugees" + fill_in "proposal_question", with: "¿Would you like to give assistance to war refugees?" + fill_in "proposal_summary", with: "In summary, what we want is..." + fill_in "proposal_description", with: "This is very important because..." + fill_in "proposal_external_url", with: "http://rescue.org/refugees" + fill_in "proposal_responsible_name", with: "Isabel Garcia" + fill_in "proposal_responsible_name", with: "Isabel Garcia" + check "proposal_terms_of_service" - click_button 'Create proposal' + click_button "Create proposal" - expect(page).to have_content 'Proposal created successfully.' + expect(page).to have_content "Proposal created successfully." - click_link 'Not now, go to my proposal' + click_link "Not now, go to my proposal" - expect(Proposal.last.responsible_name).to eq('Isabel Garcia') + expect(Proposal.last.responsible_name).to eq("Isabel Garcia") end - scenario 'Responsible name field is not shown for verified users' do + scenario "Responsible name field is not shown for verified users" do author = create(:user, :level_two) login_as(author) visit new_proposal_path - expect(page).not_to have_selector('#proposal_responsible_name') + expect(page).not_to have_selector("#proposal_responsible_name") - fill_in 'proposal_title', with: 'Help refugees' - fill_in 'proposal_question', with: '¿Would you like to give assistance to war refugees?' - fill_in 'proposal_summary', with: 'In summary, what we want is...' - fill_in 'proposal_description', with: 'This is very important because...' - fill_in 'proposal_external_url', with: 'http://rescue.org/refugees' - check 'proposal_terms_of_service' + fill_in "proposal_title", with: "Help refugees" + fill_in "proposal_question", with: "¿Would you like to give assistance to war refugees?" + fill_in "proposal_summary", with: "In summary, what we want is..." + fill_in "proposal_description", with: "This is very important because..." + fill_in "proposal_external_url", with: "http://rescue.org/refugees" + check "proposal_terms_of_service" - click_button 'Create proposal' - expect(page).to have_content 'Proposal created successfully.' + click_button "Create proposal" + expect(page).to have_content "Proposal created successfully." - click_link 'Not now, go to my proposal' + click_link "Not now, go to my proposal" expect(Proposal.last.responsible_name).to eq(author.document_number) end - scenario 'Errors on create' do + scenario "Errors on create" do author = create(:user) login_as(author) visit new_proposal_path - click_button 'Create proposal' + click_button "Create proposal" 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_proposal_path - fill_in 'proposal_title', with: 'Testing an attack' - fill_in 'proposal_question', with: '¿Would you like to give assistance to war refugees?' - fill_in 'proposal_summary', with: 'In summary, what we want is...' - fill_in 'proposal_description', with: '

This is

' - fill_in 'proposal_external_url', with: 'http://rescue.org/refugees' - fill_in 'proposal_responsible_name', with: 'Isabel Garcia' - check 'proposal_terms_of_service' + fill_in "proposal_title", with: "Testing an attack" + fill_in "proposal_question", with: "¿Would you like to give assistance to war refugees?" + fill_in "proposal_summary", with: "In summary, what we want is..." + fill_in "proposal_description", with: "

This is

" + fill_in "proposal_external_url", with: "http://rescue.org/refugees" + fill_in "proposal_responsible_name", with: "Isabel Garcia" + check "proposal_terms_of_service" - click_button 'Create proposal' + click_button "Create proposal" - expect(page).to have_content 'Proposal created successfully.' + expect(page).to have_content "Proposal created successfully." - click_link 'Not now, go to my proposal' + click_link "Not now, go to my proposal" - expect(page).to have_content 'Testing an attack' - expect(page.html).to include '

This is alert("an attack");

' - expect(page.html).not_to include '' - expect(page.html).not_to include '<p>This is' + expect(page).to have_content "Testing an attack" + expect(page.html).to include "

This is alert('an attack');

" + expect(page.html).not_to include "" + 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_proposal_path - fill_in 'proposal_title', with: 'Testing auto link' - fill_in 'proposal_question', with: 'Should I stay or should I go?' - fill_in 'proposal_summary', with: 'In summary, what we want is...' - fill_in 'proposal_description', with: '

This is a link www.example.org

' - fill_in 'proposal_responsible_name', with: 'Isabel Garcia' - check 'proposal_terms_of_service' + fill_in "proposal_title", with: "Testing auto link" + fill_in "proposal_question", with: "Should I stay or should I go?" + fill_in "proposal_summary", with: "In summary, what we want is..." + fill_in "proposal_description", with: "

This is a link www.example.org

" + fill_in "proposal_responsible_name", with: "Isabel Garcia" + check "proposal_terms_of_service" - click_button 'Create proposal' + click_button "Create proposal" - expect(page).to have_content 'Proposal created successfully.' + expect(page).to have_content "Proposal created successfully." - click_link 'Not now, go to my proposal' + click_link "Not now, go to my proposal" - 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 "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 = "
click me http://example.org" login_as(author) visit new_proposal_path - fill_in 'proposal_title', with: 'Testing auto link' - fill_in 'proposal_question', with: 'Should I stay or should I go?' - fill_in 'proposal_summary', with: 'In summary, what we want is...' - fill_in 'proposal_description', with: js_injection_string - fill_in 'proposal_responsible_name', with: 'Isabel Garcia' - check 'proposal_terms_of_service' + fill_in "proposal_title", with: "Testing auto link" + fill_in "proposal_question", with: "Should I stay or should I go?" + fill_in "proposal_summary", with: "In summary, what we want is..." + fill_in "proposal_description", with: js_injection_string + fill_in "proposal_responsible_name", with: "Isabel Garcia" + check "proposal_terms_of_service" - click_button 'Create proposal' + click_button "Create proposal" - expect(page).to have_content 'Proposal created successfully.' + expect(page).to have_content "Proposal created successfully." - click_link 'Not now, go to my proposal' + click_link "Not now, go to my proposal" - 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 "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 "" - click_link 'Edit' + click_link "Edit" expect(page).to have_current_path(edit_proposal_path(Proposal.last)) - expect(page).not_to have_link('click me') + expect(page).not_to have_link("click me") expect(page.html).not_to include "" end - context 'Geozones' do + context "Geozones" do scenario "Default whole city" do author = create(:user) @@ -460,70 +460,70 @@ feature 'Proposals' do visit new_proposal_path - fill_in 'proposal_title', with: 'Help refugees' - fill_in 'proposal_question', with: '¿Would you like to give assistance to war refugees?' - fill_in 'proposal_summary', with: 'In summary, what we want is...' - fill_in 'proposal_description', with: 'This is very important because...' - fill_in 'proposal_external_url', with: 'http://rescue.org/refugees' - fill_in 'proposal_video_url', with: 'https://www.youtube.com/watch?v=yPQfcG-eimk' - fill_in 'proposal_responsible_name', with: 'Isabel Garcia' - check 'proposal_terms_of_service' + fill_in "proposal_title", with: "Help refugees" + fill_in "proposal_question", with: "¿Would you like to give assistance to war refugees?" + fill_in "proposal_summary", with: "In summary, what we want is..." + fill_in "proposal_description", with: "This is very important because..." + fill_in "proposal_external_url", with: "http://rescue.org/refugees" + fill_in "proposal_video_url", with: "https://www.youtube.com/watch?v=yPQfcG-eimk" + fill_in "proposal_responsible_name", with: "Isabel Garcia" + check "proposal_terms_of_service" - click_button 'Create proposal' + click_button "Create proposal" - expect(page).to have_content 'Proposal created successfully.' + expect(page).to have_content "Proposal created successfully." - click_link 'Not now, go to my proposal' + click_link "Not now, go to my proposal" within "#geozone" do - expect(page).to have_content 'All city' + expect(page).to have_content "All city" end end scenario "Specific geozone" do - geozone = create(:geozone, name: 'California') - geozone = create(:geozone, name: 'New York') + geozone = create(:geozone, name: "California") + geozone = create(:geozone, name: "New York") author = create(:user) login_as(author) visit new_proposal_path - fill_in 'proposal_title', with: 'Help refugees' - fill_in 'proposal_question', with: '¿Would you like to give assistance to war refugees?' - fill_in 'proposal_summary', with: 'In summary, what we want is...' - fill_in 'proposal_description', with: 'This is very important because...' - fill_in 'proposal_external_url', with: 'http://rescue.org/refugees' - fill_in 'proposal_video_url', with: 'https://www.youtube.com/watch?v=yPQfcG-eimk' - fill_in 'proposal_responsible_name', with: 'Isabel Garcia' - check 'proposal_terms_of_service' + fill_in "proposal_title", with: "Help refugees" + fill_in "proposal_question", with: "¿Would you like to give assistance to war refugees?" + fill_in "proposal_summary", with: "In summary, what we want is..." + fill_in "proposal_description", with: "This is very important because..." + fill_in "proposal_external_url", with: "http://rescue.org/refugees" + fill_in "proposal_video_url", with: "https://www.youtube.com/watch?v=yPQfcG-eimk" + fill_in "proposal_responsible_name", with: "Isabel Garcia" + check "proposal_terms_of_service" - select('California', from: 'proposal_geozone_id') - click_button 'Create proposal' + select("California", from: "proposal_geozone_id") + click_button "Create proposal" - expect(page).to have_content 'Proposal created successfully.' + expect(page).to have_content "Proposal created successfully." - click_link 'Not now, go to my proposal' + click_link "Not now, go to my proposal" within "#geozone" do - expect(page).to have_content 'California' + expect(page).to have_content "California" end end end - context 'Retired proposals' do - scenario 'Retire' do + context "Retired proposals" do + scenario "Retire" do proposal = create(:proposal) login_as(proposal.author) visit user_path(proposal.author) within("#proposal_#{proposal.id}") do - click_link 'Retire' + click_link "Retire" end expect(page).to have_current_path(retire_form_proposal_path(proposal)) - select 'Duplicated', from: 'proposal_retired_reason' - fill_in 'proposal_retired_explanation', with: 'There are three other better proposals with the same subject' + select "Duplicated", from: "proposal_retired_reason" + fill_in "proposal_retired_explanation", with: "There are three other better proposals with the same subject" click_button "Retire proposal" expect(page).to have_content "Proposal retired" @@ -531,38 +531,38 @@ feature 'Proposals' do visit proposal_path(proposal) expect(page).to have_content proposal.title - expect(page).to have_content 'Proposal retired by the author' - expect(page).to have_content 'Duplicated' - expect(page).to have_content 'There are three other better proposals with the same subject' + expect(page).to have_content "Proposal retired by the author" + expect(page).to have_content "Duplicated" + expect(page).to have_content "There are three other better proposals with the same subject" end - scenario 'Fields are mandatory' do + scenario "Fields are mandatory" do proposal = create(:proposal) login_as(proposal.author) visit retire_form_proposal_path(proposal) - click_button 'Retire proposal' + click_button "Retire proposal" - expect(page).not_to have_content 'Proposal retired' + expect(page).not_to have_content "Proposal retired" expect(page).to have_content "can't be blank", count: 2 end - scenario 'Index do not list retired proposals by default' do + scenario "Index do not list retired proposals by default" do create_featured_proposals not_retired = create(:proposal) retired = create(:proposal, retired_at: Time.current) visit proposals_path - expect(page).to have_selector('#proposals .proposal', count: 1) - within('#proposals') do + expect(page).to have_selector("#proposals .proposal", count: 1) + within("#proposals") do expect(page).to have_content not_retired.title expect(page).not_to have_content retired.title end end - scenario 'Index has a link to retired proposals list' do + scenario "Index has a link to retired proposals list" do create_featured_proposals not_retired = create(:proposal) retired = create(:proposal, retired_at: Time.current) @@ -570,42 +570,42 @@ feature 'Proposals' do visit proposals_path expect(page).not_to have_content retired.title - click_link 'Proposals retired by the author' + click_link "Proposals retired by the author" expect(page).to have_content retired.title expect(page).not_to have_content not_retired.title end - scenario 'Retired proposals index interface elements' do - visit proposals_path(retired: 'all') + scenario "Retired proposals index interface elements" do + visit proposals_path(retired: "all") - expect(page).not_to have_content 'Advanced search' - expect(page).not_to have_content 'Categories' - expect(page).not_to have_content 'Districts' + expect(page).not_to have_content "Advanced search" + expect(page).not_to have_content "Categories" + expect(page).not_to have_content "Districts" end - scenario 'Retired proposals index has links to filter by retired_reason' do - unfeasible = create(:proposal, retired_at: Time.current, retired_reason: 'unfeasible') - duplicated = create(:proposal, retired_at: Time.current, retired_reason: 'duplicated') + scenario "Retired proposals index has links to filter by retired_reason" do + unfeasible = create(:proposal, retired_at: Time.current, retired_reason: "unfeasible") + duplicated = create(:proposal, retired_at: Time.current, retired_reason: "duplicated") - visit proposals_path(retired: 'all') + visit proposals_path(retired: "all") expect(page).to have_content unfeasible.title expect(page).to have_content duplicated.title - expect(page).to have_link 'Duplicated' - expect(page).to have_link 'Underway' - expect(page).to have_link 'Unfeasible' - expect(page).to have_link 'Done' - expect(page).to have_link 'Other' + expect(page).to have_link "Duplicated" + expect(page).to have_link "Underway" + expect(page).to have_link "Unfeasible" + expect(page).to have_link "Done" + expect(page).to have_link "Other" - click_link 'Unfeasible' + click_link "Unfeasible" expect(page).to have_content unfeasible.title expect(page).not_to have_content duplicated.title end 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 proposal = create(:proposal) expect(proposal).to be_editable login_as(create(:user)) @@ -613,10 +613,10 @@ feature 'Proposals' do visit edit_proposal_path(proposal) expect(page).not_to have_current_path(edit_proposal_path(proposal)) expect(page).to have_current_path(root_path) - expect(page).to have_content 'You do not have permission' + expect(page).to have_content "You do not have permission" end - scenario 'Update should not be posible if proposal is not editable' do + scenario "Update should not be posible if proposal is not editable" do proposal = create(:proposal) Setting["max_votes_for_proposal_edit"] = 10 11.times { create(:vote, votable: proposal) } @@ -628,23 +628,23 @@ feature 'Proposals' do expect(page).not_to have_current_path(edit_proposal_path(proposal)) expect(page).to have_current_path(root_path) - expect(page).to have_content 'You do not have permission' + expect(page).to have_content "You do not have permission" Setting["max_votes_for_proposal_edit"] = 1000 end - scenario 'Update should be posible for the author of an editable proposal' do + scenario "Update should be posible for the author of an editable proposal" do proposal = create(:proposal) login_as(proposal.author) visit edit_proposal_path(proposal) expect(page).to have_current_path(edit_proposal_path(proposal)) - fill_in 'proposal_title', with: "End child poverty" - fill_in 'proposal_question', with: '¿Would you like to give assistance to war refugees?' - fill_in 'proposal_summary', with: 'Basically...' - fill_in 'proposal_description', with: "Let's do something to end child poverty" - fill_in 'proposal_external_url', with: 'http://rescue.org/refugees' - fill_in 'proposal_responsible_name', with: 'Isabel Garcia' + fill_in "proposal_title", with: "End child poverty" + fill_in "proposal_question", with: "¿Would you like to give assistance to war refugees?" + fill_in "proposal_summary", with: "Basically..." + fill_in "proposal_description", with: "Let's do something to end child poverty" + fill_in "proposal_external_url", with: "http://rescue.org/refugees" + fill_in "proposal_responsible_name", with: "Isabel Garcia" click_button "Save changes" @@ -654,27 +654,27 @@ feature 'Proposals' 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 proposal = create(:proposal) login_as(proposal.author) visit edit_proposal_path(proposal) - fill_in 'proposal_title', with: "" + fill_in "proposal_title", with: "" click_button "Save changes" expect(page).to have_content error_message end - feature 'Proposal index order filters' do + feature "Proposal index order filters" do - scenario 'Default order is hot_score', :js do + scenario "Default order is hot_score", :js do create_featured_proposals - best_proposal = create(:proposal, title: 'Best proposal') + best_proposal = create(:proposal, title: "Best proposal") best_proposal.update_column(:hot_score, 10) - worst_proposal = create(:proposal, title: 'Worst proposal') + worst_proposal = create(:proposal, title: "Worst proposal") worst_proposal.update_column(:hot_score, 2) - medium_proposal = create(:proposal, title: 'Medium proposal') + medium_proposal = create(:proposal, title: "Medium proposal") medium_proposal.update_column(:hot_score, 5) visit proposals_path @@ -683,162 +683,162 @@ feature 'Proposals' do expect(medium_proposal.title).to appear_before(worst_proposal.title) end - scenario 'Proposals are ordered by confidence_score', :js do + scenario "Proposals are ordered by confidence_score", :js do create_featured_proposals - best_proposal = create(:proposal, title: 'Best proposal') + best_proposal = create(:proposal, title: "Best proposal") best_proposal.update_column(:confidence_score, 10) - worst_proposal = create(:proposal, title: 'Worst proposal') + worst_proposal = create(:proposal, title: "Worst proposal") worst_proposal.update_column(:confidence_score, 2) - medium_proposal = create(:proposal, title: 'Medium proposal') + medium_proposal = create(:proposal, title: "Medium proposal") medium_proposal.update_column(:confidence_score, 5) visit proposals_path - click_link 'highest rated' - expect(page).to have_selector('a.is-active', text: 'highest rated') + click_link "highest rated" + expect(page).to have_selector("a.is-active", text: "highest rated") - within '#proposals' do + within "#proposals" do expect(best_proposal.title).to appear_before(medium_proposal.title) expect(medium_proposal.title).to appear_before(worst_proposal.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 'Proposals are ordered by newest', :js do + scenario "Proposals are ordered by newest", :js do create_featured_proposals - best_proposal = create(:proposal, title: 'Best proposal', created_at: Time.current) - medium_proposal = create(:proposal, title: 'Medium proposal', created_at: Time.current - 1.hour) - worst_proposal = create(:proposal, title: 'Worst proposal', created_at: Time.current - 1.day) + best_proposal = create(:proposal, title: "Best proposal", created_at: Time.current) + medium_proposal = create(:proposal, title: "Medium proposal", created_at: Time.current - 1.hour) + worst_proposal = create(:proposal, title: "Worst proposal", created_at: Time.current - 1.day) visit proposals_path - click_link 'newest' - expect(page).to have_selector('a.is-active', text: 'newest') + click_link "newest" + expect(page).to have_selector("a.is-active", text: "newest") - within '#proposals' do + within "#proposals" do expect(best_proposal.title).to appear_before(medium_proposal.title) expect(medium_proposal.title).to appear_before(worst_proposal.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_proposal) { create(:proposal, title: 'Best', cached_votes_up: 10, tag_list: 'Sport') } - let!(:medium_proposal) { create(:proposal, title: 'Medium', cached_votes_up: 5, tag_list: 'Sport') } - let!(:worst_proposal) { create(:proposal, title: 'Worst', cached_votes_up: 1, tag_list: 'Sport') } + let!(:best_proposal) { create(:proposal, title: "Best", cached_votes_up: 10, tag_list: "Sport") } + let!(:medium_proposal) { create(:proposal, title: "Medium", cached_votes_up: 5, tag_list: "Sport") } + let!(:worst_proposal) { create(:proposal, title: "Worst", cached_votes_up: 1, tag_list: "Sport") } before do - Setting['feature.user.recommendations'] = true - Setting['feature.user.recommendations_on_proposals'] = true + Setting["feature.user.recommendations"] = true + Setting["feature.user.recommendations_on_proposals"] = true end after do - Setting['feature.user.recommendations'] = nil - Setting['feature.user.recommendations_on_proposals'] = nil + Setting["feature.user.recommendations"] = nil + Setting["feature.user.recommendations_on_proposals"] = nil end scenario "can't be sorted if there's no logged user" do visit proposals_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 proposals_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 proposals_path - click_link 'recommendations' + click_link "recommendations" - expect(page).to have_content 'There are not proposals related to your interests' + expect(page).to have_content "There are not proposals 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 proposals_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 proposals_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 '#proposals-list' do + within "#proposals-list" do expect(best_proposal.title).to appear_before(medium_proposal.title) expect(medium_proposal.title).to appear_before(worst_proposal.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_proposals: false) - proposal = create(:proposal, tag_list: 'Sport') + proposal = create(:proposal, tag_list: "Sport") create(:follow, followable: proposal, user: user) login_as(user) visit proposals_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 proposals_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 proposals 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 proposals are now disabled for this account") user.reload @@ -850,14 +850,14 @@ feature 'Proposals' do end end - feature 'Archived proposals' do + feature "Archived proposals" do - scenario 'show on archived tab' do + scenario "show on archived tab" do create_featured_proposals archived_proposals = create_archived_proposals visit proposals_path - click_link 'archived' + click_link "archived" within("#proposals-list") do archived_proposals.each do |proposal| @@ -866,7 +866,7 @@ feature 'Proposals' do end end - scenario 'do not show in other index tabs' do + scenario "do not show in other index tabs" do create_featured_proposals archived_proposal = create(:proposal, :archived) @@ -886,11 +886,11 @@ feature 'Proposals' do end end - scenario 'do not show support buttons in index' do + scenario "do not show support buttons in index" do create_featured_proposals archived_proposals = create_archived_proposals - visit proposals_path(order: 'archival_date') + visit proposals_path(order: "archival_date") within("#proposals-list") do archived_proposals.each do |proposal| @@ -901,14 +901,14 @@ feature 'Proposals' do end end - scenario 'do not show support buttons in show' do + scenario "do not show support buttons in show" do archived_proposal = create(:proposal, :archived) visit proposal_path(archived_proposal) expect(page).to have_content "This proposal has been archived and can't collect supports" end - scenario 'do not show in featured proposals section' do + scenario "do not show in featured proposals section" do featured_proposal = create(:proposal, :with_confidence_score, cached_votes_up: 100) archived_proposal = create(:proposal, :archived, :with_confidence_score, cached_votes_up: 10000) @@ -941,7 +941,7 @@ feature 'Proposals' do create(:proposal, :archived, title: "Some votes").update_column(:confidence_score, 25) visit proposals_path - click_link 'archived' + click_link "archived" within("#proposals-list") do expect(all(".proposal")[0].text).to match "Most voted" @@ -956,7 +956,7 @@ feature 'Proposals' do context "Basic search" do - scenario 'Search by text' do + scenario "Search by text" do proposal1 = create(:proposal, title: "Get Schwifty") proposal2 = create(:proposal, title: "Schwifty Hello") proposal3 = create(:proposal, title: "Do not show me") @@ -969,7 +969,7 @@ feature 'Proposals' do end within("#proposals") do - expect(page).to have_css('.proposal', count: 2) + expect(page).to have_css(".proposal", count: 2) expect(page).to have_content(proposal1.title) expect(page).to have_content(proposal2.title) @@ -977,7 +977,7 @@ feature 'Proposals' do end end - scenario 'Search by proposal code' do + scenario "Search by proposal code" do proposal1 = create(:proposal, title: "Get Schwifty") proposal2 = create(:proposal, title: "Schwifty Hello") @@ -989,7 +989,7 @@ feature 'Proposals' do end within("#proposals") do - expect(page).to have_css('.proposal', count: 1) + expect(page).to have_css(".proposal", count: 1) expect(page).to have_content(proposal1.title) expect(page).not_to have_content(proposal2.title) @@ -1045,7 +1045,7 @@ feature 'Proposals' do visit proposals_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 citizen proposals") @@ -1068,7 +1068,7 @@ feature 'Proposals' do visit proposals_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 citizen proposals") @@ -1091,7 +1091,7 @@ feature 'Proposals' do visit proposals_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 citizen proposals") @@ -1114,7 +1114,7 @@ feature 'Proposals' do visit proposals_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 citizen proposals") @@ -1137,7 +1137,7 @@ feature 'Proposals' do visit proposals_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 citizen proposals") @@ -1293,7 +1293,7 @@ feature 'Proposals' 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" @@ -1310,7 +1310,7 @@ feature 'Proposals' 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" @@ -1319,8 +1319,8 @@ feature 'Proposals' do 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 @@ -1329,16 +1329,16 @@ feature 'Proposals' 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" expect(page).to have_content("citizen proposals cannot be found") 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 @@ -1372,7 +1372,7 @@ feature 'Proposals' do visit proposals_path fill_in "search", with: "Show what you got" click_button "Search" - click_link 'newest' + click_link "newest" expect(page).to have_selector("a.is-active", text: "newest") within("#proposals") do @@ -1384,8 +1384,8 @@ feature 'Proposals' do end scenario "Reorder by recommendations results maintaing search" do - Setting['feature.user.recommendations'] = true - Setting['feature.user.recommendations_for_proposals'] = true + Setting["feature.user.recommendations"] = true + Setting["feature.user.recommendations_for_proposals"] = true user = create(:user, recommended_proposals: true) login_as(user) @@ -1400,7 +1400,7 @@ feature 'Proposals' do visit proposals_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("#proposals") do @@ -1410,11 +1410,11 @@ feature 'Proposals' do expect(page).not_to have_content "Do not display" end - Setting['feature.user.recommendations'] = nil - Setting['feature.user.recommendations_for_proposals'] = nil + Setting["feature.user.recommendations"] = nil + Setting["feature.user.recommendations_for_proposals"] = nil end - scenario 'After a search do not show featured proposals' do + scenario "After a search do not show featured proposals" do featured_proposals = create_featured_proposals proposal = create(:proposal, title: "Abcdefghi") @@ -1424,13 +1424,13 @@ feature 'Proposals' do click_button "Search" end - expect(page).not_to have_selector('#proposals .proposal-featured') - expect(page).not_to have_selector('#featured-proposals') + expect(page).not_to have_selector("#proposals .proposal-featured") + expect(page).not_to have_selector("#featured-proposals") end end - scenario 'Conflictive' do + scenario "Conflictive" do good_proposal = create(:proposal) conflictive_proposal = create(:proposal, :conflictive) @@ -1476,7 +1476,7 @@ feature 'Proposals' do expect(Flag.flagged?(user, proposal)).not_to be end - scenario 'Flagging/Unflagging AJAX', :js do + scenario "Flagging/Unflagging AJAX", :js do user = create(:user) proposal = create(:proposal) @@ -1552,21 +1552,21 @@ feature 'Proposals' do "proposal_path", { } - scenario 'Erased author' do + scenario "Erased author" do user = create(:user) proposal = create(:proposal, author: user) user.erase visit proposals_path - expect(page).to have_content('User deleted') + expect(page).to have_content("User deleted") visit proposal_path(proposal) - expect(page).to have_content('User deleted') + expect(page).to have_content("User deleted") create_featured_proposals visit proposals_path - expect(page).to have_content('User deleted') + expect(page).to have_content("User deleted") end context "Filter" do @@ -1592,7 +1592,7 @@ feature 'Proposals' do end within("#proposals") do - expect(page).to have_css('.proposal', count: 2) + expect(page).to have_css(".proposal", count: 2) expect(page).to have_content(@proposal1.title) expect(page).to have_content(@proposal2.title) expect(page).not_to have_content(@proposal3.title) @@ -1607,7 +1607,7 @@ feature 'Proposals' do click_link "California" end within("#proposals") do - expect(page).to have_css('.proposal', count: 2) + expect(page).to have_css(".proposal", count: 2) expect(page).to have_content(@proposal1.title) expect(page).to have_content(@proposal2.title) expect(page).not_to have_content(@proposal3.title) @@ -1622,7 +1622,7 @@ feature 'Proposals' do end within("#proposals") do - expect(page).to have_css('.proposal', count: 2) + expect(page).to have_css(".proposal", count: 2) expect(page).to have_content(@proposal1.title) expect(page).to have_content(@proposal2.title) expect(page).not_to have_content(@proposal3.title) @@ -1632,41 +1632,41 @@ feature 'Proposals' do end end - context 'Suggesting proposals' do - scenario 'Show up to 5 suggestions', :js do + context "Suggesting proposals" do + scenario "Show up to 5 suggestions", :js do author = create(:user) login_as(author) - create(:proposal, title: 'First proposal, has search term') - create(:proposal, title: 'Second title') - create(:proposal, title: 'Third proposal, has search term') - create(:proposal, title: 'Fourth proposal, has search term') - create(:proposal, title: 'Fifth proposal, has search term') - create(:proposal, title: 'Sixth proposal, has search term') - create(:proposal, title: 'Seventh proposal, has search term') + create(:proposal, title: "First proposal, has search term") + create(:proposal, title: "Second title") + create(:proposal, title: "Third proposal, has search term") + create(:proposal, title: "Fourth proposal, has search term") + create(:proposal, title: "Fifth proposal, has search term") + create(:proposal, title: "Sixth proposal, has search term") + create(:proposal, title: "Seventh proposal, has search term") visit new_proposal_path - fill_in 'proposal_title', with: 'search' + fill_in "proposal_title", with: "search" check "proposal_terms_of_service" - within('div#js-suggest') do + within("div#js-suggest") do expect(page).to have_content "You are seeing 5 of 6 proposals containing the term 'search'" end end - scenario 'No found suggestions', :js do + scenario "No found suggestions", :js do author = create(:user) login_as(author) - create(:proposal, title: 'First proposal').update_column(:confidence_score, 10) - create(:proposal, title: 'Second proposal').update_column(:confidence_score, 8) + create(:proposal, title: "First proposal").update_column(:confidence_score, 10) + create(:proposal, title: "Second proposal").update_column(:confidence_score, 8) visit new_proposal_path - fill_in 'proposal_title', with: 'debate' + fill_in "proposal_title", with: "debate" check "proposal_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 @@ -1674,13 +1674,13 @@ feature 'Proposals' do context "Summary" do scenario "Displays proposals grouped by category" do - create(:tag, :category, name: 'Culture') - create(:tag, :category, name: 'Social Services') + create(:tag, :category, name: "Culture") + create(:tag, :category, name: "Social Services") - 3.times { create(:proposal, tag_list: 'Culture') } - 3.times { create(:proposal, tag_list: 'Social Services') } + 3.times { create(:proposal, tag_list: "Culture") } + 3.times { create(:proposal, tag_list: "Social Services") } - create(:proposal, tag_list: 'Random') + create(:proposal, tag_list: "Random") visit proposals_path click_link "The most supported proposals by category" @@ -1697,8 +1697,8 @@ feature 'Proposals' do end scenario "Displays proposals grouped by district" do - california = create(:geozone, name: 'California') - new_york = create(:geozone, name: 'New York') + california = create(:geozone, name: "California") + new_york = create(:geozone, name: "New York") 3.times { create(:proposal, geozone: california) } 3.times { create(:proposal, geozone: new_york) } @@ -1718,8 +1718,8 @@ feature 'Proposals' do end scenario "Displays a maximum of 3 proposals per category" do - create(:tag, :category, name: 'culture') - 4.times { create(:proposal, tag_list: 'culture') } + create(:tag, :category, name: "culture") + 4.times { create(:proposal, tag_list: "culture") } visit summary_proposals_path @@ -1727,12 +1727,12 @@ feature 'Proposals' do end scenario "Orders proposals by votes" do - create(:tag, :category, name: 'culture') - best_proposal = create(:proposal, title: 'Best', tag_list: 'culture') + create(:tag, :category, name: "culture") + best_proposal = create(:proposal, title: "Best", tag_list: "culture") best_proposal.update_column(:confidence_score, 10) - worst_proposal = create(:proposal, title: 'Worst', tag_list: 'culture') + worst_proposal = create(:proposal, title: "Worst", tag_list: "culture") worst_proposal.update_column(:confidence_score, 2) - medium_proposal = create(:proposal, title: 'Medium', tag_list: 'culture') + medium_proposal = create(:proposal, title: "Medium", tag_list: "culture") medium_proposal.update_column(:confidence_score, 5) visit summary_proposals_path @@ -1742,15 +1742,15 @@ feature 'Proposals' do end scenario "Displays proposals from last week" do - create(:tag, :category, name: 'culture') - proposal1 = create(:proposal, tag_list: 'culture', created_at: 1.day.ago) - proposal2 = create(:proposal, tag_list: 'culture', created_at: 5.days.ago) - proposal3 = create(:proposal, tag_list: 'culture', created_at: 8.days.ago) + create(:tag, :category, name: "culture") + proposal1 = create(:proposal, tag_list: "culture", created_at: 1.day.ago) + proposal2 = create(:proposal, tag_list: "culture", created_at: 5.days.ago) + proposal3 = create(:proposal, tag_list: "culture", created_at: 8.days.ago) visit summary_proposals_path within("#proposals") do - expect(page).to have_css('.proposal', count: 2) + expect(page).to have_css(".proposal", count: 2) expect(page).to have_content(proposal1.title) expect(page).to have_content(proposal2.title) @@ -1762,9 +1762,9 @@ feature 'Proposals' do end -feature 'Successful proposals' do +feature "Successful proposals" do - scenario 'Successful proposals do not show support buttons in index' do + scenario "Successful proposals do not show support buttons in index" do successful_proposals = create_successful_proposals visit proposals_path @@ -1777,7 +1777,7 @@ feature 'Successful proposals' do end end - scenario 'Successful proposals do not show support buttons in show' do + scenario "Successful proposals do not show support buttons in show" do successful_proposals = create_successful_proposals successful_proposals.each do |proposal| @@ -1789,7 +1789,7 @@ feature 'Successful proposals' do end end - scenario 'Successful proposals do not show create question button in index' do + scenario "Successful proposals do not show create question button in index" do successful_proposals = create_successful_proposals admin = create(:administrator) @@ -1804,7 +1804,7 @@ feature 'Successful proposals' do end end - scenario 'Successful proposals do not show create question button in show' do + scenario "Successful proposals do not show create question button in show" do successful_proposals = create_successful_proposals admin = create(:administrator) @@ -1821,7 +1821,7 @@ feature 'Successful proposals' do context "Skip user verification" do before do - Setting["feature.user.skip_verification"] = 'true' + Setting["feature.user.skip_verification"] = "true" end after do @@ -1834,24 +1834,24 @@ feature 'Successful proposals' do visit proposals_path - within('aside') do - click_link 'Create a proposal' + within("aside") do + click_link "Create a proposal" end expect(current_path).to eq(new_proposal_path) - fill_in 'proposal_title', with: 'Help refugees' - fill_in 'proposal_summary', with: 'In summary what we want is...' - fill_in 'proposal_question', with: 'Would you like to?' - fill_in 'proposal_description', with: 'This is very important because...' - fill_in 'proposal_external_url', with: 'http://rescue.org/refugees' - fill_in 'proposal_video_url', with: 'https://www.youtube.com/watch?v=yPQfcG-eimk' - fill_in 'proposal_tag_list', with: 'Refugees, Solidarity' - check 'proposal_terms_of_service' + fill_in "proposal_title", with: "Help refugees" + fill_in "proposal_summary", with: "In summary what we want is..." + fill_in "proposal_question", with: "Would you like to?" + fill_in "proposal_description", with: "This is very important because..." + fill_in "proposal_external_url", with: "http://rescue.org/refugees" + fill_in "proposal_video_url", with: "https://www.youtube.com/watch?v=yPQfcG-eimk" + fill_in "proposal_tag_list", with: "Refugees, Solidarity" + check "proposal_terms_of_service" - click_button 'Create proposal' + click_button "Create proposal" - expect(page).to have_content 'Proposal created successfully.' + expect(page).to have_content "Proposal created successfully." end end end diff --git a/spec/features/registration_form_spec.rb b/spec/features/registration_form_spec.rb index 8210e5c48..b7c0a6385 100644 --- a/spec/features/registration_form_spec.rb +++ b/spec/features/registration_form_spec.rb @@ -1,40 +1,40 @@ -require 'rails_helper' +require "rails_helper" -feature 'Registration form' do +feature "Registration form" do - scenario 'username is not available', :js do + scenario "username is not available", :js do user = create(:user) visit new_user_registration_path expect(page).not_to have_content I18n.t("devise_views.users.registrations.new.username_is_not_available") fill_in "user_username", with: user.username - check 'user_terms_of_service' + check "user_terms_of_service" expect(page).to have_content I18n.t("devise_views.users.registrations.new.username_is_not_available") end - scenario 'username is available', :js do + scenario "username is available", :js do visit new_user_registration_path expect(page).not_to have_content I18n.t("devise_views.users.registrations.new.username_is_available") fill_in "user_username", with: "available username" - check 'user_terms_of_service' + check "user_terms_of_service" expect(page).to have_content I18n.t("devise_views.users.registrations.new.username_is_available") end - scenario 'do not save blank redeemable codes' do - visit new_user_registration_path(use_redeemable_code: 'true') + scenario "do not save blank redeemable codes" do + visit new_user_registration_path(use_redeemable_code: "true") - fill_in 'user_username', with: "NewUserWithCode77" - fill_in 'user_email', with: "new@consul.dev" - fill_in 'user_password', with: "password" - fill_in 'user_password_confirmation', with: "password" - fill_in 'user_redeemable_code', with: " " - check 'user_terms_of_service' + fill_in "user_username", with: "NewUserWithCode77" + fill_in "user_email", with: "new@consul.dev" + fill_in "user_password", with: "password" + fill_in "user_password_confirmation", with: "password" + fill_in "user_redeemable_code", with: " " + check "user_terms_of_service" - click_button 'Register' + click_button "Register" expect(page).to have_content "Thank you for registering" @@ -43,37 +43,37 @@ feature 'Registration form' do expect(new_user.redeemable_code).to be_nil end - scenario 'Create with invisible_captcha honeypot field' do + scenario "Create with invisible_captcha honeypot field" do visit new_user_registration_path - fill_in 'user_username', with: "robot" - fill_in 'user_address', with: 'This is the honeypot field' - fill_in 'user_email', with: 'robot@robot.com' - fill_in 'user_password', with: 'destroyallhumans' - fill_in 'user_password_confirmation', with: 'destroyallhumans' - check 'user_terms_of_service' + fill_in "user_username", with: "robot" + fill_in "user_address", with: "This is the honeypot field" + fill_in "user_email", with: "robot@robot.com" + fill_in "user_password", with: "destroyallhumans" + fill_in "user_password_confirmation", with: "destroyallhumans" + check "user_terms_of_service" - click_button 'Register' + click_button "Register" expect(page.status_code).to eq(200) expect(page.html).to be_empty expect(page).to have_current_path(user_registration_path) end - scenario 'Create organization too fast' do + scenario "Create organization too fast" do allow(InvisibleCaptcha).to receive(:timestamp_threshold).and_return(Float::INFINITY) visit new_user_registration_path - fill_in 'user_username', with: "robot" - fill_in 'user_address', with: 'This is the honeypot field' - fill_in 'user_email', with: 'robot@robot.com' - fill_in 'user_password', with: 'destroyallhumans' - fill_in 'user_password_confirmation', with: 'destroyallhumans' - check 'user_terms_of_service' + fill_in "user_username", with: "robot" + fill_in "user_address", with: "This is the honeypot field" + fill_in "user_email", with: "robot@robot.com" + fill_in "user_password", with: "destroyallhumans" + fill_in "user_password_confirmation", with: "destroyallhumans" + check "user_terms_of_service" - click_button 'Register' + click_button "Register" - 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_user_registration_path) end diff --git a/spec/features/sessions_spec.rb b/spec/features/sessions_spec.rb index c5b098a25..968dd6a6e 100644 --- a/spec/features/sessions_spec.rb +++ b/spec/features/sessions_spec.rb @@ -1,8 +1,8 @@ -require 'rails_helper' +require "rails_helper" -feature 'Sessions' do +feature "Sessions" do - scenario 'Staying in the same page after doing login/logout' do + scenario "Staying in the same page after doing login/logout" do user = create(:user, sign_in_count: 10) debate = create(:debate) @@ -10,12 +10,12 @@ feature 'Sessions' do login_through_form_as(user) - expect(page).to have_content('You have been signed in successfully') + expect(page).to have_content("You have been signed in successfully") expect(page).to have_current_path(debate_path(debate)) - click_link 'Sign out' + click_link "Sign out" - expect(page).to have_content('You have been signed out successfully') + expect(page).to have_content("You have been signed out successfully") expect(page).to have_current_path(debate_path(debate)) end diff --git a/spec/features/site_customization/content_blocks_spec.rb b/spec/features/site_customization/content_blocks_spec.rb index ee215dd0f..3919ee429 100644 --- a/spec/features/site_customization/content_blocks_spec.rb +++ b/spec/features/site_customization/content_blocks_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" feature "Custom content blocks" do scenario "top links" do diff --git a/spec/features/site_customization/custom_pages_spec.rb b/spec/features/site_customization/custom_pages_spec.rb index b3b478698..0c659ab2b 100644 --- a/spec/features/site_customization/custom_pages_spec.rb +++ b/spec/features/site_customization/custom_pages_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" feature "Custom Pages" do context "Override existing page" do diff --git a/spec/features/social_media_meta_tags_spec.rb b/spec/features/social_media_meta_tags_spec.rb index 0eb1d30f6..b002113a6 100644 --- a/spec/features/social_media_meta_tags_spec.rb +++ b/spec/features/social_media_meta_tags_spec.rb @@ -1,39 +1,39 @@ -require 'rails_helper' +require "rails_helper" -feature 'Social media meta tags' do +feature "Social media meta tags" do - context 'Setting social media meta tags' do + context "Setting social media meta tags" do - let(:meta_keywords) { 'citizen, participation, open government' } - let(:meta_title) { 'CONSUL' } - let(:meta_description) { 'Citizen participation tool for an open, '\ - 'transparent and democratic government.' } - let(:twitter_handle) { '@consul_test' } - let(:url) { 'http://consul.dev' } - let(:facebook_handle) { 'consultest' } - let(:org_name) { 'CONSUL TEST' } + let(:meta_keywords) { "citizen, participation, open government" } + let(:meta_title) { "CONSUL" } + let(:meta_description) { "Citizen participation tool for an open, "\ + "transparent and democratic government." } + let(:twitter_handle) { "@consul_test" } + let(:url) { "http://consul.dev" } + let(:facebook_handle) { "consultest" } + let(:org_name) { "CONSUL TEST" } before do - Setting['meta_keywords'] = meta_keywords - Setting['meta_title'] = meta_title - Setting['meta_description'] = meta_description - Setting['twitter_handle'] = twitter_handle - Setting['url'] = url - Setting['facebook_handle'] = facebook_handle - Setting['org_name'] = org_name + Setting["meta_keywords"] = meta_keywords + Setting["meta_title"] = meta_title + Setting["meta_description"] = meta_description + Setting["twitter_handle"] = twitter_handle + Setting["url"] = url + Setting["facebook_handle"] = facebook_handle + Setting["org_name"] = org_name end after do - Setting['meta_keywords'] = nil - Setting['meta_title'] = nil - Setting['meta_description'] = nil - Setting['twitter_handle'] = nil - Setting['url'] = 'http://example.com' - Setting['facebook_handle'] = nil - Setting['org_name'] = 'CONSUL' + Setting["meta_keywords"] = nil + Setting["meta_title"] = nil + Setting["meta_description"] = nil + Setting["twitter_handle"] = nil + Setting["url"] = "http://example.com" + Setting["facebook_handle"] = nil + Setting["org_name"] = "CONSUL" end - scenario 'Social media meta tags partial render settings content' do + scenario "Social media meta tags partial render settings content" do visit root_path expect(page).to have_meta "keywords", with: meta_keywords @@ -41,14 +41,14 @@ feature 'Social media meta tags' do expect(page).to have_meta "twitter:title", with: meta_title expect(page).to have_meta "twitter:description", with: meta_description expect(page).to have_meta "twitter:image", - with:'http://www.example.com/social_media_icon_twitter.png' + with:"http://www.example.com/social_media_icon_twitter.png" expect(page).to have_property "og:title", with: meta_title expect(page).to have_property "article:publisher", with: url - expect(page).to have_property "article:author", with: 'https://www.facebook.com/' + + expect(page).to have_property "article:author", with: "https://www.facebook.com/" + facebook_handle - expect(page).to have_property "og:url", with: 'http://www.example.com/' - expect(page).to have_property "og:image", with: 'http://www.example.com/social_media_icon.png' + expect(page).to have_property "og:url", with: "http://www.example.com/" + expect(page).to have_property "og:image", with: "http://www.example.com/social_media_icon.png" expect(page).to have_property "og:site_name", with: org_name expect(page).to have_property "og:description", with: meta_description end diff --git a/spec/features/stats_spec.rb b/spec/features/stats_spec.rb index 89a31ef14..f14efea9a 100644 --- a/spec/features/stats_spec.rb +++ b/spec/features/stats_spec.rb @@ -1,10 +1,10 @@ -require 'rails_helper' +require "rails_helper" -feature 'Stats' do +feature "Stats" do - 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) } @@ -18,7 +18,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) @@ -36,7 +36,7 @@ feature 'Stats' do expect(page).to have_content "Total votes 6" end - scenario 'Users' do + scenario "Users" do 1.times { create(:user, :level_three) } 2.times { create(:user, :level_two) } 2.times { create(:user) } diff --git a/spec/features/tags/budget_investments_spec.rb b/spec/features/tags/budget_investments_spec.rb index 9994a5425..940c98c67 100644 --- a/spec/features/tags/budget_investments_spec.rb +++ b/spec/features/tags/budget_investments_spec.rb @@ -1,17 +1,17 @@ -require 'rails_helper' +require "rails_helper" -feature 'Tags' do +feature "Tags" do - let(:author) { create(:user, :level_two, username: 'Isabel') } + let(:author) { create(:user, :level_two, username: "Isabel") } let(:budget) { create(:budget, name: "Big Budget") } let(:group) { create(:budget_group, name: "Health", budget: budget) } let!(:heading) { create(:budget_heading, name: "More hospitals", - group: group, latitude: '40.416775', longitude: '-3.703790') } - let!(:tag_medio_ambiente) { create(:tag, :category, name: 'Medio Ambiente') } - let!(:tag_economia) { create(:tag, :category, name: 'Economía') } + group: group, latitude: "40.416775", longitude: "-3.703790") } + let!(:tag_medio_ambiente) { create(:tag, :category, name: "Medio Ambiente") } + let!(:tag_economia) { create(:tag, :category, name: "Economía") } let(:admin) { create(:administrator).user } - scenario 'Index' do + scenario "Index" do earth = create(:budget_investment, heading: heading, tag_list: tag_medio_ambiente.name) money = create(:budget_investment, heading: heading, tag_list: tag_economia.name) @@ -26,33 +26,33 @@ feature 'Tags' do end end - scenario 'Index shows 3 tags with no plus link' do + scenario "Index shows 3 tags with no plus link" do tag_list = ["Medio Ambiente", "Corrupción", "Fiestas populares"] create :budget_investment, heading: heading, tag_list: tag_list visit budget_investments_path(budget, heading_id: heading.id) - within('.budget-investment .tags') do + within(".budget-investment .tags") do tag_list.each do |tag| expect(page).to have_content tag end - expect(page).not_to have_content '+' + expect(page).not_to have_content "+" end end - scenario 'Index shows up to 5 tags per proposal' do + scenario "Index shows up to 5 tags per proposal" do create_featured_proposals tag_list = ["Hacienda", "Economía", "Medio Ambiente", "Corrupción", "Fiestas populares", "Prensa"] create :budget_investment, heading: heading, tag_list: tag_list visit budget_investments_path(budget, heading_id: heading.id) - within('.budget-investment .tags') do - expect(page).to have_content '1+' + within(".budget-investment .tags") do + expect(page).to have_content "1+" end end - scenario 'Show' do + scenario "Show" do investment = create(:budget_investment, heading: heading, tag_list: "#{tag_medio_ambiente.name}, #{tag_economia.name}") visit budget_investment_path(budget, investment) @@ -61,39 +61,39 @@ feature 'Tags' do expect(page).to have_content(tag_economia.name) end - scenario 'Create with custom tags' do + scenario "Create with custom tags" 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 skyscraper' - fill_in 'budget_investment_description', with: 'I want to live in a high tower over the clouds' - check 'budget_investment_terms_of_service' + select heading.name, from: "budget_investment_heading_id" + fill_in "budget_investment_title", with: "Build a skyscraper" + fill_in "budget_investment_description", with: "I want to live in a high tower over the clouds" + check "budget_investment_terms_of_service" - fill_in 'budget_investment_tag_list', with: "#{tag_medio_ambiente.name}, #{tag_economia.name}" + fill_in "budget_investment_tag_list", with: "#{tag_medio_ambiente.name}, #{tag_economia.name}" - click_button 'Create Investment' + click_button "Create Investment" - expect(page).to have_content 'Investment created successfully.' + expect(page).to have_content "Investment created successfully." expect(page).to have_content tag_economia.name expect(page).to have_content tag_medio_ambiente.name end - scenario 'Category with category tags', :js do + scenario "Category with category tags", :js 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 skyscraper' - fill_in_ckeditor 'budget_investment_description', with: 'If I had a gym near my place I could go do Zumba' - check 'budget_investment_terms_of_service' + select heading.name, from: "budget_investment_heading_id" + fill_in "budget_investment_title", with: "Build a skyscraper" + fill_in_ckeditor "budget_investment_description", with: "If I had a gym near my place I could go do Zumba" + check "budget_investment_terms_of_service" - find('.js-add-tag-link', text: tag_economia.name).click - click_button 'Create Investment' + find(".js-add-tag-link", text: tag_economia.name).click + click_button "Create Investment" - expect(page).to have_content 'Investment created successfully.' + expect(page).to have_content "Investment created successfully." within "#tags_budget_investment_#{Budget::Investment.last.id}" do expect(page).to have_content tag_economia.name @@ -104,90 +104,90 @@ feature 'Tags' do scenario "Turbolinks sanity check from budget's show", :js do login_as(author) - education = create(:tag, name: 'Education', kind: 'category') - health = create(:tag, name: 'Health', kind: 'category') + education = create(:tag, name: "Education", kind: "category") + health = create(:tag, name: "Health", kind: "category") visit budget_path(budget) click_link "Create a budget investment" - select heading.name, from: 'budget_investment_heading_id' - fill_in 'budget_investment_title', with: 'Build a skyscraper' - fill_in_ckeditor 'budget_investment_description', with: 'If I had a gym near my place I could go do Zumba' - check 'budget_investment_terms_of_service' + select heading.name, from: "budget_investment_heading_id" + fill_in "budget_investment_title", with: "Build a skyscraper" + fill_in_ckeditor "budget_investment_description", with: "If I had a gym near my place I could go do Zumba" + check "budget_investment_terms_of_service" - find('.js-add-tag-link', text: 'Education').click - click_button 'Create Investment' + find(".js-add-tag-link", text: "Education").click + click_button "Create Investment" - expect(page).to have_content 'Investment created successfully.' + expect(page).to have_content "Investment created successfully." within "#tags_budget_investment_#{Budget::Investment.last.id}" do - expect(page).to have_content 'Education' - expect(page).not_to have_content 'Health' + expect(page).to have_content "Education" + expect(page).not_to have_content "Health" end end scenario "Turbolinks sanity check from budget heading's show", :js do login_as(author) - education = create(:tag, name: 'Education', kind: 'category') - health = create(:tag, name: 'Health', kind: 'category') + education = create(:tag, name: "Education", kind: "category") + health = create(:tag, name: "Health", kind: "category") visit budget_investments_path(budget, heading_id: heading.id) click_link "Create a budget investment" - select heading.name, from: 'budget_investment_heading_id' - fill_in 'budget_investment_title', with: 'Build a skyscraper' - fill_in_ckeditor 'budget_investment_description', with: 'If I had a gym near my place I could go do Zumba' - check 'budget_investment_terms_of_service' + select heading.name, from: "budget_investment_heading_id" + fill_in "budget_investment_title", with: "Build a skyscraper" + fill_in_ckeditor "budget_investment_description", with: "If I had a gym near my place I could go do Zumba" + check "budget_investment_terms_of_service" - find('.js-add-tag-link', text: 'Education').click - click_button 'Create Investment' + find(".js-add-tag-link", text: "Education").click + click_button "Create Investment" - expect(page).to have_content 'Investment created successfully.' + expect(page).to have_content "Investment created successfully." within "#tags_budget_investment_#{Budget::Investment.last.id}" do - expect(page).to have_content 'Education' - expect(page).not_to have_content 'Health' + expect(page).to have_content "Education" + expect(page).not_to have_content "Health" end end - scenario 'Create with too many tags' do + scenario "Create with too many tags" 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 skyscraper' - fill_in 'budget_investment_description', with: 'I want to live in a high tower over the clouds' - check 'budget_investment_terms_of_service' + select heading.name, from: "budget_investment_heading_id" + fill_in "budget_investment_title", with: "Build a skyscraper" + fill_in "budget_investment_description", with: "I want to live in a high tower over the clouds" + check "budget_investment_terms_of_service" - fill_in 'budget_investment_tag_list', with: "Impuestos, Economía, Hacienda, Sanidad, Educación, Política, Igualdad" + fill_in "budget_investment_tag_list", with: "Impuestos, Economía, Hacienda, Sanidad, Educación, Política, Igualdad" - click_button 'Create Investment' + click_button "Create Investment" expect(page).to have_content error_message - expect(page).to have_content 'tags must be less than or equal to 6' + expect(page).to have_content "tags must be less than or equal to 6" end - scenario 'Create with dangerous strings' do + scenario "Create with dangerous strings" 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 skyscraper' - fill_in 'budget_investment_description', with: 'I want to live in a high tower over the clouds' - check 'budget_investment_terms_of_service' + select heading.name, from: "budget_investment_heading_id" + fill_in "budget_investment_title", with: "Build a skyscraper" + fill_in "budget_investment_description", with: "I want to live in a high tower over the clouds" + check "budget_investment_terms_of_service" - fill_in 'budget_investment_tag_list', with: 'user_id=1, &a=3, ' + fill_in "budget_investment_tag_list", with: "user_id=1, &a=3, " - click_button 'Create Investment' + click_button "Create Investment" - expect(page).to have_content 'Investment created successfully.' - expect(page).to have_content 'user_id1' - expect(page).to have_content 'a3' - expect(page).to have_content 'scriptalert("hey");script' - expect(page.html).not_to include 'user_id=1, &a=3, ' + expect(page).to have_content "Investment created successfully." + expect(page).to have_content "user_id1" + expect(page).to have_content "a3" + expect(page).to have_content "scriptalert('hey');script" + expect(page.html).not_to include "user_id=1, &a=3, " end context "Filter" do @@ -195,7 +195,7 @@ feature 'Tags' do scenario "From index" do investment1 = create(:budget_investment, heading: heading, tag_list: tag_economia.name) - investment2 = create(:budget_investment, heading: heading, tag_list: 'Health') + investment2 = create(:budget_investment, heading: heading, tag_list: "Health") visit budget_investments_path(budget, heading_id: heading.id) @@ -204,28 +204,28 @@ feature 'Tags' do end within("#budget-investments") do - expect(page).to have_css('.budget-investment', count: 1) + expect(page).to have_css(".budget-investment", count: 1) expect(page).to have_content(investment1.title) end end scenario "From show" do investment1 = create(:budget_investment, heading: heading, tag_list: tag_economia.name) - investment2 = create(:budget_investment, heading: heading, tag_list: 'Health') + investment2 = create(:budget_investment, heading: heading, tag_list: "Health") visit budget_investment_path(budget, investment1) click_link tag_economia.name within("#budget-investments") do - expect(page).to have_css('.budget-investment', count: 1) + expect(page).to have_css(".budget-investment", count: 1) expect(page).to have_content(investment1.title) end end end - context 'Tag cloud' do + context "Tag cloud" do let(:new_tag) { "New Tag" } let(:newer_tag) { "Newer" } @@ -233,7 +233,7 @@ feature 'Tags' do let!(:investment2) { create(:budget_investment, heading: heading, tag_list: new_tag) } let!(:investment3) { create(:budget_investment, heading: heading, tag_list: newer_tag) } - scenario 'Display user tags' do + scenario "Display user tags" do Budget::Phase::PHASE_KINDS.each do |phase| budget.update(phase: phase) @@ -284,7 +284,7 @@ feature 'Tags' do let!(:investment2) { create(:budget_investment, heading: heading, tag_list: tag_medio_ambiente.name) } let!(:investment3) { create(:budget_investment, heading: heading, tag_list: tag_economia.name) } - scenario 'Display category tags' do + scenario "Display category tags" do Budget::Phase::PHASE_KINDS.each do |phase| budget.update(phase: phase) @@ -331,28 +331,28 @@ feature 'Tags' do context "Valuation" do scenario "Users do not see valuator tags" do - investment = create(:budget_investment, heading: heading, tag_list: 'Park') - investment.set_tag_list_on(:valuation, 'Education') + investment = create(:budget_investment, heading: heading, tag_list: "Park") + investment.set_tag_list_on(:valuation, "Education") investment.save visit budget_investment_path(budget, investment) - expect(page).to have_content 'Park' - expect(page).not_to have_content 'Education' + expect(page).to have_content "Park" + expect(page).not_to have_content "Education" end scenario "Valuators do not see user tags" do - investment = create(:budget_investment, heading: heading, tag_list: 'Park') - investment.set_tag_list_on(:valuation, 'Education') + investment = create(:budget_investment, heading: heading, tag_list: "Park") + investment.set_tag_list_on(:valuation, "Education") investment.save login_as(admin) visit admin_budget_budget_investment_path(budget, investment) - click_link 'Edit classification' + click_link "Edit classification" - expect(page).to have_content 'Education' - expect(page).not_to have_content 'Park' + expect(page).to have_content "Education" + expect(page).not_to have_content "Park" end end diff --git a/spec/features/tags/debates_spec.rb b/spec/features/tags/debates_spec.rb index 99578b3e1..281b59608 100644 --- a/spec/features/tags/debates_spec.rb +++ b/spec/features/tags/debates_spec.rb @@ -1,10 +1,10 @@ -require 'rails_helper' +require "rails_helper" -feature 'Tags' do +feature "Tags" do - scenario 'Index' do - earth = create(:debate, tag_list: 'Medio Ambiente') - money = create(:debate, tag_list: 'Economía') + scenario "Index" do + earth = create(:debate, tag_list: "Medio Ambiente") + money = create(:debate, tag_list: "Economía") visit debates_path @@ -17,43 +17,43 @@ feature 'Tags' do end end - scenario 'Index shows up to 5 tags per proposal' do + scenario "Index shows up to 5 tags per proposal" do tag_list = ["Hacienda", "Economía", "Medio Ambiente", "Corrupción", "Fiestas populares", "Prensa"] create :debate, tag_list: tag_list visit debates_path - within('.debate .tags') do - expect(page).to have_content '1+' + within(".debate .tags") do + expect(page).to have_content "1+" end end - scenario 'Index shows 3 tags with no plus link' do + scenario "Index shows 3 tags with no plus link" do tag_list = ["Medio Ambiente", "Corrupción", "Fiestas populares"] create :debate, tag_list: tag_list visit debates_path - within('.debate .tags') do + within(".debate .tags") do tag_list.each do |tag| expect(page).to have_content tag end - expect(page).not_to have_content '+' + expect(page).not_to have_content "+" end end - scenario 'Index tag does not show featured debates' do + scenario "Index tag does not show featured debates" do featured_debates = create_featured_debates debates = create(:debate, tag_list: "123") visit debates_path(tag: "123") - 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 - scenario 'Show' do - debate = create(:debate, tag_list: 'Hacienda, Economía') + scenario "Show" do + debate = create(:debate, tag_list: "Hacienda, Economía") visit debate_path(debate) @@ -61,99 +61,99 @@ feature 'Tags' do expect(page).to have_content "Hacienda" end - scenario 'Create' do + scenario "Create" do user = create(:user) login_as(user) visit new_debate_path - fill_in 'debate_title', with: 'Title' - fill_in 'debate_description', with: 'Description' - check 'debate_terms_of_service' + fill_in "debate_title", with: "Title" + fill_in "debate_description", with: "Description" + check "debate_terms_of_service" - fill_in 'debate_tag_list', with: "Impuestos, Economía, Hacienda" + fill_in "debate_tag_list", with: "Impuestos, Economía, Hacienda" - click_button 'Start a debate' + click_button "Start a debate" - expect(page).to have_content 'Debate created successfully.' - expect(page).to have_content 'Economía' - expect(page).to have_content 'Hacienda' - expect(page).to have_content 'Impuestos' + expect(page).to have_content "Debate created successfully." + expect(page).to have_content "Economía" + expect(page).to have_content "Hacienda" + expect(page).to have_content "Impuestos" end - scenario 'Create with too many tags' do + scenario "Create with too many tags" do user = create(:user) login_as(user) visit new_debate_path - fill_in 'debate_title', with: 'Title' - fill_in 'debate_description', with: 'Description' - check 'debate_terms_of_service' + fill_in "debate_title", with: "Title" + fill_in "debate_description", with: "Description" + check "debate_terms_of_service" - fill_in 'debate_tag_list', with: "Impuestos, Economía, Hacienda, Sanidad, Educación, Política, Igualdad" + fill_in "debate_tag_list", with: "Impuestos, Economía, Hacienda, Sanidad, Educación, Política, Igualdad" - click_button 'Start a debate' + click_button "Start a debate" expect(page).to have_content error_message - expect(page).to have_content 'tags must be less than or equal to 6' + expect(page).to have_content "tags must be less than or equal to 6" end - scenario 'Create with dangerous strings' do + scenario "Create with dangerous strings" do user = create(:user) login_as(user) visit new_debate_path - fill_in 'debate_title', with: 'A test of dangerous strings' - fill_in 'debate_description', with: 'A description suitable for this test' - check 'debate_terms_of_service' + fill_in "debate_title", with: "A test of dangerous strings" + fill_in "debate_description", with: "A description suitable for this test" + check "debate_terms_of_service" - fill_in 'debate_tag_list', with: 'user_id=1, &a=3, ' + fill_in "debate_tag_list", with: "user_id=1, &a=3, " - click_button 'Start a debate' + click_button "Start a debate" - expect(page).to have_content 'Debate created successfully.' - expect(page).to have_content 'user_id1' - expect(page).to have_content 'a3' - expect(page).to have_content 'scriptalert("hey");script' - expect(page.html).not_to include 'user_id=1, &a=3, ' + expect(page).to have_content "Debate created successfully." + expect(page).to have_content "user_id1" + expect(page).to have_content "a3" + expect(page).to have_content "scriptalert('hey');script" + expect(page.html).not_to include "user_id=1, &a=3, " end - scenario 'Update' do - debate = create(:debate, tag_list: 'Economía') + scenario "Update" do + debate = create(:debate, tag_list: "Economía") login_as(debate.author) visit edit_debate_path(debate) expect(page).to have_selector("input[value='Economía']") - fill_in 'debate_tag_list', with: "Economía, Hacienda" - click_button 'Save changes' + fill_in "debate_tag_list", with: "Economía, Hacienda" + click_button "Save changes" - expect(page).to have_content 'Debate updated successfully.' - within('.tags') do - expect(page).to have_css('a', text: 'Economía') - expect(page).to have_css('a', text: 'Hacienda') + expect(page).to have_content "Debate updated successfully." + within(".tags") do + expect(page).to have_css("a", text: "Economía") + expect(page).to have_css("a", text: "Hacienda") end end - scenario 'Delete' do - debate = create(:debate, tag_list: 'Economía') + scenario "Delete" do + debate = create(:debate, tag_list: "Economía") login_as(debate.author) visit edit_debate_path(debate) - fill_in 'debate_tag_list', with: "" - click_button 'Save changes' + fill_in "debate_tag_list", with: "" + click_button "Save changes" - expect(page).to have_content 'Debate updated successfully.' - expect(page).not_to have_content 'Economía' + expect(page).to have_content "Debate updated successfully." + expect(page).not_to have_content "Economía" end context "Filter" do scenario "From index" do - debate1 = create(:debate, tag_list: 'Education') - debate2 = create(:debate, tag_list: 'Health') + debate1 = create(:debate, tag_list: "Education") + debate2 = create(:debate, tag_list: "Health") visit debates_path @@ -162,32 +162,32 @@ feature 'Tags' do end 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 scenario "From show" do - debate1 = create(:debate, tag_list: 'Education') - debate2 = create(:debate, tag_list: 'Health') + debate1 = create(:debate, tag_list: "Education") + debate2 = create(:debate, tag_list: "Health") visit debate_path(debate1) click_link "Education" 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 end - context 'Tag cloud' do + context "Tag cloud" do - scenario 'Display user tags' do - earth = create(:debate, tag_list: 'Medio Ambiente') - money = create(:debate, tag_list: 'Economía') + scenario "Display user tags" do + earth = create(:debate, tag_list: "Medio Ambiente") + money = create(:debate, tag_list: "Economía") visit debates_path @@ -198,9 +198,9 @@ feature 'Tags' do end scenario "Filter by user tags" do - debate1 = create(:debate, tag_list: 'Medio Ambiente') - debate2 = create(:debate, tag_list: 'Medio Ambiente') - debate3 = create(:debate, tag_list: 'Economía') + debate1 = create(:debate, tag_list: "Medio Ambiente") + debate2 = create(:debate, tag_list: "Medio Ambiente") + debate3 = create(:debate, tag_list: "Economía") visit debates_path @@ -215,4 +215,4 @@ feature 'Tags' do end end -end \ No newline at end of file +end diff --git a/spec/features/tags/proposals_spec.rb b/spec/features/tags/proposals_spec.rb index 7c8a5c026..3331bbc5f 100644 --- a/spec/features/tags/proposals_spec.rb +++ b/spec/features/tags/proposals_spec.rb @@ -1,11 +1,11 @@ -require 'rails_helper' +require "rails_helper" -feature 'Tags' do +feature "Tags" do - scenario 'Index' do + scenario "Index" do create_featured_proposals - earth = create(:proposal, tag_list: 'Medio Ambiente') - money = create(:proposal, tag_list: 'Economía') + earth = create(:proposal, tag_list: "Medio Ambiente") + money = create(:proposal, tag_list: "Economía") visit proposals_path @@ -18,45 +18,45 @@ feature 'Tags' do end end - scenario 'Index shows up to 5 tags per proposal' do + scenario "Index shows up to 5 tags per proposal" do create_featured_proposals tag_list = ["Hacienda", "Economía", "Medio Ambiente", "Corrupción", "Fiestas populares", "Prensa"] create :proposal, tag_list: tag_list visit proposals_path - within('.proposal .tags') do - expect(page).to have_content '1+' + within(".proposal .tags") do + expect(page).to have_content "1+" end end - scenario 'Index featured proposals does not show tags' do + scenario "Index featured proposals does not show tags" do featured_proposals = create_featured_proposals proposal = create(:proposal, tag_list: "123") visit proposals_path(tag: "123") - expect(page).not_to have_selector('#proposals .proposal-featured') - expect(page).not_to have_selector('#featured-proposals') + expect(page).not_to have_selector("#proposals .proposal-featured") + expect(page).not_to have_selector("#featured-proposals") end - scenario 'Index shows 3 tags with no plus link' do + scenario "Index shows 3 tags with no plus link" do create_featured_proposals tag_list = ["Medio Ambiente", "Corrupción", "Fiestas populares"] create :proposal, tag_list: tag_list visit proposals_path - within('.proposal .tags') do + within(".proposal .tags") do tag_list.each do |tag| expect(page).to have_content tag end - expect(page).not_to have_content '+' + expect(page).not_to have_content "+" end end - scenario 'Show' do - proposal = create(:proposal, tag_list: 'Hacienda, Economía') + scenario "Show" do + proposal = create(:proposal, tag_list: "Hacienda, Economía") visit proposal_path(proposal) @@ -64,142 +64,142 @@ feature 'Tags' do expect(page).to have_content "Hacienda" end - scenario 'Create with custom tags' do + scenario "Create with custom tags" do user = create(:user) login_as(user) visit new_proposal_path - fill_in 'proposal_title', with: 'Help refugees' - fill_in 'proposal_question', with: '¿Would you like to give assistance to war refugees?' - fill_in 'proposal_summary', with: 'In summary, what we want is...' - fill_in 'proposal_description', with: 'This is very important because...' - fill_in 'proposal_responsible_name', with: 'Isabel Garcia' - fill_in 'proposal_tag_list', with: 'Economía, Hacienda' - check 'proposal_terms_of_service' + fill_in "proposal_title", with: "Help refugees" + fill_in "proposal_question", with: "¿Would you like to give assistance to war refugees?" + fill_in "proposal_summary", with: "In summary, what we want is..." + fill_in "proposal_description", with: "This is very important because..." + fill_in "proposal_responsible_name", with: "Isabel Garcia" + fill_in "proposal_tag_list", with: "Economía, Hacienda" + check "proposal_terms_of_service" - click_button 'Create proposal' + click_button "Create proposal" - expect(page).to have_content 'Proposal created successfully.' + expect(page).to have_content "Proposal created successfully." - click_link 'Not now, go to my proposal' + click_link "Not now, go to my proposal" - expect(page).to have_content 'Economía' - expect(page).to have_content 'Hacienda' + expect(page).to have_content "Economía" + expect(page).to have_content "Hacienda" end - scenario 'Category with category tags', :js do + scenario "Category with category tags", :js do user = create(:user) login_as(user) - education = create(:tag, :category, name: 'Education') - health = create(:tag, :category, name: 'Health') + education = create(:tag, :category, name: "Education") + health = create(:tag, :category, name: "Health") visit new_proposal_path - fill_in 'proposal_title', with: 'Help refugees' - fill_in 'proposal_question', with: '¿Would you like to give assistance to war refugees?' - fill_in 'proposal_summary', with: 'In summary, what we want is...' - fill_in_ckeditor 'proposal_description', with: 'A description with enough characters' - fill_in 'proposal_external_url', with: 'http://rescue.org/refugees' - fill_in 'proposal_video_url', with: 'https://www.youtube.com/watch?v=Ae6gQmhaMn4' - fill_in 'proposal_responsible_name', with: 'Isabel Garcia' - check 'proposal_terms_of_service' + fill_in "proposal_title", with: "Help refugees" + fill_in "proposal_question", with: "¿Would you like to give assistance to war refugees?" + fill_in "proposal_summary", with: "In summary, what we want is..." + fill_in_ckeditor "proposal_description", with: "A description with enough characters" + fill_in "proposal_external_url", with: "http://rescue.org/refugees" + fill_in "proposal_video_url", with: "https://www.youtube.com/watch?v=Ae6gQmhaMn4" + fill_in "proposal_responsible_name", with: "Isabel Garcia" + check "proposal_terms_of_service" - find('.js-add-tag-link', text: 'Education').click - click_button 'Create proposal' + find(".js-add-tag-link", text: "Education").click + click_button "Create proposal" - expect(page).to have_content 'Proposal created successfully.' + expect(page).to have_content "Proposal created successfully." - click_link 'Not now, go to my proposal' + click_link "Not now, go to my proposal" within "#tags_proposal_#{Proposal.last.id}" do - expect(page).to have_content 'Education' - expect(page).not_to have_content 'Health' + expect(page).to have_content "Education" + expect(page).not_to have_content "Health" end end - scenario 'Create with too many tags' do + scenario "Create with too many tags" do user = create(:user) login_as(user) visit new_proposal_path - fill_in 'proposal_title', with: 'Title' - fill_in 'proposal_description', with: 'Description' - check 'proposal_terms_of_service' + fill_in "proposal_title", with: "Title" + fill_in "proposal_description", with: "Description" + check "proposal_terms_of_service" - fill_in 'proposal_tag_list', with: "Impuestos, Economía, Hacienda, Sanidad, Educación, Política, Igualdad" + fill_in "proposal_tag_list", with: "Impuestos, Economía, Hacienda, Sanidad, Educación, Política, Igualdad" - click_button 'Create proposal' + click_button "Create proposal" expect(page).to have_content error_message - expect(page).to have_content 'tags must be less than or equal to 6' + expect(page).to have_content "tags must be less than or equal to 6" end - scenario 'Create with dangerous strings' do + scenario "Create with dangerous strings" do author = create(:user) login_as(author) visit new_proposal_path - fill_in 'proposal_title', with: 'A test of dangerous strings' - fill_in 'proposal_question', with: '¿Would you like to give assistance to war refugees?' - fill_in 'proposal_summary', with: 'In summary, what we want is...' - fill_in 'proposal_description', with: 'A description suitable for this test' - fill_in 'proposal_external_url', with: 'http://rescue.org/refugees' - fill_in 'proposal_responsible_name', with: 'Isabel Garcia' - check 'proposal_terms_of_service' + fill_in "proposal_title", with: "A test of dangerous strings" + fill_in "proposal_question", with: "¿Would you like to give assistance to war refugees?" + fill_in "proposal_summary", with: "In summary, what we want is..." + fill_in "proposal_description", with: "A description suitable for this test" + fill_in "proposal_external_url", with: "http://rescue.org/refugees" + fill_in "proposal_responsible_name", with: "Isabel Garcia" + check "proposal_terms_of_service" - fill_in 'proposal_tag_list', with: 'user_id=1, &a=3, ' + fill_in "proposal_tag_list", with: "user_id=1, &a=3, " - click_button 'Create proposal' + click_button "Create proposal" - expect(page).to have_content 'Proposal created successfully.' + expect(page).to have_content "Proposal created successfully." - click_link 'Not now, go to my proposal' + click_link "Not now, go to my proposal" - expect(page).to have_content 'user_id1' - expect(page).to have_content 'a3' - expect(page).to have_content 'scriptalert("hey");script' - expect(page.html).not_to include 'user_id=1, &a=3, ' + expect(page).to have_content "user_id1" + expect(page).to have_content "a3" + expect(page).to have_content "scriptalert('hey');script" + expect(page.html).not_to include "user_id=1, &a=3, " end - scenario 'Update' do - proposal = create(:proposal, tag_list: 'Economía') + scenario "Update" do + proposal = create(:proposal, tag_list: "Economía") login_as(proposal.author) visit edit_proposal_path(proposal) expect(page).to have_selector("input[value='Economía']") - fill_in 'proposal_tag_list', with: "Economía, Hacienda" - click_button 'Save changes' + fill_in "proposal_tag_list", with: "Economía, Hacienda" + click_button "Save changes" - expect(page).to have_content 'Proposal updated successfully.' - within('.tags') do - expect(page).to have_css('a', text: 'Economía') - expect(page).to have_css('a', text: 'Hacienda') + expect(page).to have_content "Proposal updated successfully." + within(".tags") do + expect(page).to have_css("a", text: "Economía") + expect(page).to have_css("a", text: "Hacienda") end end - scenario 'Delete' do - proposal = create(:proposal, tag_list: 'Economía') + scenario "Delete" do + proposal = create(:proposal, tag_list: "Economía") login_as(proposal.author) visit edit_proposal_path(proposal) - fill_in 'proposal_tag_list', with: "" - click_button 'Save changes' + fill_in "proposal_tag_list", with: "" + click_button "Save changes" - expect(page).to have_content 'Proposal updated successfully.' - expect(page).not_to have_content 'Economía' + expect(page).to have_content "Proposal updated successfully." + expect(page).not_to have_content "Economía" end context "Filter" do scenario "From index" do create_featured_proposals - proposal1 = create(:proposal, tag_list: 'Education') - proposal2 = create(:proposal, tag_list: 'Health') + proposal1 = create(:proposal, tag_list: "Education") + proposal2 = create(:proposal, tag_list: "Health") visit proposals_path @@ -208,32 +208,32 @@ feature 'Tags' do end within("#proposals") do - expect(page).to have_css('.proposal', count: 1) + expect(page).to have_css(".proposal", count: 1) expect(page).to have_content(proposal1.title) end end scenario "From show" do - proposal1 = create(:proposal, tag_list: 'Education') - proposal2 = create(:proposal, tag_list: 'Health') + proposal1 = create(:proposal, tag_list: "Education") + proposal2 = create(:proposal, tag_list: "Health") visit proposal_path(proposal1) click_link "Education" within("#proposals") do - expect(page).to have_css('.proposal', count: 1) + expect(page).to have_css(".proposal", count: 1) expect(page).to have_content(proposal1.title) end end end - context 'Tag cloud' do + context "Tag cloud" do - scenario 'Display user tags' do - earth = create(:proposal, tag_list: 'Medio Ambiente') - money = create(:proposal, tag_list: 'Economía') + scenario "Display user tags" do + earth = create(:proposal, tag_list: "Medio Ambiente") + money = create(:proposal, tag_list: "Economía") visit proposals_path @@ -244,9 +244,9 @@ feature 'Tags' do end scenario "Filter by user tags" do - proposal1 = create(:proposal, tag_list: 'Medio Ambiente') - proposal2 = create(:proposal, tag_list: 'Medio Ambiente') - proposal3 = create(:proposal, tag_list: 'Economía') + proposal1 = create(:proposal, tag_list: "Medio Ambiente") + proposal2 = create(:proposal, tag_list: "Medio Ambiente") + proposal3 = create(:proposal, tag_list: "Economía") visit proposals_path @@ -264,12 +264,12 @@ feature 'Tags' do context "Categories" do - scenario 'Display category tags' do - create(:tag, :category, name: 'Medio Ambiente') - create(:tag, :category, name: 'Economía') + scenario "Display category tags" do + create(:tag, :category, name: "Medio Ambiente") + create(:tag, :category, name: "Economía") - earth = create(:proposal, tag_list: 'Medio Ambiente') - money = create(:proposal, tag_list: 'Economía') + earth = create(:proposal, tag_list: "Medio Ambiente") + money = create(:proposal, tag_list: "Economía") visit proposals_path @@ -280,12 +280,12 @@ feature 'Tags' do end scenario "Filter by category tags" do - create(:tag, :category, name: 'Medio Ambiente') - create(:tag, :category, name: 'Economía') + create(:tag, :category, name: "Medio Ambiente") + create(:tag, :category, name: "Economía") - proposal1 = create(:proposal, tag_list: 'Medio Ambiente') - proposal2 = create(:proposal, tag_list: 'Medio Ambiente') - proposal3 = create(:proposal, tag_list: 'Economía') + proposal1 = create(:proposal, tag_list: "Medio Ambiente") + proposal2 = create(:proposal, tag_list: "Medio Ambiente") + proposal3 = create(:proposal, tag_list: "Economía") visit proposals_path diff --git a/spec/features/tags_spec.rb b/spec/features/tags_spec.rb index 4aeec69df..16e26d9f6 100644 --- a/spec/features/tags_spec.rb +++ b/spec/features/tags_spec.rb @@ -1,10 +1,10 @@ -require 'rails_helper' +require "rails_helper" -feature 'Tags' do +feature "Tags" do - scenario 'Index' do - earth = create(:debate, tag_list: 'Medio Ambiente') - money = create(:debate, tag_list: 'Economía') + scenario "Index" do + earth = create(:debate, tag_list: "Medio Ambiente") + money = create(:debate, tag_list: "Economía") visit debates_path @@ -17,27 +17,27 @@ feature 'Tags' do end end - scenario 'Filtered' do - debate1 = create(:debate, tag_list: 'Salud') - debate2 = create(:debate, tag_list: 'salud') - debate3 = create(:debate, tag_list: 'Hacienda') - debate4 = create(:debate, tag_list: 'Hacienda') + scenario "Filtered" do + debate1 = create(:debate, tag_list: "Salud") + debate2 = create(:debate, tag_list: "salud") + debate3 = create(:debate, tag_list: "Hacienda") + debate4 = create(:debate, tag_list: "Hacienda") visit debates_path - first(:link, 'Salud').click + first(:link, "Salud").click 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) expect(page).not_to have_content(debate4.title) end - visit debates_path(search: 'salud') + visit debates_path(search: "salud") 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) @@ -45,8 +45,8 @@ feature 'Tags' do end end - scenario 'Show' do - debate = create(:debate, tag_list: 'Hacienda, Economía') + scenario "Show" do + debate = create(:debate, tag_list: "Hacienda, Economía") visit debate_path(debate) @@ -54,78 +54,78 @@ feature 'Tags' do expect(page).to have_content "Hacienda" end - scenario 'Create' do + scenario "Create" do user = create(:user) login_as(user) visit new_debate_path - fill_in 'debate_title', with: 'Title' - fill_in 'debate_description', with: 'Description' - check 'debate_terms_of_service' + fill_in "debate_title", with: "Title" + fill_in "debate_description", with: "Description" + check "debate_terms_of_service" - fill_in 'debate_tag_list', with: "Impuestos, Economía, Hacienda" + fill_in "debate_tag_list", with: "Impuestos, Economía, Hacienda" - click_button 'Start a debate' + click_button "Start a debate" - expect(page).to have_content 'Debate created successfully.' - expect(page).to have_content 'Economía' - expect(page).to have_content 'Hacienda' - expect(page).to have_content 'Impuestos' + expect(page).to have_content "Debate created successfully." + expect(page).to have_content "Economía" + expect(page).to have_content "Hacienda" + expect(page).to have_content "Impuestos" end - scenario 'Create with too many tags' do + scenario "Create with too many tags" do user = create(:user) login_as(user) visit new_debate_path - fill_in 'debate_title', with: 'Title' - fill_in 'debate_description', with: 'Description' - check 'debate_terms_of_service' + fill_in "debate_title", with: "Title" + fill_in "debate_description", with: "Description" + check "debate_terms_of_service" - fill_in 'debate_tag_list', with: "Impuestos, Economía, Hacienda, Sanidad, Educación, Política, Igualdad" + fill_in "debate_tag_list", with: "Impuestos, Economía, Hacienda, Sanidad, Educación, Política, Igualdad" - click_button 'Start a debate' + click_button "Start a debate" expect(page).to have_content error_message - expect(page).to have_content 'tags must be less than or equal to 6' + expect(page).to have_content "tags must be less than or equal to 6" end - scenario 'Update' do - debate = create(:debate, tag_list: 'Economía') + scenario "Update" do + debate = create(:debate, tag_list: "Economía") login_as(debate.author) visit edit_debate_path(debate) expect(page).to have_selector("input[value='Economía']") - fill_in 'debate_tag_list', with: "Economía, Hacienda" - click_button 'Save changes' + fill_in "debate_tag_list", with: "Economía, Hacienda" + click_button "Save changes" - expect(page).to have_content 'Debate updated successfully.' - within('.tags') do - expect(page).to have_css('a', text: 'Economía') - expect(page).to have_css('a', text: 'Hacienda') + expect(page).to have_content "Debate updated successfully." + within(".tags") do + expect(page).to have_css("a", text: "Economía") + expect(page).to have_css("a", text: "Hacienda") end end - scenario 'Delete' do - debate = create(:debate, tag_list: 'Economía') + scenario "Delete" do + debate = create(:debate, tag_list: "Economía") login_as(debate.author) visit edit_debate_path(debate) - fill_in 'debate_tag_list', with: "" - click_button 'Save changes' + fill_in "debate_tag_list", with: "" + click_button "Save changes" - expect(page).to have_content 'Debate updated successfully.' - expect(page).not_to have_content 'Economía' + expect(page).to have_content "Debate updated successfully." + expect(page).not_to have_content "Economía" end - context 'Tag cloud' do + context "Tag cloud" do - scenario 'Proposals' do - earth = create(:proposal, tag_list: 'Medio Ambiente') - money = create(:proposal, tag_list: 'Economía') + scenario "Proposals" do + earth = create(:proposal, tag_list: "Medio Ambiente") + money = create(:proposal, tag_list: "Economía") visit proposals_path @@ -135,9 +135,9 @@ feature 'Tags' do end end - scenario 'Debates' do - earth = create(:debate, tag_list: 'Medio Ambiente') - money = create(:debate, tag_list: 'Economía') + scenario "Debates" do + earth = create(:debate, tag_list: "Medio Ambiente") + money = create(:debate, tag_list: "Economía") visit debates_path @@ -148,13 +148,13 @@ feature 'Tags' do end scenario "scoped by category" do - create(:tag, :category, name: 'Medio Ambiente') - create(:tag, :category, name: 'Economía') + create(:tag, :category, name: "Medio Ambiente") + create(:tag, :category, name: "Economía") - earth = create(:proposal, tag_list: 'Medio Ambiente, Agua') - money = create(:proposal, tag_list: 'Economía, Corrupción') + earth = create(:proposal, tag_list: "Medio Ambiente, Agua") + money = create(:proposal, tag_list: "Economía, Corrupción") - visit proposals_path(search: 'Economía') + visit proposals_path(search: "Economía") within "#tag-cloud" do expect(page).to have_css(".tag", count: 1) @@ -164,13 +164,13 @@ feature 'Tags' do end scenario "scoped by district" do - create(:geozone, name: 'Madrid') - create(:geozone, name: 'Barcelona') + create(:geozone, name: "Madrid") + create(:geozone, name: "Barcelona") - earth = create(:proposal, tag_list: 'Madrid, Agua') - money = create(:proposal, tag_list: 'Barcelona, Playa') + earth = create(:proposal, tag_list: "Madrid, Agua") + money = create(:proposal, tag_list: "Barcelona, Playa") - visit proposals_path(search: 'Barcelona') + visit proposals_path(search: "Barcelona") within "#tag-cloud" do expect(page).to have_css(".tag", count: 1) @@ -180,9 +180,9 @@ feature 'Tags' do end scenario "tag links" do - proposal1 = create(:proposal, tag_list: 'Medio Ambiente') - proposal2 = create(:proposal, tag_list: 'Medio Ambiente') - proposal3 = create(:proposal, tag_list: 'Economía') + proposal1 = create(:proposal, tag_list: "Medio Ambiente") + proposal2 = create(:proposal, tag_list: "Medio Ambiente") + proposal3 = create(:proposal, tag_list: "Economía") visit proposals_path @@ -198,4 +198,4 @@ feature 'Tags' do end -end \ No newline at end of file +end diff --git a/spec/features/topics_specs.rb b/spec/features/topics_specs.rb index 51342af02..0169af157 100644 --- a/spec/features/topics_specs.rb +++ b/spec/features/topics_specs.rb @@ -1,14 +1,14 @@ -require 'rails_helper' +require "rails_helper" -feature 'Topics' do +feature "Topics" do context "Concerns" do - it_behaves_like 'notifiable in-app', Topic + it_behaves_like "notifiable in-app", Topic end - context 'New' do + context "New" do - scenario 'Create new topic link should redirect to sign up for anonymous users', :js do + scenario "Create new topic link should redirect to sign up for anonymous users", :js do proposal = create(:proposal) community = proposal.community @@ -20,7 +20,7 @@ feature 'Topics' do expect(page).to have_current_path(new_user_session_path) end - scenario 'Can access to new topic page with user logged', :js do + scenario "Can access to new topic page with user logged", :js do proposal = create(:proposal) community = proposal.community user = create(:user) @@ -32,7 +32,7 @@ feature 'Topics' do expect(page).to have_content "Create a topic" end - scenario 'Should have content on new topic page', :js do + scenario "Should have content on new topic page", :js do proposal = create(:proposal) community = proposal.community user = create(:user) @@ -52,9 +52,9 @@ feature 'Topics' do end - context 'Create' do + context "Create" do - scenario 'Can create a new topic', :js do + scenario "Can create a new topic", :js do proposal = create(:proposal) community = proposal.community user = create(:user) @@ -69,7 +69,7 @@ feature 'Topics' do expect(page).to have_current_path(community_path(community)) end - scenario 'Can not create a new topic when user not logged', :js do + scenario "Can not create a new topic when user not logged", :js do proposal = create(:proposal) community = proposal.community @@ -80,9 +80,9 @@ feature 'Topics' do end - context 'Edit' do + context "Edit" do - scenario 'Can edit a topic' do + scenario "Can edit a topic" do proposal = create(:proposal) community = proposal.community user = create(:user) @@ -98,7 +98,7 @@ feature 'Topics' do expect(page).to have_current_path(community_path(community)) end - scenario 'Can not edit a topic when user logged is not an author' do + scenario "Can not edit a topic when user logged is not an author" do proposal = create(:proposal) community = proposal.community topic = create(:topic, community: community) @@ -112,9 +112,9 @@ feature 'Topics' do end - context 'Show' do + context "Show" do - scenario 'Can show topic' do + scenario "Can show topic" do proposal = create(:proposal) community = proposal.community topic = create(:topic, community: community) @@ -127,9 +127,9 @@ feature 'Topics' do end - context 'Destroy' do + context "Destroy" do - scenario 'Can destroy a topic' do + scenario "Can destroy a topic" do proposal = create(:proposal) community = proposal.community user = create(:user) @@ -144,7 +144,7 @@ feature 'Topics' do expect(page).to have_current_path(community_path(community)) end - scenario 'Can not destroy a topic when user logged is not an author' do + scenario "Can not destroy a topic when user logged is not an author" do proposal = create(:proposal) community = proposal.community topic = create(:topic, community: community) diff --git a/spec/features/tracks_spec.rb b/spec/features/tracks_spec.rb index 2e2e4ec2f..073c2af59 100644 --- a/spec/features/tracks_spec.rb +++ b/spec/features/tracks_spec.rb @@ -1,16 +1,16 @@ -require 'rails_helper' +require "rails_helper" -feature 'Tracking' do +feature "Tracking" do - context 'Custom variable' do + context "Custom variable" do - scenario 'Usertype anonymous' do + scenario "Usertype anonymous" do visit proposals_path expect(page.html).to include "anonymous" end - scenario 'Usertype level_1_user' do + scenario "Usertype level_1_user" do create(:geozone) user = create(:user) login_as(user) @@ -20,93 +20,93 @@ feature 'Tracking' do expect(page.html).to include "level_1_user" end - scenario 'Usertype level_2_user' do + scenario "Usertype level_2_user" do create(:geozone) user = create(:user) login_as(user) visit account_path - click_link 'Verify my account' + click_link "Verify my account" verify_residence - fill_in 'sms_phone', with: "611111111" - click_button 'Send' + fill_in "sms_phone", with: "611111111" + click_button "Send" user = user.reload - fill_in 'sms_confirmation_code', with: user.sms_confirmation_code - click_button 'Send' + fill_in "sms_confirmation_code", with: user.sms_confirmation_code + click_button "Send" expect(page.html).to include "level_2_user" end end - context 'Tracking events' do - scenario 'Verification: start census' do + context "Tracking events" do + scenario "Verification: start census" do user = create(:user) login_as(user) visit account_path - click_link 'Verify my account' + click_link "Verify my account" expect(page.html).to include "data-track-event-category=verification" expect(page.html).to include "data-track-event-action=start_census" end - scenario 'Verification: success census & start sms' do + scenario "Verification: success census & start sms" do create(:geozone) user = create(:user) login_as(user) visit account_path - click_link 'Verify my account' + click_link "Verify my account" verify_residence - fill_in 'sms_phone', with: "611111111" - click_button 'Send' + fill_in "sms_phone", with: "611111111" + click_button "Send" expect(page.html).to include "data-track-event-category=verification" expect(page.html).to include "data-track-event-action=start_sms" end - scenario 'Verification: success sms' do + scenario "Verification: success sms" do create(:geozone) user = create(:user) login_as(user) visit account_path - click_link 'Verify my account' + click_link "Verify my account" verify_residence - fill_in 'sms_phone', with: "611111111" - click_button 'Send' + fill_in "sms_phone", with: "611111111" + click_button "Send" user = user.reload - fill_in 'sms_confirmation_code', with: user.sms_confirmation_code - click_button 'Send' + fill_in "sms_confirmation_code", with: user.sms_confirmation_code + click_button "Send" expect(page.html).to include "data-track-event-category=verification" expect(page.html).to include "data-track-event-action=success_sms" end - scenario 'Verification: letter' do + scenario "Verification: letter" do create(:geozone) user = create(:user) login_as(user) visit account_path - click_link 'Verify my account' + click_link "Verify my account" verify_residence - fill_in 'sms_phone', with: "611111111" - click_button 'Send' + fill_in "sms_phone", with: "611111111" + click_button "Send" user = user.reload - fill_in 'sms_confirmation_code', with: user.sms_confirmation_code - click_button 'Send' + fill_in "sms_confirmation_code", with: user.sms_confirmation_code + click_button "Send" click_link "Send me a letter with the code" diff --git a/spec/features/user_invites_spec.rb b/spec/features/user_invites_spec.rb index 81c02f5cc..ab439c1d5 100644 --- a/spec/features/user_invites_spec.rb +++ b/spec/features/user_invites_spec.rb @@ -1,6 +1,6 @@ -require 'rails_helper' +require "rails_helper" -feature 'User invites' do +feature "User invites" do background do login_as_manager diff --git a/spec/features/users_auth_spec.rb b/spec/features/users_auth_spec.rb index 2da1118ab..040f64305 100644 --- a/spec/features/users_auth_spec.rb +++ b/spec/features/users_auth_spec.rb @@ -1,22 +1,22 @@ -require 'rails_helper' +require "rails_helper" -feature 'Users' do +feature "Users" do - context 'Regular authentication' do - context 'Sign up' do + context "Regular authentication" do + context "Sign up" do - scenario 'Success' do + scenario "Success" do message = "You have been sent a message containing a verification link. Please click on this link to activate your account." - visit '/' - click_link 'Register' + visit "/" + click_link "Register" - fill_in 'user_username', with: 'Manuela Carmena' - fill_in 'user_email', with: 'manuela@consul.dev' - fill_in 'user_password', with: 'judgementday' - fill_in 'user_password_confirmation', with: 'judgementday' - check 'user_terms_of_service' + fill_in "user_username", with: "Manuela Carmena" + fill_in "user_email", with: "manuela@consul.dev" + fill_in "user_password", with: "judgementday" + fill_in "user_password_confirmation", with: "judgementday" + check "user_terms_of_service" - click_button 'Register' + click_button "Register" expect(page).to have_content message @@ -25,125 +25,125 @@ feature 'Users' do expect(page).to have_content "Your account has been confirmed." end - scenario 'Errors on sign up' do - visit '/' - click_link 'Register' - click_button 'Register' + scenario "Errors on sign up" do + visit "/" + click_link "Register" + click_button "Register" expect(page).to have_content error_message end end - context 'Sign in' do + context "Sign in" do - scenario 'sign in with email' do - create(:user, email: 'manuela@consul.dev', password: 'judgementday') + scenario "sign in with email" do + create(:user, email: "manuela@consul.dev", password: "judgementday") - visit '/' - click_link 'Sign in' - fill_in 'user_login', with: 'manuela@consul.dev' - fill_in 'user_password', with: 'judgementday' - click_button 'Enter' + visit "/" + click_link "Sign in" + fill_in "user_login", with: "manuela@consul.dev" + fill_in "user_password", with: "judgementday" + click_button "Enter" - expect(page).to have_content 'You have been signed in successfully.' + expect(page).to have_content "You have been signed in successfully." end - scenario 'Sign in with username' do - create(:user, username: '👻👽👾🤖', email: 'ash@nostromo.dev', password: 'xenomorph') + scenario "Sign in with username" do + create(:user, username: "👻👽👾🤖", email: "ash@nostromo.dev", password: "xenomorph") - visit '/' - click_link 'Sign in' - fill_in 'user_login', with: '👻👽👾🤖' - fill_in 'user_password', with: 'xenomorph' - click_button 'Enter' + visit "/" + click_link "Sign in" + fill_in "user_login", with: "👻👽👾🤖" + fill_in "user_password", with: "xenomorph" + click_button "Enter" - expect(page).to have_content 'You have been signed in successfully.' + expect(page).to have_content "You have been signed in successfully." end - scenario 'Avoid username-email collisions' do - u1 = create(:user, username: 'Spidey', email: 'peter@nyc.dev', password: 'greatpower') - u2 = create(:user, username: 'peter@nyc.dev', email: 'venom@nyc.dev', password: 'symbiote') + scenario "Avoid username-email collisions" do + u1 = create(:user, username: "Spidey", email: "peter@nyc.dev", password: "greatpower") + u2 = create(:user, username: "peter@nyc.dev", email: "venom@nyc.dev", password: "symbiote") - visit '/' - click_link 'Sign in' - fill_in 'user_login', with: 'peter@nyc.dev' - fill_in 'user_password', with: 'greatpower' - click_button 'Enter' + visit "/" + click_link "Sign in" + fill_in "user_login", with: "peter@nyc.dev" + fill_in "user_password", with: "greatpower" + click_button "Enter" - expect(page).to have_content 'You have been signed in successfully.' + expect(page).to have_content "You have been signed in successfully." visit account_path - expect(page).to have_link 'My activity', href: user_path(u1) + expect(page).to have_link "My activity", href: user_path(u1) - visit '/' - click_link 'Sign out' + visit "/" + click_link "Sign out" - expect(page).to have_content 'You have been signed out successfully.' + expect(page).to have_content "You have been signed out successfully." - click_link 'Sign in' - fill_in 'user_login', with: 'peter@nyc.dev' - fill_in 'user_password', with: 'symbiote' - click_button 'Enter' + click_link "Sign in" + fill_in "user_login", with: "peter@nyc.dev" + fill_in "user_password", with: "symbiote" + click_button "Enter" - expect(page).not_to have_content 'You have been signed in successfully.' - expect(page).to have_content 'Invalid login or password.' + expect(page).not_to have_content "You have been signed in successfully." + expect(page).to have_content "Invalid login or password." - fill_in 'user_login', with: 'venom@nyc.dev' - fill_in 'user_password', with: 'symbiote' - click_button 'Enter' + fill_in "user_login", with: "venom@nyc.dev" + fill_in "user_password", with: "symbiote" + click_button "Enter" - expect(page).to have_content 'You have been signed in successfully.' + expect(page).to have_content "You have been signed in successfully." visit account_path - expect(page).to have_link 'My activity', href: user_path(u2) + expect(page).to have_link "My activity", href: user_path(u2) end end end - context 'OAuth authentication' do - context 'Twitter' do + context "OAuth authentication" do + context "Twitter" do - let(:twitter_hash){ {provider: 'twitter', uid: '12345', info: {name: 'manuela'}} } - let(:twitter_hash_with_email){ {provider: 'twitter', uid: '12345', info: {name: 'manuela', email: 'manuelacarmena@example.com'}} } + let(:twitter_hash){ {provider: "twitter", uid: "12345", info: {name: "manuela"}} } + let(:twitter_hash_with_email){ {provider: "twitter", uid: "12345", info: {name: "manuela", email: "manuelacarmena@example.com"}} } let(:twitter_hash_with_verified_email) do { - provider: 'twitter', - uid: '12345', + provider: "twitter", + uid: "12345", info: { - name: 'manuela', - email: 'manuelacarmena@example.com', - verified: '1' + name: "manuela", + email: "manuelacarmena@example.com", + verified: "1" } } end - scenario 'Sign up when Oauth provider has a verified email' do + scenario "Sign up when Oauth provider has a verified email" do OmniAuth.config.add_mock(:twitter, twitter_hash_with_verified_email) - visit '/' - click_link 'Register' + visit "/" + click_link "Register" - click_link 'Sign up with Twitter' + click_link "Sign up with Twitter" expect_to_be_signed_in - click_link 'My account' - expect(page).to have_field('account_username', with: 'manuela') + click_link "My account" + expect(page).to have_field("account_username", with: "manuela") visit edit_user_registration_path - expect(page).to have_field('user_email', with: 'manuelacarmena@example.com') + expect(page).to have_field("user_email", with: "manuelacarmena@example.com") end - scenario 'Sign up when Oauth provider has an unverified email' do + scenario "Sign up when Oauth provider has an unverified email" do OmniAuth.config.add_mock(:twitter, twitter_hash_with_email) - visit '/' - click_link 'Register' + visit "/" + click_link "Register" - click_link 'Sign up with Twitter' + click_link "Sign up with Twitter" expect(page).to have_current_path(new_user_session_path) expect(page).to have_content "To continue, please click on the confirmation link that we have sent you via email" @@ -151,208 +151,208 @@ feature 'Users' do confirm_email expect(page).to have_content "Your account has been confirmed" - visit '/' - click_link 'Sign in' - click_link 'Sign in with Twitter' + visit "/" + click_link "Sign in" + click_link "Sign in with Twitter" expect_to_be_signed_in - click_link 'My account' - expect(page).to have_field('account_username', with: 'manuela') + click_link "My account" + expect(page).to have_field("account_username", with: "manuela") visit edit_user_registration_path - expect(page).to have_field('user_email', with: 'manuelacarmena@example.com') + expect(page).to have_field("user_email", with: "manuelacarmena@example.com") end - scenario 'Sign up, when no email was provided by OAuth provider' do + scenario "Sign up, when no email was provided by OAuth provider" do OmniAuth.config.add_mock(:twitter, twitter_hash) - visit '/' - click_link 'Register' - click_link 'Sign up with Twitter' + visit "/" + click_link "Register" + click_link "Sign up with Twitter" expect(page).to have_current_path(finish_signup_path) - fill_in 'user_email', with: 'manueladelascarmenas@example.com' - click_button 'Register' + fill_in "user_email", with: "manueladelascarmenas@example.com" + click_button "Register" expect(page).to have_content "To continue, please click on the confirmation link that we have sent you via email" confirm_email expect(page).to have_content "Your account has been confirmed" - visit '/' - click_link 'Sign in' - click_link 'Sign in with Twitter' + visit "/" + click_link "Sign in" + click_link "Sign in with Twitter" expect_to_be_signed_in - click_link 'My account' - expect(page).to have_field('account_username', with: 'manuela') + click_link "My account" + expect(page).to have_field("account_username", with: "manuela") visit edit_user_registration_path - expect(page).to have_field('user_email', with: 'manueladelascarmenas@example.com') + expect(page).to have_field("user_email", with: "manueladelascarmenas@example.com") end - scenario 'Cancelling signup' do + scenario "Cancelling signup" do OmniAuth.config.add_mock(:twitter, twitter_hash) - visit '/' - click_link 'Register' - click_link 'Sign up with Twitter' + visit "/" + click_link "Register" + click_link "Sign up with Twitter" expect(page).to have_current_path(finish_signup_path) - click_link 'Cancel login' + click_link "Cancel login" - visit '/' + visit "/" expect_not_to_be_signed_in end - scenario 'Sign in, user was already signed up with OAuth' do - user = create(:user, email: 'manuela@consul.dev', password: 'judgementday') - create(:identity, uid: '12345', provider: 'twitter', user: user) + scenario "Sign in, user was already signed up with OAuth" do + user = create(:user, email: "manuela@consul.dev", password: "judgementday") + create(:identity, uid: "12345", provider: "twitter", user: user) OmniAuth.config.add_mock(:twitter, twitter_hash) - visit '/' - click_link 'Sign in' - click_link 'Sign in with Twitter' + visit "/" + click_link "Sign in" + click_link "Sign in with Twitter" expect_to_be_signed_in - click_link 'My account' - expect(page).to have_field('account_username', with: user.username) + click_link "My account" + expect(page).to have_field("account_username", with: user.username) visit edit_user_registration_path - expect(page).to have_field('user_email', with: user.email) + expect(page).to have_field("user_email", with: user.email) end - scenario 'Try to register with the username of an already existing user' do - create(:user, username: 'manuela', email: 'manuela@consul.dev', password: 'judgementday') + scenario "Try to register with the username of an already existing user" do + create(:user, username: "manuela", email: "manuela@consul.dev", password: "judgementday") OmniAuth.config.add_mock(:twitter, twitter_hash_with_verified_email) - visit '/' - click_link 'Register' - click_link 'Sign up with Twitter' + visit "/" + click_link "Register" + click_link "Sign up with Twitter" expect(page).to have_current_path(finish_signup_path) - expect(page).to have_field('user_username', with: 'manuela') + expect(page).to have_field("user_username", with: "manuela") - click_button 'Register' + click_button "Register" expect(page).to have_current_path(do_finish_signup_path) - fill_in 'user_username', with: 'manuela2' - click_button 'Register' + fill_in "user_username", with: "manuela2" + click_button "Register" expect_to_be_signed_in - click_link 'My account' - expect(page).to have_field('account_username', with: 'manuela2') + click_link "My account" + expect(page).to have_field("account_username", with: "manuela2") visit edit_user_registration_path - expect(page).to have_field('user_email', with: 'manuelacarmena@example.com') + expect(page).to have_field("user_email", with: "manuelacarmena@example.com") end - scenario 'Try to register with the email of an already existing user, when no email was provided by oauth' do - create(:user, username: 'peter', email: 'manuela@example.com') + scenario "Try to register with the email of an already existing user, when no email was provided by oauth" do + create(:user, username: "peter", email: "manuela@example.com") OmniAuth.config.add_mock(:twitter, twitter_hash) - visit '/' - click_link 'Register' - click_link 'Sign up with Twitter' + visit "/" + click_link "Register" + click_link "Sign up with Twitter" expect(page).to have_current_path(finish_signup_path) - fill_in 'user_email', with: 'manuela@example.com' - click_button 'Register' + fill_in "user_email", with: "manuela@example.com" + click_button "Register" expect(page).to have_current_path(do_finish_signup_path) - fill_in 'user_email', with: 'somethingelse@example.com' - click_button 'Register' + fill_in "user_email", with: "somethingelse@example.com" + click_button "Register" expect(page).to have_content "To continue, please click on the confirmation link that we have sent you via email" confirm_email expect(page).to have_content "Your account has been confirmed" - visit '/' - click_link 'Sign in' - click_link 'Sign in with Twitter' + visit "/" + click_link "Sign in" + click_link "Sign in with Twitter" expect_to_be_signed_in - click_link 'My account' - expect(page).to have_field('account_username', with: 'manuela') + click_link "My account" + expect(page).to have_field("account_username", with: "manuela") visit edit_user_registration_path - expect(page).to have_field('user_email', with: 'somethingelse@example.com') + expect(page).to have_field("user_email", with: "somethingelse@example.com") end - scenario 'Try to register with the email of an already existing user, when an unconfirmed email was provided by oauth' do - create(:user, username: 'peter', email: 'manuelacarmena@example.com') + scenario "Try to register with the email of an already existing user, when an unconfirmed email was provided by oauth" do + create(:user, username: "peter", email: "manuelacarmena@example.com") OmniAuth.config.add_mock(:twitter, twitter_hash_with_email) - visit '/' - click_link 'Register' - click_link 'Sign up with Twitter' + visit "/" + click_link "Register" + click_link "Sign up with Twitter" expect(page).to have_current_path(finish_signup_path) - expect(page).to have_field('user_email', with: 'manuelacarmena@example.com') - fill_in 'user_email', with: 'somethingelse@example.com' - click_button 'Register' + expect(page).to have_field("user_email", with: "manuelacarmena@example.com") + fill_in "user_email", with: "somethingelse@example.com" + click_button "Register" expect(page).to have_content "To continue, please click on the confirmation link that we have sent you via email" confirm_email expect(page).to have_content "Your account has been confirmed" - visit '/' - click_link 'Sign in' - click_link 'Sign in with Twitter' + visit "/" + click_link "Sign in" + click_link "Sign in with Twitter" expect_to_be_signed_in - click_link 'My account' - expect(page).to have_field('account_username', with: 'manuela') + click_link "My account" + expect(page).to have_field("account_username", with: "manuela") visit edit_user_registration_path - expect(page).to have_field('user_email', with: 'somethingelse@example.com') + expect(page).to have_field("user_email", with: "somethingelse@example.com") end end end - scenario 'Sign out' do + scenario "Sign out" do user = create(:user) login_as(user) visit "/" - click_link 'Sign out' + click_link "Sign out" - expect(page).to have_content 'You have been signed out successfully.' + expect(page).to have_content "You have been signed out successfully." end - scenario 'Reset password' do - create(:user, email: 'manuela@consul.dev') + scenario "Reset password" do + create(:user, email: "manuela@consul.dev") - visit '/' - click_link 'Sign in' - click_link 'Forgotten your password?' + visit "/" + click_link "Sign in" + click_link "Forgotten your password?" - fill_in 'user_email', with: 'manuela@consul.dev' - click_button 'Send instructions' + fill_in "user_email", with: "manuela@consul.dev" + click_button "Send instructions" expect(page).to have_content "In a few minutes, you will receive an email containing instructions on resetting your password." sent_token = /.*reset_password_token=(.*)".*/.match(ActionMailer::Base.deliveries.last.body.to_s)[1] visit edit_user_password_path(reset_password_token: sent_token) - fill_in 'user_password', with: 'new password' - fill_in 'user_password_confirmation', with: 'new password' - click_button 'Change my password' + fill_in "user_password", with: "new password" + fill_in "user_password_confirmation", with: "new password" + click_button "Change my password" expect(page).to have_content "Your password has been changed successfully." end - scenario 'Sign in, admin with password expired' do + scenario "Sign in, admin with password expired" do user = create(:user, password_changed_at: Time.current - 1.year) admin = create(:administrator, user: user) @@ -361,16 +361,16 @@ feature 'Users' do expect(page).to have_content "Your password is expired" - fill_in 'user_current_password', with: 'judgmentday' - fill_in 'user_password', with: '123456789' - fill_in 'user_password_confirmation', with: '123456789' + fill_in "user_current_password", with: "judgmentday" + fill_in "user_password", with: "123456789" + fill_in "user_password_confirmation", with: "123456789" - click_button 'Change your password' + click_button "Change your password" expect(page).to have_content "Password successfully updated" end - scenario 'Sign in, admin without password expired' do + scenario "Sign in, admin without password expired" do user = create(:user, password_changed_at: Time.current - 360.days) admin = create(:administrator, user: user) @@ -380,7 +380,7 @@ feature 'Users' do expect(page).not_to have_content "Your password is expired" end - scenario 'Sign in, user with password expired' do + scenario "Sign in, user with password expired" do user = create(:user, password_changed_at: Time.current - 1.year) login_as(user) @@ -389,8 +389,8 @@ feature 'Users' do expect(page).not_to have_content "Your password is expired" end - scenario 'Admin with password expired trying to use same password' do - user = create(:user, password_changed_at: Time.current - 1.year, password: '123456789') + scenario "Admin with password expired trying to use same password" do + user = create(:user, password_changed_at: Time.current - 1.year, password: "123456789") admin = create(:administrator, user: user) login_as(admin.user) @@ -398,10 +398,10 @@ feature 'Users' do expect(page).to have_content "Your password is expired" - fill_in 'user_current_password', with: 'judgmentday' - fill_in 'user_password', with: '123456789' - fill_in 'user_password_confirmation', with: '123456789' - click_button 'Change your password' + fill_in "user_current_password", with: "judgmentday" + fill_in "user_password", with: "123456789" + fill_in "user_password_confirmation", with: "123456789" + click_button "Change your password" expect(page).to have_content "must be different than the current password." end diff --git a/spec/features/users_spec.rb b/spec/features/users_spec.rb index 7baab30ea..ec4970887 100644 --- a/spec/features/users_spec.rb +++ b/spec/features/users_spec.rb @@ -1,8 +1,8 @@ -require 'rails_helper' +require "rails_helper" -feature 'Users' do +feature "Users" do - feature 'Show (public page)' do + feature "Show (public page)" do background do @user = create(:user) @@ -14,23 +14,23 @@ feature 'Users' do visit user_path(@user) end - scenario 'shows user public activity' do - expect(page).to have_content('1 Debate') - expect(page).to have_content('2 Proposals') - expect(page).to have_content('3 Investments') - expect(page).to have_content('4 Comments') + scenario "shows user public activity" do + expect(page).to have_content("1 Debate") + expect(page).to have_content("2 Proposals") + expect(page).to have_content("3 Investments") + expect(page).to have_content("4 Comments") end - scenario 'shows only items where user has activity' do + scenario "shows only items where user has activity" do @user.proposals.destroy_all - expect(page).not_to have_content('0 Proposals') - expect(page).to have_content('1 Debate') - expect(page).to have_content('3 Investments') - expect(page).to have_content('4 Comments') + expect(page).not_to have_content("0 Proposals") + expect(page).to have_content("1 Debate") + expect(page).to have_content("3 Investments") + expect(page).to have_content("4 Comments") end - scenario 'default filter is proposals' do + scenario "default filter is proposals" do @user.proposals.each do |proposal| expect(page).to have_content(proposal.title) end @@ -44,14 +44,14 @@ feature 'Users' do end end - scenario 'shows debates by default if user has no proposals' do + scenario "shows debates by default if user has no proposals" do @user.proposals.destroy_all visit user_path(@user) expect(page).to have_content(@user.debates.first.title) end - scenario 'shows investments by default if user has no proposals nor debates' do + scenario "shows investments by default if user has no proposals nor debates" do @user.proposals.destroy_all @user.debates.destroy_all visit user_path(@user) @@ -59,7 +59,7 @@ feature 'Users' do expect(page).to have_content(@user.budget_investments.first.title) end - scenario 'shows comments by default if user has no proposals nor debates nor investments' do + scenario "shows comments by default if user has no proposals nor debates nor investments" do @user.proposals.destroy_all @user.debates.destroy_all @user.budget_investments.destroy_all @@ -70,8 +70,8 @@ feature 'Users' do end end - scenario 'filters' do - click_link '1 Debate' + scenario "filters" do + click_link "1 Debate" @user.debates.each do |debate| expect(page).to have_content(debate.title) @@ -85,7 +85,7 @@ feature 'Users' do expect(page).not_to have_content(comment.body) end - click_link '4 Comments' + click_link "4 Comments" @user.comments.each do |comment| expect(page).to have_content(comment.body) @@ -99,7 +99,7 @@ feature 'Users' do expect(page).not_to have_content(debate.title) end - click_link '2 Proposals' + click_link "2 Proposals" @user.proposals.each do |proposal| expect(page).to have_content(proposal.title) @@ -116,7 +116,7 @@ feature 'Users' do scenario "Show alert when user wants to delete a budget investment", :js do user = create(:user, :level_two) - budget = create(:budget, phase: 'accepting') + budget = create(:budget, phase: "accepting") budget_investment = create(:budget_investment, author_id: user.id, budget: budget) login_as(user) @@ -125,106 +125,106 @@ feature 'Users' do expect(page).to have_link budget_investment.title within("#budget_investment_#{budget_investment.id}") do - dismiss_confirm { click_link 'Delete' } + dismiss_confirm { click_link "Delete" } end expect(page).to have_link budget_investment.title within("#budget_investment_#{budget_investment.id}") do - accept_confirm { click_link 'Delete' } + accept_confirm { click_link "Delete" } end expect(page).not_to have_link budget_investment.title end end - feature 'Public activity' do + feature "Public activity" do background do @user = create(:user) end - scenario 'visible by default' do + scenario "visible by default" do visit user_path(@user) expect(page).to have_content(@user.username) - expect(page).not_to have_content('activity list private') + expect(page).not_to have_content("activity list private") end - scenario 'user can hide public page' do + scenario "user can hide public page" do login_as(@user) visit account_path - uncheck 'account_public_activity' - click_button 'Save changes' + uncheck "account_public_activity" + click_button "Save changes" logout visit user_path(@user) - expect(page).to have_content('activity list private') + expect(page).to have_content("activity list private") end - scenario 'is always visible for the owner' do + scenario "is always visible for the owner" do login_as(@user) visit account_path - uncheck 'account_public_activity' - click_button 'Save changes' + uncheck "account_public_activity" + click_button "Save changes" visit user_path(@user) - expect(page).not_to have_content('activity list private') + expect(page).not_to have_content("activity list private") end - scenario 'is always visible for admins' do + scenario "is always visible for admins" do login_as(@user) visit account_path - uncheck 'account_public_activity' - click_button 'Save changes' + uncheck "account_public_activity" + click_button "Save changes" logout login_as(create(:administrator).user) visit user_path(@user) - expect(page).not_to have_content('activity list private') + expect(page).not_to have_content("activity list private") end - scenario 'is always visible for moderators' do + scenario "is always visible for moderators" do login_as(@user) visit account_path - uncheck 'account_public_activity' - click_button 'Save changes' + uncheck "account_public_activity" + click_button "Save changes" logout login_as(create(:moderator).user) visit user_path(@user) - expect(page).not_to have_content('activity list private') + expect(page).not_to have_content("activity list private") end - feature 'User email' do + feature "User email" do background do @user = create(:user) end - scenario 'is not shown if no user logged in' do + scenario "is not shown if no user logged in" do visit user_path(@user) expect(page).not_to have_content(@user.email) end - scenario 'is not shown if logged in user is a regular user' do + scenario "is not shown if logged in user is a regular user" do login_as(create(:user)) visit user_path(@user) expect(page).not_to have_content(@user.email) end - scenario 'is not shown if logged in user is moderator' do + scenario "is not shown if logged in user is moderator" do login_as(create(:moderator).user) visit user_path(@user) expect(page).not_to have_content(@user.email) end - scenario 'is shown if logged in user is admin' do + scenario "is shown if logged in user is admin" do login_as(create(:administrator).user) visit user_path(@user) expect(page).to have_content(@user.email) @@ -234,20 +234,20 @@ feature 'Users' do end - feature 'Public interests' do + feature "Public interests" do background do @user = create(:user) end - scenario 'Display interests' do + scenario "Display interests" do proposal = create(:proposal, tag_list: "Sport") create(:follow, :followed_proposal, followable: proposal, user: @user) login_as(@user) visit account_path - check 'account_public_interests' - click_button 'Save changes' + check "account_public_interests" + click_button "Save changes" logout @@ -255,7 +255,7 @@ feature 'Users' do expect(page).to have_content("Sport") end - scenario 'Not display interests when proposal has been destroyed' do + scenario "Not display interests when proposal has been destroyed" do proposal = create(:proposal, tag_list: "Sport") create(:follow, :followed_proposal, followable: proposal, user: @user) proposal.destroy @@ -263,8 +263,8 @@ feature 'Users' do login_as(@user) visit account_path - check 'account_public_interests' - click_button 'Save changes' + check "account_public_interests" + click_button "Save changes" logout @@ -272,103 +272,103 @@ feature 'Users' do expect(page).not_to have_content("Sport") end - scenario 'No visible by default' do + scenario "No visible by default" do visit user_path(@user) expect(page).to have_content(@user.username) - expect(page).not_to have_css('#public_interests') + expect(page).not_to have_css("#public_interests") end - scenario 'User can display public page' do + scenario "User can display public page" do proposal = create(:proposal, tag_list: "Sport") create(:follow, :followed_proposal, followable: proposal, user: @user) login_as(@user) visit account_path - check 'account_public_interests' - click_button 'Save changes' + check "account_public_interests" + click_button "Save changes" logout - visit user_path(@user, filter: 'follows', page: '1') + visit user_path(@user, filter: "follows", page: "1") - expect(page).to have_css('#public_interests') + expect(page).to have_css("#public_interests") end - scenario 'Is always visible for the owner' do + scenario "Is always visible for the owner" do proposal = create(:proposal, tag_list: "Sport") create(:follow, :followed_proposal, followable: proposal, user: @user) login_as(@user) visit account_path - uncheck 'account_public_interests' - click_button 'Save changes' + uncheck "account_public_interests" + click_button "Save changes" - visit user_path(@user, filter: 'follows', page: '1') - expect(page).to have_css('#public_interests') + visit user_path(@user, filter: "follows", page: "1") + expect(page).to have_css("#public_interests") end - scenario 'Is always visible for admins' do + scenario "Is always visible for admins" do proposal = create(:proposal, tag_list: "Sport") create(:follow, :followed_proposal, followable: proposal, user: @user) login_as(@user) visit account_path - uncheck 'account_public_interests' - click_button 'Save changes' + uncheck "account_public_interests" + click_button "Save changes" logout login_as(create(:administrator).user) - visit user_path(@user, filter: 'follows', page: '1') - expect(page).to have_css('#public_interests') + visit user_path(@user, filter: "follows", page: "1") + expect(page).to have_css("#public_interests") end - scenario 'Is always visible for moderators' do + scenario "Is always visible for moderators" do proposal = create(:proposal, tag_list: "Sport") create(:follow, :followed_proposal, followable: proposal, user: @user) login_as(@user) visit account_path - uncheck 'account_public_interests' - click_button 'Save changes' + uncheck "account_public_interests" + click_button "Save changes" logout login_as(create(:moderator).user) - visit user_path(@user, filter: 'follows', page: '1') - expect(page).to have_css('#public_interests') + visit user_path(@user, filter: "follows", page: "1") + expect(page).to have_css("#public_interests") end - scenario 'Should display generic interests title' do + scenario "Should display generic interests title" do proposal = create(:proposal, tag_list: "Sport") create(:follow, :followed_proposal, followable: proposal, user: @user) @user.update(public_interests: true) - visit user_path(@user, filter: 'follows', page: '1') + visit user_path(@user, filter: "follows", page: "1") expect(page).to have_content("Tags of elements this user follows") end - scenario 'Should display custom interests title when user is visiting own user page' do + scenario "Should display custom interests title when user is visiting own user page" do proposal = create(:proposal, tag_list: "Sport") create(:follow, :followed_proposal, followable: proposal, user: @user) @user.update(public_interests: true) login_as(@user) - visit user_path(@user, filter: 'follows', page: '1') + visit user_path(@user, filter: "follows", page: "1") expect(page).to have_content("Tags of elements you follow") end end - feature 'Special comments' do + feature "Special comments" do - scenario 'comments posted as moderator are not visible in user activity' do + scenario "comments posted as moderator are not visible in user activity" do moderator = create(:administrator).user comment = create(:comment, user: moderator) moderator_comment = create(:comment, user: moderator, moderator_id: moderator.id) @@ -379,7 +379,7 @@ feature 'Users' do expect(page).not_to have_content(moderator_comment.body) end - scenario 'comments posted as admin are not visible in user activity' do + scenario "comments posted as admin are not visible in user activity" do admin = create(:administrator).user comment = create(:comment, user: admin) admin_comment = create(:comment, user: admin, administrator_id: admin.id) @@ -389,7 +389,7 @@ feature 'Users' do expect(page).not_to have_content(admin_comment.body) end - scenario 'valuation comments are not visible in user activity' do + scenario "valuation comments are not visible in user activity" do admin = create(:administrator).user comment = create(:comment, user: admin) investment = create(:budget_investment) @@ -400,29 +400,29 @@ feature 'Users' do expect(page).not_to have_content(valuation_comment.body) end - scenario 'shows only comments from active features' do + scenario "shows only comments from active features" do user = create(:user) 1.times {create(:comment, user: user, commentable: create(:debate))} 2.times {create(:comment, user: user, commentable: create(:budget_investment))} 4.times {create(:comment, user: user, commentable: create(:proposal))} visit user_path(user) - expect(page).to have_content('7 Comments') + expect(page).to have_content("7 Comments") - Setting['feature.debates'] = nil + Setting["feature.debates"] = nil visit user_path(user) - expect(page).to have_content('6 Comments') + expect(page).to have_content("6 Comments") - Setting['feature.budgets'] = nil + Setting["feature.budgets"] = nil visit user_path(user) - expect(page).to have_content('4 Comments') + expect(page).to have_content("4 Comments") - Setting['feature.debates'] = true - Setting['feature.budgets'] = true + Setting["feature.debates"] = true + Setting["feature.budgets"] = true end end - feature 'Following (public page)' do + feature "Following (public page)" do before do @user = create(:user) @@ -431,10 +431,10 @@ feature 'Users' do scenario "Do not display follows' tab when user is not following any followables" do visit user_path(@user) - expect(page).not_to have_content('0 Following') + expect(page).not_to have_content("0 Following") end - scenario 'Active following tab by default when follows filters selected', :js do + scenario "Active following tab by default when follows filters selected", :js do proposal = create(:proposal, author: @user) create(:follow, followable: proposal, user: @user) @@ -453,80 +453,80 @@ feature 'Users' do hidden_proposal.hide visit user_path(@user) - expect(page).to have_content('1 Following') + expect(page).to have_content("1 Following") end - describe 'Proposals' do + describe "Proposals" do - scenario 'Display following tab when user is following one proposal at least' do + scenario "Display following tab when user is following one proposal at least" do proposal = create(:proposal) create(:follow, followable: proposal, user: @user) visit user_path(@user) - expect(page).to have_content('1 Following') + expect(page).to have_content("1 Following") end - scenario 'Display proposal tab when user is following one proposal at least' do + scenario "Display proposal tab when user is following one proposal at least" do proposal = create(:proposal) create(:follow, followable: proposal, user: @user) visit user_path(@user, filter: "follows") - expect(page).to have_link('Citizen proposals', href: "#citizen_proposals") + expect(page).to have_link("Citizen proposals", href: "#citizen_proposals") end scenario "Do not display proposals' tab when user is not following any proposal" do visit user_path(@user, filter: "follows") - expect(page).not_to have_link('Citizen proposals', href: "#citizen_proposals") + expect(page).not_to have_link("Citizen proposals", href: "#citizen_proposals") end - scenario 'Display proposals with link to proposal' do + scenario "Display proposals with link to proposal" do proposal = create(:proposal, author: @user) create(:follow, followable: proposal, user: @user) login_as @user visit user_path(@user, filter: "follows") - click_link 'Citizen proposals' + click_link "Citizen proposals" expect(page).to have_content proposal.title end end - describe 'Budget Investments' do + describe "Budget Investments" do - scenario 'Display following tab when user is following one budget investment at least' do + scenario "Display following tab when user is following one budget investment at least" do budget_investment = create(:budget_investment) create(:follow, followable: budget_investment, user: @user) visit user_path(@user) - expect(page).to have_content('1 Following') + expect(page).to have_content("1 Following") end - scenario 'Display budget investment tab when user is following one budget investment at least' do + scenario "Display budget investment tab when user is following one budget investment at least" do budget_investment = create(:budget_investment) create(:follow, followable: budget_investment, user: @user) visit user_path(@user, filter: "follows") - expect(page).to have_link('Investments', href: "#investments") + expect(page).to have_link("Investments", href: "#investments") end - scenario 'Not display budget investment tab when user is not following any budget investment' do + scenario "Not display budget investment tab when user is not following any budget investment" do visit user_path(@user, filter: "follows") - expect(page).not_to have_link('Investments', href: "#investments") + expect(page).not_to have_link("Investments", href: "#investments") end - scenario 'Display budget investment with link to budget investment' do + scenario "Display budget investment with link to budget investment" do user = create(:user, :level_two) budget_investment = create(:budget_investment, author: user) create(:follow, followable: budget_investment, user: user) visit user_path(user, filter: "follows") - click_link 'Investments' + click_link "Investments" expect(page).to have_link budget_investment.title end diff --git a/spec/features/valuation/budget_investments_spec.rb b/spec/features/valuation/budget_investments_spec.rb index 396f3a007..5649c8873 100644 --- a/spec/features/valuation/budget_investments_spec.rb +++ b/spec/features/valuation/budget_investments_spec.rb @@ -1,32 +1,32 @@ -require 'rails_helper' +require "rails_helper" -feature 'Valuation budget investments' do +feature "Valuation budget investments" do let(:budget) { create(:budget, :valuating) } let(:valuator) do - create(:valuator, user: create(:user, username: 'Rachel', email: 'rachel@valuators.org')) + create(:valuator, user: create(:user, username: "Rachel", email: "rachel@valuators.org")) end background do login_as(valuator.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 valuation_budget_budget_investments_path(create(:budget)) }.to raise_exception(FeatureFlags::FeatureDisabled) - Setting['feature.budgets'] = true + Setting["feature.budgets"] = true end - scenario 'Display link to valuation section' do + scenario "Display link to valuation section" do visit root_path expect(page).to have_link "Valuation", href: valuation_root_path end - feature 'Index' do - scenario 'Index shows budget investments assigned to current valuator' do + feature "Index" do + scenario "Index shows budget investments assigned to current valuator" do investment1 = create(:budget_investment, :visible_to_valuators, budget: budget) investment2 = create(:budget_investment, :visible_to_valuators, budget: budget) @@ -38,7 +38,7 @@ feature 'Valuation budget investments' do expect(page).not_to have_content(investment2.title) end - scenario 'Index shows no budget investment to admins no valuators' do + scenario "Index shows no budget investment to admins no valuators" do investment1 = create(:budget_investment, :visible_to_valuators, budget: budget) investment2 = create(:budget_investment, :visible_to_valuators, budget: budget) @@ -52,7 +52,7 @@ feature 'Valuation budget investments' do expect(page).not_to have_content(investment2.title) end - scenario 'Index orders budget investments by votes' do + scenario "Index orders budget investments by votes" do investment10 = create(:budget_investment, :visible_to_valuators, budget: budget, cached_votes_up: 10) investment100 = create(:budget_investment, :visible_to_valuators, budget: budget, @@ -70,7 +70,7 @@ feature 'Valuation budget investments' do expect(investment10.title).to appear_before(investment1.title) end - scenario 'Index displays investments paginated' do + scenario "Index displays investments paginated" do per_page = Kaminari.config.default_per_page (per_page + 2).times do investment = create(:budget_investment, :visible_to_valuators, budget: budget) @@ -79,7 +79,7 @@ feature 'Valuation budget investments' do visit valuation_budget_budget_investments_path(budget) - expect(page).to have_css('.budget_investment', count: per_page) + expect(page).to have_css(".budget_investment", count: per_page) within("ul.pagination") do expect(page).to have_content("1") expect(page).to have_content("2") @@ -87,7 +87,7 @@ feature 'Valuation budget investments' do click_link "Next", exact: false end - expect(page).to have_css('.budget_investment', count: 2) + expect(page).to have_css(".budget_investment", count: 2) end scenario "Index filtering by heading", :js do @@ -123,10 +123,10 @@ feature 'Valuation budget investments' do expect(page).not_to have_link("Finished ONE") expect(page).not_to have_link("Finished TWO") - expect(page).to have_link('All headings (4)') - expect(page).to have_link('Only Valuating (1)') - expect(page).to have_link('Valuating&Finished (2)') - expect(page).to have_link('Only Finished (1)') + expect(page).to have_link("All headings (4)") + expect(page).to have_link("Only Valuating (1)") + expect(page).to have_link("Valuating&Finished (2)") + expect(page).to have_link("Only Finished (1)") click_link "Only Valuating (1)", exact: false expect(page).to have_link("Valuating Investment ONE") @@ -134,7 +134,7 @@ feature 'Valuation budget investments' do expect(page).not_to have_link("Finished ONE") expect(page).not_to have_link("Finished TWO") - click_link 'Valuation finished' + click_link "Valuation finished" expect(page).not_to have_link("Valuating Investment ONE") expect(page).not_to have_link("Valuating Investment TWO") expect(page).not_to have_link("Finished ONE") @@ -146,7 +146,7 @@ feature 'Valuation budget investments' do expect(page).not_to have_link("Finished ONE") expect(page).not_to have_link("Finished TWO") - click_link 'Valuation finished' + click_link "Valuation finished" expect(page).not_to have_link("Valuating Investment ONE") expect(page).not_to have_link("Valuating Investment TWO") expect(page).to have_link("Finished ONE") @@ -158,7 +158,7 @@ feature 'Valuation budget investments' do expect(page).not_to have_link("Finished ONE") expect(page).not_to have_link("Finished TWO") - click_link 'Valuation finished' + click_link "Valuation finished" expect(page).not_to have_link("Valuating Investment ONE") expect(page).not_to have_link("Valuating Investment TWO") expect(page).not_to have_link("Finished ONE") @@ -166,8 +166,8 @@ feature 'Valuation budget investments' do end scenario "Current filter is properly highlighted" do - filters_links = {'valuating' => 'Under valuation', - 'valuation_finished' => 'Valuation finished'} + filters_links = {"valuating" => "Under valuation", + "valuation_finished" => "Valuation finished"} visit valuation_budget_budget_investments_path(budget) @@ -199,28 +199,28 @@ feature 'Valuation budget investments' do expect(page).to have_content("Ongoing valuation") expect(page).not_to have_content("Old idea") - visit valuation_budget_budget_investments_path(budget, filter: 'valuating') + visit valuation_budget_budget_investments_path(budget, filter: "valuating") expect(page).to have_content("Ongoing valuation") expect(page).not_to have_content("Old idea") - visit valuation_budget_budget_investments_path(budget, filter: 'valuation_finished') + visit valuation_budget_budget_investments_path(budget, filter: "valuation_finished") expect(page).not_to have_content("Ongoing valuation") expect(page).to have_content("Old idea") end end - feature 'Show' do + feature "Show" do let(:administrator) do - create(:administrator, user: create(:user, username: 'Ana', email: 'ana@admins.org')) + create(:administrator, user: create(:user, username: "Ana", email: "ana@admins.org")) end let(:second_valuator) do - create(:valuator, user: create(:user, username: 'Rick', email: 'rick@valuators.org')) + create(:valuator, user: create(:user, username: "Rick", email: "rick@valuators.org")) end let(:investment) do - create(:budget_investment, budget: budget, price: 1234, feasibility: 'unfeasible', - unfeasibility_explanation: 'It is impossible', + create(:budget_investment, budget: budget, price: 1234, feasibility: "unfeasible", + unfeasibility_explanation: "It is impossible", administrator: administrator,) end @@ -228,7 +228,7 @@ feature 'Valuation budget investments' do investment.valuators << [valuator, second_valuator] end - scenario 'visible for assigned valuators' do + scenario "visible for assigned valuators" do investment.update(visible_to_valuators: true) visit valuation_budget_budget_investments_path(budget) @@ -239,18 +239,18 @@ feature 'Valuation budget investments' do expect(page).to have_content(investment.description) expect(page).to have_content(investment.author.name) expect(page).to have_content(investment.heading.name) - expect(page).to have_content('1234') - expect(page).to have_content('Unfeasible') - expect(page).to have_content('It is impossible') - expect(page).to have_content('Ana (ana@admins.org)') + expect(page).to have_content("1234") + expect(page).to have_content("Unfeasible") + expect(page).to have_content("It is impossible") + expect(page).to have_content("Ana (ana@admins.org)") - within('#assigned_valuators') do - expect(page).to have_content('Rachel (rachel@valuators.org)') - expect(page).to have_content('Rick (rick@valuators.org)') + within("#assigned_valuators") do + expect(page).to have_content("Rachel (rachel@valuators.org)") + expect(page).to have_content("Rick (rick@valuators.org)") end end - scenario 'visible for admins' do + scenario "visible for admins" do logout login_as create(:administrator).user @@ -260,18 +260,18 @@ feature 'Valuation budget investments' do expect(page).to have_content(investment.description) expect(page).to have_content(investment.author.name) expect(page).to have_content(investment.heading.name) - expect(page).to have_content('1234') - expect(page).to have_content('Unfeasible') - expect(page).to have_content('It is impossible') - expect(page).to have_content('Ana (ana@admins.org)') + expect(page).to have_content("1234") + expect(page).to have_content("Unfeasible") + expect(page).to have_content("It is impossible") + expect(page).to have_content("Ana (ana@admins.org)") - within('#assigned_valuators') do - expect(page).to have_content('Rachel (rachel@valuators.org)') - expect(page).to have_content('Rick (rick@valuators.org)') + within("#assigned_valuators") do + expect(page).to have_content("Rachel (rachel@valuators.org)") + expect(page).to have_content("Rick (rick@valuators.org)") end end - scenario 'not visible for not assigned valuators' do + scenario "not visible for not assigned valuators" do logout login_as create(:valuator).user @@ -282,7 +282,7 @@ feature 'Valuation budget investments' do end - feature 'Valuate' do + feature "Valuate" do let(:admin) { create(:administrator) } let(:investment) do group = create(:budget_group, budget: budget) @@ -295,71 +295,71 @@ feature 'Valuation budget investments' do investment.valuators << valuator end - scenario 'Dossier empty by default' do + scenario "Dossier empty by default" do investment.update(visible_to_valuators: true) visit valuation_budget_budget_investments_path(budget) click_link investment.title - within('#price') { expect(page).to have_content('Undefined') } - within('#price_first_year') { expect(page).to have_content('Undefined') } - within('#duration') { expect(page).to have_content('Undefined') } - within('#feasibility') { expect(page).to have_content('Undecided') } - expect(page).not_to have_content('Valuation finished') + within("#price") { expect(page).to have_content("Undefined") } + within("#price_first_year") { expect(page).to have_content("Undefined") } + within("#duration") { expect(page).to have_content("Undefined") } + within("#feasibility") { expect(page).to have_content("Undecided") } + expect(page).not_to have_content("Valuation finished") end - scenario 'Edit dossier' do + scenario "Edit dossier" do investment.update(visible_to_valuators: true) visit valuation_budget_budget_investments_path(budget) within("#budget_investment_#{investment.id}") do click_link "Edit dossier" end - fill_in 'budget_investment_price', with: '12345' - fill_in 'budget_investment_price_first_year', with: '9876' - fill_in 'budget_investment_price_explanation', with: 'Very cheap idea' - choose 'budget_investment_feasibility_feasible' - fill_in 'budget_investment_duration', with: '19 months' - click_button 'Save changes' + fill_in "budget_investment_price", with: "12345" + fill_in "budget_investment_price_first_year", with: "9876" + fill_in "budget_investment_price_explanation", with: "Very cheap idea" + choose "budget_investment_feasibility_feasible" + fill_in "budget_investment_duration", with: "19 months" + click_button "Save changes" expect(page).to have_content "Dossier updated" visit valuation_budget_budget_investments_path(budget) click_link investment.title - within('#price') { expect(page).to have_content('12345') } - within('#price_first_year') { expect(page).to have_content('9876') } - expect(page).to have_content('Very cheap idea') - within('#duration') { expect(page).to have_content('19 months') } - within('#feasibility') { expect(page).to have_content('Feasible') } - expect(page).not_to have_content('Valuation finished') + within("#price") { expect(page).to have_content("12345") } + within("#price_first_year") { expect(page).to have_content("9876") } + expect(page).to have_content("Very cheap idea") + within("#duration") { expect(page).to have_content("19 months") } + within("#feasibility") { expect(page).to have_content("Feasible") } + expect(page).not_to have_content("Valuation finished") end - scenario 'Feasibility can be marked as pending' do + scenario "Feasibility can be marked as pending" do visit valuation_budget_budget_investment_path(budget, investment) - click_link 'Edit dossier' + click_link "Edit dossier" expect(find("#budget_investment_feasibility_undecided")).to be_checked - choose 'budget_investment_feasibility_feasible' - click_button 'Save changes' + choose "budget_investment_feasibility_feasible" + click_button "Save changes" visit edit_valuation_budget_budget_investment_path(budget, investment) expect(find("#budget_investment_feasibility_undecided")).not_to be_checked expect(find("#budget_investment_feasibility_feasible")).to be_checked - choose 'budget_investment_feasibility_undecided' - click_button 'Save changes' + choose "budget_investment_feasibility_undecided" + click_button "Save changes" visit edit_valuation_budget_budget_investment_path(budget, investment) expect(find("#budget_investment_feasibility_undecided")).to be_checked end - scenario 'Feasibility selection makes proper fields visible', :js do - feasible_fields = ['Price (€)', 'Cost during the first year (€)', 'Price explanation', - 'Time scope'] - unfeasible_fields = ['Feasibility explanation'] - any_feasibility_fields = ['Valuation finished'] + scenario "Feasibility selection makes proper fields visible", :js do + feasible_fields = ["Price (€)", "Cost during the first year (€)", "Price explanation", + "Time scope"] + unfeasible_fields = ["Feasibility explanation"] + any_feasibility_fields = ["Valuation finished"] undecided_fields = feasible_fields + unfeasible_fields + any_feasibility_fields visit edit_valuation_budget_budget_investment_path(budget, investment) @@ -370,7 +370,7 @@ feature 'Valuation budget investments' do expect(page).to have_content(field) end - choose 'budget_investment_feasibility_feasible' + choose "budget_investment_feasibility_feasible" unfeasible_fields.each do |field| expect(page).not_to have_content(field) @@ -380,7 +380,7 @@ feature 'Valuation budget investments' do expect(page).to have_content(field) end - choose 'budget_investment_feasibility_unfeasible' + choose "budget_investment_feasibility_unfeasible" feasible_fields.each do |field| expect(page).not_to have_content(field) @@ -390,7 +390,7 @@ feature 'Valuation budget investments' do expect(page).to have_content(field) end - click_button 'Save changes' + click_button "Save changes" visit edit_valuation_budget_budget_investment_path(budget, investment) @@ -403,45 +403,45 @@ feature 'Valuation budget investments' do expect(page).to have_content(field) end - choose 'budget_investment_feasibility_undecided' + choose "budget_investment_feasibility_undecided" undecided_fields.each do |field| expect(page).to have_content(field) end end - scenario 'Finish valuation' do + scenario "Finish valuation" do investment.update(visible_to_valuators: true) visit valuation_budget_budget_investment_path(budget, investment) - click_link 'Edit dossier' + click_link "Edit dossier" - find_field('budget_investment[valuation_finished]').click - click_button 'Save changes' + find_field("budget_investment[valuation_finished]").click + click_button "Save changes" visit valuation_budget_budget_investments_path(budget) expect(page).not_to have_content investment.title - click_link 'Valuation finished' + click_link "Valuation finished" expect(page).to have_content investment.title click_link investment.title - expect(page).to have_content('Valuation finished') + expect(page).to have_content("Valuation finished") end - context 'Reopen valuation' do + context "Reopen valuation" do background do investment.update( valuation_finished: true, - feasibility: 'feasible', - unfeasibility_explanation: 'Explanation is explanatory', + feasibility: "feasible", + unfeasibility_explanation: "Explanation is explanatory", price: 999, price_first_year: 666, - price_explanation: 'Democracy is not cheap', - duration: '1 light year' + price_explanation: "Democracy is not cheap", + duration: "1 light year" ) end - scenario 'Admins can reopen & modify finished valuation' do + scenario "Admins can reopen & modify finished valuation" do logout login_as(admin.user) visit edit_valuation_budget_budget_investment_path(budget, investment) @@ -449,27 +449,27 @@ feature 'Valuation budget investments' do expect(page).to have_selector("input[id='budget_investment_feasibility_undecided']") expect(page).to have_selector("textarea[id='budget_investment_unfeasibility_explanation']") expect(page).to have_selector("input[name='budget_investment[valuation_finished]']") - expect(page).to have_button('Save changes') + expect(page).to have_button("Save changes") end - scenario 'Valuators that are not admins cannot reopen or modify a finished valuation' do + scenario "Valuators that are not admins cannot reopen or modify a finished valuation" do visit edit_valuation_budget_budget_investment_path(budget, investment) expect(page).not_to have_selector("input[id='budget_investment_feasibility_undecided']") expect(page).not_to have_selector("textarea[id='budget_investment_unfeasibility_explanation']") expect(page).not_to have_selector("input[name='budget_investment[valuation_finished]']") - expect(page).to have_content('Valuation finished') - expect(page).to have_content('Feasibility: Feasible') - expect(page).to have_content('Feasibility explanation: Explanation is explanatory') - expect(page).to have_content('Price (€): 999') - expect(page).to have_content('Cost during the first year: 666') - expect(page).to have_content('Price explanation: Democracy is not cheap') - expect(page).to have_content('Time scope: 1 light year') - expect(page).not_to have_button('Save changes') + expect(page).to have_content("Valuation finished") + expect(page).to have_content("Feasibility: Feasible") + expect(page).to have_content("Feasibility explanation: Explanation is explanatory") + expect(page).to have_content("Price (€): 999") + expect(page).to have_content("Cost during the first year: 666") + expect(page).to have_content("Price explanation: Democracy is not cheap") + expect(page).to have_content("Time scope: 1 light year") + expect(page).not_to have_button("Save changes") end end - scenario 'Validates price formats' do + scenario "Validates price formats" do investment.update(visible_to_valuators: true) visit valuation_budget_budget_investments_path(budget) @@ -478,16 +478,16 @@ feature 'Valuation budget investments' do click_link "Edit dossier" end - fill_in 'budget_investment_price', with: '12345,98' - fill_in 'budget_investment_price_first_year', with: '9876.6' - click_button 'Save changes' + fill_in "budget_investment_price", with: "12345,98" + fill_in "budget_investment_price_first_year", with: "9876.6" + click_button "Save changes" - expect(page).to have_content('2 errors') - expect(page).to have_content('Only integer numbers', count: 2) + expect(page).to have_content("2 errors") + expect(page).to have_content("Only integer numbers", count: 2) end - scenario 'not visible to valuators when budget is not valuating' do - budget.update(phase: 'publishing_prices') + scenario "not visible to valuators when budget is not valuating" do + budget.update(phase: "publishing_prices") investment = create(:budget_investment, budget: budget) investment.valuators << [valuator] @@ -495,11 +495,11 @@ feature 'Valuation budget investments' do login_as(valuator.user) visit edit_valuation_budget_budget_investment_path(budget, investment) - expect(page).to have_content('Investments can only be valuated when Budget is in valuating phase') + expect(page).to have_content("Investments can only be valuated when Budget is in valuating phase") end - scenario 'visible to admins regardless of not being in valuating phase' do - budget.update(phase: 'publishing_prices') + scenario "visible to admins regardless of not being in valuating phase" do + budget.update(phase: "publishing_prices") user = create(:user) admin = create(:administrator, user: user) @@ -511,7 +511,7 @@ feature 'Valuation budget investments' do login_as(admin.user) visit valuation_budget_budget_investment_path(budget, investment) - click_link 'Edit dossier' + click_link "Edit dossier" expect(page).to have_content investment.title end diff --git a/spec/features/valuation/budgets_spec.rb b/spec/features/valuation/budgets_spec.rb index ac8e79ab3..bc5a828ec 100644 --- a/spec/features/valuation/budgets_spec.rb +++ b/spec/features/valuation/budgets_spec.rb @@ -1,29 +1,29 @@ -require 'rails_helper' +require "rails_helper" -feature 'Valuation budgets' do +feature "Valuation budgets" do background do - @valuator = create(:valuator, user: create(:user, username: 'Rachel', email: 'rachel@valuators.org')) + @valuator = create(:valuator, user: create(:user, username: "Rachel", email: "rachel@valuators.org")) login_as(@valuator.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 valuation_budgets_path }.to raise_exception(FeatureFlags::FeatureDisabled) - Setting['feature.budgets'] = true + Setting["feature.budgets"] = true end - context 'Index' do + context "Index" do - scenario 'Displaying budgets' do + scenario "Displaying budgets" do budget = create(:budget) visit valuation_budgets_path expect(page).to have_content(budget.name) end - scenario 'Filters by phase' do + scenario "Filters by phase" do budget1 = create(:budget, :finished) budget2 = create(:budget, :finished) budget3 = create(:budget, :accepting) diff --git a/spec/features/valuation_spec.rb b/spec/features/valuation_spec.rb index 3ae2558a5..d67070760 100644 --- a/spec/features/valuation_spec.rb +++ b/spec/features/valuation_spec.rb @@ -1,10 +1,10 @@ -require 'rails_helper' +require "rails_helper" -feature 'Valuation' do +feature "Valuation" do let(:user) { create(:user) } - context 'Access' do - scenario 'Access as regular user is not authorized' do + context "Access" do + scenario "Access as regular user is not authorized" do login_as(user) visit root_path @@ -16,7 +16,7 @@ feature 'Valuation' 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 root_path @@ -29,7 +29,7 @@ feature 'Valuation' 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 root_path @@ -42,7 +42,7 @@ feature 'Valuation' 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 root_path @@ -55,7 +55,7 @@ feature 'Valuation' do expect(page).to have_content "You do not have permission to access this page" end - scenario 'Access as a valuator is authorized' do + scenario "Access as a valuator is authorized" do create(:valuator, user: user) create(:budget) @@ -69,7 +69,7 @@ feature 'Valuation' do expect(page).not_to have_content "You do not have permission to access this page" end - scenario 'Access as an administrator is authorized' do + scenario "Access as an administrator is authorized" do create(:administrator, user: user) create(:budget) @@ -84,31 +84,31 @@ feature 'Valuation' do end end - scenario 'Valuation access links' do + scenario "Valuation access links" do create(:valuator, user: user) create(:budget) login_as(user) visit root_path - expect(page).to have_link('Valuation') - expect(page).not_to have_link('Administration') - expect(page).not_to have_link('Moderation') + expect(page).to have_link("Valuation") + expect(page).not_to have_link("Administration") + expect(page).not_to have_link("Moderation") end - scenario 'Valuation dashboard' do + scenario "Valuation dashboard" do create(:valuator, user: user) create(:budget) login_as(user) visit root_path - click_link 'Valuation' + click_link "Valuation" expect(page).to have_current_path(valuation_root_path) - expect(page).to have_css('#valuation_menu') - expect(page).not_to have_css('#admin_menu') - expect(page).not_to have_css('#moderation_menu') + expect(page).to have_css("#valuation_menu") + expect(page).not_to have_css("#admin_menu") + expect(page).not_to have_css("#moderation_menu") end end diff --git a/spec/features/verification/email_spec.rb b/spec/features/verification/email_spec.rb index d29a56a80..662da10f6 100644 --- a/spec/features/verification/email_spec.rb +++ b/spec/features/verification/email_spec.rb @@ -1,28 +1,28 @@ -require 'rails_helper' +require "rails_helper" -feature 'Verify email' do +feature "Verify email" do - scenario 'Verify' do + scenario "Verify" do user = create(:user, residence_verified_at: Time.current, - document_number: '12345678Z', - document_type: 'dni') + document_number: "12345678Z", + document_type: "dni") verified_user = create(:verified_user, - document_number: '12345678Z', - document_type: 'dni', - email: 'rock@example.com') + document_number: "12345678Z", + document_type: "dni", + email: "rock@example.com") login_as(user) visit verified_user_path within("#verified_user_#{verified_user.id}_email") do - expect(page).to have_content 'roc*@example.com' + expect(page).to have_content "roc*@example.com" click_button "Send code" end - expect(page).to have_content 'We have sent a confirmation email to your account: rock@example.com' + expect(page).to have_content "We have sent a confirmation email to your account: rock@example.com" sent_token = /.*email_verification_token=(.*)".*/.match(ActionMailer::Base.deliveries.last.body.to_s)[1] visit email_path(email_verification_token: sent_token) @@ -45,13 +45,13 @@ feature 'Verify email' do scenario "Errors on sending confirmation email" do user = create(:user, residence_verified_at: Time.current, - document_number: '12345678Z', - document_type: 'dni') + document_number: "12345678Z", + document_type: "dni") verified_user = create(:verified_user, - document_number: '12345678Z', - document_type: 'dni', - email: 'rock@example.com') + document_number: "12345678Z", + document_type: "dni", + email: "rock@example.com") login_as(user) diff --git a/spec/features/verification/letter_spec.rb b/spec/features/verification/letter_spec.rb index 463b22ebb..b1dd74acf 100644 --- a/spec/features/verification/letter_spec.rb +++ b/spec/features/verification/letter_spec.rb @@ -1,8 +1,8 @@ -require 'rails_helper' +require "rails_helper" -feature 'Verify Letter' do +feature "Verify Letter" do - scenario 'Request a letter' do + scenario "Request a letter" do user = create(:user, residence_verified_at: Time.current, confirmed_phone: "611111111") @@ -20,7 +20,7 @@ feature 'Verify Letter' do expect(user.letter_verification_code).to be end - scenario 'Go to office instead of send letter' do + scenario "Go to office instead of send letter" do Setting["verification_offices_url"] = "http://offices.consul" user = create(:user, residence_verified_at: Time.current, confirmed_phone: "611111111") @@ -37,7 +37,7 @@ feature 'Verify Letter' do login_as(user) visit new_letter_path - expect(page).to have_content 'You have not yet confirmed your residency' + expect(page).to have_content "You have not yet confirmed your residency" expect(page).to have_current_path(new_residence_path) end @@ -47,7 +47,7 @@ feature 'Verify Letter' do login_as(user) visit new_letter_path - expect(page).to have_content 'You have not yet entered the confirmation code' + expect(page).to have_content "You have not yet entered the confirmation code" expect(page).to have_current_path(new_sms_path) end @@ -123,7 +123,7 @@ feature 'Verify Letter' do expect(page).to have_content "can't be blank" end - scenario '6 tries allowed' do + scenario "6 tries allowed" do user = create(:user, residence_verified_at: Time.current, confirmed_phone: "611111111", letter_verification_code: "123456") diff --git a/spec/features/verification/level_three_verification_spec.rb b/spec/features/verification/level_three_verification_spec.rb index 1e339307c..1cdd96fde 100644 --- a/spec/features/verification/level_three_verification_spec.rb +++ b/spec/features/verification/level_three_verification_spec.rb @@ -1,19 +1,19 @@ -require 'rails_helper' +require "rails_helper" -feature 'Level three verification' do - scenario 'Verification with residency and verified sms' do +feature "Level three verification" do + scenario "Verification with residency and verified sms" do create(:geozone) user = create(:user) verified_user = create(:verified_user, - document_number: '12345678Z', - document_type: '1', - phone: '611111111') + document_number: "12345678Z", + document_type: "1", + phone: "611111111") login_as(user) visit account_path - click_link 'Verify my account' + click_link "Verify my account" verify_residence @@ -21,11 +21,11 @@ feature 'Level three verification' do click_button "Send code" end - expect(page).to have_content 'Security code confirmation' + expect(page).to have_content "Security code confirmation" user = user.reload - fill_in 'sms_confirmation_code', with: user.sms_confirmation_code - click_button 'Send' + fill_in "sms_confirmation_code", with: user.sms_confirmation_code + click_button "Send" expect(page).to have_content "Code correct. Your account is now verified" @@ -33,19 +33,19 @@ feature 'Level three verification' do expect(page).to have_content "Account verified" end - scenario 'Verification with residency and verified email' do + scenario "Verification with residency and verified email" do create(:geozone) user = create(:user) verified_user = create(:verified_user, - document_number: '12345678Z', - document_type: '1', - email: 'rock@example.com') + document_number: "12345678Z", + document_type: "1", + email: "rock@example.com") login_as(user) visit account_path - click_link 'Verify my account' + click_link "Verify my account" verify_residence @@ -53,7 +53,7 @@ feature 'Level three verification' do click_button "Send code" end - expect(page).to have_content 'We have sent a confirmation email to your account: rock@example.com' + expect(page).to have_content "We have sent a confirmation email to your account: rock@example.com" sent_token = /.*email_verification_token=(.*)".*/.match(ActionMailer::Base.deliveries.last.body.to_s)[1] visit email_path(email_verification_token: sent_token) @@ -64,26 +64,26 @@ feature 'Level three verification' do expect(page).to have_content "Account verified" end - scenario 'Verification with residency and sms and letter' do + scenario "Verification with residency and sms and letter" do create(:geozone) user = create(:user) login_as(user) visit account_path - click_link 'Verify my account' + click_link "Verify my account" verify_residence - fill_in 'sms_phone', with: "611111111" - click_button 'Send' + fill_in "sms_phone", with: "611111111" + click_button "Send" - expect(page).to have_content 'Security code confirmation' + expect(page).to have_content "Security code confirmation" user = user.reload - fill_in 'sms_confirmation_code', with: user.sms_confirmation_code - click_button 'Send' + fill_in "sms_confirmation_code", with: user.sms_confirmation_code + click_button "Send" - expect(page).to have_content 'Code correct' + expect(page).to have_content "Code correct" click_link "Send me a letter with the code" diff --git a/spec/features/verification/level_two_verification_spec.rb b/spec/features/verification/level_two_verification_spec.rb index 0c6c0f349..085926fba 100644 --- a/spec/features/verification/level_two_verification_spec.rb +++ b/spec/features/verification/level_two_verification_spec.rb @@ -1,27 +1,27 @@ -require 'rails_helper' +require "rails_helper" -feature 'Level two verification' do +feature "Level two verification" do - scenario 'Verification with residency and sms' do + scenario "Verification with residency and sms" do create(:geozone) user = create(:user) login_as(user) visit account_path - click_link 'Verify my account' + click_link "Verify my account" verify_residence - fill_in 'sms_phone', with: "611111111" - click_button 'Send' + fill_in "sms_phone", with: "611111111" + click_button "Send" - expect(page).to have_content 'Security code confirmation' + expect(page).to have_content "Security code confirmation" user = user.reload - fill_in 'sms_confirmation_code', with: user.sms_confirmation_code - click_button 'Send' + fill_in "sms_confirmation_code", with: user.sms_confirmation_code + click_button "Send" - expect(page).to have_content 'Code correct' + expect(page).to have_content "Code correct" end context "In Spanish, with no fallbacks" do diff --git a/spec/features/verification/residence_spec.rb b/spec/features/verification/residence_spec.rb index ac2096fce..15dd29d38 100644 --- a/spec/features/verification/residence_spec.rb +++ b/spec/features/verification/residence_spec.rb @@ -1,125 +1,125 @@ -require 'rails_helper' +require "rails_helper" -feature 'Residence' do +feature "Residence" do background { create(:geozone) } - scenario 'Verify resident' do + scenario "Verify resident" do user = create(:user) login_as(user) visit account_path - click_link 'Verify my account' + click_link "Verify my account" - fill_in 'residence_document_number', with: "12345678Z" - select 'DNI', from: 'residence_document_type' - select_date '31-December-1980', from: 'residence_date_of_birth' - fill_in 'residence_postal_code', with: '28013' - check 'residence_terms_of_service' + fill_in "residence_document_number", with: "12345678Z" + select "DNI", from: "residence_document_type" + select_date "31-December-1980", from: "residence_date_of_birth" + fill_in "residence_postal_code", with: "28013" + check "residence_terms_of_service" - click_button 'Verify residence' + click_button "Verify residence" - expect(page).to have_content 'Residence verified' + expect(page).to have_content "Residence verified" end - scenario 'When trying to verify a deregistered account old votes are reassigned' do - erased_user = create(:user, document_number: '12345678Z', document_type: '1', erased_at: Time.current) + scenario "When trying to verify a deregistered account old votes are reassigned" do + erased_user = create(:user, document_number: "12345678Z", document_type: "1", erased_at: Time.current) vote = create(:vote, voter: erased_user) new_user = create(:user) login_as(new_user) visit account_path - click_link 'Verify my account' + click_link "Verify my account" - fill_in 'residence_document_number', with: '12345678Z' - select 'DNI', from: 'residence_document_type' - select_date '31-December-1980', from: 'residence_date_of_birth' - fill_in 'residence_postal_code', with: '28013' - check 'residence_terms_of_service' + fill_in "residence_document_number", with: "12345678Z" + select "DNI", from: "residence_document_type" + select_date "31-December-1980", from: "residence_date_of_birth" + fill_in "residence_postal_code", with: "28013" + check "residence_terms_of_service" - click_button 'Verify residence' + click_button "Verify residence" - expect(page).to have_content 'Residence verified' + expect(page).to have_content "Residence verified" expect(vote.reload.voter).to eq(new_user) expect(erased_user.reload.document_number).to be_blank - expect(new_user.reload.document_number).to eq('12345678Z') + expect(new_user.reload.document_number).to eq("12345678Z") end - scenario 'Error on verify' do + scenario "Error on verify" do user = create(:user) login_as(user) visit account_path - click_link 'Verify my account' + click_link "Verify my account" - click_button 'Verify residence' + click_button "Verify residence" expect(page).to have_content(/\d errors? prevented the verification of your residence/) end - scenario 'Error on postal code not in census' do + scenario "Error on postal code not in census" do user = create(:user) login_as(user) visit account_path - click_link 'Verify my account' + click_link "Verify my account" - fill_in 'residence_document_number', with: "12345678Z" - select 'DNI', from: 'residence_document_type' - select '1997', from: 'residence_date_of_birth_1i' - select 'January', from: 'residence_date_of_birth_2i' - select '1', from: 'residence_date_of_birth_3i' - fill_in 'residence_postal_code', with: '12345' - check 'residence_terms_of_service' + fill_in "residence_document_number", with: "12345678Z" + select "DNI", from: "residence_document_type" + select "1997", from: "residence_date_of_birth_1i" + select "January", from: "residence_date_of_birth_2i" + select "1", from: "residence_date_of_birth_3i" + fill_in "residence_postal_code", with: "12345" + check "residence_terms_of_service" - click_button 'Verify residence' + click_button "Verify residence" - expect(page).to have_content 'In order to be verified, you must be registered' + expect(page).to have_content "In order to be verified, you must be registered" end - scenario 'Error on census' do + scenario "Error on census" do user = create(:user) login_as(user) visit account_path - click_link 'Verify my account' + click_link "Verify my account" - fill_in 'residence_document_number', with: "12345678Z" - select 'DNI', from: 'residence_document_type' - select '1997', from: 'residence_date_of_birth_1i' - select 'January', from: 'residence_date_of_birth_2i' - select '1', from: 'residence_date_of_birth_3i' - fill_in 'residence_postal_code', with: '28013' - check 'residence_terms_of_service' + fill_in "residence_document_number", with: "12345678Z" + select "DNI", from: "residence_document_type" + select "1997", from: "residence_date_of_birth_1i" + select "January", from: "residence_date_of_birth_2i" + select "1", from: "residence_date_of_birth_3i" + fill_in "residence_postal_code", with: "28013" + check "residence_terms_of_service" - click_button 'Verify residence' + click_button "Verify residence" - expect(page).to have_content 'The Census was unable to verify your information' + expect(page).to have_content "The Census was unable to verify your information" end - scenario '5 tries allowed' do + scenario "5 tries allowed" do user = create(:user) login_as(user) visit account_path - click_link 'Verify my account' + click_link "Verify my account" 5.times do - fill_in 'residence_document_number', with: "12345678Z" - select 'DNI', from: 'residence_document_type' - select '1997', from: 'residence_date_of_birth_1i' - select 'January', from: 'residence_date_of_birth_2i' - select '1', from: 'residence_date_of_birth_3i' - fill_in 'residence_postal_code', with: '28013' - check 'residence_terms_of_service' + fill_in "residence_document_number", with: "12345678Z" + select "DNI", from: "residence_document_type" + select "1997", from: "residence_date_of_birth_1i" + select "January", from: "residence_date_of_birth_2i" + select "1", from: "residence_date_of_birth_3i" + fill_in "residence_postal_code", with: "28013" + check "residence_terms_of_service" - click_button 'Verify residence' - expect(page).to have_content 'The Census was unable to verify your information' + click_button "Verify residence" + expect(page).to have_content "The Census was unable to verify your information" end - click_button 'Verify residence' + click_button "Verify residence" expect(page).to have_content "You have reached the maximum number of attempts. Please try again later." expect(page).to have_current_path(account_path) diff --git a/spec/features/verification/sms_spec.rb b/spec/features/verification/sms_spec.rb index 9274a1eb4..956d28136 100644 --- a/spec/features/verification/sms_spec.rb +++ b/spec/features/verification/sms_spec.rb @@ -1,72 +1,72 @@ -require 'rails_helper' +require "rails_helper" -feature 'SMS Verification' do +feature "SMS Verification" do - scenario 'Verify' do + scenario "Verify" do user = create(:user, residence_verified_at: Time.current) login_as(user) visit new_sms_path - fill_in 'sms_phone', with: "611111111" - click_button 'Send' + fill_in "sms_phone", with: "611111111" + click_button "Send" - expect(page).to have_content 'Security code confirmation' + expect(page).to have_content "Security code confirmation" user = user.reload - fill_in 'sms_confirmation_code', with: user.sms_confirmation_code - click_button 'Send' + fill_in "sms_confirmation_code", with: user.sms_confirmation_code + click_button "Send" - expect(page).to have_content 'Code correct' + expect(page).to have_content "Code correct" end - scenario 'Errors on phone number' do + scenario "Errors on phone number" do user = create(:user, residence_verified_at: Time.current) login_as(user) visit new_sms_path - click_button 'Send' + click_button "Send" expect(page).to have_content error_message("phone") end - scenario 'Errors on verification code' do + scenario "Errors on verification code" do user = create(:user, residence_verified_at: Time.current) login_as(user) visit new_sms_path - fill_in 'sms_phone', with: "611111111" - click_button 'Send' + fill_in "sms_phone", with: "611111111" + click_button "Send" - expect(page).to have_content 'Security code confirmation' + expect(page).to have_content "Security code confirmation" - click_button 'Send' + click_button "Send" - expect(page).to have_content 'Incorrect confirmation code' + expect(page).to have_content "Incorrect confirmation code" end - scenario 'Deny access unless residency verified' do + scenario "Deny access unless residency verified" do user = create(:user) login_as(user) visit new_sms_path - expect(page).to have_content 'You have not yet confirmed your residency' + expect(page).to have_content "You have not yet confirmed your residency" expect(page).to have_current_path(new_residence_path) end - scenario '5 tries allowed' do + scenario "5 tries allowed" do user = create(:user, residence_verified_at: Time.current) login_as(user) visit new_sms_path 5.times do - fill_in 'sms_phone', with: "611111111" - click_button 'Send' - click_link 'Click here to send it again' + fill_in "sms_phone", with: "611111111" + click_button "Send" + click_link "Click here to send it again" end expect(page).to have_content "You have reached the maximum number of attempts. Please try again later." diff --git a/spec/features/verification/verification_path_spec.rb b/spec/features/verification/verification_path_spec.rb index b7abf4a56..c97830318 100644 --- a/spec/features/verification/verification_path_spec.rb +++ b/spec/features/verification/verification_path_spec.rb @@ -1,6 +1,6 @@ -require 'rails_helper' +require "rails_helper" -feature 'Verification path' do +feature "Verification path" do scenario "User is an organization" do user = create(:user, verified_at: Time.current) @@ -19,7 +19,7 @@ feature 'Verification path' do visit verification_path expect(page).to have_current_path(account_path) - expect(page).to have_content 'Your account is already verified' + expect(page).to have_content "Your account is already verified" end scenario "User requested a letter" do @@ -95,7 +95,7 @@ feature 'Verification path' do visit step_path expect(page).to have_current_path(account_path) - expect(page).to have_content 'Your account is already verified' + expect(page).to have_content "Your account is already verified" end end diff --git a/spec/features/verification/verified_user_spec.rb b/spec/features/verification/verified_user_spec.rb index 87be185e9..541bf11e8 100644 --- a/spec/features/verification/verified_user_spec.rb +++ b/spec/features/verification/verified_user_spec.rb @@ -1,67 +1,67 @@ -require 'rails_helper' +require "rails_helper" -feature 'Verified users' do +feature "Verified users" do scenario "Verified emails" do user = create(:user, residence_verified_at: Time.current, - document_number: '12345678Z') + document_number: "12345678Z") create(:verified_user, - document_number: '12345678Z', - email: 'rock@example.com') + document_number: "12345678Z", + email: "rock@example.com") create(:verified_user, - document_number: '12345678Z', - email: 'roll@example.com') + document_number: "12345678Z", + email: "roll@example.com") create(:verified_user, - document_number: '99999999R', - email: 'another@example.com') + document_number: "99999999R", + email: "another@example.com") login_as(user) visit verified_user_path - expect(page).to have_content 'roc*@example.com' - expect(page).to have_content 'rol*@example.com' - expect(page).not_to have_content 'ano*@example.com' + expect(page).to have_content "roc*@example.com" + expect(page).to have_content "rol*@example.com" + expect(page).not_to have_content "ano*@example.com" end scenario "Verified phones" do user = create(:user, residence_verified_at: Time.current, - document_number: '12345678Z') + document_number: "12345678Z") create(:verified_user, - document_number: '12345678Z', - phone: '611111111') + document_number: "12345678Z", + phone: "611111111") create(:verified_user, - document_number: '12345678Z', - phone: '622222222') + document_number: "12345678Z", + phone: "622222222") create(:verified_user, - document_number: '99999999R', - phone: '633333333') + document_number: "99999999R", + phone: "633333333") login_as(user) visit verified_user_path - expect(page).to have_content '******111' - expect(page).to have_content '******222' - expect(page).not_to have_content '******333' + expect(page).to have_content "******111" + expect(page).to have_content "******222" + expect(page).not_to have_content "******333" end scenario "No emails or phones" do user = create(:user, residence_verified_at: Time.current, - document_number: '12345678Z') + document_number: "12345678Z") create(:verified_user, - document_number: '12345678Z') + document_number: "12345678Z") create(:verified_user, - document_number: '12345678Z') + document_number: "12345678Z") login_as(user) visit verified_user_path @@ -72,11 +72,11 @@ feature 'Verified users' do scenario "Select a verified email" do user = create(:user, residence_verified_at: Time.current, - document_number: '12345678Z') + document_number: "12345678Z") verified_user = create(:verified_user, - document_number: '12345678Z', - email: 'rock@example.com') + document_number: "12345678Z", + email: "rock@example.com") login_as(user) visit verified_user_path @@ -85,18 +85,18 @@ feature 'Verified users' do click_button "Send code" end - expect(page).to have_content 'We have sent a confirmation email to your account: rock@example.com' + expect(page).to have_content "We have sent a confirmation email to your account: rock@example.com" expect(page).to have_current_path(account_path) end scenario "Select a verified phone" do user = create(:user, residence_verified_at: Time.current, - document_number: '12345678Z') + document_number: "12345678Z") verified_user = create(:verified_user, - document_number: '12345678Z', - phone: '611111111') + document_number: "12345678Z", + phone: "611111111") login_as(user) visit verified_user_path @@ -105,17 +105,17 @@ feature 'Verified users' do click_button "Send code" end - expect(page).to have_content 'Enter the confirmation code' + expect(page).to have_content "Enter the confirmation code" end scenario "Continue without selecting any verified information" do user = create(:user, residence_verified_at: Time.current, - document_number: '12345678Z') + document_number: "12345678Z") create(:verified_user, - document_number: '12345678Z', - phone: '611111111') + document_number: "12345678Z", + phone: "611111111") login_as(user) visit verified_user_path diff --git a/spec/features/votes_spec.rb b/spec/features/votes_spec.rb index f16452ad0..eb9154050 100644 --- a/spec/features/votes_spec.rb +++ b/spec/features/votes_spec.rb @@ -1,13 +1,13 @@ -require 'rails_helper' +require "rails_helper" -feature 'Votes' do +feature "Votes" do background do @manuela = create(:user, verified_at: Time.current) @pablo = create(:user) end - feature 'Debates' do + feature "Debates" do background { login_as(@manuela) } scenario "Index shows user votes on debates" do @@ -59,44 +59,44 @@ feature 'Votes' do end end - feature 'Single debate' do + feature "Single debate" do - scenario 'Show no votes' do + scenario "Show no votes" do visit debate_path(create(:debate)) expect(page).to have_content "No votes" - within('.in-favor') do + within(".in-favor") do expect(page).to have_content "0%" expect(page).not_to have_css("a.voted") expect(page).not_to have_css("a.no-voted") end - within('.against') do + within(".against") do expect(page).to have_content "0%" expect(page).not_to have_css("a.voted") expect(page).not_to have_css("a.no-voted") end end - scenario 'Update', :js do + scenario "Update", :js do visit debate_path(create(:debate)) - find('.in-favor a').click + find(".in-favor a").click - within('.in-favor') do + within(".in-favor") do expect(page).to have_content "100%" expect(page).to have_css("a.voted") end - find('.against a').click + find(".against a").click - within('.in-favor') do + within(".in-favor") do expect(page).to have_content "0%" expect(page).to have_css("a.no-voted") end - within('.against') do + within(".against") do expect(page).to have_content "100%" expect(page).to have_css("a.voted") end @@ -104,24 +104,24 @@ feature 'Votes' do expect(page).to have_content "1 vote" end - scenario 'Trying to vote multiple times', :js do + scenario "Trying to vote multiple times", :js do visit debate_path(create(:debate)) - find('.in-favor a').click + find(".in-favor a").click expect(page).to have_content "1 vote" - find('.in-favor a').click + find(".in-favor a").click expect(page).not_to have_content "2 votes" - within('.in-favor') do + within(".in-favor") do expect(page).to have_content "100%" end - within('.against') do + within(".against") do expect(page).to have_content "0%" end end - scenario 'Show' do + scenario "Show" do debate = create(:debate) create(:vote, voter: @manuela, votable: debate, vote_flag: true) create(:vote, voter: @pablo, votable: debate, vote_flag: false) @@ -130,28 +130,28 @@ feature 'Votes' do expect(page).to have_content "No votes" - within('.in-favor') do + within(".in-favor") do expect(page).to have_content "50%" expect(page).to have_css("a.voted") end - within('.against') do + within(".against") do expect(page).to have_content "50%" expect(page).to have_css("a.no-voted") end end - scenario 'Create from debate show', :js do + scenario "Create from debate show", :js do visit debate_path(create(:debate)) - find('.in-favor a').click + find(".in-favor a").click - within('.in-favor') do + within(".in-favor") do expect(page).to have_content "100%" expect(page).to have_css("a.voted") end - within('.against') do + within(".against") do expect(page).to have_content "0%" expect(page).to have_css("a.no-voted") end @@ -159,20 +159,20 @@ feature 'Votes' do expect(page).to have_content "1 vote" end - scenario 'Create in index', :js do + scenario "Create in index", :js do create(:debate) visit debates_path within("#debates") do - find('.in-favor a').click + find(".in-favor a").click - within('.in-favor') do + within(".in-favor") do expect(page).to have_content "100%" expect(page).to have_css("a.voted") end - within('.against') do + within(".against") do expect(page).to have_content "0%" expect(page).to have_css("a.no-voted") end @@ -184,7 +184,7 @@ feature 'Votes' do end end - feature 'Proposals' do + feature "Proposals" do background { login_as(@manuela) } scenario "Index shows user votes on proposals" do @@ -210,55 +210,55 @@ feature 'Votes' do end end - feature 'Single proposal' do + feature "Single proposal" do background do @proposal = create(:proposal) end - scenario 'Show no votes' do + scenario "Show no votes" do visit proposal_path(@proposal) expect(page).to have_content "No supports" end - scenario 'Trying to vote multiple times', :js do + scenario "Trying to vote multiple times", :js do visit proposal_path(@proposal) - within('.supports') do - find('.in-favor a').click + within(".supports") do + find(".in-favor a").click expect(page).to have_content "1 support" expect(page).not_to have_selector ".in-favor a" end end - scenario 'Show' do + scenario "Show" do create(:vote, voter: @manuela, votable: @proposal, vote_flag: true) create(:vote, voter: @pablo, votable: @proposal, vote_flag: true) visit proposal_path(@proposal) - within('.supports') do + within(".supports") do expect(page).to have_content "2 supports" end end - scenario 'Create from proposal show', :js do + scenario "Create from proposal show", :js do visit proposal_path(@proposal) - within('.supports') do - find('.in-favor a').click + within(".supports") do + find(".in-favor a").click expect(page).to have_content "1 support" expect(page).to have_content "You have already supported this proposal. Share it!" end end - scenario 'Create in listed proposal in index', :js do + scenario "Create in listed proposal in index", :js do create_featured_proposals visit proposals_path within("#proposal_#{@proposal.id}") do - find('.in-favor a').click + find(".in-favor a").click expect(page).to have_content "1 support" expect(page).to have_content "You have already supported this proposal. Share it!" @@ -266,11 +266,11 @@ feature 'Votes' do expect(page).to have_current_path(proposals_path) end - scenario 'Create in featured proposal in index', :js do + scenario "Create in featured proposal in index", :js do visit proposals_path within("#proposal_#{@proposal.id}") do - find('.in-favor a').click + find(".in-favor a").click expect(page).to have_content "You have already supported this proposal. Share it!" end @@ -279,7 +279,7 @@ feature 'Votes' do end end - scenario 'Not logged user trying to vote debates', :js do + scenario "Not logged user trying to vote debates", :js do debate = create(:debate) visit debates_path @@ -289,7 +289,7 @@ feature 'Votes' do end end - scenario 'Not logged user trying to vote proposals', :js do + scenario "Not logged user trying to vote proposals", :js do proposal = create(:proposal) visit proposals_path @@ -305,7 +305,7 @@ feature 'Votes' do end end - scenario 'Not logged user trying to vote comments in debates', :js do + scenario "Not logged user trying to vote comments in debates", :js do debate = create(:debate) comment = create(:comment, commentable: debate) @@ -316,7 +316,7 @@ feature 'Votes' do end end - scenario 'Not logged user trying to vote comments in proposals', :js do + scenario "Not logged user trying to vote comments in proposals", :js do proposal = create(:proposal) comment = create(:comment, commentable: proposal) @@ -327,7 +327,7 @@ feature 'Votes' do end end - scenario 'Anonymous user trying to vote debates', :js do + scenario "Anonymous user trying to vote debates", :js do user = create(:user) debate = create(:debate) @@ -368,19 +368,19 @@ feature 'Votes' do end end - feature 'Spending Proposals' do + feature "Spending Proposals" do background do - Setting['feature.spending_proposals'] = true - Setting['feature.spending_proposal_features.voting_allowed'] = true - login_as(@manuela) + Setting["feature.spending_proposals"] = true + Setting["feature.spending_proposal_features.voting_allowed"] = true + login_as(@manuela) 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 - feature 'Index' do + feature "Index" do scenario "Index shows user votes on proposals" do spending_proposal1 = create(:spending_proposal) spending_proposal2 = create(:spending_proposal) @@ -404,12 +404,12 @@ feature 'Votes' do end end - scenario 'Create from spending proposal index', :js do + scenario "Create from spending proposal index", :js do spending_proposal = create(:spending_proposal) visit spending_proposals_path - within('.supports') do - find('.in-favor a').click + within(".supports") do + find(".in-favor a").click expect(page).to have_content "1 support" expect(page).to have_content "You have already supported this. Share it!" @@ -417,32 +417,32 @@ feature 'Votes' do end end - feature 'Single spending proposal' do + feature "Single spending proposal" do background do @proposal = create(:spending_proposal) end - scenario 'Show no votes' do + scenario "Show no votes" do visit spending_proposal_path(@proposal) expect(page).to have_content "No supports" end - scenario 'Trying to vote multiple times', :js do + scenario "Trying to vote multiple times", :js do visit spending_proposal_path(@proposal) - within('.supports') do - find('.in-favor a').click + within(".supports") do + find(".in-favor a").click expect(page).to have_content "1 support" expect(page).not_to have_selector ".in-favor a" end end - scenario 'Create from proposal show', :js do + scenario "Create from proposal show", :js do visit spending_proposal_path(@proposal) - within('.supports') do - find('.in-favor a').click + within(".supports") do + find(".in-favor a").click expect(page).to have_content "1 support" expect(page).to have_content "You have already supported this. Share it!" @@ -450,7 +450,7 @@ feature 'Votes' do end end - scenario 'Disable voting on spending proposals', :js do + scenario "Disable voting on spending proposals", :js do login_as(@manuela) Setting["feature.spending_proposal_features.voting_allowed"] = nil spending_proposal = create(:spending_proposal) diff --git a/spec/features/welcome_spec.rb b/spec/features/welcome_spec.rb index 08256bec1..53232f678 100644 --- a/spec/features/welcome_spec.rb +++ b/spec/features/welcome_spec.rb @@ -1,8 +1,8 @@ -require 'rails_helper' +require "rails_helper" feature "Welcome screen" do - scenario 'a regular users sees it the first time he logs in' do + scenario "a regular users sees it the first time he logs in" do user = create(:user) login_through_form_as(user) @@ -10,7 +10,7 @@ feature "Welcome screen" do expect(page).to have_current_path(welcome_path) end - scenario 'a regular user does not see it when coing to /email' do + scenario "a regular user does not see it when coing to /email" do plain, encrypted = Devise.token_generator.generate(User, :email_verification_token) @@ -18,17 +18,17 @@ feature "Welcome screen" do visit email_path(email_verification_token: encrypted) - fill_in 'user_login', with: user.email - fill_in 'user_password', with: user.password + fill_in "user_login", with: user.email + fill_in "user_password", with: user.password - click_button 'Enter' + click_button "Enter" expect(page).to have_content("You are a verified user") expect(page).to have_current_path(account_path) end - scenario 'it is not shown more than once' do + scenario "it is not shown more than once" do user = create(:user, sign_in_count: 2) login_through_form_as(user) @@ -36,7 +36,7 @@ feature "Welcome screen" do expect(page).to have_current_path(root_path) end - scenario 'is not shown to organizations' do + scenario "is not shown to organizations" do organization = create(:organization) login_through_form_as(organization.user) @@ -44,7 +44,7 @@ feature "Welcome screen" do expect(page).to have_current_path(root_path) end - scenario 'it is not shown to level-2 users' do + scenario "it is not shown to level-2 users" do user = create(:user, residence_verified_at: Time.current, confirmed_phone: "123") login_through_form_as(user) @@ -52,7 +52,7 @@ feature "Welcome screen" do expect(page).to have_current_path(root_path) end - scenario 'it is not shown to level-3 users' do + scenario "it is not shown to level-3 users" do user = create(:user, verified_at: Time.current) login_through_form_as(user) @@ -60,7 +60,7 @@ feature "Welcome screen" do expect(page).to have_current_path(root_path) end - scenario 'is not shown to administrators' do + scenario "is not shown to administrators" do administrator = create(:administrator) login_through_form_as(administrator.user) @@ -68,10 +68,10 @@ feature "Welcome screen" do expect(page).to have_current_path(root_path) end - scenario 'a regular users sees it the first time he logs in, with all options active - if the setting skip_verification is activated' do + scenario "a regular users sees it the first time he logs in, with all options active + if the setting skip_verification is activated" do - Setting["feature.user.skip_verification"] = 'true' + Setting["feature.user.skip_verification"] = "true" user = create(:user) diff --git a/spec/helpers/admin_helper_spec.rb b/spec/helpers/admin_helper_spec.rb index 0239f1926..1f20ee1b4 100644 --- a/spec/helpers/admin_helper_spec.rb +++ b/spec/helpers/admin_helper_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe AdminHelper do diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 4dd775c73..b17a14756 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe ApplicationHelper do diff --git a/spec/helpers/comments_helper_spec.rb b/spec/helpers/comments_helper_spec.rb index 6888ff5d4..e24677757 100644 --- a/spec/helpers/comments_helper_spec.rb +++ b/spec/helpers/comments_helper_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" # Specs in this file have access to a helper object that includes # the CommentsHelper. For example: @@ -12,51 +12,51 @@ require 'rails_helper' # end RSpec.describe CommentsHelper, type: :helper do - describe '#user_level_class' do + describe "#user_level_class" do def comment_double(as_administrator: false, as_moderator: false, official: false) - user = instance_double('User', official?: official, official_level: 'Y') - instance_double('Comment', as_administrator?: as_administrator, as_moderator?: as_moderator, user: user) + user = instance_double("User", official?: official, official_level: "Y") + instance_double("Comment", as_administrator?: as_administrator, as_moderator?: as_moderator, user: user) end - it 'returns is-admin for comment done as administrator' do + it "returns is-admin for comment done as administrator" do comment = comment_double(as_administrator: true) - expect(helper.user_level_class(comment)).to eq('is-admin') + expect(helper.user_level_class(comment)).to eq("is-admin") end - it 'returns is-moderator for comment done as moderator' do + it "returns is-moderator for comment done as moderator" do comment = comment_double(as_moderator: true) - expect(helper.user_level_class(comment)).to eq('is-moderator') + expect(helper.user_level_class(comment)).to eq("is-moderator") end - it 'returns level followed by official level if user is official' do + it "returns level followed by official level if user is official" do comment = comment_double(official: true) - expect(helper.user_level_class(comment)).to eq('level-Y') + expect(helper.user_level_class(comment)).to eq("level-Y") end - it 'returns an empty class otherwise' do + it "returns an empty class otherwise" do comment = comment_double - expect(helper.user_level_class(comment)).to eq('') + expect(helper.user_level_class(comment)).to eq("") end end - describe '#comment_author_class' do - it 'returns is-author if author is the commenting user' do + describe "#comment_author_class" do + it "returns is-author if author is the commenting user" do author_id = 42 - comment = instance_double('Comment', user_id: author_id) + comment = instance_double("Comment", user_id: author_id) - expect(helper.comment_author_class(comment, author_id)).to eq('is-author') + expect(helper.comment_author_class(comment, author_id)).to eq("is-author") end - it 'returns an empty string if commenter is not the author' do + it "returns an empty string if commenter is not the author" do author_id = 42 - comment = instance_double('Comment', user_id: author_id - 1) + comment = instance_double("Comment", user_id: author_id - 1) - expect(helper.comment_author_class(comment, author_id)).to eq('') + expect(helper.comment_author_class(comment, author_id)).to eq("") end end end diff --git a/spec/helpers/geozones_helper_spec.rb b/spec/helpers/geozones_helper_spec.rb index 0c0c13d70..366be6c39 100644 --- a/spec/helpers/geozones_helper_spec.rb +++ b/spec/helpers/geozones_helper_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe GeozonesHelper do diff --git a/spec/helpers/locales_helper_spec.rb b/spec/helpers/locales_helper_spec.rb index 6031ae144..3ae50dbde 100644 --- a/spec/helpers/locales_helper_spec.rb +++ b/spec/helpers/locales_helper_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe LocalesHelper do diff --git a/spec/helpers/proposals_helper_spec.rb b/spec/helpers/proposals_helper_spec.rb index 87da34be3..6ee3706e0 100644 --- a/spec/helpers/proposals_helper_spec.rb +++ b/spec/helpers/proposals_helper_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe ProposalsHelper do diff --git a/spec/helpers/settings_helper_spec.rb b/spec/helpers/settings_helper_spec.rb index 0db6fed10..df5eda7d2 100644 --- a/spec/helpers/settings_helper_spec.rb +++ b/spec/helpers/settings_helper_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" RSpec.describe SettingsHelper, type: :helper do diff --git a/spec/helpers/text_helper_spec.rb b/spec/helpers/text_helper_spec.rb index 2b9884b9a..6fce5abb1 100644 --- a/spec/helpers/text_helper_spec.rb +++ b/spec/helpers/text_helper_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe TextHelper do diff --git a/spec/helpers/users_helper_spec.rb b/spec/helpers/users_helper_spec.rb index 544c65d82..71de4ee27 100644 --- a/spec/helpers/users_helper_spec.rb +++ b/spec/helpers/users_helper_spec.rb @@ -1,8 +1,8 @@ -require 'rails_helper' +require "rails_helper" describe UsersHelper do - describe '#humanize_document_type' do + describe "#humanize_document_type" do it "returns a humanized document type" do expect(humanize_document_type("1")).to eq "DNI" expect(humanize_document_type("2")).to eq "Passport" @@ -10,14 +10,14 @@ describe UsersHelper do end end - describe '#deleted_commentable_text' do + describe "#deleted_commentable_text" do it "returns the appropriate message for deleted debates" do debate = create(:debate) comment = create(:comment, commentable: debate) debate.hide - expect(comment_commentable_title(comment)).to eq('' + comment.commentable.title + + expect(comment_commentable_title(comment)).to eq("" + comment.commentable.title + ' (This debate has been deleted)') end @@ -27,7 +27,7 @@ describe UsersHelper do proposal.hide - expect(comment_commentable_title(comment)).to eq('' + comment.commentable.title + + expect(comment_commentable_title(comment)).to eq("" + comment.commentable.title + ' (This proposal has been deleted)') end @@ -37,12 +37,12 @@ describe UsersHelper do investment.hide - expect(comment_commentable_title(comment)).to eq('' + comment.commentable.title + + expect(comment_commentable_title(comment)).to eq("" + comment.commentable.title + ' (This investment project has been deleted)') end end - describe '#comment_commentable_title' do + describe "#comment_commentable_title" do it "returns a link to the comment" do comment = create(:comment) expect(comment_commentable_title(comment)).to eq link_to comment.commentable.title, comment @@ -51,7 +51,7 @@ describe UsersHelper do it "returns a hint if the commentable has been deleted" do comment = create(:comment) comment.commentable.hide - expect(comment_commentable_title(comment)).to eq('' + comment.commentable.title + + expect(comment_commentable_title(comment)).to eq("" + comment.commentable.title + ' (This debate has been deleted)') end end diff --git a/spec/helpers/verification_helper_spec.rb b/spec/helpers/verification_helper_spec.rb index 5934018a4..c5fe164d5 100644 --- a/spec/helpers/verification_helper_spec.rb +++ b/spec/helpers/verification_helper_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe VerificationHelper do diff --git a/spec/helpers/votes_helper_spec.rb b/spec/helpers/votes_helper_spec.rb index 9f86a63b4..c402fb2b4 100644 --- a/spec/helpers/votes_helper_spec.rb +++ b/spec/helpers/votes_helper_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe VotesHelper do @@ -24,8 +24,8 @@ describe VotesHelper do create_list(:vote, 8, votable: debate, vote_flag: true) create_list(:vote, 3, votable: debate, vote_flag: false) - expect(votes_percentage('likes', debate)).to eq("72%") - expect(votes_percentage('dislikes', debate)).to eq("28%") + expect(votes_percentage("likes", debate)).to eq("72%") + expect(votes_percentage("dislikes", debate)).to eq("28%") end end diff --git a/spec/i18n_spec.rb b/spec/i18n_spec.rb index e1d60e2fc..522931e92 100644 --- a/spec/i18n_spec.rb +++ b/spec/i18n_spec.rb @@ -1,17 +1,17 @@ -require 'rails_helper' -require 'i18n/tasks' +require "rails_helper" +require "i18n/tasks" -describe 'I18n' do +describe "I18n" do let(:i18n) { I18n::Tasks::BaseTask.new } let(:missing_keys) { i18n.missing_keys } let(:unused_keys) { i18n.unused_keys } - it 'does not have missing keys' do + it "does not have missing keys" do expect(missing_keys).to be_empty, "Missing #{missing_keys.leaves.count} i18n keys, run `i18n-tasks missing' to show them" end - it 'does not have unused keys' do + it "does not have unused keys" do expect(unused_keys).to be_empty, "#{unused_keys.leaves.count} unused i18n keys, run `i18n-tasks unused' to show them" end diff --git a/spec/lib/acts_as_paranoid_aliases_spec.rb b/spec/lib/acts_as_paranoid_aliases_spec.rb index f7e3ce35f..c304e6b62 100644 --- a/spec/lib/acts_as_paranoid_aliases_spec.rb +++ b/spec/lib/acts_as_paranoid_aliases_spec.rb @@ -1,9 +1,9 @@ -require 'rails_helper' +require "rails_helper" -describe 'Paranoid methods' do +describe "Paranoid methods" do - describe '.hide_all' do - it 'hides all instances in the id list' do + describe ".hide_all" do + it "hides all instances in the id list" do debate1 = create(:debate) debate2 = create(:debate) debate3 = create(:debate) @@ -17,8 +17,8 @@ describe 'Paranoid methods' do end end - describe '.restore_all' do - it 'restores all instances in the id list' do + describe ".restore_all" do + it "restores all instances in the id list" do debate1 = create(:debate) debate2 = create(:debate) debate3 = create(:debate) @@ -34,8 +34,8 @@ describe 'Paranoid methods' do end end - describe '#restore' do - it 'resets the confirmed_hide_at attribute' do + describe "#restore" do + it "resets the confirmed_hide_at attribute" do debate = create(:debate, :hidden, :with_confirmed_hide) debate.restore diff --git a/spec/lib/acts_as_taggable_on_spec.rb b/spec/lib/acts_as_taggable_on_spec.rb index 934c312b8..390efb49d 100644 --- a/spec/lib/acts_as_taggable_on_spec.rb +++ b/spec/lib/acts_as_taggable_on_spec.rb @@ -1,8 +1,8 @@ -require 'rails_helper' +require "rails_helper" describe ActsAsTaggableOn do - describe 'Tagging' do + describe "Tagging" do describe "when tagging debates or proposals" do let(:proposal) { create(:proposal) } let(:debate) { create(:debate) } @@ -44,7 +44,7 @@ describe ActsAsTaggableOn do end end - describe 'Tag' do + describe "Tag" do describe "#recalculate_custom_counter_for" do it "updates the counters of proposals and debates, taking into account hidden ones" do tag = ActsAsTaggableOn::Tag.create(name: "foo") @@ -57,10 +57,10 @@ describe ActsAsTaggableOn do tag.update(debates_count: 0, proposals_count: 0) - tag.recalculate_custom_counter_for('Debate') + tag.recalculate_custom_counter_for("Debate") expect(tag.debates_count).to eq(1) - tag.recalculate_custom_counter_for('Proposal') + tag.recalculate_custom_counter_for("Proposal") expect(tag.proposals_count).to eq(1) end end @@ -86,7 +86,7 @@ describe ActsAsTaggableOn do end it "blocks other kinds of tags" do - tag = create(:tag, kind: 'foo') + tag = create(:tag, kind: "foo") proposal = create(:proposal) proposal.tag_list.add(tag) proposal.save @@ -100,7 +100,7 @@ describe ActsAsTaggableOn do expect(ActsAsTaggableOn::Tag.public_for_api).not_to include(tag) end - it 'only permits tags on proposals or debates' do + it "only permits tags on proposals or debates" do tag_1 = create(:tag) tag_2 = create(:tag) tag_3 = create(:tag) @@ -120,7 +120,7 @@ describe ActsAsTaggableOn do expect(ActsAsTaggableOn::Tag.public_for_api).to match_array([tag_1, tag_3]) end - it 'blocks tags after its taggings became hidden' do + it "blocks tags after its taggings became hidden" do tag = create(:tag) proposal = create(:proposal) proposal.tag_list.add(tag) @@ -136,15 +136,15 @@ describe ActsAsTaggableOn do describe "search" do it "containing the word in the name" do - create(:tag, name: 'Familia') - create(:tag, name: 'Cultura') - create(:tag, name: 'Salud') - create(:tag, name: 'Famosos') + create(:tag, name: "Familia") + create(:tag, name: "Cultura") + create(:tag, name: "Salud") + create(:tag, name: "Famosos") - expect(ActsAsTaggableOn::Tag.pg_search('f').length).to eq(2) - expect(ActsAsTaggableOn::Tag.search('cultura').first.name).to eq('Cultura') - expect(ActsAsTaggableOn::Tag.search('sal').first.name).to eq('Salud') - expect(ActsAsTaggableOn::Tag.search('fami').first.name).to eq('Familia') + expect(ActsAsTaggableOn::Tag.pg_search("f").length).to eq(2) + expect(ActsAsTaggableOn::Tag.search("cultura").first.name).to eq("Cultura") + expect(ActsAsTaggableOn::Tag.search("sal").first.name).to eq("Salud") + expect(ActsAsTaggableOn::Tag.search("fami").first.name).to eq("Familia") end end diff --git a/spec/lib/admin_wysiwyg_sanitizer_spec.rb b/spec/lib/admin_wysiwyg_sanitizer_spec.rb index 4593b8699..2ff151414 100644 --- a/spec/lib/admin_wysiwyg_sanitizer_spec.rb +++ b/spec/lib/admin_wysiwyg_sanitizer_spec.rb @@ -1,10 +1,10 @@ -require 'rails_helper' +require "rails_helper" describe AdminWYSIWYGSanitizer do let(:sanitizer) { AdminWYSIWYGSanitizer.new } - describe '#sanitize' do - it 'allows images' do + describe "#sanitize" do + it "allows images" do html = 'DangerousSmile image' expect(sanitizer.sanitize(html)).to eq(html) end diff --git a/spec/lib/age_spec.rb b/spec/lib/age_spec.rb index f7b408db7..fdaf352e9 100644 --- a/spec/lib/age_spec.rb +++ b/spec/lib/age_spec.rb @@ -1,7 +1,7 @@ -require 'rails_helper' +require "rails_helper" describe Age do - describe '.in_years' do + describe ".in_years" do it "handles nils" do expect(described_class.in_years(nil)).to be_nil end diff --git a/spec/lib/cache_spec.rb b/spec/lib/cache_spec.rb index 680799d2e..a80fa9da3 100644 --- a/spec/lib/cache_spec.rb +++ b/spec/lib/cache_spec.rb @@ -1,9 +1,9 @@ -require 'rails_helper' +require "rails_helper" -describe 'Cache flow' do +describe "Cache flow" do - describe 'Tag destroy' do - it 'invalidates Debate cache keys' do + describe "Tag destroy" do + it "invalidates Debate cache keys" do debate = create(:debate, tag_list: "Good, Bad") tag = ActsAsTaggableOn::Tag.find_by(name: "Bad") diff --git a/spec/lib/census_api_spec.rb b/spec/lib/census_api_spec.rb index aebf2edfd..32df56587 100644 --- a/spec/lib/census_api_spec.rb +++ b/spec/lib/census_api_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe CensusApi do let(:api) { described_class.new } - describe '#get_document_number_variants' do + describe "#get_document_number_variants" do it "trims and cleans up entry" do - expect(api.get_document_number_variants(2, ' 1 2@ 34')).to eq(['1234']) + expect(api.get_document_number_variants(2, " 1 2@ 34")).to eq(["1234"]) end it "returns only one try for passports & residence cards" do - expect(api.get_document_number_variants(2, '1234')).to eq(['1234']) - expect(api.get_document_number_variants(3, '1234')).to eq(['1234']) + expect(api.get_document_number_variants(2, "1234")).to eq(["1234"]) + expect(api.get_document_number_variants(3, "1234")).to eq(["1234"]) end - it 'takes only the last 8 digits for dnis and resicence cards' do - expect(api.get_document_number_variants(1, '543212345678')).to eq(['12345678']) + it "takes only the last 8 digits for dnis and resicence cards" do + expect(api.get_document_number_variants(1, "543212345678")).to eq(["12345678"]) end - it 'tries all the dni variants padding with zeroes' do - expect(api.get_document_number_variants(1, '0123456')).to eq(['123456', '0123456', '00123456']) - expect(api.get_document_number_variants(1, '00123456')).to eq(['123456', '0123456', '00123456']) + it "tries all the dni variants padding with zeroes" do + expect(api.get_document_number_variants(1, "0123456")).to eq(["123456", "0123456", "00123456"]) + expect(api.get_document_number_variants(1, "00123456")).to eq(["123456", "0123456", "00123456"]) end - it 'adds upper and lowercase letter when the letter is present' do - expect(api.get_document_number_variants(1, '1234567A')).to eq(%w(1234567 01234567 1234567a 1234567A 01234567a 01234567A)) + it "adds upper and lowercase letter when the letter is present" do + expect(api.get_document_number_variants(1, "1234567A")).to eq(%w(1234567 01234567 1234567a 1234567A 01234567a 01234567A)) end end - describe '#call' do + describe "#call" do let(:invalid_body) { {get_habita_datos_response: {get_habita_datos_return: {datos_habitante: {}}}} } let(:valid_body) do { diff --git a/spec/lib/census_caller_spec.rb b/spec/lib/census_caller_spec.rb index 17d37b393..d8ed6784d 100644 --- a/spec/lib/census_caller_spec.rb +++ b/spec/lib/census_caller_spec.rb @@ -1,10 +1,10 @@ -require 'rails_helper' +require "rails_helper" describe CensusCaller do let(:api) { described_class.new } - describe '#call' do - it 'returns data from local_census_records if census API is not available' do + describe "#call" do + it "returns data from local_census_records if census API is not available" do census_api_response = CensusApi::Response.new(get_habita_datos_response: { get_habita_datos_return: { datos_habitante: {}, datos_vivienda: {} } } diff --git a/spec/lib/email_digests_spec.rb b/spec/lib/email_digests_spec.rb index c5477610d..841b5032c 100644 --- a/spec/lib/email_digests_spec.rb +++ b/spec/lib/email_digests_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe EmailDigest do @@ -140,14 +140,14 @@ describe EmailDigest do describe "#valid_email?" do it "returns a MatchData if email is valid" do - user = create(:user, email: 'valid_email@email.com') + user = create(:user, email: "valid_email@email.com") email_digest = described_class.new(user) expect(email_digest.valid_email?).to be_a(MatchData) end it "returns nil if email is invalid" do - user = create(:user, email: 'invalid_email@email..com') + user = create(:user, email: "invalid_email@email..com") email_digest = described_class.new(user) expect(email_digest.valid_email?).to be(nil) diff --git a/spec/lib/graph_ql/api_types_creator_spec.rb b/spec/lib/graph_ql/api_types_creator_spec.rb index 78ef4ec6b..125cdc478 100644 --- a/spec/lib/graph_ql/api_types_creator_spec.rb +++ b/spec/lib/graph_ql/api_types_creator_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe GraphQL::ApiTypesCreator do let(:created_types) { {} } @@ -6,53 +6,53 @@ describe GraphQL::ApiTypesCreator do describe "::create_type" do it "creates fields for Int attributes" do debate_type = described_class.create_type(Debate, { id: :integer }, created_types) - created_field = debate_type.fields['id'] + created_field = debate_type.fields["id"] expect(created_field).to be_a(GraphQL::Field) expect(created_field.type).to be_a(GraphQL::ScalarType) - expect(created_field.type.name).to eq('Int') + expect(created_field.type.name).to eq("Int") end it "creates fields for String attributes" do debate_type = described_class.create_type(Debate, { title: :string }, created_types) - created_field = debate_type.fields['title'] + created_field = debate_type.fields["title"] expect(created_field).to be_a(GraphQL::Field) expect(created_field.type).to be_a(GraphQL::ScalarType) - expect(created_field.type.name).to eq('String') + expect(created_field.type.name).to eq("String") end it "creates connections for :belongs_to associations" do user_type = described_class.create_type(User, { id: :integer }, created_types) debate_type = described_class.create_type(Debate, { author: User }, created_types) - connection = debate_type.fields['author'] + connection = debate_type.fields["author"] expect(connection).to be_a(GraphQL::Field) expect(connection.type).to eq(user_type) - expect(connection.name).to eq('author') + expect(connection.name).to eq("author") end it "creates connections for :has_one associations" do user_type = described_class.create_type(User, { organization: Organization }, created_types) organization_type = described_class.create_type(Organization, { id: :integer }, created_types) - connection = user_type.fields['organization'] + connection = user_type.fields["organization"] expect(connection).to be_a(GraphQL::Field) expect(connection.type).to eq(organization_type) - expect(connection.name).to eq('organization') + expect(connection.name).to eq("organization") end it "creates connections for :has_many associations" do comment_type = described_class.create_type(Comment, { id: :integer }, created_types) debate_type = described_class.create_type(Debate, { comments: [Comment] }, created_types) - connection = debate_type.fields['comments'] + connection = debate_type.fields["comments"] expect(connection).to be_a(GraphQL::Field) expect(connection.type).to eq(comment_type.connection_type) - expect(connection.name).to eq('comments') + expect(connection.name).to eq("comments") end end end diff --git a/spec/lib/graph_ql/query_type_creator_spec.rb b/spec/lib/graph_ql/query_type_creator_spec.rb index ee694072b..5d0c2328c 100644 --- a/spec/lib/graph_ql/query_type_creator_spec.rb +++ b/spec/lib/graph_ql/query_type_creator_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe GraphQL::QueryTypeCreator do let(:api_type_definitions) do @@ -12,24 +12,24 @@ describe GraphQL::QueryTypeCreator do describe "::create" do let(:query_type) { described_class.create(api_types) } - it 'creates a QueryType with fields to retrieve single objects whose model fields included an ID' do - field = query_type.fields['proposal'] + it "creates a QueryType with fields to retrieve single objects whose model fields included an ID" do + field = query_type.fields["proposal"] expect(field).to be_a(GraphQL::Field) expect(field.type).to eq(api_types[Proposal]) - expect(field.name).to eq('proposal') + expect(field.name).to eq("proposal") end - it 'creates a QueryType without fields to retrieve single objects whose model fields did not include an ID' do - expect(query_type.fields['proposal_notification']).to be_nil + it "creates a QueryType without fields to retrieve single objects whose model fields did not include an ID" do + expect(query_type.fields["proposal_notification"]).to be_nil end it "creates a QueryType with connections to retrieve collections of objects" do - connection = query_type.fields['proposals'] + connection = query_type.fields["proposals"] expect(connection).to be_a(GraphQL::Field) expect(connection.type).to eq(api_types[Proposal].connection_type) - expect(connection.name).to eq('proposals') + expect(connection.name).to eq("proposals") end end end diff --git a/spec/lib/graphql_spec.rb b/spec/lib/graphql_spec.rb index 3617d79a8..9f7d7c770 100644 --- a/spec/lib/graphql_spec.rb +++ b/spec/lib/graphql_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" api_types = GraphQL::ApiTypesCreator.create(API_TYPE_DEFINITIONS) query_type = GraphQL::QueryTypeCreator.create(api_types) @@ -12,213 +12,213 @@ def execute(query_string, context = {}, variables = {}) end def dig(response, path) - response.dig(*path.split('.')) + response.dig(*path.split(".")) end def hidden_field?(response, field_name) - data_is_empty = response['data'].nil? - error_is_present = ((response['errors'].first['message'] =~ /Field '#{field_name}' doesn't exist on type '[[:alnum:]]*'/) == 0) + data_is_empty = response["data"].nil? + error_is_present = ((response["errors"].first["message"] =~ /Field '#{field_name}' doesn't exist on type '[[:alnum:]]*'/) == 0) data_is_empty && error_is_present end def extract_fields(response, collection_name, field_chain) - fields = field_chain.split('.') + fields = field_chain.split(".") dig(response, "data.#{collection_name}.edges").collect do |node| begin if fields.size > 1 - node['node'][fields.first][fields.second] + node["node"][fields.first][fields.second] else - node['node'][fields.first] + node["node"][fields.first] end rescue NoMethodError end end.compact end -describe 'Consul Schema' do +describe "Consul Schema" do let(:user) { create(:user) } let(:proposal) { create(:proposal, author: user) } - it 'returns fields of Int type' do + it "returns fields of Int type" do response = execute("{ proposal(id: #{proposal.id}) { id } }") - expect(dig(response, 'data.proposal.id')).to eq(proposal.id) + expect(dig(response, "data.proposal.id")).to eq(proposal.id) end - it 'returns fields of String type' do + it "returns fields of String type" do response = execute("{ proposal(id: #{proposal.id}) { title } }") - expect(dig(response, 'data.proposal.title')).to eq(proposal.title) + expect(dig(response, "data.proposal.title")).to eq(proposal.title) end - xit 'returns has_one associations' do + xit "returns has_one associations" do organization = create(:organization) response = execute("{ user(id: #{organization.user_id}) { organization { name } } }") - expect(dig(response, 'data.user.organization.name')).to eq(organization.name) + expect(dig(response, "data.user.organization.name")).to eq(organization.name) end - it 'returns belongs_to associations' do + it "returns belongs_to associations" do response = execute("{ proposal(id: #{proposal.id}) { public_author { username } } }") - expect(dig(response, 'data.proposal.public_author.username')).to eq(proposal.public_author.username) + expect(dig(response, "data.proposal.public_author.username")).to eq(proposal.public_author.username) end - it 'returns has_many associations' do + it "returns has_many associations" do comments_author = create(:user) comment_1 = create(:comment, author: comments_author, commentable: proposal) comment_2 = create(:comment, author: comments_author, commentable: proposal) response = execute("{ proposal(id: #{proposal.id}) { comments { edges { node { body } } } } }") - comments = dig(response, 'data.proposal.comments.edges').collect { |edge| edge['node'] } - comment_bodies = comments.collect { |comment| comment['body'] } + comments = dig(response, "data.proposal.comments.edges").collect { |edge| edge["node"] } + comment_bodies = comments.collect { |comment| comment["body"] } expect(comment_bodies).to match_array([comment_1.body, comment_2.body]) end - xit 'executes deeply nested queries' do + xit "executes deeply nested queries" do org_user = create(:user) organization = create(:organization, user: org_user) org_proposal = create(:proposal, author: org_user) response = execute("{ proposal(id: #{org_proposal.id}) { public_author { organization { name } } } }") - expect(dig(response, 'data.proposal.public_author.organization.name')).to eq(organization.name) + expect(dig(response, "data.proposal.public_author.organization.name")).to eq(organization.name) end - it 'hides confidential fields of Int type' do + it "hides confidential fields of Int type" do response = execute("{ user(id: #{user.id}) { failed_census_calls_count } }") - expect(hidden_field?(response, 'failed_census_calls_count')).to be_truthy + expect(hidden_field?(response, "failed_census_calls_count")).to be_truthy end - it 'hides confidential fields of String type' do + it "hides confidential fields of String type" do response = execute("{ user(id: #{user.id}) { encrypted_password } }") - expect(hidden_field?(response, 'encrypted_password')).to be_truthy + expect(hidden_field?(response, "encrypted_password")).to be_truthy end - it 'hides confidential has_one associations' do + it "hides confidential has_one associations" do user.administrator = create(:administrator) response = execute("{ user(id: #{user.id}) { administrator { id } } }") - expect(hidden_field?(response, 'administrator')).to be_truthy + expect(hidden_field?(response, "administrator")).to be_truthy end - it 'hides confidential belongs_to associations' do + it "hides confidential belongs_to associations" do create(:failed_census_call, user: user) response = execute("{ user(id: #{user.id}) { failed_census_calls { id } } }") - expect(hidden_field?(response, 'failed_census_calls')).to be_truthy + expect(hidden_field?(response, "failed_census_calls")).to be_truthy end - it 'hides confidential has_many associations' do + it "hides confidential has_many associations" do create(:direct_message, sender: user) response = execute("{ user(id: #{user.id}) { direct_messages_sent { id } } }") - expect(hidden_field?(response, 'direct_messages_sent')).to be_truthy + expect(hidden_field?(response, "direct_messages_sent")).to be_truthy end - it 'hides confidential fields inside deeply nested queries' do + it "hides confidential fields inside deeply nested queries" do response = execute("{ proposals(first: 1) { edges { node { public_author { encrypted_password } } } } }") - expect(hidden_field?(response, 'encrypted_password')).to be_truthy + expect(hidden_field?(response, "encrypted_password")).to be_truthy end - describe 'Users' do + describe "Users" do let(:user) { create(:user, public_activity: false) } - it 'does not link debates if activity is not public' do + it "does not link debates if activity is not public" do create(:debate, author: user) response = execute("{ user(id: #{user.id}) { public_debates { edges { node { title } } } } }") - received_debates = dig(response, 'data.user.public_debates.edges') + received_debates = dig(response, "data.user.public_debates.edges") expect(received_debates).to eq [] end - it 'does not link proposals if activity is not public' do + it "does not link proposals if activity is not public" do create(:proposal, author: user) response = execute("{ user(id: #{user.id}) { public_proposals { edges { node { title } } } } }") - received_proposals = dig(response, 'data.user.public_proposals.edges') + received_proposals = dig(response, "data.user.public_proposals.edges") expect(received_proposals).to eq [] end - it 'does not link comments if activity is not public' do + it "does not link comments if activity is not public" do create(:comment, author: user) response = execute("{ user(id: #{user.id}) { public_comments { edges { node { body } } } } }") - received_comments = dig(response, 'data.user.public_comments.edges') + received_comments = dig(response, "data.user.public_comments.edges") expect(received_comments).to eq [] end end - describe 'Proposals' do - it 'does not include hidden proposals' do + describe "Proposals" do + it "does not include hidden proposals" do visible_proposal = create(:proposal) hidden_proposal = create(:proposal, :hidden) - response = execute('{ proposals { edges { node { title } } } }') - received_titles = extract_fields(response, 'proposals', 'title') + response = execute("{ proposals { edges { node { title } } } }") + received_titles = extract_fields(response, "proposals", "title") expect(received_titles).to match_array [visible_proposal.title] end - xit 'only returns proposals of the Human Rights proceeding' do + xit "only returns proposals of the Human Rights proceeding" do proposal = create(:proposal) - human_rights_proposal = create(:proposal, proceeding: 'Derechos Humanos', sub_proceeding: 'Right to have a job') + human_rights_proposal = create(:proposal, proceeding: "Derechos Humanos", sub_proceeding: "Right to have a job") other_proceeding_proposal = create(:proposal) - other_proceeding_proposal.update_attribute(:proceeding, 'Another proceeding') + other_proceeding_proposal.update_attribute(:proceeding, "Another proceeding") - response = execute('{ proposals { edges { node { title } } } }') - received_titles = extract_fields(response, 'proposals', 'title') + response = execute("{ proposals { edges { node { title } } } }") + received_titles = extract_fields(response, "proposals", "title") expect(received_titles).to match_array [proposal.title, human_rights_proposal.title] end - it 'includes proposals of authors even if public activity is set to false' do + it "includes proposals of authors even if public activity is set to false" do visible_author = create(:user, public_activity: true) hidden_author = create(:user, public_activity: false) visible_proposal = create(:proposal, author: visible_author) hidden_proposal = create(:proposal, author: hidden_author) - response = execute('{ proposals { edges { node { title } } } }') - received_titles = extract_fields(response, 'proposals', 'title') + response = execute("{ proposals { edges { node { title } } } }") + received_titles = extract_fields(response, "proposals", "title") expect(received_titles).to match_array [visible_proposal.title, hidden_proposal.title] end - it 'does not link author if public activity is set to false' do + it "does not link author if public activity is set to false" do visible_author = create(:user, public_activity: true) hidden_author = create(:user, public_activity: false) visible_proposal = create(:proposal, author: visible_author) hidden_proposal = create(:proposal, author: hidden_author) - response = execute('{ proposals { edges { node { public_author { username } } } } }') - received_authors = extract_fields(response, 'proposals', 'public_author.username') + response = execute("{ proposals { edges { node { public_author { username } } } } }") + received_authors = extract_fields(response, "proposals", "public_author.username") expect(received_authors).to match_array [visible_author.username] end - it 'only returns date and hour for created_at' do + it "only returns date and hour for created_at" do created_at = Time.zone.parse("2017-12-31 9:30:15") create(:proposal, created_at: created_at) - response = execute('{ proposals { edges { node { public_created_at } } } }') - received_timestamps = extract_fields(response, 'proposals', 'public_created_at') + response = execute("{ proposals { edges { node { public_created_at } } } }") + received_timestamps = extract_fields(response, "proposals", "public_created_at") expect(Time.zone.parse(received_timestamps.first)).to eq Time.zone.parse("2017-12-31 9:00:00") end - it 'only retruns tags with kind nil or category' do - tag = create(:tag, name: 'Parks') - category_tag = create(:tag, :category, name: 'Health') - admin_tag = create(:tag, name: 'Admin tag', kind: 'admin') + it "only retruns tags with kind nil or category" do + tag = create(:tag, name: "Parks") + category_tag = create(:tag, :category, name: "Health") + admin_tag = create(:tag, name: "Admin tag", kind: "admin") - proposal = create(:proposal, tag_list: 'Parks, Health, Admin tag') + proposal = create(:proposal, tag_list: "Parks, Health, Admin tag") response = execute("{ proposal(id: #{proposal.id}) { tags { edges { node { name } } } } }") - received_tags = dig(response, 'data.proposal.tags.edges').map { |node| node['node']['name'] } + received_tags = dig(response, "data.proposal.tags.edges").map { |node| node["node"]["name"] } - expect(received_tags).to match_array ['Parks', 'Health'] + expect(received_tags).to match_array ["Parks", "Health"] end - it 'returns nested votes for a proposal' do + it "returns nested votes for a proposal" do proposal = create(:proposal) 2.times { create(:vote, votable: proposal) } @@ -230,357 +230,357 @@ describe 'Consul Schema' do end - describe 'Debates' do - it 'does not include hidden debates' do + describe "Debates" do + it "does not include hidden debates" do visible_debate = create(:debate) hidden_debate = create(:debate, :hidden) - response = execute('{ debates { edges { node { title } } } }') - received_titles = extract_fields(response, 'debates', 'title') + response = execute("{ debates { edges { node { title } } } }") + received_titles = extract_fields(response, "debates", "title") expect(received_titles).to match_array [visible_debate.title] end - it 'includes debates of authors even if public activity is set to false' do + it "includes debates of authors even if public activity is set to false" do visible_author = create(:user, public_activity: true) hidden_author = create(:user, public_activity: false) visible_debate = create(:debate, author: visible_author) hidden_debate = create(:debate, author: hidden_author) - response = execute('{ debates { edges { node { title } } } }') - received_titles = extract_fields(response, 'debates', 'title') + response = execute("{ debates { edges { node { title } } } }") + received_titles = extract_fields(response, "debates", "title") expect(received_titles).to match_array [visible_debate.title, hidden_debate.title] end - it 'does not link author if public activity is set to false' do + it "does not link author if public activity is set to false" do visible_author = create(:user, public_activity: true) hidden_author = create(:user, public_activity: false) visible_debate = create(:debate, author: visible_author) hidden_debate = create(:debate, author: hidden_author) - response = execute('{ debates { edges { node { public_author { username } } } } }') - received_authors = extract_fields(response, 'debates', 'public_author.username') + response = execute("{ debates { edges { node { public_author { username } } } } }") + received_authors = extract_fields(response, "debates", "public_author.username") expect(received_authors).to match_array [visible_author.username] end - it 'only returns date and hour for created_at' do + it "only returns date and hour for created_at" do created_at = Time.zone.parse("2017-12-31 9:30:15") create(:debate, created_at: created_at) - response = execute('{ debates { edges { node { public_created_at } } } }') - received_timestamps = extract_fields(response, 'debates', 'public_created_at') + response = execute("{ debates { edges { node { public_created_at } } } }") + received_timestamps = extract_fields(response, "debates", "public_created_at") expect(Time.zone.parse(received_timestamps.first)).to eq Time.zone.parse("2017-12-31 9:00:00") end - it 'only retruns tags with kind nil or category' do - tag = create(:tag, name: 'Parks') - category_tag = create(:tag, :category, name: 'Health') - admin_tag = create(:tag, name: 'Admin tag', kind: 'admin') + it "only retruns tags with kind nil or category" do + tag = create(:tag, name: "Parks") + category_tag = create(:tag, :category, name: "Health") + admin_tag = create(:tag, name: "Admin tag", kind: "admin") - debate = create(:debate, tag_list: 'Parks, Health, Admin tag') + debate = create(:debate, tag_list: "Parks, Health, Admin tag") response = execute("{ debate(id: #{debate.id}) { tags { edges { node { name } } } } }") - received_tags = dig(response, 'data.debate.tags.edges').map { |node| node['node']['name'] } + received_tags = dig(response, "data.debate.tags.edges").map { |node| node["node"]["name"] } - expect(received_tags).to match_array ['Parks', 'Health'] + expect(received_tags).to match_array ["Parks", "Health"] end end - describe 'Comments' do - it 'only returns comments from proposals, debates and polls' do + describe "Comments" do + it "only returns comments from proposals, debates and polls" do proposal_comment = create(:comment, commentable: create(:proposal)) debate_comment = create(:comment, commentable: create(:debate)) poll_comment = create(:comment, commentable: create(:poll)) spending_proposal_comment = build(:comment, commentable: create(:spending_proposal)).save(skip_validation: true) - response = execute('{ comments { edges { node { commentable_type } } } }') - received_commentables = extract_fields(response, 'comments', 'commentable_type') + response = execute("{ comments { edges { node { commentable_type } } } }") + received_commentables = extract_fields(response, "comments", "commentable_type") - expect(received_commentables).to match_array ['Proposal', 'Debate', 'Poll'] + expect(received_commentables).to match_array ["Proposal", "Debate", "Poll"] end - it 'displays comments of authors even if public activity is set to false' do + it "displays comments of authors even if public activity is set to false" do visible_author = create(:user, public_activity: true) hidden_author = create(:user, public_activity: false) visible_comment = create(:comment, user: visible_author) hidden_comment = create(:comment, user: hidden_author) - response = execute('{ comments { edges { node { body } } } }') - received_comments = extract_fields(response, 'comments', 'body') + response = execute("{ comments { edges { node { body } } } }") + received_comments = extract_fields(response, "comments", "body") expect(received_comments).to match_array [visible_comment.body, hidden_comment.body] end - it 'does not link author if public activity is set to false' do + it "does not link author if public activity is set to false" do visible_author = create(:user, public_activity: true) hidden_author = create(:user, public_activity: false) visible_comment = create(:comment, author: visible_author) hidden_comment = create(:comment, author: hidden_author) - response = execute('{ comments { edges { node { public_author { username } } } } }') - received_authors = extract_fields(response, 'comments', 'public_author.username') + response = execute("{ comments { edges { node { public_author { username } } } } }") + received_authors = extract_fields(response, "comments", "public_author.username") expect(received_authors).to match_array [visible_author.username] end - it 'does not include hidden comments' do + it "does not include hidden comments" do visible_comment = create(:comment) hidden_comment = create(:comment, hidden_at: Time.current) - response = execute('{ comments { edges { node { body } } } }') - received_comments = extract_fields(response, 'comments', 'body') + response = execute("{ comments { edges { node { body } } } }") + received_comments = extract_fields(response, "comments", "body") expect(received_comments).to match_array [visible_comment.body] end - it 'does not include comments from hidden proposals' do + it "does not include comments from hidden proposals" do visible_proposal = create(:proposal) hidden_proposal = create(:proposal, hidden_at: Time.current) visible_proposal_comment = create(:comment, commentable: visible_proposal) hidden_proposal_comment = create(:comment, commentable: hidden_proposal) - response = execute('{ comments { edges { node { body } } } }') - received_comments = extract_fields(response, 'comments', 'body') + response = execute("{ comments { edges { node { body } } } }") + received_comments = extract_fields(response, "comments", "body") expect(received_comments).to match_array [visible_proposal_comment.body] end - it 'does not include comments from hidden debates' do + it "does not include comments from hidden debates" do visible_debate = create(:debate) hidden_debate = create(:debate, hidden_at: Time.current) visible_debate_comment = create(:comment, commentable: visible_debate) hidden_debate_comment = create(:comment, commentable: hidden_debate) - response = execute('{ comments { edges { node { body } } } }') - received_comments = extract_fields(response, 'comments', 'body') + response = execute("{ comments { edges { node { body } } } }") + received_comments = extract_fields(response, "comments", "body") expect(received_comments).to match_array [visible_debate_comment.body] end - it 'does not include comments from hidden polls' do + it "does not include comments from hidden polls" do visible_poll = create(:poll) hidden_poll = create(:poll, hidden_at: Time.current) visible_poll_comment = create(:comment, commentable: visible_poll) hidden_poll_comment = create(:comment, commentable: hidden_poll) - response = execute('{ comments { edges { node { body } } } }') - received_comments = extract_fields(response, 'comments', 'body') + response = execute("{ comments { edges { node { body } } } }") + received_comments = extract_fields(response, "comments", "body") expect(received_comments).to match_array [visible_poll_comment.body] end - it 'does not include comments of debates that are not public' do + it "does not include comments of debates that are not public" do not_public_debate = create(:debate, :hidden) not_public_debate_comment = create(:comment, commentable: not_public_debate) allow(Comment).to receive(:public_for_api).and_return([]) - response = execute('{ comments { edges { node { body } } } }') - received_comments = extract_fields(response, 'comments', 'body') + response = execute("{ comments { edges { node { body } } } }") + received_comments = extract_fields(response, "comments", "body") expect(received_comments).not_to include(not_public_debate_comment.body) end - it 'does not include comments of proposals that are not public' do + it "does not include comments of proposals that are not public" do not_public_proposal = create(:proposal) not_public_proposal_comment = create(:comment, commentable: not_public_proposal) allow(Comment).to receive(:public_for_api).and_return([]) - response = execute('{ comments { edges { node { body } } } }') - received_comments = extract_fields(response, 'comments', 'body') + response = execute("{ comments { edges { node { body } } } }") + received_comments = extract_fields(response, "comments", "body") expect(received_comments).not_to include(not_public_proposal_comment.body) end - it 'does not include comments of polls that are not public' do + it "does not include comments of polls that are not public" do not_public_poll = create(:poll) not_public_poll_comment = create(:comment, commentable: not_public_poll) allow(Comment).to receive(:public_for_api).and_return([]) - response = execute('{ comments { edges { node { body } } } }') - received_comments = extract_fields(response, 'comments', 'body') + response = execute("{ comments { edges { node { body } } } }") + received_comments = extract_fields(response, "comments", "body") expect(received_comments).not_to include(not_public_poll_comment.body) end - it 'only returns date and hour for created_at' do + it "only returns date and hour for created_at" do created_at = Time.zone.parse("2017-12-31 9:30:15") create(:comment, created_at: created_at) - response = execute('{ comments { edges { node { public_created_at } } } }') - received_timestamps = extract_fields(response, 'comments', 'public_created_at') + response = execute("{ comments { edges { node { public_created_at } } } }") + received_timestamps = extract_fields(response, "comments", "public_created_at") expect(Time.zone.parse(received_timestamps.first)).to eq Time.zone.parse("2017-12-31 9:00:00") end - it 'does not include valuation comments' do + it "does not include valuation comments" do visible_comment = create(:comment) valuation_comment = create(:comment, :valuation) - response = execute('{ comments { edges { node { body } } } }') - received_comments = extract_fields(response, 'comments', 'body') + response = execute("{ comments { edges { node { body } } } }") + received_comments = extract_fields(response, "comments", "body") expect(received_comments).not_to include(valuation_comment.body) end end - describe 'Geozones' do - it 'returns geozones' do + describe "Geozones" do + it "returns geozones" do geozone_names = [ create(:geozone), create(:geozone) ].map { |geozone| geozone.name } - response = execute('{ geozones { edges { node { name } } } }') - received_names = extract_fields(response, 'geozones', 'name') + response = execute("{ geozones { edges { node { name } } } }") + received_names = extract_fields(response, "geozones", "name") expect(received_names).to match_array geozone_names end end - describe 'Proposal notifications' do + describe "Proposal notifications" do - it 'does not include proposal notifications for hidden proposals' do + it "does not include proposal notifications for hidden proposals" do visible_proposal = create(:proposal) hidden_proposal = create(:proposal, :hidden) visible_proposal_notification = create(:proposal_notification, proposal: visible_proposal) hidden_proposal_notification = create(:proposal_notification, proposal: hidden_proposal) - response = execute('{ proposal_notifications { edges { node { title } } } }') - received_notifications = extract_fields(response, 'proposal_notifications', 'title') + response = execute("{ proposal_notifications { edges { node { title } } } }") + received_notifications = extract_fields(response, "proposal_notifications", "title") expect(received_notifications).to match_array [visible_proposal_notification.title] end - it 'does not include proposal notifications for proposals that are not public' do + it "does not include proposal notifications for proposals that are not public" do not_public_proposal = create(:proposal) not_public_proposal_notification = create(:proposal_notification, proposal: not_public_proposal) allow(ProposalNotification).to receive(:public_for_api).and_return([]) - response = execute('{ proposal_notifications { edges { node { title } } } }') - received_notifications = extract_fields(response, 'proposal_notifications', 'title') + response = execute("{ proposal_notifications { edges { node { title } } } }") + received_notifications = extract_fields(response, "proposal_notifications", "title") expect(received_notifications).not_to include(not_public_proposal_notification.title) end - it 'only returns date and hour for created_at' do + it "only returns date and hour for created_at" do created_at = Time.zone.parse("2017-12-31 9:30:15") create(:proposal_notification, created_at: created_at) - response = execute('{ proposal_notifications { edges { node { public_created_at } } } }') - received_timestamps = extract_fields(response, 'proposal_notifications', 'public_created_at') + response = execute("{ proposal_notifications { edges { node { public_created_at } } } }") + received_timestamps = extract_fields(response, "proposal_notifications", "public_created_at") expect(Time.zone.parse(received_timestamps.first)).to eq Time.zone.parse("2017-12-31 9:00:00") end - it 'only links proposal if public' do + it "only links proposal if public" do visible_proposal = create(:proposal) hidden_proposal = create(:proposal, :hidden) visible_proposal_notification = create(:proposal_notification, proposal: visible_proposal) hidden_proposal_notification = create(:proposal_notification, proposal: hidden_proposal) - response = execute('{ proposal_notifications { edges { node { proposal { title } } } } }') - received_proposals = extract_fields(response, 'proposal_notifications', 'proposal.title') + response = execute("{ proposal_notifications { edges { node { proposal { title } } } } }") + received_proposals = extract_fields(response, "proposal_notifications", "proposal.title") expect(received_proposals).to match_array [visible_proposal.title] end end - describe 'Tags' do - it 'only display tags with kind nil or category' do - tag = create(:tag, name: 'Parks') - category_tag = create(:tag, :category, name: 'Health') - admin_tag = create(:tag, name: 'Admin tag', kind: 'admin') + describe "Tags" do + it "only display tags with kind nil or category" do + tag = create(:tag, name: "Parks") + category_tag = create(:tag, :category, name: "Health") + admin_tag = create(:tag, name: "Admin tag", kind: "admin") - proposal = create(:proposal, tag_list: 'Parks') - proposal = create(:proposal, tag_list: 'Health') - proposal = create(:proposal, tag_list: 'Admin tag') + proposal = create(:proposal, tag_list: "Parks") + proposal = create(:proposal, tag_list: "Health") + proposal = create(:proposal, tag_list: "Admin tag") - response = execute('{ tags { edges { node { name } } } }') - received_tags = extract_fields(response, 'tags', 'name') + response = execute("{ tags { edges { node { name } } } }") + received_tags = extract_fields(response, "tags", "name") - expect(received_tags).to match_array ['Parks', 'Health'] + expect(received_tags).to match_array ["Parks", "Health"] end - it 'uppercase and lowercase tags work ok together for proposals' do - create(:tag, name: 'Health') - create(:tag, name: 'health') - create(:proposal, tag_list: 'health') - create(:proposal, tag_list: 'Health') + it "uppercase and lowercase tags work ok together for proposals" do + create(:tag, name: "Health") + create(:tag, name: "health") + create(:proposal, tag_list: "health") + create(:proposal, tag_list: "Health") - response = execute('{ tags { edges { node { name } } } }') - received_tags = extract_fields(response, 'tags', 'name') + response = execute("{ tags { edges { node { name } } } }") + received_tags = extract_fields(response, "tags", "name") - expect(received_tags).to match_array ['Health', 'health'] + expect(received_tags).to match_array ["Health", "health"] end - it 'uppercase and lowercase tags work ok together for debates' do - create(:tag, name: 'Health') - create(:tag, name: 'health') - create(:debate, tag_list: 'Health') - create(:debate, tag_list: 'health') + it "uppercase and lowercase tags work ok together for debates" do + create(:tag, name: "Health") + create(:tag, name: "health") + create(:debate, tag_list: "Health") + create(:debate, tag_list: "health") - response = execute('{ tags { edges { node { name } } } }') - received_tags = extract_fields(response, 'tags', 'name') + response = execute("{ tags { edges { node { name } } } }") + received_tags = extract_fields(response, "tags", "name") - expect(received_tags).to match_array ['Health', 'health'] + expect(received_tags).to match_array ["Health", "health"] end - it 'does not display tags for hidden proposals' do - proposal = create(:proposal, tag_list: 'Health') - hidden_proposal = create(:proposal, :hidden, tag_list: 'SPAM') + it "does not display tags for hidden proposals" do + proposal = create(:proposal, tag_list: "Health") + hidden_proposal = create(:proposal, :hidden, tag_list: "SPAM") - response = execute('{ tags { edges { node { name } } } }') - received_tags = extract_fields(response, 'tags', 'name') + response = execute("{ tags { edges { node { name } } } }") + received_tags = extract_fields(response, "tags", "name") - expect(received_tags).to match_array ['Health'] + expect(received_tags).to match_array ["Health"] end - it 'does not display tags for hidden debates' do - debate = create(:debate, tag_list: 'Health, Transportation') - hidden_debate = create(:debate, :hidden, tag_list: 'SPAM') + it "does not display tags for hidden debates" do + debate = create(:debate, tag_list: "Health, Transportation") + hidden_debate = create(:debate, :hidden, tag_list: "SPAM") - response = execute('{ tags { edges { node { name } } } }') - received_tags = extract_fields(response, 'tags', 'name') + response = execute("{ tags { edges { node { name } } } }") + received_tags = extract_fields(response, "tags", "name") - expect(received_tags).to match_array ['Health', 'Transportation'] + expect(received_tags).to match_array ["Health", "Transportation"] end xit "does not display tags for proceeding's proposals" do - valid_proceeding_proposal = create(:proposal, proceeding: 'Derechos Humanos', sub_proceeding: 'Right to a Home', tag_list: 'Health') - invalid_proceeding_proposal = create(:proposal, tag_list: 'Animals') - invalid_proceeding_proposal.update_attribute('proceeding', 'Random') + valid_proceeding_proposal = create(:proposal, proceeding: "Derechos Humanos", sub_proceeding: "Right to a Home", tag_list: "Health") + invalid_proceeding_proposal = create(:proposal, tag_list: "Animals") + invalid_proceeding_proposal.update_attribute("proceeding", "Random") - response = execute('{ tags { edges { node { name } } } }') - received_tags = extract_fields(response, 'tags', 'name') + response = execute("{ tags { edges { node { name } } } }") + received_tags = extract_fields(response, "tags", "name") - expect(received_tags).to match_array ['Health'] + expect(received_tags).to match_array ["Health"] end - it 'does not display tags for taggings that are not public' do - proposal = create(:proposal, tag_list: 'Health') + it "does not display tags for taggings that are not public" do + proposal = create(:proposal, tag_list: "Health") allow(ActsAsTaggableOn::Tag).to receive(:public_for_api).and_return([]) - response = execute('{ tags { edges { node { name } } } }') - received_tags = extract_fields(response, 'tags', 'name') + response = execute("{ tags { edges { node { name } } } }") + received_tags = extract_fields(response, "tags", "name") - expect(received_tags).not_to include('Health') + expect(received_tags).not_to include("Health") end end - describe 'Votes' do + describe "Votes" do - it 'only returns votes from proposals, debates and comments' do + it "only returns votes from proposals, debates and comments" do proposal = create(:proposal) debate = create(:debate) comment = create(:comment) @@ -591,52 +591,52 @@ describe 'Consul Schema' do comment_vote = create(:vote, votable: comment) spending_proposal_vote = create(:vote, votable: spending_proposal) - response = execute('{ votes { edges { node { votable_type } } } }') - received_votables = extract_fields(response, 'votes', 'votable_type') + response = execute("{ votes { edges { node { votable_type } } } }") + received_votables = extract_fields(response, "votes", "votable_type") - expect(received_votables).to match_array ['Proposal', 'Debate', 'Comment'] + expect(received_votables).to match_array ["Proposal", "Debate", "Comment"] end - it 'does not include votes from hidden debates' do + it "does not include votes from hidden debates" do visible_debate = create(:debate) hidden_debate = create(:debate, :hidden) visible_debate_vote = create(:vote, votable: visible_debate) hidden_debate_vote = create(:vote, votable: hidden_debate) - response = execute('{ votes { edges { node { votable_id } } } }') - received_debates = extract_fields(response, 'votes', 'votable_id') + response = execute("{ votes { edges { node { votable_id } } } }") + received_debates = extract_fields(response, "votes", "votable_id") expect(received_debates).to match_array [visible_debate.id] end - it 'does not include votes of hidden proposals' do + it "does not include votes of hidden proposals" do visible_proposal = create(:proposal) hidden_proposal = create(:proposal, hidden_at: Time.current) visible_proposal_vote = create(:vote, votable: visible_proposal) hidden_proposal_vote = create(:vote, votable: hidden_proposal) - response = execute('{ votes { edges { node { votable_id } } } }') - received_proposals = extract_fields(response, 'votes', 'votable_id') + response = execute("{ votes { edges { node { votable_id } } } }") + received_proposals = extract_fields(response, "votes", "votable_id") expect(received_proposals).to match_array [visible_proposal.id] end - it 'does not include votes of hidden comments' do + it "does not include votes of hidden comments" do visible_comment = create(:comment) hidden_comment = create(:comment, hidden_at: Time.current) visible_comment_vote = create(:vote, votable: visible_comment) hidden_comment_vote = create(:vote, votable: hidden_comment) - response = execute('{ votes { edges { node { votable_id } } } }') - received_comments = extract_fields(response, 'votes', 'votable_id') + response = execute("{ votes { edges { node { votable_id } } } }") + received_comments = extract_fields(response, "votes", "votable_id") expect(received_comments).to match_array [visible_comment.id] end - it 'does not include votes of comments from a hidden proposal' do + it "does not include votes of comments from a hidden proposal" do visible_proposal = create(:proposal) hidden_proposal = create(:proposal, :hidden) @@ -646,13 +646,13 @@ describe 'Consul Schema' do visible_proposal_comment_vote = create(:vote, votable: visible_proposal_comment) hidden_proposal_comment_vote = create(:vote, votable: hidden_proposal_comment) - response = execute('{ votes { edges { node { votable_id } } } }') - received_votables = extract_fields(response, 'votes', 'votable_id') + response = execute("{ votes { edges { node { votable_id } } } }") + received_votables = extract_fields(response, "votes", "votable_id") expect(received_votables).to match_array [visible_proposal_comment.id] end - it 'does not include votes of comments from a hidden debate' do + it "does not include votes of comments from a hidden debate" do visible_debate = create(:debate) hidden_debate = create(:debate, :hidden) @@ -662,54 +662,54 @@ describe 'Consul Schema' do visible_debate_comment_vote = create(:vote, votable: visible_debate_comment) hidden_debate_comment_vote = create(:vote, votable: hidden_debate_comment) - response = execute('{ votes { edges { node { votable_id } } } }') - received_votables = extract_fields(response, 'votes', 'votable_id') + response = execute("{ votes { edges { node { votable_id } } } }") + received_votables = extract_fields(response, "votes", "votable_id") expect(received_votables).to match_array [visible_debate_comment.id] end - it 'does not include votes of debates that are not public' do + it "does not include votes of debates that are not public" do not_public_debate = create(:debate) allow(Vote).to receive(:public_for_api).and_return([]) not_public_debate_vote = create(:vote, votable: not_public_debate) - response = execute('{ votes { edges { node { votable_id } } } }') - received_votables = extract_fields(response, 'votes', 'votable_id') + response = execute("{ votes { edges { node { votable_id } } } }") + received_votables = extract_fields(response, "votes", "votable_id") expect(received_votables).not_to include(not_public_debate.id) end - it 'does not include votes of a hidden proposals' do + it "does not include votes of a hidden proposals" do not_public_proposal = create(:proposal) allow(Vote).to receive(:public_for_api).and_return([]) not_public_proposal_vote = create(:vote, votable: not_public_proposal) - response = execute('{ votes { edges { node { votable_id } } } }') - received_votables = extract_fields(response, 'votes', 'votable_id') + response = execute("{ votes { edges { node { votable_id } } } }") + received_votables = extract_fields(response, "votes", "votable_id") expect(received_votables).not_to include(not_public_proposal.id) end - it 'does not include votes of a hidden comments' do + it "does not include votes of a hidden comments" do not_public_comment = create(:comment) allow(Vote).to receive(:public_for_api).and_return([]) not_public_comment_vote = create(:vote, votable: not_public_comment) - response = execute('{ votes { edges { node { votable_id } } } }') - received_votables = extract_fields(response, 'votes', 'votable_id') + response = execute("{ votes { edges { node { votable_id } } } }") + received_votables = extract_fields(response, "votes", "votable_id") expect(received_votables).not_to include(not_public_comment.id) end - it 'only returns date and hour for created_at' do + it "only returns date and hour for created_at" do created_at = Time.zone.parse("2017-12-31 9:30:15") create(:vote, created_at: created_at) - response = execute('{ votes { edges { node { public_created_at } } } }') - received_timestamps = extract_fields(response, 'votes', 'public_created_at') + response = execute("{ votes { edges { node { public_created_at } } } }") + received_timestamps = extract_fields(response, "votes", "public_created_at") expect(Time.zone.parse(received_timestamps.first)).to eq Time.zone.parse("2017-12-31 9:00:00") end diff --git a/spec/lib/local_census_spec.rb b/spec/lib/local_census_spec.rb index 0f4286cd4..abe7a2b32 100644 --- a/spec/lib/local_census_spec.rb +++ b/spec/lib/local_census_spec.rb @@ -1,33 +1,33 @@ -require 'rails_helper' +require "rails_helper" describe LocalCensus do let(:api) { described_class.new } - describe '#get_document_number_variants' do + describe "#get_document_number_variants" do it "trims and cleans up entry" do - expect(api.get_document_number_variants(2, ' 1 2@ 34')).to eq(['1234']) + expect(api.get_document_number_variants(2, " 1 2@ 34")).to eq(["1234"]) end it "returns only one try for passports & residence cards" do - expect(api.get_document_number_variants(2, '1234')).to eq(['1234']) - expect(api.get_document_number_variants(3, '1234')).to eq(['1234']) + expect(api.get_document_number_variants(2, "1234")).to eq(["1234"]) + expect(api.get_document_number_variants(3, "1234")).to eq(["1234"]) end - it 'takes only the last 8 digits for dnis and resicence cards' do - expect(api.get_document_number_variants(1, '543212345678')).to eq(['12345678']) + it "takes only the last 8 digits for dnis and resicence cards" do + expect(api.get_document_number_variants(1, "543212345678")).to eq(["12345678"]) end - it 'tries all the dni variants padding with zeroes' do - expect(api.get_document_number_variants(1, '0123456')).to eq(['123456', '0123456', '00123456']) - expect(api.get_document_number_variants(1, '00123456')).to eq(['123456', '0123456', '00123456']) + it "tries all the dni variants padding with zeroes" do + expect(api.get_document_number_variants(1, "0123456")).to eq(["123456", "0123456", "00123456"]) + expect(api.get_document_number_variants(1, "00123456")).to eq(["123456", "0123456", "00123456"]) end - it 'adds upper and lowercase letter when the letter is present' do - expect(api.get_document_number_variants(1, '1234567A')).to eq(['1234567', '01234567', '1234567a', '1234567A', '01234567a', '01234567A']) + it "adds upper and lowercase letter when the letter is present" do + expect(api.get_document_number_variants(1, "1234567A")).to eq(["1234567", "01234567", "1234567a", "1234567A", "01234567a", "01234567A"]) end end - describe '#call' do + describe "#call" do let(:invalid_body) { nil } let(:valid_body) { create(:local_census_record) } diff --git a/spec/lib/manager_authenticator_spec.rb b/spec/lib/manager_authenticator_spec.rb index 8ca0c7a67..a696074aa 100644 --- a/spec/lib/manager_authenticator_spec.rb +++ b/spec/lib/manager_authenticator_spec.rb @@ -1,41 +1,41 @@ -require 'rails_helper' +require "rails_helper" describe ManagerAuthenticator do let(:authenticator) { described_class.new(login: "JJB033", clave_usuario: "31415926", fecha_conexion: "20151031135905") } - describe 'initialization params' do - it 'causes auth to return false if blank login' do + describe "initialization params" do + it "causes auth to return false if blank login" do blank_login_authenticator = described_class.new(login: "", clave_usuario: "31415926", fecha_conexion: "20151031135905") expect(blank_login_authenticator.auth).to be false end - it 'causes auth to return false if blank user_key' do + it "causes auth to return false if blank user_key" do blank_user_key_authenticator = described_class.new(login: "JJB033", clave_usuario: "", fecha_conexion: "20151031135905") expect(blank_user_key_authenticator.auth).to be false end - it 'causes auth to return false if blank date' do + it "causes auth to return false if blank date" do blank_date_authenticator = described_class.new(login: "JJB033", clave_usuario: "31415926", fecha_conexion: "") expect(blank_date_authenticator.auth).to be false end end - describe '#auth' do - it 'returns false if not manager_exists' do + describe "#auth" do + it "returns false if not manager_exists" do allow(authenticator).to receive(:manager_exists?).and_return(false) allow(authenticator).to receive(:application_authorized?).and_return(true) expect(authenticator.auth).to be false end - it 'returns false if not application_authorized' do + it "returns false if not application_authorized" do allow(authenticator).to receive(:manager_exists?).and_return(true) allow(authenticator).to receive(:application_authorized?).and_return(false) expect(authenticator.auth).to be false end - it 'returns ok if manager_exists and application_authorized' do + it "returns ok if manager_exists and application_authorized" do allow(authenticator).to receive(:manager_exists?).and_return(true) allow(authenticator).to receive(:application_authorized?).and_return(true) @@ -43,15 +43,15 @@ describe ManagerAuthenticator do end end - describe 'SOAP' do - it 'calls the verification user method' do + describe "SOAP" do + it "calls the verification user method" do message = { ub: {user_key: "31415926", date: "20151031135905"} } allow(authenticator).to receive(:application_authorized?).and_return(true) allow(authenticator.send(:client)).to receive(:call).with(:get_status_user_data, message: message) authenticator.auth end - it 'calls the permissions check method' do + it "calls the permissions check method" do allow(authenticator).to receive(:manager_exists?).and_return(true) allow(authenticator.send(:client)).to receive(:call).with(:get_applications_user_list, message: { ub: {user_key: "31415926"} }) authenticator.auth diff --git a/spec/lib/migrate_spending_proposals_to_investments_spec.rb b/spec/lib/migrate_spending_proposals_to_investments_spec.rb index bd206220b..2a1853c88 100644 --- a/spec/lib/migrate_spending_proposals_to_investments_spec.rb +++ b/spec/lib/migrate_spending_proposals_to_investments_spec.rb @@ -1,10 +1,10 @@ -require 'rails_helper' +require "rails_helper" describe MigrateSpendingProposalsToInvestments do let(:importer) { described_class.new } - describe '#import' do + describe "#import" do it "Creates the budget if it doesn't exist" do sp = create(:spending_proposal) @@ -57,9 +57,9 @@ describe MigrateSpendingProposalsToInvestments do feasible = create(:spending_proposal, feasible: true) unfeasible = create(:spending_proposal, feasible: false) - expect(importer.import(sp).feasibility).to eq('undecided') - expect(importer.import(feasible).feasibility).to eq('feasible') - expect(importer.import(unfeasible).feasibility).to eq('unfeasible') + expect(importer.import(sp).feasibility).to eq("undecided") + expect(importer.import(feasible).feasibility).to eq("feasible") + expect(importer.import(unfeasible).feasibility).to eq("unfeasible") end it "Imports valuation assignments" do diff --git a/spec/lib/tag_sanitizer_spec.rb b/spec/lib/tag_sanitizer_spec.rb index 177821fbe..db269dddd 100644 --- a/spec/lib/tag_sanitizer_spec.rb +++ b/spec/lib/tag_sanitizer_spec.rb @@ -1,27 +1,27 @@ -require 'rails_helper' +require "rails_helper" describe TagSanitizer do subject { described_class.new } - describe '#sanitize_tag' do - it 'allows regular text, even spaces' do - expect(subject.sanitize_tag('hello there')).to eq('hello there') + describe "#sanitize_tag" do + it "allows regular text, even spaces" do + expect(subject.sanitize_tag("hello there")).to eq("hello there") end - it 'filters out dangerous strings' do - expect(subject.sanitize_tag('user_id=1')).to eq('user_id1') + it "filters out dangerous strings" do + expect(subject.sanitize_tag("user_id=1")).to eq("user_id1") end - it 'sets up a max length for each tag' do - long_tag = '1' * (described_class.tag_max_length + 100) + it "sets up a max length for each tag" do + long_tag = "1" * (described_class.tag_max_length + 100) expect(subject.sanitize_tag(long_tag).size).to eq(described_class.tag_max_length) end end - describe '#sanitize_tag_list' do - it 'returns a new tag list with sanitized tags' do + describe "#sanitize_tag_list" do + it "returns a new tag list with sanitized tags" do expect(subject.sanitize_tag_list(%w{x=1 y?z})).to eq(%w(x1 yz)) end end diff --git a/spec/lib/tasks/communities_spec.rb b/spec/lib/tasks/communities_spec.rb index 3c3d17682..048b69d3b 100644 --- a/spec/lib/tasks/communities_spec.rb +++ b/spec/lib/tasks/communities_spec.rb @@ -1,17 +1,17 @@ -require 'rails_helper' +require "rails_helper" -describe 'Communities Rake' do +describe "Communities Rake" do - describe '#associate_community' do + describe "#associate_community" do let :run_rake_task do - Rake::Task['communities:associate_community'].reenable - Rake.application.invoke_task 'communities:associate_community' + Rake::Task["communities:associate_community"].reenable + Rake.application.invoke_task "communities:associate_community" end - context 'Associate community to Proposal' do + context "Associate community to Proposal" do - it 'When proposal has not community_id' do + it "When proposal has not community_id" do proposal = create(:proposal) proposal.update(community_id: nil) expect(proposal.community).to be_nil @@ -23,9 +23,9 @@ describe 'Communities Rake' do end end - context 'Associate community to Budget Investment' do + context "Associate community to Budget Investment" do - it 'When budget investment has not community_id' do + it "When budget investment has not community_id" do investment = create(:budget_investment) investment.update(community_id: nil) expect(investment.community).to be_nil diff --git a/spec/lib/tasks/dev_seed_spec.rb b/spec/lib/tasks/dev_seed_spec.rb index 0bd63035e..71c816df3 100644 --- a/spec/lib/tasks/dev_seed_spec.rb +++ b/spec/lib/tasks/dev_seed_spec.rb @@ -1,11 +1,11 @@ -require 'rails_helper' +require "rails_helper" -describe 'rake db:dev_seed' do +describe "rake db:dev_seed" do let :run_rake_task do - Rake.application.invoke_task('db:dev_seed[avoid_log]') + Rake.application.invoke_task("db:dev_seed[avoid_log]") end - it 'seeds the database without errors' do + it "seeds the database without errors" do expect { run_rake_task }.not_to raise_error end end diff --git a/spec/lib/tasks/map_location_spec.rb b/spec/lib/tasks/map_location_spec.rb index 42cae9241..61ff2eef2 100644 --- a/spec/lib/tasks/map_location_spec.rb +++ b/spec/lib/tasks/map_location_spec.rb @@ -1,6 +1,6 @@ -require 'rails_helper' +require "rails_helper" -describe 'rake map_locations:destroy' do +describe "rake map_locations:destroy" do before do create(:map_location, :proposal_map_location) empty_location = create(:map_location, :proposal_map_location) @@ -9,10 +9,10 @@ describe 'rake map_locations:destroy' do end let :run_rake_task do - Rake.application.invoke_task('map_locations:destroy') + Rake.application.invoke_task("map_locations:destroy") end - it 'destroys empty locations' do + it "destroys empty locations" do expect(MapLocation.all.size).to eq(2) run_rake_task expect(MapLocation.all.size).to eq(1) diff --git a/spec/lib/tasks/settings_spec.rb b/spec/lib/tasks/settings_spec.rb index 22cee28e1..9e84bca33 100644 --- a/spec/lib/tasks/settings_spec.rb +++ b/spec/lib/tasks/settings_spec.rb @@ -1,67 +1,67 @@ -require 'rails_helper' +require "rails_helper" -describe 'Settings Rake' do +describe "Settings Rake" do - describe '#per_page_code_migration' do + describe "#per_page_code_migration" do let :run_rake_task do - Rake::Task['settings:per_page_code_migration'].reenable - Rake.application.invoke_task 'settings:per_page_code_migration' + Rake::Task["settings:per_page_code_migration"].reenable + Rake.application.invoke_task "settings:per_page_code_migration" end - context 'Neither per_page_code_head or per_page_code Settings exist' do + context "Neither per_page_code_head or per_page_code Settings exist" do before do - Setting.where(key: 'per_page_code').first&.destroy - Setting.where(key: 'per_page_code_head').first&.destroy + Setting.where(key: "per_page_code").first&.destroy + Setting.where(key: "per_page_code_head").first&.destroy run_rake_task end - it 'has per_page_code_head setting present and no per_page_code' do - expect(Setting.where(key: 'per_page_code_head').count).to eq(1) - expect(Setting['per_page_code_head']).to eq(nil) - expect(Setting.where(key: 'per_page_code').count).to eq(0) + it "has per_page_code_head setting present and no per_page_code" do + expect(Setting.where(key: "per_page_code_head").count).to eq(1) + expect(Setting["per_page_code_head"]).to eq(nil) + expect(Setting.where(key: "per_page_code").count).to eq(0) end end - context 'Both per_page_code_head or per_page_code Settings exist' do + context "Both per_page_code_head or per_page_code Settings exist" do before do - Setting['per_page_code'] = 'per_page_code' - Setting['per_page_code_head'] = 'per_page_code_head' + Setting["per_page_code"] = "per_page_code" + Setting["per_page_code_head"] = "per_page_code_head" run_rake_task end - it 'has per_page_code_head setting present and no per_page_code' do - expect(Setting.where(key: 'per_page_code_head').count).to eq(1) - expect(Setting['per_page_code_head']).to eq('per_page_code_head') - expect(Setting.where(key: 'per_page_code').count).to eq(0) + it "has per_page_code_head setting present and no per_page_code" do + expect(Setting.where(key: "per_page_code_head").count).to eq(1) + expect(Setting["per_page_code_head"]).to eq("per_page_code_head") + expect(Setting.where(key: "per_page_code").count).to eq(0) end end - context 'per_page_code_head exists, but per_page_code does not' do + context "per_page_code_head exists, but per_page_code does not" do before do - Setting.where(key: 'per_page_code').first&.destroy - Setting['per_page_code_head'] = 'per_page_code_head' + Setting.where(key: "per_page_code").first&.destroy + Setting["per_page_code_head"] = "per_page_code_head" run_rake_task end - it 'has per_page_code_head setting present and no per_page_code' do - expect(Setting.where(key: 'per_page_code_head').count).to eq(1) - expect(Setting['per_page_code_head']).to eq('per_page_code_head') - expect(Setting.where(key: 'per_page_code').count).to eq(0) + it "has per_page_code_head setting present and no per_page_code" do + expect(Setting.where(key: "per_page_code_head").count).to eq(1) + expect(Setting["per_page_code_head"]).to eq("per_page_code_head") + expect(Setting.where(key: "per_page_code").count).to eq(0) end end - context 'per_page_code_head does not exist, but per_page_code does' do + context "per_page_code_head does not exist, but per_page_code does" do before do - Setting['per_page_code'] = 'per_page_code' - Setting.where(key: 'per_page_code_head').first&.destroy + Setting["per_page_code"] = "per_page_code" + Setting.where(key: "per_page_code_head").first&.destroy run_rake_task end - it 'has per_page_code_head setting present and no per_page_code' do - expect(Setting.where(key: 'per_page_code_head').count).to eq(1) - expect(Setting['per_page_code_head']).to eq('per_page_code') - expect(Setting.where(key: 'per_page_code').count).to eq(0) + it "has per_page_code_head setting present and no per_page_code" do + expect(Setting.where(key: "per_page_code_head").count).to eq(1) + expect(Setting["per_page_code_head"]).to eq("per_page_code") + expect(Setting.where(key: "per_page_code").count).to eq(0) end end diff --git a/spec/lib/tasks/sitemap_spec.rb b/spec/lib/tasks/sitemap_spec.rb index 72f0ed461..e7c38a62c 100644 --- a/spec/lib/tasks/sitemap_spec.rb +++ b/spec/lib/tasks/sitemap_spec.rb @@ -1,28 +1,28 @@ -require 'rails_helper' +require "rails_helper" -feature 'rake sitemap:create' do +feature "rake sitemap:create" do before do - @file ||= Rails.root.join('public', 'sitemap.xml') + @file ||= Rails.root.join("public", "sitemap.xml") # To avoid spec failures if file does not exist # Useful on CI environments or if file was created # previous to the specs (to ensure a clean state) File.delete(@file) if File.exist?(@file) - Rake::Task['sitemap:create'].reenable - Rake.application.invoke_task('sitemap:create') + Rake::Task["sitemap:create"].reenable + Rake.application.invoke_task("sitemap:create") end - it 'generates a sitemap' do + it "generates a sitemap" do expect(@file).to exist end - it 'generates a valid sitemap' do + it "generates a valid sitemap" do sitemap = Nokogiri::XML(File.open(@file)) expect(sitemap.errors).to be_empty end - it 'generates a sitemap with expected and valid URLs' do + it "generates a sitemap with expected and valid URLs" do sitemap = File.read(@file) # Static pages @@ -37,7 +37,7 @@ feature 'rake sitemap:create' do expect(sitemap).to include(proposals_path) expect(sitemap).to include(legislation_processes_path) - expect(sitemap).to have_content('0.7', count: 5) - expect(sitemap).to have_content('daily', count: 5) + expect(sitemap).to have_content("0.7", count: 5) + expect(sitemap).to have_content("daily", count: 5) end end diff --git a/spec/lib/user_segments_spec.rb b/spec/lib/user_segments_spec.rb index 4f1f9ef75..4d1057ddd 100644 --- a/spec/lib/user_segments_spec.rb +++ b/spec/lib/user_segments_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe UserSegments do let(:user1) { create(:user) } @@ -178,8 +178,8 @@ describe UserSegments do investment1 = create(:budget_investment) investment2 = create(:budget_investment) budget = create(:budget) - investment1.vote_by(voter: user1, vote: 'yes') - investment2.vote_by(voter: user2, vote: 'yes') + investment1.vote_by(voter: user1, vote: "yes") + investment2.vote_by(voter: user2, vote: "yes") investment1.update(budget: budget) investment2.update(budget: budget) diff --git a/spec/lib/wysiwyg_sanitizer_spec.rb b/spec/lib/wysiwyg_sanitizer_spec.rb index e86c351ef..0af450225 100644 --- a/spec/lib/wysiwyg_sanitizer_spec.rb +++ b/spec/lib/wysiwyg_sanitizer_spec.rb @@ -1,38 +1,38 @@ -require 'rails_helper' +require "rails_helper" describe WYSIWYGSanitizer do subject { described_class.new } - describe '#sanitize' do + describe "#sanitize" do - it 'returns an html_safe string' do - expect(subject.sanitize('hello')).to be_html_safe + it "returns an html_safe string" do + expect(subject.sanitize("hello")).to be_html_safe end - it 'allows basic html formatting' do - html = '

This is a paragraph

' + it "allows basic html formatting" do + html = "

This is a paragraph

" expect(subject.sanitize(html)).to eq(html) end - it 'allows links' do + it "allows links" do html = '

Home

' expect(subject.sanitize(html)).to eq(html) end - it 'allows headings' do - html = '

Objectives

Fix flaky specs

Explain why the test is flaky

' + it "allows headings" do + html = "

Objectives

Fix flaky specs

Explain why the test is flaky

" expect(subject.sanitize(html)).to eq(html) end - it 'filters out dangerous tags' do - html = '

This is

' - expect(subject.sanitize(html)).to eq('

This is alert("dangerous");

') + it "filters out dangerous tags" do + html = "

This is

" + expect(subject.sanitize(html)).to eq("

This is alert('dangerous');

") end - it 'filters images' do - html = 'DangerousSmile image' - expect(subject.sanitize(html)).to eq('Dangerous image') + it "filters images" do + html = "DangerousSmile image" + expect(subject.sanitize(html)).to eq("Dangerous image") end end diff --git a/spec/mailers/devise_mailer_spec.rb b/spec/mailers/devise_mailer_spec.rb index e5d241fef..ef4e0c38c 100644 --- a/spec/mailers/devise_mailer_spec.rb +++ b/spec/mailers/devise_mailer_spec.rb @@ -1,5 +1,5 @@ # coding: utf-8 -require 'rails_helper' +require "rails_helper" describe DeviseMailer do describe "#confirmation_instructions" do diff --git a/spec/mailers/mailer_spec.rb b/spec/mailers/mailer_spec.rb index dbd80da6f..6215a3c3a 100644 --- a/spec/mailers/mailer_spec.rb +++ b/spec/mailers/mailer_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Mailer do describe "#comment" do diff --git a/spec/models/abilities/administrator_spec.rb b/spec/models/abilities/administrator_spec.rb index 2a7efc28b..9c88f0367 100644 --- a/spec/models/abilities/administrator_spec.rb +++ b/spec/models/abilities/administrator_spec.rb @@ -1,5 +1,5 @@ -require 'rails_helper' -require 'cancan/matchers' +require "rails_helper" +require "cancan/matchers" describe Abilities::Administrator do subject(:ability) { Ability.new(user) } @@ -78,8 +78,8 @@ describe Abilities::Administrator do it { should be_able_to(:update, Budget::Investment) } it { should be_able_to(:hide, Budget::Investment) } - it { should be_able_to(:valuate, create(:budget_investment, budget: create(:budget, phase: 'valuating'))) } - it { should be_able_to(:valuate, create(:budget_investment, budget: create(:budget, phase: 'finished'))) } + it { should be_able_to(:valuate, create(:budget_investment, budget: create(:budget, phase: "valuating"))) } + it { should be_able_to(:valuate, create(:budget_investment, budget: create(:budget, phase: "finished"))) } it { should be_able_to(:destroy, proposal_image) } it { should be_able_to(:destroy, proposal_document) } diff --git a/spec/models/abilities/common_spec.rb b/spec/models/abilities/common_spec.rb index 9b88c0721..796861f61 100644 --- a/spec/models/abilities/common_spec.rb +++ b/spec/models/abilities/common_spec.rb @@ -1,5 +1,5 @@ -require 'rails_helper' -require 'cancan/matchers' +require "rails_helper" +require "cancan/matchers" describe Abilities::Common do subject(:ability) { Ability.new(user) } @@ -15,10 +15,10 @@ describe Abilities::Common do let(:own_comment) { create(:comment, author: user) } let(:own_proposal) { create(:proposal, author: user) } - let(:accepting_budget) { create(:budget, phase: 'accepting') } - let(:reviewing_budget) { create(:budget, phase: 'reviewing') } - let(:selecting_budget) { create(:budget, phase: 'selecting') } - let(:balloting_budget) { create(:budget, phase: 'balloting') } + let(:accepting_budget) { create(:budget, phase: "accepting") } + let(:reviewing_budget) { create(:budget, phase: "reviewing") } + let(:selecting_budget) { create(:budget, phase: "selecting") } + let(:balloting_budget) { create(:budget, phase: "balloting") } let(:investment_in_accepting_budget) { create(:budget_investment, budget: accepting_budget) } let(:investment_in_reviewing_budget) { create(:budget_investment, budget: reviewing_budget) } @@ -98,7 +98,7 @@ describe Abilities::Common do it { should be_able_to(:destroy, own_budget_investment_image) } it { should_not be_able_to(:destroy, budget_investment_image) } - describe 'flagging content' do + describe "flagging content" do it { should be_able_to(:flag, debate) } it { should be_able_to(:unflag, debate) } diff --git a/spec/models/abilities/everyone_spec.rb b/spec/models/abilities/everyone_spec.rb index 2167c748d..b93dd3b9b 100644 --- a/spec/models/abilities/everyone_spec.rb +++ b/spec/models/abilities/everyone_spec.rb @@ -1,5 +1,5 @@ -require 'rails_helper' -require 'cancan/matchers' +require "rails_helper" +require "cancan/matchers" describe Abilities::Everyone do subject(:ability) { Ability.new(user) } @@ -8,8 +8,8 @@ describe Abilities::Everyone do let(:debate) { create(:debate) } let(:proposal) { create(:proposal) } - let(:reviewing_ballot_budget) { create(:budget, phase: 'reviewing_ballots') } - let(:finished_budget) { create(:budget, phase: 'finished') } + let(:reviewing_ballot_budget) { create(:budget, phase: "reviewing_ballots") } + let(:finished_budget) { create(:budget, phase: "finished") } it { should be_able_to(:index, Debate) } it { should be_able_to(:show, debate) } diff --git a/spec/models/abilities/moderator_spec.rb b/spec/models/abilities/moderator_spec.rb index a2b374a85..d09f4dcbf 100644 --- a/spec/models/abilities/moderator_spec.rb +++ b/spec/models/abilities/moderator_spec.rb @@ -1,5 +1,5 @@ -require 'rails_helper' -require 'cancan/matchers' +require "rails_helper" +require "cancan/matchers" describe Abilities::Moderator do subject(:ability) { Ability.new(user) } diff --git a/spec/models/abilities/organization_spec.rb b/spec/models/abilities/organization_spec.rb index a897a03df..05d4e6c0f 100644 --- a/spec/models/abilities/organization_spec.rb +++ b/spec/models/abilities/organization_spec.rb @@ -1,7 +1,7 @@ -require 'rails_helper' -require 'cancan/matchers' +require "rails_helper" +require "cancan/matchers" -describe 'Abilities::Organization' do +describe "Abilities::Organization" do subject(:ability) { Ability.new(user) } let(:user) { organization.user } diff --git a/spec/models/abilities/valuator_spec.rb b/spec/models/abilities/valuator_spec.rb index 3b40457b8..c9764c831 100644 --- a/spec/models/abilities/valuator_spec.rb +++ b/spec/models/abilities/valuator_spec.rb @@ -1,5 +1,5 @@ -require 'rails_helper' -require 'cancan/matchers' +require "rails_helper" +require "cancan/matchers" describe Abilities::Valuator do subject(:ability) { Ability.new(user) } @@ -8,9 +8,9 @@ describe Abilities::Valuator do let(:valuator) { create(:valuator) } let(:group) { create(:valuator_group) } let(:non_assigned_investment) { create(:budget_investment) } - let(:assigned_investment) { create(:budget_investment, budget: create(:budget, phase: 'valuating')) } - let(:group_assigned_investment) { create(:budget_investment, budget: create(:budget, phase: 'valuating')) } - let(:finished_assigned_investment) { create(:budget_investment, budget: create(:budget, phase: 'finished')) } + let(:assigned_investment) { create(:budget_investment, budget: create(:budget, phase: "valuating")) } + let(:group_assigned_investment) { create(:budget_investment, budget: create(:budget, phase: "valuating")) } + let(:finished_assigned_investment) { create(:budget_investment, budget: create(:budget, phase: "finished")) } before do assigned_investment.valuators << valuator diff --git a/spec/models/activity_spec.rb b/spec/models/activity_spec.rb index d048a6bb8..39b8650ff 100644 --- a/spec/models/activity_spec.rb +++ b/spec/models/activity_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Activity do diff --git a/spec/models/admin_notification_spec.rb b/spec/models/admin_notification_spec.rb index daaae0c32..7bb56a311 100644 --- a/spec/models/admin_notification_spec.rb +++ b/spec/models/admin_notification_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe AdminNotification do let(:admin_notification) { build(:admin_notification) } @@ -9,82 +9,82 @@ describe AdminNotification do expect(admin_notification).to be_valid end - it 'is not valid without a title' do + it "is not valid without a title" do admin_notification.title = nil expect(admin_notification).not_to be_valid end - it 'is not valid without a body' do + it "is not valid without a body" do admin_notification.body = nil expect(admin_notification).not_to be_valid end - it 'is not valid without a segment_recipient' do + it "is not valid without a segment_recipient" do admin_notification.segment_recipient = nil expect(admin_notification).not_to be_valid end - describe '#complete_link_url' do - it 'does not change link if there is no value' do + describe "#complete_link_url" do + it "does not change link if there is no value" do expect(admin_notification.link).to be_nil end - it 'fixes a link without http://' do - admin_notification.link = 'lol.consul.dev' + it "fixes a link without http://" do + admin_notification.link = "lol.consul.dev" expect(admin_notification).to be_valid - expect(admin_notification.link).to eq('http://lol.consul.dev') + expect(admin_notification.link).to eq("http://lol.consul.dev") end - it 'fixes a link with wwww. but without http://' do - admin_notification.link = 'www.lol.consul.dev' + it "fixes a link with wwww. but without http://" do + admin_notification.link = "www.lol.consul.dev" expect(admin_notification).to be_valid - expect(admin_notification.link).to eq('http://www.lol.consul.dev') + expect(admin_notification.link).to eq("http://www.lol.consul.dev") end - it 'does not modify a link with http://' do - admin_notification.link = 'http://lol.consul.dev' + it "does not modify a link with http://" do + admin_notification.link = "http://lol.consul.dev" expect(admin_notification).to be_valid - expect(admin_notification.link).to eq('http://lol.consul.dev') + expect(admin_notification.link).to eq("http://lol.consul.dev") end - it 'does not modify a link with https://' do - admin_notification.link = 'https://lol.consul.dev' + it "does not modify a link with https://" do + admin_notification.link = "https://lol.consul.dev" expect(admin_notification).to be_valid - expect(admin_notification.link).to eq('https://lol.consul.dev') + expect(admin_notification.link).to eq("https://lol.consul.dev") end - it 'does not modify a link with http://wwww.' do - admin_notification.link = 'http://www.lol.consul.dev' + it "does not modify a link with http://wwww." do + admin_notification.link = "http://www.lol.consul.dev" expect(admin_notification).to be_valid - expect(admin_notification.link).to eq('http://www.lol.consul.dev') + expect(admin_notification.link).to eq("http://www.lol.consul.dev") end end - describe '#valid_segment_recipient?' do - it 'is false when segment_recipient value is invalid' do - admin_notification.update(segment_recipient: 'invalid_segment_name') - error = 'The user recipients segment is invalid' + describe "#valid_segment_recipient?" do + it "is false when segment_recipient value is invalid" do + admin_notification.update(segment_recipient: "invalid_segment_name") + error = "The user recipients segment is invalid" expect(admin_notification).not_to be_valid expect(admin_notification.errors.messages[:segment_recipient]).to include(error) end end - describe '#list_of_recipients' do - let(:erased_user) { create(:user, username: 'erased_user') } + describe "#list_of_recipients" do + let(:erased_user) { create(:user, username: "erased_user") } before do 2.times { create(:user) } erased_user.erase - admin_notification.update(segment_recipient: 'all_users') + admin_notification.update(segment_recipient: "all_users") end - it 'returns list of all active users' do + it "returns list of all active users" do expect(admin_notification.list_of_recipients.count).to eq(2) expect(admin_notification.list_of_recipients).not_to include(erased_user) end diff --git a/spec/models/ahoy/data_source_spec.rb b/spec/models/ahoy/data_source_spec.rb index 5b5f636e7..8d9bdb8a8 100644 --- a/spec/models/ahoy/data_source_spec.rb +++ b/spec/models/ahoy/data_source_spec.rb @@ -1,35 +1,35 @@ -require 'rails_helper' +require "rails_helper" describe Ahoy::DataSource do - describe '#build' do + describe "#build" 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 'works without data sources' do + it "works without data sources" do ds = described_class.new expect(ds.build).to eq x: [] end - it 'works with single data sources' do + it "works with single data sources" do ds = described_class.new - ds.add 'foo', Ahoy::Event.where(name: 'foo').group_by_day(:time).count + ds.add "foo", Ahoy::Event.where(name: "foo").group_by_day(:time).count expect(ds.build).to eq :x => ["2015-01-01", "2015-01-02"], "foo" => [2, 1] end - it 'combines data sources' do + it "combines data sources" do ds = described_class.new - ds.add 'foo', Ahoy::Event.where(name: 'foo').group_by_day(:time).count - ds.add 'bar', Ahoy::Event.where(name: 'bar').group_by_day(:time).count + ds.add "foo", Ahoy::Event.where(name: "foo").group_by_day(:time).count + ds.add "bar", Ahoy::Event.where(name: "bar").group_by_day(:time).count expect(ds.build).to eq :x => ["2015-01-01", "2015-01-02", "2015-01-03"], "foo" => [2, 1, 0], "bar" => [1, 0, 2] end end diff --git a/spec/models/budget/ballot/line_spec.rb b/spec/models/budget/ballot/line_spec.rb index 8d3c66e75..e91d36416 100644 --- a/spec/models/budget/ballot/line_spec.rb +++ b/spec/models/budget/ballot/line_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Budget::Ballot::Line do @@ -9,7 +9,7 @@ describe Budget::Ballot::Line do let(:ballot) { create(:budget_ballot, budget: budget) } let(:ballot_line) { build(:budget_ballot_line, ballot: ballot, investment: investment) } - describe 'Validations' do + describe "Validations" do it "is valid and automatically denormallyze budget, group and heading when validated" do expect(ballot_line).to be_valid @@ -18,7 +18,7 @@ describe Budget::Ballot::Line do expect(ballot_line.heading).to eq(heading) end - describe 'Money' do + describe "Money" do it "is not valid if insufficient funds" do investment.update(price: heading.price + 1) expect(ballot_line).not_to be_valid @@ -30,7 +30,7 @@ describe Budget::Ballot::Line do end end - describe 'Selectibility' do + describe "Selectibility" do it "is not valid if investment is unselected" do investment.update(selected: false) expect(ballot_line).not_to be_valid diff --git a/spec/models/budget/ballot_spec.rb b/spec/models/budget/ballot_spec.rb index de61fcaa9..66a2e6900 100644 --- a/spec/models/budget/ballot_spec.rb +++ b/spec/models/budget/ballot_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Budget::Ballot do diff --git a/spec/models/budget/content_block_spec.rb b/spec/models/budget/content_block_spec.rb index 5e77adad6..68d6f0a17 100644 --- a/spec/models/budget/content_block_spec.rb +++ b/spec/models/budget/content_block_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Budget::ContentBlock do let(:block) { build(:heading_content_block) } diff --git a/spec/models/budget/heading_spec.rb b/spec/models/budget/heading_spec.rb index 3003d1c74..2d69839e6 100644 --- a/spec/models/budget/heading_spec.rb +++ b/spec/models/budget/heading_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Budget::Heading do @@ -54,11 +54,11 @@ describe Budget::Heading do describe "Save population" do it "Allows population == nil" do - expect(create(:budget_heading, group: group, name: 'Population is nil', population: nil)).to be_valid + expect(create(:budget_heading, group: group, name: "Population is nil", population: nil)).to be_valid end it "Doesn't allow population <= 0" do - heading = create(:budget_heading, group: group, name: 'Population is > 0') + heading = create(:budget_heading, group: group, name: "Population is > 0") heading.population = 0 expect(heading).not_to be_valid @@ -74,96 +74,96 @@ describe Budget::Heading do describe "save latitude" do it "Doesn't allow latitude < -90" do - heading = create(:budget_heading, group: group, name: 'Latitude is < -90') + heading = create(:budget_heading, group: group, name: "Latitude is < -90") - heading.latitude = '-90.127491' + heading.latitude = "-90.127491" expect(heading).not_to be_valid - heading.latitude = '-91.723491' + heading.latitude = "-91.723491" expect(heading).not_to be_valid - heading.latitude = '-108.127412' + heading.latitude = "-108.127412" expect(heading).not_to be_valid - heading.latitude = '-1100.888491' + heading.latitude = "-1100.888491" expect(heading).not_to be_valid end it "Doesn't allow latitude > 90" do - heading = create(:budget_heading, group: group, name: 'Latitude is > 90') + heading = create(:budget_heading, group: group, name: "Latitude is > 90") - heading.latitude = '90.127491' + heading.latitude = "90.127491" expect(heading).not_to be_valid - heading.latitude = '97.723491' + heading.latitude = "97.723491" expect(heading).not_to be_valid - heading.latitude = '119.127412' + heading.latitude = "119.127412" expect(heading).not_to be_valid - heading.latitude = '1200.888491' + heading.latitude = "1200.888491" expect(heading).not_to be_valid - heading.latitude = '+128.888491' + heading.latitude = "+128.888491" expect(heading).not_to be_valid - heading.latitude = '+255.888491' + heading.latitude = "+255.888491" expect(heading).not_to be_valid end it "Doesn't allow latitude length > 22" do - heading = create(:budget_heading, group: group, name: 'Latitude length is > 22') + heading = create(:budget_heading, group: group, name: "Latitude length is > 22") - heading.latitude = '10.12749112312418238128213' + heading.latitude = "10.12749112312418238128213" expect(heading).not_to be_valid - heading.latitude = '7.7234941211121231231241' + heading.latitude = "7.7234941211121231231241" expect(heading).not_to be_valid - heading.latitude = '9.1274124111241248688995' + heading.latitude = "9.1274124111241248688995" expect(heading).not_to be_valid - heading.latitude = '+12.8884911231238684445311' + heading.latitude = "+12.8884911231238684445311" expect(heading).not_to be_valid end it "Allows latitude inside [-90,90] interval" do - heading = create(:budget_heading, group: group, name: 'Latitude is inside [-90,90] interval') + heading = create(:budget_heading, group: group, name: "Latitude is inside [-90,90] interval") - heading.latitude = '90' + heading.latitude = "90" expect(heading).to be_valid - heading.latitude = '-90' + heading.latitude = "-90" expect(heading).to be_valid - heading.latitude = '-90.000' + heading.latitude = "-90.000" expect(heading).to be_valid - heading.latitude = '-90.00000' + heading.latitude = "-90.00000" expect(heading).to be_valid - heading.latitude = '90.000' + heading.latitude = "90.000" expect(heading).to be_valid - heading.latitude = '90.00000' + heading.latitude = "90.00000" expect(heading).to be_valid - heading.latitude = '-80.123451' + heading.latitude = "-80.123451" expect(heading).to be_valid - heading.latitude = '+65.888491' + heading.latitude = "+65.888491" expect(heading).to be_valid - heading.latitude = '80.144812' + heading.latitude = "80.144812" expect(heading).to be_valid - heading.latitude = '17.417412' + heading.latitude = "17.417412" expect(heading).to be_valid - heading.latitude = '-21.000054' + heading.latitude = "-21.000054" expect(heading).to be_valid - heading.latitude = '+80.888491' + heading.latitude = "+80.888491" expect(heading).to be_valid end end @@ -172,97 +172,97 @@ describe Budget::Heading do describe "save longitude" do it "Doesn't allow longitude < -180" do - heading = create(:budget_heading, group: group, name: 'Longitude is < -180') + heading = create(:budget_heading, group: group, name: "Longitude is < -180") - heading.longitude = '-180.127491' + heading.longitude = "-180.127491" expect(heading).not_to be_valid - heading.longitude = '-181.723491' + heading.longitude = "-181.723491" expect(heading).not_to be_valid - heading.longitude = '-188.127412' + heading.longitude = "-188.127412" expect(heading).not_to be_valid - heading.longitude = '-1100.888491' + heading.longitude = "-1100.888491" expect(heading).not_to be_valid end it "Doesn't allow longitude > 180" do - heading = create(:budget_heading, group: group, name: 'Longitude is > 180') + heading = create(:budget_heading, group: group, name: "Longitude is > 180") - heading.longitude = '190.127491' + heading.longitude = "190.127491" expect(heading).not_to be_valid - heading.longitude = '197.723491' + heading.longitude = "197.723491" expect(heading).not_to be_valid - heading.longitude = '+207.723491' + heading.longitude = "+207.723491" expect(heading).not_to be_valid - heading.longitude = '300.723491' + heading.longitude = "300.723491" expect(heading).not_to be_valid - heading.longitude = '189.127412' + heading.longitude = "189.127412" expect(heading).not_to be_valid - heading.longitude = '1200.888491' + heading.longitude = "1200.888491" expect(heading).not_to be_valid end it "Doesn't allow longitude length > 23" do - heading = create(:budget_heading, group: group, name: 'Longitude length is > 23') + heading = create(:budget_heading, group: group, name: "Longitude length is > 23") - heading.longitude = '50.1274911123124112312418238128213' + heading.longitude = "50.1274911123124112312418238128213" expect(heading).not_to be_valid - heading.longitude = '53.73412349178811231241' + heading.longitude = "53.73412349178811231241" expect(heading).not_to be_valid - heading.longitude = '+20.1274124124124123121435' + heading.longitude = "+20.1274124124124123121435" expect(heading).not_to be_valid - heading.longitude = '10.88849112312312311232123311' + heading.longitude = "10.88849112312312311232123311" expect(heading).not_to be_valid end it "Allows longitude inside [-180,180] interval" do heading = create(:budget_heading, group: group, - name: 'Longitude is inside [-180,180] interval') + name: "Longitude is inside [-180,180] interval") - heading.longitude = '180' + heading.longitude = "180" expect(heading).to be_valid - heading.longitude = '-180' + heading.longitude = "-180" expect(heading).to be_valid - heading.longitude = '-180.000' + heading.longitude = "-180.000" expect(heading).to be_valid - heading.longitude = '-180.00000' + heading.longitude = "-180.00000" expect(heading).to be_valid - heading.longitude = '180.000' + heading.longitude = "180.000" expect(heading).to be_valid - heading.longitude = '180.00000' + heading.longitude = "180.00000" expect(heading).to be_valid - heading.longitude = '+75.00000' + heading.longitude = "+75.00000" expect(heading).to be_valid - heading.longitude = '+15.023321' + heading.longitude = "+15.023321" expect(heading).to be_valid - heading.longitude = '-80.123451' + heading.longitude = "-80.123451" expect(heading).to be_valid - heading.longitude = '80.144812' + heading.longitude = "80.144812" expect(heading).to be_valid - heading.longitude = '17.417412' + heading.longitude = "17.417412" expect(heading).to be_valid - heading.longitude = '-21.000054' + heading.longitude = "-21.000054" expect(heading).to be_valid end end @@ -270,8 +270,8 @@ describe Budget::Heading do describe "heading" do it "can be deleted if no budget's investments associated" do - heading1 = create(:budget_heading, group: group, name: 'name') - heading2 = create(:budget_heading, group: group, name: 'name 2') + heading1 = create(:budget_heading, group: group, name: "name") + heading2 = create(:budget_heading, group: group, name: "name 2") create(:budget_investment, heading: heading1) diff --git a/spec/models/budget/investment_spec.rb b/spec/models/budget/investment_spec.rb index b4491f4e7..c012ff5ca 100644 --- a/spec/models/budget/investment_spec.rb +++ b/spec/models/budget/investment_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Budget::Investment do let(:investment) { build(:budget_investment) } @@ -618,15 +618,15 @@ describe Budget::Investment do context "attributes" do it "searches by title" do - budget_investment = create(:budget_investment, title: 'save the world') - results = described_class.search('save the world') + budget_investment = create(:budget_investment, title: "save the world") + results = described_class.search("save the world") expect(results).to eq([budget_investment]) end it "searches by author name" do - author = create(:user, username: 'Danny Trejo') + author = create(:user, username: "Danny Trejo") budget_investment = create(:budget_investment, author: author) - results = described_class.search('Danny') + results = described_class.search("Danny") expect(results).to eq([budget_investment]) end @@ -634,19 +634,19 @@ describe Budget::Investment do context "tags" do it "searches by tags" do - investment = create(:budget_investment, tag_list: 'Latina') + investment = create(:budget_investment, tag_list: "Latina") - results = described_class.search('Latina') + results = described_class.search("Latina") expect(results.first).to eq(investment) - results = described_class.search('Latin') + results = described_class.search("Latin") expect(results.first).to eq(investment) end end end - describe 'Permissions' do + describe "Permissions" do let(:budget) { create(:budget) } let(:group) { create(:budget_group, budget: budget) } let(:heading) { create(:budget_heading, group: group) } @@ -654,7 +654,7 @@ describe Budget::Investment do let(:luser) { create(:user) } let(:district_sp) { create(:budget_investment, budget: budget, group: group, heading: heading) } - describe '#reason_for_not_being_selectable_by' do + describe "#reason_for_not_being_selectable_by" do it "rejects not logged in users" do expect(district_sp.reason_for_not_being_selectable_by(nil)).to eq(:not_logged_in) end @@ -908,7 +908,7 @@ describe Budget::Investment do describe "Final Voting" do - describe 'Permissions' do + describe "Permissions" do let(:budget) { create(:budget) } let(:group) { create(:budget_group, budget: budget) } let(:heading) { create(:budget_heading, group: group) } @@ -917,7 +917,7 @@ describe Budget::Investment do let(:ballot) { create(:budget_ballot, budget: budget) } let(:investment) { create(:budget_investment, :selected, budget: budget, heading: heading) } - describe '#reason_for_not_being_ballotable_by' do + describe "#reason_for_not_being_ballotable_by" do it "rejects not logged in users" do expect(investment.reason_for_not_being_ballotable_by(nil, ballot)).to eq(:not_logged_in) end diff --git a/spec/models/budget/phase_spec.rb b/spec/models/budget/phase_spec.rb index 34b99e26f..81c3c9a63 100644 --- a/spec/models/budget/phase_spec.rb +++ b/spec/models/budget/phase_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Budget::Phase do @@ -29,7 +29,7 @@ describe Budget::Phase do end it "is not valid with a kind not in valid budget phases" do - expect(build(:budget_phase, kind: 'invalid_phase_kind')).not_to be_valid + expect(build(:budget_phase, kind: "invalid_phase_kind")).not_to be_valid end it "is not valid with the same kind as another budget's phase" do diff --git a/spec/models/budget/reclassified_vote_spec.rb b/spec/models/budget/reclassified_vote_spec.rb index 059b5595c..a4ca44dac 100644 --- a/spec/models/budget/reclassified_vote_spec.rb +++ b/spec/models/budget/reclassified_vote_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Budget::ReclassifiedVote do diff --git a/spec/models/budget/result_spec.rb b/spec/models/budget/result_spec.rb index a650e25c5..02025e42f 100644 --- a/spec/models/budget/result_spec.rb +++ b/spec/models/budget/result_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Budget::Result do diff --git a/spec/models/budget_spec.rb b/spec/models/budget_spec.rb index 3faec8d21..da069f558 100644 --- a/spec/models/budget_spec.rb +++ b/spec/models/budget_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Budget do @@ -64,7 +64,7 @@ describe Budget do expect(budget).to be_valid end - budget.phase = 'inexisting' + budget.phase = "inexisting" expect(budget).not_to be_valid end @@ -178,35 +178,35 @@ describe Budget do describe "investments_orders" do it "is random when accepting and reviewing" do - budget.phase = 'accepting' - expect(budget.investments_orders).to eq(['random']) - budget.phase = 'reviewing' - expect(budget.investments_orders).to eq(['random']) + budget.phase = "accepting" + expect(budget.investments_orders).to eq(["random"]) + budget.phase = "reviewing" + expect(budget.investments_orders).to eq(["random"]) end it "is random and price when ballotting and reviewing ballots" do - budget.phase = 'publishing_prices' - expect(budget.investments_orders).to eq(['random', 'price']) - budget.phase = 'balloting' - expect(budget.investments_orders).to eq(['random', 'price']) - budget.phase = 'reviewing_ballots' - expect(budget.investments_orders).to eq(['random', 'price']) + budget.phase = "publishing_prices" + expect(budget.investments_orders).to eq(["random", "price"]) + budget.phase = "balloting" + expect(budget.investments_orders).to eq(["random", "price"]) + budget.phase = "reviewing_ballots" + expect(budget.investments_orders).to eq(["random", "price"]) end it "is random and confidence_score in all other cases" do - budget.phase = 'selecting' - expect(budget.investments_orders).to eq(['random', 'confidence_score']) - budget.phase = 'valuating' - expect(budget.investments_orders).to eq(['random', 'confidence_score']) + budget.phase = "selecting" + expect(budget.investments_orders).to eq(["random", "confidence_score"]) + budget.phase = "valuating" + expect(budget.investments_orders).to eq(["random", "confidence_score"]) end end - describe '#has_winning_investments?' do - it 'should return true if there is a winner investment' do + describe "#has_winning_investments?" do + it "should return true if there is a winner investment" do budget.investments << build(:budget_investment, :winner, price: 3, ballot_lines_count: 2) expect(budget.has_winning_investments?).to eq true end - it 'hould return false if there is not a winner investment' do + it "hould return false if there is not a winner investment" do expect(budget.has_winning_investments?).to eq false end end @@ -256,31 +256,31 @@ describe Budget do end it "correctly formats Euros with Spanish" do - budget.update(currency_symbol: '€') + budget.update(currency_symbol: "€") I18n.locale = :es - expect(budget.formatted_amount(1000.00)).to eq ('1.000 €') + expect(budget.formatted_amount(1000.00)).to eq ("1.000 €") end it "correctly formats Dollars with Spanish" do - budget.update(currency_symbol: '$') + budget.update(currency_symbol: "$") I18n.locale = :es - expect(budget.formatted_amount(1000.00)).to eq ('1.000 $') + expect(budget.formatted_amount(1000.00)).to eq ("1.000 $") end it "correctly formats Dollars with English" do - budget.update(currency_symbol: '$') + budget.update(currency_symbol: "$") I18n.locale = :en - expect(budget.formatted_amount(1000.00)).to eq ('$1,000') + expect(budget.formatted_amount(1000.00)).to eq ("$1,000") end it "correctly formats Euros with English" do - budget.update(currency_symbol: '€') + budget.update(currency_symbol: "€") I18n.locale = :en - expect(budget.formatted_amount(1000.00)).to eq ('€1,000') + expect(budget.formatted_amount(1000.00)).to eq ("€1,000") end end end diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb index 837464527..59b016e13 100644 --- a/spec/models/comment_spec.rb +++ b/spec/models/comment_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Comment do @@ -63,7 +63,7 @@ describe Comment do expect(comment.confidence_score).to eq(1) end - describe 'actions which affect it' do + describe "actions which affect it" do let(:comment) { create(:comment, :with_confidence_score) } it "increases with like" do @@ -175,14 +175,14 @@ describe Comment do expect(described_class.public_for_api).not_to include(comment) end - it 'does not return comments on elements which are not debates or proposals' do + it "does not return comments on elements which are not debates or proposals" do budget_investment = create(:budget_investment) comment = create(:comment, commentable: budget_investment) expect(described_class.public_for_api).not_to include(comment) end - it 'does not return comments with no commentable' do + it "does not return comments with no commentable" do comment = build(:comment, commentable: nil).save!(validate: false) expect(described_class.public_for_api).not_to include(comment) diff --git a/spec/models/community_spec.rb b/spec/models/community_spec.rb index dfc0bf403..2de0dcb47 100644 --- a/spec/models/community_spec.rb +++ b/spec/models/community_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" RSpec.describe Community, type: :model do diff --git a/spec/models/concerns/has_public_author.rb b/spec/models/concerns/has_public_author.rb index a5a9c2811..13dcf72ac 100644 --- a/spec/models/concerns/has_public_author.rb +++ b/spec/models/concerns/has_public_author.rb @@ -1,9 +1,9 @@ -require 'spec_helper' +require "spec_helper" -shared_examples_for 'has_public_author' do +shared_examples_for "has_public_author" do let(:model) { described_class } - describe 'public_author' do + describe "public_author" do it "returns author if author's activity is public" do author = create(:user, public_activity: true) authored_element = create(model.to_s.underscore.to_sym, author: author) diff --git a/spec/models/concerns/sluggable.rb b/spec/models/concerns/sluggable.rb index 1b5038d71..cba8960f5 100644 --- a/spec/models/concerns/sluggable.rb +++ b/spec/models/concerns/sluggable.rb @@ -1,9 +1,9 @@ -require 'spec_helper' +require "spec_helper" -shared_examples_for 'sluggable' do |updatable_slug_trait:| +shared_examples_for "sluggable" do |updatable_slug_trait:| - describe 'generate_slug' do - let(:factory_name) { described_class.name.parameterize('_').to_sym } + describe "generate_slug" do + let(:factory_name) { described_class.name.parameterize("_").to_sym } let(:sluggable) { create(factory_name, name: "Marló Brañido Carlo") } context "when a new sluggable is created" do @@ -14,15 +14,15 @@ shared_examples_for 'sluggable' do |updatable_slug_trait:| context "slug updating condition is true" do it "slug is updated" do - updatable = create(factory_name, updatable_slug_trait, name: 'Old Name') - expect{updatable.update_attributes(name: 'New Name')} - .to change{ updatable.slug }.from('old-name').to('new-name') + updatable = create(factory_name, updatable_slug_trait, name: "Old Name") + expect{updatable.update_attributes(name: "New Name")} + .to change{ updatable.slug }.from("old-name").to("new-name") end end context "slug updating condition is false" do it "slug isn't updated" do - expect{sluggable.update_attributes(name: 'New Name')} + expect{sluggable.update_attributes(name: "New Name")} .not_to (change{ sluggable.slug }) end end diff --git a/spec/models/custom/verification/residence_spec.rb b/spec/models/custom/verification/residence_spec.rb index 4b40e8ff6..f4ecf7f88 100644 --- a/spec/models/custom/verification/residence_spec.rb +++ b/spec/models/custom/verification/residence_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Verification::Residence do diff --git a/spec/models/debate_spec.rb b/spec/models/debate_spec.rb index 8b6e2b052..12da638ee 100644 --- a/spec/models/debate_spec.rb +++ b/spec/models/debate_spec.rb @@ -1,5 +1,5 @@ # coding: utf-8 -require 'rails_helper' +require "rails_helper" describe Debate do let(:debate) { build(:debate) } @@ -67,7 +67,7 @@ describe Debate do it "sanitizes the tag list" do debate.tag_list = "user_id=1" debate.valid? - expect(debate.tag_list).to eq(['user_id1']) + expect(debate.tag_list).to eq(["user_id1"]) end it "is not valid with a tag list of more than 6 elements" do @@ -176,24 +176,24 @@ describe Debate do describe "from level two verified users" do it "registers vote" do user = create(:user, residence_verified_at: Time.current, confirmed_phone: "666333111") - expect {debate.register_vote(user, 'yes')}.to change{debate.reload.votes_for.size}.by(1) + expect {debate.register_vote(user, "yes")}.to change{debate.reload.votes_for.size}.by(1) end it "does not increase anonymous votes counter " do user = create(:user, residence_verified_at: Time.current, confirmed_phone: "666333111") - expect {debate.register_vote(user, 'yes')}.not_to change{debate.reload.cached_anonymous_votes_total} + expect {debate.register_vote(user, "yes")}.not_to change{debate.reload.cached_anonymous_votes_total} end end describe "from level three verified users" do it "registers vote" do user = create(:user, verified_at: Time.current) - expect {debate.register_vote(user, 'yes')}.to change{debate.reload.votes_for.size}.by(1) + expect {debate.register_vote(user, "yes")}.to change{debate.reload.votes_for.size}.by(1) end it "does not increase anonymous votes counter " do user = create(:user, verified_at: Time.current) - expect {debate.register_vote(user, 'yes')}.not_to change{debate.reload.cached_anonymous_votes_total} + expect {debate.register_vote(user, "yes")}.not_to change{debate.reload.cached_anonymous_votes_total} end end @@ -202,12 +202,12 @@ describe Debate do it "registers vote" do user = create(:user) - expect {debate.register_vote(user, 'yes')}.to change {debate.reload.votes_for.size}.by(1) + expect {debate.register_vote(user, "yes")}.to change {debate.reload.votes_for.size}.by(1) end it "increases anonymous votes counter" do user = create(:user) - expect {debate.register_vote(user, 'yes')}.to change {debate.reload.cached_anonymous_votes_total}.by(1) + expect {debate.register_vote(user, "yes")}.to change {debate.reload.cached_anonymous_votes_total}.by(1) end end @@ -216,24 +216,24 @@ describe Debate do it "does not register vote " do user = create(:user) - expect {debate.register_vote(user, 'yes')}.not_to change {debate.reload.votes_for.size} + expect {debate.register_vote(user, "yes")}.not_to change {debate.reload.votes_for.size} end it "does not increase anonymous votes counter " do user = create(:user) - expect {debate.register_vote(user, 'yes')}.not_to change {debate.reload.cached_anonymous_votes_total} + expect {debate.register_vote(user, "yes")}.not_to change {debate.reload.cached_anonymous_votes_total} end end end - describe '#anonymous_votes_ratio' do + describe "#anonymous_votes_ratio" do it "returns the percentage of anonymous votes of the total votes" do debate = create(:debate, cached_anonymous_votes_total: 25, cached_votes_total: 100) expect(debate.anonymous_votes_ratio).to eq(25.0) end end - describe '#hot_score' do + describe "#hot_score" do let(:now) { Time.current } it "period is correctly calculated to get exact votes per day" do @@ -301,7 +301,7 @@ describe Debate do expect(newer_debate.hot_score).to be > older_debate.hot_score end - describe 'actions which affect it' do + describe "actions which affect it" do let(:debate) { create(:debate) } @@ -346,7 +346,7 @@ describe Debate do expect(debate.confidence_score).to eq(-800) end - describe 'actions which affect it' do + describe "actions which affect it" do let(:debate) { create(:debate, :with_confidence_score) } it "increases with like" do @@ -418,7 +418,7 @@ describe Debate do describe "custom tag counters when hiding/restoring" do it "decreases the tag counter when hiden, and increases it when restored" do debate = create(:debate, tag_list: "foo") - tag = ActsAsTaggableOn::Tag.where(name: 'foo').first + tag = ActsAsTaggableOn::Tag.where(name: "foo").first expect(tag.debates_count).to eq(1) debate.hide @@ -480,28 +480,28 @@ describe Debate do context "attributes" do it "searches by title" do - debate = create(:debate, title: 'save the world') - results = described_class.search('save the world') + debate = create(:debate, title: "save the world") + results = described_class.search("save the world") expect(results).to eq([debate]) end it "searches by description" do - debate = create(:debate, description: 'in order to save the world one must think about...') - results = described_class.search('one must think') + debate = create(:debate, description: "in order to save the world one must think about...") + results = described_class.search("one must think") expect(results).to eq([debate]) end it "searches by author name" do - author = create(:user, username: 'Danny Trejo') + author = create(:user, username: "Danny Trejo") debate = create(:debate, author: author) - results = described_class.search('Danny') + results = described_class.search("Danny") expect(results).to eq([debate]) end it "searches by geozone" do - geozone = create(:geozone, name: 'California') + geozone = create(:geozone, name: "California") debate = create(:debate, geozone: geozone) - results = described_class.search('California') + results = described_class.search("California") expect(results).to eq([debate]) end @@ -510,15 +510,15 @@ describe Debate do context "stemming" do it "searches word stems" do - debate = create(:debate, title: 'limpiar') + debate = create(:debate, title: "limpiar") - results = described_class.search('limpiará') + results = described_class.search("limpiará") expect(results).to eq([debate]) - results = described_class.search('limpiémos') + results = described_class.search("limpiémos") expect(results).to eq([debate]) - results = described_class.search('limpió') + results = described_class.search("limpió") expect(results).to eq([debate]) end @@ -527,17 +527,17 @@ describe Debate do context "accents" do it "searches with accents" do - debate = create(:debate, title: 'difusión') + debate = create(:debate, title: "difusión") - results = described_class.search('difusion') + results = described_class.search("difusion") expect(results).to eq([debate]) - debate2 = create(:debate, title: 'estadisticas') - results = described_class.search('estadísticas') + debate2 = create(:debate, title: "estadisticas") + results = described_class.search("estadísticas") expect(results).to eq([debate2]) - debate3 = create(:debate, title: 'público') - results = described_class.search('publico') + debate3 = create(:debate, title: "público") + results = described_class.search("publico") expect(results).to eq([debate3]) end @@ -545,9 +545,9 @@ describe Debate do context "case" do it "searches case insensite" do - debate = create(:debate, title: 'SHOUT') + debate = create(:debate, title: "SHOUT") - results = described_class.search('shout') + results = described_class.search("shout") expect(results).to eq([debate]) debate2 = create(:debate, title: "scream") @@ -558,12 +558,12 @@ describe Debate do context "tags" do it "searches by tags" do - debate = create(:debate, tag_list: 'Latina') + debate = create(:debate, tag_list: "Latina") - results = described_class.search('Latina') + results = described_class.search("Latina") expect(results.first).to eq(debate) - results = described_class.search('Latin') + results = described_class.search("Latin") expect(results.first).to eq(debate) end end @@ -571,22 +571,22 @@ describe Debate do context "order" do it "orders by weight" do - debate_description = create(:debate, description: 'stop corruption') - debate_title = create(:debate, title: 'stop corruption') + debate_description = create(:debate, description: "stop corruption") + debate_title = create(:debate, title: "stop corruption") - results = described_class.search('stop corruption') + results = described_class.search("stop corruption") expect(results.first).to eq(debate_title) expect(results.second).to eq(debate_description) end it "orders by weight and then votes" do - title_some_votes = create(:debate, title: 'stop corruption', cached_votes_up: 5) - title_least_voted = create(:debate, title: 'stop corruption', cached_votes_up: 2) - title_most_voted = create(:debate, title: 'stop corruption', cached_votes_up: 10) - description_most_voted = create(:debate, description: 'stop corruption', cached_votes_up: 10) + title_some_votes = create(:debate, title: "stop corruption", cached_votes_up: 5) + title_least_voted = create(:debate, title: "stop corruption", cached_votes_up: 2) + title_most_voted = create(:debate, title: "stop corruption", cached_votes_up: 10) + description_most_voted = create(:debate, description: "stop corruption", cached_votes_up: 10) - results = described_class.search('stop corruption') + results = described_class.search("stop corruption") expect(results.first).to eq(title_most_voted) expect(results.second).to eq(title_some_votes) @@ -595,10 +595,10 @@ describe Debate do end it "gives much more weight to word matches than votes" do - exact_title_few_votes = create(:debate, title: 'stop corruption', cached_votes_up: 5) - similar_title_many_votes = create(:debate, title: 'stop some of the corruption', cached_votes_up: 500) + exact_title_few_votes = create(:debate, title: "stop corruption", cached_votes_up: 5) + similar_title_many_votes = create(:debate, title: "stop some of the corruption", cached_votes_up: 500) - results = described_class.search('stop corruption') + results = described_class.search("stop corruption") expect(results.first).to eq(exact_title_few_votes) expect(results.second).to eq(similar_title_many_votes) @@ -609,15 +609,15 @@ describe Debate do context "reorder" do it "is able to reorder by hot_score after searching" do - lowest_score = create(:debate, title: 'stop corruption', cached_votes_up: 1) - highest_score = create(:debate, title: 'stop corruption', cached_votes_up: 2) - average_score = create(:debate, title: 'stop corruption', cached_votes_up: 3) + lowest_score = create(:debate, title: "stop corruption", cached_votes_up: 1) + highest_score = create(:debate, title: "stop corruption", cached_votes_up: 2) + average_score = create(:debate, title: "stop corruption", cached_votes_up: 3) lowest_score.update_column(:hot_score, 1) highest_score.update_column(:hot_score, 100) average_score.update_column(:hot_score, 10) - results = described_class.search('stop corruption') + results = described_class.search("stop corruption") expect(results.first).to eq(average_score) expect(results.second).to eq(highest_score) @@ -631,15 +631,15 @@ describe Debate do end it "is able to reorder by confidence_score after searching" do - lowest_score = create(:debate, title: 'stop corruption', cached_votes_up: 1) - highest_score = create(:debate, title: 'stop corruption', cached_votes_up: 2) - average_score = create(:debate, title: 'stop corruption', cached_votes_up: 3) + lowest_score = create(:debate, title: "stop corruption", cached_votes_up: 1) + highest_score = create(:debate, title: "stop corruption", cached_votes_up: 2) + average_score = create(:debate, title: "stop corruption", cached_votes_up: 3) lowest_score.update_column(:confidence_score, 1) highest_score.update_column(:confidence_score, 100) average_score.update_column(:confidence_score, 10) - results = described_class.search('stop corruption') + results = described_class.search("stop corruption") expect(results.first).to eq(average_score) expect(results.second).to eq(highest_score) @@ -653,11 +653,11 @@ describe Debate do end it "is able to reorder by created_at after searching" do - recent = create(:debate, title: 'stop corruption', cached_votes_up: 1, created_at: 1.week.ago) - newest = create(:debate, title: 'stop corruption', cached_votes_up: 2, created_at: Time.current) - oldest = create(:debate, title: 'stop corruption', cached_votes_up: 3, created_at: 1.month.ago) + recent = create(:debate, title: "stop corruption", cached_votes_up: 1, created_at: 1.week.ago) + newest = create(:debate, title: "stop corruption", cached_votes_up: 2, created_at: Time.current) + oldest = create(:debate, title: "stop corruption", cached_votes_up: 3, created_at: 1.month.ago) - results = described_class.search('stop corruption') + results = described_class.search("stop corruption") expect(results.first).to eq(oldest) expect(results.second).to eq(newest) @@ -671,11 +671,11 @@ describe Debate do end it "is able to reorder by most commented after searching" do - least_commented = create(:debate, title: 'stop corruption', cached_votes_up: 1, comments_count: 1) - most_commented = create(:debate, title: 'stop corruption', cached_votes_up: 2, comments_count: 100) - some_comments = create(:debate, title: 'stop corruption', cached_votes_up: 3, comments_count: 10) + least_commented = create(:debate, title: "stop corruption", cached_votes_up: 1, comments_count: 1) + most_commented = create(:debate, title: "stop corruption", cached_votes_up: 2, comments_count: 100) + some_comments = create(:debate, title: "stop corruption", cached_votes_up: 3, comments_count: 10) - results = described_class.search('stop corruption') + results = described_class.search("stop corruption") expect(results.first).to eq(some_comments) expect(results.second).to eq(most_commented) @@ -693,30 +693,30 @@ describe Debate do context "no results" do it "no words match" do - debate = create(:debate, title: 'save world') + debate = create(:debate, title: "save world") - results = described_class.search('destroy planet') + results = described_class.search("destroy planet") expect(results).to eq([]) end it "too many typos" do - debate = create(:debate, title: 'fantastic') + debate = create(:debate, title: "fantastic") - results = described_class.search('frantac') + results = described_class.search("frantac") expect(results).to eq([]) end it "too much stemming" do - debate = create(:debate, title: 'reloj') + debate = create(:debate, title: "reloj") - results = described_class.search('superrelojimetro') + results = described_class.search("superrelojimetro") expect(results).to eq([]) end it "empty" do - debate = create(:debate, title: 'great') + debate = create(:debate, title: "great") - results = described_class.search('') + results = described_class.search("") expect(results).to eq([]) end @@ -741,13 +741,13 @@ describe Debate do end end - describe 'public_for_api scope' do - it 'returns debates' do + describe "public_for_api scope" do + it "returns debates" do debate = create(:debate) expect(described_class.public_for_api).to include(debate) end - it 'does not return hidden debates' do + it "does not return hidden debates" do debate = create(:debate, :hidden) expect(described_class.public_for_api).not_to include(debate) end diff --git a/spec/models/direct_message_spec.rb b/spec/models/direct_message_spec.rb index 4cb3d1c45..1c67c363f 100644 --- a/spec/models/direct_message_spec.rb +++ b/spec/models/direct_message_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe DirectMessage do diff --git a/spec/models/direct_upload_spec.rb b/spec/models/direct_upload_spec.rb index 05bb73537..ab7183825 100644 --- a/spec/models/direct_upload_spec.rb +++ b/spec/models/direct_upload_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe DirectUpload do @@ -43,7 +43,7 @@ describe DirectUpload do proposal_document_direct_upload.save_attachment expect(File.exist?(proposal_document_direct_upload.relation.attachment.path)).to eq(true) - expect(proposal_document_direct_upload.relation.attachment.path).to include('cached_attachments') + expect(proposal_document_direct_upload.relation.attachment.path).to include("cached_attachments") end end diff --git a/spec/models/document_spec.rb b/spec/models/document_spec.rb index bc5d4e923..b65a6f318 100644 --- a/spec/models/document_spec.rb +++ b/spec/models/document_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Document do diff --git a/spec/models/flag_spec.rb b/spec/models/flag_spec.rb index 50caf8d46..30a69acec 100644 --- a/spec/models/flag_spec.rb +++ b/spec/models/flag_spec.rb @@ -1,53 +1,53 @@ -require 'rails_helper' +require "rails_helper" describe Flag do let(:user) { create(:user) } let(:comment) { create(:comment) } - describe '.flag' do + describe ".flag" do - it 'creates a flag when there is none' do + it "creates a flag when there is none" do expect { described_class.flag(user, comment) }.to change{ described_class.count }.by(1) expect(described_class.last.user).to eq(user) expect(described_class.last.flaggable).to eq(comment) end - it 'does nothing if the flag already exists' do + it "does nothing if the flag already exists" do described_class.flag(user, comment) expect(described_class.flag(user, comment)).to eq(false) expect(described_class.by_user_and_flaggable(user, comment).count).to eq(1) end - it 'increases the flag count' do + it "increases the flag count" do expect { described_class.flag(user, comment) }.to change{ comment.reload.flags_count }.by(1) end end - describe '.unflag' do - it 'raises an error if the flag does not exist' do + describe ".unflag" do + it "raises an error if the flag does not exist" do expect(described_class.unflag(user, comment)).to eq(false) end - describe 'when the flag already exists' do + describe "when the flag already exists" do before { described_class.flag(user, comment) } - it 'removes an existing flag' do + it "removes an existing flag" do expect { described_class.unflag(user, comment) }.to change{ described_class.count }.by(-1) end - it 'decreases the flag count' do + it "decreases the flag count" do expect { described_class.unflag(user, comment) }.to change{ comment.reload.flags_count }.by(-1) end end end - describe '.flagged?' do - it 'returns false when the user has not flagged the comment' do + describe ".flagged?" do + it "returns false when the user has not flagged the comment" do expect(described_class.flagged?(user, comment)).not_to be end - it 'returns true when the user has flagged the comment' do + it "returns true when the user has flagged the comment" do described_class.flag(user, comment) expect(described_class.flagged?(user, comment)).to be end diff --git a/spec/models/follow_spec.rb b/spec/models/follow_spec.rb index d2014fed3..122062d12 100644 --- a/spec/models/follow_spec.rb +++ b/spec/models/follow_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Follow do diff --git a/spec/models/geozone_spec.rb b/spec/models/geozone_spec.rb index 792ae2e0b..cd2c4aaa8 100644 --- a/spec/models/geozone_spec.rb +++ b/spec/models/geozone_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Geozone do let(:geozone) { build(:geozone) } diff --git a/spec/models/i18n_content_spec.rb b/spec/models/i18n_content_spec.rb index 17eaefe8f..23aff1ebb 100644 --- a/spec/models/i18n_content_spec.rb +++ b/spec/models/i18n_content_spec.rb @@ -1,23 +1,23 @@ -require 'rails_helper' +require "rails_helper" RSpec.describe I18nContent, type: :model do let(:i18n_content) { build(:i18n_content) } - it 'is valid' do + it "is valid" do expect(i18n_content).to be_valid end - it 'is not valid if key is not unique' do + it "is not valid if key is not unique" do new_content = create(:i18n_content) expect(i18n_content).not_to be_valid expect(i18n_content.errors.size).to eq(1) end - context 'Scopes' do - it 'return one record when #by_key is used' do + context "Scopes" do + it "return one record when #by_key is used" do content = create(:i18n_content) - key = 'debates.form.debate_title' + key = "debates.form.debate_title" debate_title = create(:i18n_content, key: key) expect(I18nContent.all.size).to eq(2) @@ -28,14 +28,14 @@ RSpec.describe I18nContent, type: :model do expect(query).to eq([debate_title]) end - it 'return all matching records when #begins_with_key is used' do - debate_text = create(:i18n_content, key: 'debates.form.debate_text') - debate_title = create(:i18n_content, key: 'debates.form.debate_title') - proposal_title = create(:i18n_content, key: 'proposals.form.proposal_title') + it "return all matching records when #begins_with_key is used" do + debate_text = create(:i18n_content, key: "debates.form.debate_text") + debate_title = create(:i18n_content, key: "debates.form.debate_title") + proposal_title = create(:i18n_content, key: "proposals.form.proposal_title") expect(I18nContent.all.size).to eq(3) - query = I18nContent.begins_with_key('debates') + query = I18nContent.begins_with_key("debates") expect(query.size).to eq(2) expect(query).to eq([debate_text, debate_title]) @@ -43,113 +43,113 @@ RSpec.describe I18nContent, type: :model do end end - context 'Globalize' do - it 'translates key into multiple languages' do - key = 'devise_views.mailer.confirmation_instructions.welcome' - welcome = build(:i18n_content, key: key, value_en: 'Welcome', value_es: 'Bienvenido') + context "Globalize" do + it "translates key into multiple languages" do + key = "devise_views.mailer.confirmation_instructions.welcome" + welcome = build(:i18n_content, key: key, value_en: "Welcome", value_es: "Bienvenido") - expect(welcome.value_en).to eq('Welcome') - expect(welcome.value_es).to eq('Bienvenido') + expect(welcome.value_en).to eq("Welcome") + expect(welcome.value_es).to eq("Bienvenido") end - it 'responds to locales defined on model' do + it "responds to locales defined on model" do expect(i18n_content).to respond_to(:value_en) expect(i18n_content).to respond_to(:value_es) expect(i18n_content).not_to respond_to(:value_wl) end - it 'returns nil if translations are not available' do - expect(i18n_content.value_en).to eq('Text in english') - expect(i18n_content.value_es).to eq('Texto en español') + it "returns nil if translations are not available" do + expect(i18n_content.value_en).to eq("Text in english") + expect(i18n_content.value_es).to eq("Texto en español") expect(i18n_content.value_nl).to be(nil) expect(i18n_content.value_fr).to be(nil) end - it 'responds accordingly to the current locale' do - expect(i18n_content.value).to eq('Text in english') + it "responds accordingly to the current locale" do + expect(i18n_content.value).to eq("Text in english") Globalize.locale = :es - expect(i18n_content.value).to eq('Texto en español') + expect(i18n_content.value).to eq("Texto en español") end end - describe '#flat_hash' do - it 'uses one parameter' do + describe "#flat_hash" do + it "uses one parameter" do expect(I18nContent.flat_hash(nil)).to eq({ nil => nil }) - expect(I18nContent.flat_hash('string')).to eq({ - nil => 'string' + expect(I18nContent.flat_hash("string")).to eq({ + nil => "string" }) - expect(I18nContent.flat_hash({ w: 'string' })).to eq({ - 'w' => 'string' + expect(I18nContent.flat_hash({ w: "string" })).to eq({ + "w" => "string" }) - expect(I18nContent.flat_hash({ w: { p: 'string' } })).to eq({ - 'w.p' => 'string' + expect(I18nContent.flat_hash({ w: { p: "string" } })).to eq({ + "w.p" => "string" }) end - it 'uses the first two parameters' do - expect(I18nContent.flat_hash('string', 'f')).to eq({ - 'f' => 'string' + it "uses the first two parameters" do + expect(I18nContent.flat_hash("string", "f")).to eq({ + "f" => "string" }) - expect(I18nContent.flat_hash(nil, 'f')).to eq({ - 'f' => nil + expect(I18nContent.flat_hash(nil, "f")).to eq({ + "f" => nil }) - expect(I18nContent.flat_hash({ w: 'string' }, 'f')).to eq({ - 'f.w' => 'string' + expect(I18nContent.flat_hash({ w: "string" }, "f")).to eq({ + "f.w" => "string" }) - expect(I18nContent.flat_hash({ w: { p: 'string' } }, 'f')).to eq({ - 'f.w.p' => 'string' + expect(I18nContent.flat_hash({ w: { p: "string" } }, "f")).to eq({ + "f.w.p" => "string" }) end - it 'uses the first and last parameters' do + it "uses the first and last parameters" do expect { - I18nContent.flat_hash('string', nil, 'not hash') + I18nContent.flat_hash("string", nil, "not hash") }.to raise_error(NoMethodError) - expect(I18nContent.flat_hash(nil, nil, { q: 'other string' })).to eq({ - q: 'other string', + expect(I18nContent.flat_hash(nil, nil, { q: "other string" })).to eq({ + q: "other string", nil => nil }) - expect(I18nContent.flat_hash({ w: 'string' }, nil, { q: 'other string' })).to eq({ - q: 'other string', - 'w' => 'string' + expect(I18nContent.flat_hash({ w: "string" }, nil, { q: "other string" })).to eq({ + q: "other string", + "w" => "string" }) - expect(I18nContent.flat_hash({w: { p: 'string' } }, nil, { q: 'other string' })).to eq({ - q: 'other string', - 'w.p' => 'string' + expect(I18nContent.flat_hash({w: { p: "string" } }, nil, { q: "other string" })).to eq({ + q: "other string", + "w.p" => "string" }) end - it 'uses all parameters' do + it "uses all parameters" do expect { - I18nContent.flat_hash('string', 'f', 'not hash') + I18nContent.flat_hash("string", "f", "not hash") }.to raise_error NoMethodError - expect(I18nContent.flat_hash(nil, 'f', { q: 'other string' })).to eq({ - q: 'other string', - 'f' => nil + expect(I18nContent.flat_hash(nil, "f", { q: "other string" })).to eq({ + q: "other string", + "f" => nil }) - expect(I18nContent.flat_hash({ w: 'string' }, 'f', { q: 'other string' })).to eq({ - q: 'other string', - 'f.w' => 'string' + expect(I18nContent.flat_hash({ w: "string" }, "f", { q: "other string" })).to eq({ + q: "other string", + "f.w" => "string" }) - expect(I18nContent.flat_hash({ w: { p: 'string' } }, 'f', { q: 'other string' })).to eq({ - q: 'other string', - 'f.w.p' => 'string' + expect(I18nContent.flat_hash({ w: { p: "string" } }, "f", { q: "other string" })).to eq({ + q: "other string", + "f.w.p" => "string" }) end end diff --git a/spec/models/identity_spec.rb b/spec/models/identity_spec.rb index 7622c4333..eb5b8cd2e 100644 --- a/spec/models/identity_spec.rb +++ b/spec/models/identity_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" RSpec.describe Identity, type: :model do let(:identity) { build(:identity) } diff --git a/spec/models/image_spec.rb b/spec/models/image_spec.rb index cf19257cd..5f6f9f8e6 100644 --- a/spec/models/image_spec.rb +++ b/spec/models/image_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Image do diff --git a/spec/models/legislation/annotation_spec.rb b/spec/models/legislation/annotation_spec.rb index 49beb80d5..bd68ec5bf 100644 --- a/spec/models/legislation/annotation_spec.rb +++ b/spec/models/legislation/annotation_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' + require "rails_helper" RSpec.describe Legislation::Annotation, type: :model do let(:draft_version) { create(:legislation_draft_version) } diff --git a/spec/models/legislation/answer_spec.rb b/spec/models/legislation/answer_spec.rb index 5c28a82fb..57c168c18 100644 --- a/spec/models/legislation/answer_spec.rb +++ b/spec/models/legislation/answer_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" RSpec.describe Legislation::Answer, type: :model do let(:legislation_answer) { build(:legislation_answer) } @@ -9,8 +9,8 @@ RSpec.describe Legislation::Answer, type: :model do it "counts answers" do question = create(:legislation_question) - option_1 = create(:legislation_question_option, question: question, value: 'Yes') - option_2 = create(:legislation_question_option, question: question, value: 'No') + option_1 = create(:legislation_question_option, question: question, value: "Yes") + option_2 = create(:legislation_question_option, question: question, value: "No") answer = create(:legislation_answer, question: question, question_option: option_2) @@ -22,8 +22,8 @@ RSpec.describe Legislation::Answer, type: :model do it "can't answer same question more than once" do question = create(:legislation_question) - option_1 = create(:legislation_question_option, question: question, value: 'Yes') - option_2 = create(:legislation_question_option, question: question, value: 'No') + option_1 = create(:legislation_question_option, question: question, value: "Yes") + option_2 = create(:legislation_question_option, question: question, value: "No") user = create(:user) answer = create(:legislation_answer, question: question, question_option: option_2, user: user) diff --git a/spec/models/legislation/draft_version_spec.rb b/spec/models/legislation/draft_version_spec.rb index 435693174..42d9e6401 100644 --- a/spec/models/legislation/draft_version_spec.rb +++ b/spec/models/legislation/draft_version_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" RSpec.describe Legislation::DraftVersion, type: :model do let(:legislation_draft_version) { build(:legislation_draft_version) } diff --git a/spec/models/legislation/process/phase_spec.rb b/spec/models/legislation/process/phase_spec.rb index 82c3bd073..ed57d34ca 100644 --- a/spec/models/legislation/process/phase_spec.rb +++ b/spec/models/legislation/process/phase_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" RSpec.describe Legislation::Process::Phase, type: :model do let(:process) { create(:legislation_process) } diff --git a/spec/models/legislation/process/publication_spec.rb b/spec/models/legislation/process/publication_spec.rb index a489568d4..a2642b9eb 100644 --- a/spec/models/legislation/process/publication_spec.rb +++ b/spec/models/legislation/process/publication_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" RSpec.describe Legislation::Process::Publication, type: :model do let(:process) { create(:legislation_process) } diff --git a/spec/models/legislation/process_spec.rb b/spec/models/legislation/process_spec.rb index 53a8c757c..153182a12 100644 --- a/spec/models/legislation/process_spec.rb +++ b/spec/models/legislation/process_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Legislation::Process do let(:process) { create(:legislation_process) } diff --git a/spec/models/legislation/proposal_spec.rb b/spec/models/legislation/proposal_spec.rb index 2e23179a4..28ea9c72d 100644 --- a/spec/models/legislation/proposal_spec.rb +++ b/spec/models/legislation/proposal_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Legislation::Proposal do let(:proposal) { build(:legislation_proposal) } @@ -27,7 +27,7 @@ describe Legislation::Proposal do expect(proposal).not_to be_valid end - describe '#hot_score' do + describe "#hot_score" do let(:now) { Time.current } it "period is correctly calculated to get exact votes per day" do @@ -83,7 +83,7 @@ describe Legislation::Proposal do expect(newer_proposal.hot_score).to be > older_proposal.hot_score end - describe 'actions which affect it' do + describe "actions which affect it" do let(:proposal) { create(:legislation_proposal) } diff --git a/spec/models/legislation/question_option_spec.rb b/spec/models/legislation/question_option_spec.rb index eb23961ec..0c681872a 100644 --- a/spec/models/legislation/question_option_spec.rb +++ b/spec/models/legislation/question_option_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" RSpec.describe Legislation::QuestionOption, type: :model do let(:legislation_question_option) { build(:legislation_question_option) } diff --git a/spec/models/legislation/question_spec.rb b/spec/models/legislation/question_spec.rb index 679a39d1b..88dd10a09 100644 --- a/spec/models/legislation/question_spec.rb +++ b/spec/models/legislation/question_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Legislation::Question do let(:question) { create(:legislation_question) } @@ -65,7 +65,7 @@ describe Legislation::Question do end describe "notifications" do - it_behaves_like 'notifiable' + it_behaves_like "notifiable" end end diff --git a/spec/models/lock_spec.rb b/spec/models/lock_spec.rb index d3c238484..55d0bf5c1 100644 --- a/spec/models/lock_spec.rb +++ b/spec/models/lock_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Lock do diff --git a/spec/models/map_location_spec.rb b/spec/models/map_location_spec.rb index 04c323be5..a00a00485 100644 --- a/spec/models/map_location_spec.rb +++ b/spec/models/map_location_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe MapLocation do @@ -18,9 +18,9 @@ describe MapLocation do end it "is invalid when longitude/latitude/zoom are not numbers" do - map_location.longitude = 'wadus' - map_location.latitude = 'stuff' - map_location.zoom = '$%·' + map_location.longitude = "wadus" + map_location.latitude = "stuff" + map_location.zoom = "$%·" expect(map_location).not_to be_valid expect(map_location.errors.size).to eq(3) diff --git a/spec/models/milestone/status_spec.rb b/spec/models/milestone/status_spec.rb index 7e530a995..23f569cec 100644 --- a/spec/models/milestone/status_spec.rb +++ b/spec/models/milestone/status_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Milestone::Status do diff --git a/spec/models/milestone_spec.rb b/spec/models/milestone_spec.rb index 92cf96dd4..87ba6fb8b 100644 --- a/spec/models/milestone_spec.rb +++ b/spec/models/milestone_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Milestone do diff --git a/spec/models/newsletter_spec.rb b/spec/models/newsletter_spec.rb index 61abb3daf..cdde03e7f 100644 --- a/spec/models/newsletter_spec.rb +++ b/spec/models/newsletter_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Newsletter do let(:newsletter) { build(:newsletter) } @@ -7,60 +7,60 @@ describe Newsletter do expect(newsletter).to be_valid end - it 'is not valid without a subject' do + it "is not valid without a subject" do newsletter.subject = nil expect(newsletter).not_to be_valid end - it 'is not valid without a segment_recipient' do + it "is not valid without a segment_recipient" do newsletter.segment_recipient = nil expect(newsletter).not_to be_valid end - it 'is not valid with an inexistent user segment for segment_recipient' do - newsletter.segment_recipient = 'invalid_user_segment_name' + it "is not valid with an inexistent user segment for segment_recipient" do + newsletter.segment_recipient = "invalid_user_segment_name" expect(newsletter).not_to be_valid end - it 'is not valid without a from' do + it "is not valid without a from" do newsletter.from = nil expect(newsletter).not_to be_valid end - it 'is not valid without a body' do + it "is not valid without a body" do newsletter.body = nil expect(newsletter).not_to be_valid end - it 'validates from attribute email format' do + it "validates from attribute email format" do newsletter.from = "this_is_not_an_email" expect(newsletter).not_to be_valid end - describe '#valid_segment_recipient?' do - it 'is false when segment_recipient value is invalid' do - newsletter.update(segment_recipient: 'invalid_segment_name') - error = 'The user recipients segment is invalid' + describe "#valid_segment_recipient?" do + it "is false when segment_recipient value is invalid" do + newsletter.update(segment_recipient: "invalid_segment_name") + error = "The user recipients segment is invalid" expect(newsletter).not_to be_valid expect(newsletter.errors.messages[:segment_recipient]).to include(error) end end - describe '#list_of_recipient_emails' do + describe "#list_of_recipient_emails" do before do - create(:user, newsletter: true, email: 'newsletter_user@consul.dev') - create(:user, newsletter: false, email: 'no_news_user@consul.dev') - create(:user, email: 'erased_user@consul.dev').erase - newsletter.update(segment_recipient: 'all_users') + create(:user, newsletter: true, email: "newsletter_user@consul.dev") + create(:user, newsletter: false, email: "no_news_user@consul.dev") + create(:user, email: "erased_user@consul.dev").erase + newsletter.update(segment_recipient: "all_users") end - it 'returns list of recipients excluding users with disabled newsletter' do + it "returns list of recipients excluding users with disabled newsletter" do expect(newsletter.list_of_recipient_emails.count).to eq(1) - expect(newsletter.list_of_recipient_emails).to include('newsletter_user@consul.dev') - expect(newsletter.list_of_recipient_emails).not_to include('no_news_user@consul.dev') - expect(newsletter.list_of_recipient_emails).not_to include('erased_user@consul.dev') + expect(newsletter.list_of_recipient_emails).to include("newsletter_user@consul.dev") + expect(newsletter.list_of_recipient_emails).not_to include("no_news_user@consul.dev") + expect(newsletter.list_of_recipient_emails).not_to include("erased_user@consul.dev") end end diff --git a/spec/models/notification_spec.rb b/spec/models/notification_spec.rb index 474524e93..54d680267 100644 --- a/spec/models/notification_spec.rb +++ b/spec/models/notification_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Notification do diff --git a/spec/models/officing/residence_spec.rb b/spec/models/officing/residence_spec.rb index dca6b7a59..6ab02d091 100644 --- a/spec/models/officing/residence_spec.rb +++ b/spec/models/officing/residence_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Officing::Residence do @@ -60,12 +60,12 @@ describe Officing::Residence do residence.save user = residence.user - expect(user.document_number).to eq('12345678Z') + expect(user.document_number).to eq("12345678Z") expect(user.document_type).to eq("1") expect(user.date_of_birth.year).to eq(1980) expect(user.date_of_birth.month).to eq(12) expect(user.date_of_birth.day).to eq(31) - expect(user.gender).to eq('male') + expect(user.gender).to eq("male") expect(user.geozone).to eq(geozone) end @@ -74,7 +74,7 @@ describe Officing::Residence do create(:user, document_number: "12345678Z", document_type: "1", date_of_birth: Date.new(1981, 11, 30), - gender: 'female', + gender: "female", geozone: geozone) residence = build(:officing_residence, @@ -84,12 +84,12 @@ describe Officing::Residence do residence.save user = residence.user - expect(user.document_number).to eq('12345678Z') + expect(user.document_number).to eq("12345678Z") expect(user.document_type).to eq("1") expect(user.date_of_birth.year).to eq(1981) expect(user.date_of_birth.month).to eq(11) expect(user.date_of_birth.day).to eq(30) - expect(user.gender).to eq('female') + expect(user.gender).to eq("female") expect(user.geozone).to eq(geozone) end diff --git a/spec/models/organization_spec.rb b/spec/models/organization_spec.rb index 1f5105d4a..ea23d3630 100644 --- a/spec/models/organization_spec.rb +++ b/spec/models/organization_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Organization do diff --git a/spec/models/poll/answer_spec.rb b/spec/models/poll/answer_spec.rb index 9211046c9..14b0ae1db 100644 --- a/spec/models/poll/answer_spec.rb +++ b/spec/models/poll/answer_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Poll::Answer do @@ -27,15 +27,15 @@ describe Poll::Answer do it "is valid for answers included in the Poll::Question's question_answers list" do question = create(:poll_question) - create(:poll_question_answer, title: 'One', question: question) - create(:poll_question_answer, title: 'Two', question: question) - create(:poll_question_answer, title: 'Three', question: question) + create(:poll_question_answer, title: "One", question: question) + create(:poll_question_answer, title: "Two", question: question) + create(:poll_question_answer, title: "Three", question: question) - expect(build(:poll_answer, question: question, answer: 'One')).to be_valid - expect(build(:poll_answer, question: question, answer: 'Two')).to be_valid - expect(build(:poll_answer, question: question, answer: 'Three')).to be_valid + expect(build(:poll_answer, question: question, answer: "One")).to be_valid + expect(build(:poll_answer, question: question, answer: "Two")).to be_valid + expect(build(:poll_answer, question: question, answer: "Three")).to be_valid - expect(build(:poll_answer, question: question, answer: 'Four')).not_to be_valid + expect(build(:poll_answer, question: question, answer: "Four")).not_to be_valid end end @@ -49,7 +49,7 @@ describe Poll::Answer do answer = create(:poll_answer, question: question, author: author, answer: "Yes") expect(answer.poll.voters).to be_blank - answer.record_voter_participation('token') + answer.record_voter_participation("token") expect(poll.reload.voters.size).to eq(1) voter = poll.voters.first @@ -60,12 +60,12 @@ describe Poll::Answer do it "updates a poll_voter with user and poll data" do answer = create(:poll_answer, question: question, author: author, answer: "Yes") - answer.record_voter_participation('token') + answer.record_voter_participation("token") expect(poll.reload.voters.size).to eq(1) answer = create(:poll_answer, question: question, author: author, answer: "No") - answer.record_voter_participation('token') + answer.record_voter_participation("token") expect(poll.reload.voters.size).to eq(1) diff --git a/spec/models/poll/booth_assignment_spec.rb b/spec/models/poll/booth_assignment_spec.rb index ffea2065f..2ed3a4507 100644 --- a/spec/models/poll/booth_assignment_spec.rb +++ b/spec/models/poll/booth_assignment_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Poll::BoothAssignment do let(:poll){create(:poll)} diff --git a/spec/models/poll/booth_spec.rb b/spec/models/poll/booth_spec.rb index 990ac816b..8cde2263b 100644 --- a/spec/models/poll/booth_spec.rb +++ b/spec/models/poll/booth_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Poll::Booth do diff --git a/spec/models/poll/officer_assignment_spec.rb b/spec/models/poll/officer_assignment_spec.rb index 0234242ed..2a68a7259 100644 --- a/spec/models/poll/officer_assignment_spec.rb +++ b/spec/models/poll/officer_assignment_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Poll::OfficerAssignment do it "logs user data on creation" do diff --git a/spec/models/poll/officer_spec.rb b/spec/models/poll/officer_spec.rb index 146efa50e..1cbad6f5d 100644 --- a/spec/models/poll/officer_spec.rb +++ b/spec/models/poll/officer_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Poll::Officer do diff --git a/spec/models/poll/partial_result_spec.rb b/spec/models/poll/partial_result_spec.rb index 4d72fa986..fc143dbc0 100644 --- a/spec/models/poll/partial_result_spec.rb +++ b/spec/models/poll/partial_result_spec.rb @@ -1,19 +1,19 @@ -require 'rails_helper' +require "rails_helper" describe Poll::PartialResult do describe "validations" do it "validates that the answers are included in the Poll::Question's list" do question = create(:poll_question) - create(:poll_question_answer, title: 'One', question: question) - create(:poll_question_answer, title: 'Two', question: question) - create(:poll_question_answer, title: 'Three', question: question) + create(:poll_question_answer, title: "One", question: question) + create(:poll_question_answer, title: "Two", question: question) + create(:poll_question_answer, title: "Three", question: question) - expect(build(:poll_partial_result, question: question, answer: 'One')).to be_valid - expect(build(:poll_partial_result, question: question, answer: 'Two')).to be_valid - expect(build(:poll_partial_result, question: question, answer: 'Three')).to be_valid + expect(build(:poll_partial_result, question: question, answer: "One")).to be_valid + expect(build(:poll_partial_result, question: question, answer: "Two")).to be_valid + expect(build(:poll_partial_result, question: question, answer: "Three")).to be_valid - expect(build(:poll_partial_result, question: question, answer: 'Four')).not_to be_valid + expect(build(:poll_partial_result, question: question, answer: "Four")).not_to be_valid end end diff --git a/spec/models/poll/poll_spec.rb b/spec/models/poll/poll_spec.rb index f61e0ad61..6090adbe1 100644 --- a/spec/models/poll/poll_spec.rb +++ b/spec/models/poll/poll_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Poll do @@ -102,7 +102,7 @@ describe Poll do let(:level2_from_geozone) { create(:user, :level_two, geozone: geozone) } let(:all_users) { [non_user, level1, level2, level2_from_geozone] } - describe 'instance method' do + describe "instance method" do it "rejects non-users and level 1 users" do all_polls.each do |poll| expect(poll).not_to be_answerable_by(non_user) @@ -129,7 +129,7 @@ describe Poll do end end - describe 'class method' do + describe "class method" do it "returns no polls for non-users and level 1 users" do expect(described_class.answerable_by(nil)).to be_empty expect(described_class.answerable_by(level1)).to be_empty diff --git a/spec/models/poll/question_spec.rb b/spec/models/poll/question_spec.rb index 5a1265bda..87a3698f1 100644 --- a/spec/models/poll/question_spec.rb +++ b/spec/models/poll/question_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" RSpec.describe Poll::Question, type: :model do let(:poll_question) { build(:poll_question) } diff --git a/spec/models/poll/recount_spec.rb b/spec/models/poll/recount_spec.rb index e7b149f69..3ce32056a 100644 --- a/spec/models/poll/recount_spec.rb +++ b/spec/models/poll/recount_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Poll::Recount do diff --git a/spec/models/poll/shift_spec.rb b/spec/models/poll/shift_spec.rb index a4aa5451c..082e0e4c2 100644 --- a/spec/models/poll/shift_spec.rb +++ b/spec/models/poll/shift_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Poll::Shift do let(:poll) { create(:poll) } diff --git a/spec/models/poll/stats_spec.rb b/spec/models/poll/stats_spec.rb index 9c07c5224..78af334ca 100644 --- a/spec/models/poll/stats_spec.rb +++ b/spec/models/poll/stats_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Poll::Stats do @@ -7,10 +7,10 @@ describe Poll::Stats do poll = create(:poll) booth = create(:poll_booth) booth_assignment = create(:poll_booth_assignment, poll: poll, booth: booth) - create(:poll_voter, poll: poll, origin: 'web') - 3.times {create(:poll_voter, poll: poll, origin: 'booth')} + create(:poll_voter, poll: poll, origin: "web") + 3.times {create(:poll_voter, poll: poll, origin: "booth")} create(:poll_voter, poll: poll) - create(:poll_recount, origin: 'booth', white_amount: 1, null_amount: 0, total_amount: 2, booth_assignment_id: booth_assignment.id) + create(:poll_recount, origin: "booth", white_amount: 1, null_amount: 0, total_amount: 2, booth_assignment_id: booth_assignment.id) stats = described_class.new(poll).generate expect(stats[:total_participants]).to eq(5) diff --git a/spec/models/poll/voter_spec.rb b/spec/models/poll/voter_spec.rb index a82aece1f..466cbc891 100644 --- a/spec/models/poll/voter_spec.rb +++ b/spec/models/poll/voter_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Poll::Voter do @@ -76,7 +76,7 @@ describe Poll::Voter do it "is not valid if the user has voted via web" do answer = create(:poll_answer) - answer.record_voter_participation('token') + answer.record_voter_participation("token") voter = build(:poll_voter, poll: answer.question.poll, user: answer.author) expect(voter).not_to be_valid diff --git a/spec/models/proposal_notification_spec.rb b/spec/models/proposal_notification_spec.rb index 0548c03d2..40670b9d9 100644 --- a/spec/models/proposal_notification_spec.rb +++ b/spec/models/proposal_notification_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe ProposalNotification do let(:notification) { build(:proposal_notification) } @@ -165,7 +165,7 @@ describe ProposalNotification do it "records the moderation action in the Activity table" do proposal_notification.moderate_system_email(admin.user) - expect(Activity.last.actionable_type).to eq('ProposalNotification') + expect(Activity.last.actionable_type).to eq("ProposalNotification") end end end diff --git a/spec/models/proposal_spec.rb b/spec/models/proposal_spec.rb index ff6cfb117..334eee502 100644 --- a/spec/models/proposal_spec.rb +++ b/spec/models/proposal_spec.rb @@ -1,5 +1,5 @@ # coding: utf-8 -require 'rails_helper' +require "rails_helper" describe Proposal do let(:proposal) { build(:proposal) } @@ -133,7 +133,7 @@ describe Proposal do it "sanitizes the tag list" do proposal.tag_list = "user_id=1" proposal.valid? - expect(proposal.tag_list).to eq(['user_id1']) + expect(proposal.tag_list).to eq(["user_id1"]) end it "is not valid with a tag list of more than 6 elements" do @@ -209,21 +209,21 @@ describe Proposal do describe "from level two verified users" do it "registers vote" do user = create(:user, residence_verified_at: Time.current, confirmed_phone: "666333111") - expect {proposal.register_vote(user, 'yes')}.to change{proposal.reload.votes_for.size}.by(1) + expect {proposal.register_vote(user, "yes")}.to change{proposal.reload.votes_for.size}.by(1) end end describe "from level three verified users" do it "registers vote" do user = create(:user, verified_at: Time.current) - expect {proposal.register_vote(user, 'yes')}.to change{proposal.reload.votes_for.size}.by(1) + expect {proposal.register_vote(user, "yes")}.to change{proposal.reload.votes_for.size}.by(1) end end describe "from anonymous users" do it "does not register vote" do user = create(:user) - expect {proposal.register_vote(user, 'yes')}.to change{proposal.reload.votes_for.size}.by(0) + expect {proposal.register_vote(user, "yes")}.to change{proposal.reload.votes_for.size}.by(0) end end @@ -231,11 +231,11 @@ describe Proposal do user = create(:user, verified_at: Time.current) archived_proposal = create(:proposal, :archived) - expect {archived_proposal.register_vote(user, 'yes')}.to change{proposal.reload.votes_for.size}.by(0) + expect {archived_proposal.register_vote(user, "yes")}.to change{proposal.reload.votes_for.size}.by(0) end end - describe '#cached_votes_up' do + describe "#cached_votes_up" do describe "with deprecated long tag list" do @@ -251,7 +251,7 @@ describe Proposal do end end - describe '#hot_score' do + describe "#hot_score" do let(:now) { Time.current } it "period is correctly calculated to get exact votes per day" do @@ -307,7 +307,7 @@ describe Proposal do expect(newer_proposal.hot_score).to be > older_proposal.hot_score end - describe 'actions which affect it' do + describe "actions which affect it" do let(:proposal) { create(:proposal) } @@ -333,7 +333,7 @@ describe Proposal do describe "custom tag counters when hiding/restoring" do it "decreases the tag counter when hiden, and increases it when restored" do proposal = create(:proposal, tag_list: "foo") - tag = ActsAsTaggableOn::Tag.where(name: 'foo').first + tag = ActsAsTaggableOn::Tag.where(name: "foo").first expect(tag.proposals_count).to eq(1) proposal.hide @@ -363,7 +363,7 @@ describe Proposal do expect(proposal.confidence_score).to eq(1000) end - describe 'actions which affect it' do + describe "actions which affect it" do let(:proposal) { create(:proposal, :with_confidence_score) } it "increases with like" do @@ -474,40 +474,40 @@ describe Proposal do context "attributes" do it "searches by title" do - proposal = create(:proposal, title: 'save the world') - results = described_class.search('save the world') + proposal = create(:proposal, title: "save the world") + results = described_class.search("save the world") expect(results).to eq([proposal]) end it "searches by summary" do - proposal = create(:proposal, summary: 'basically...') - results = described_class.search('basically') + proposal = create(:proposal, summary: "basically...") + results = described_class.search("basically") expect(results).to eq([proposal]) end it "searches by description" do - proposal = create(:proposal, description: 'in order to save the world one must think about...') - results = described_class.search('one must think') + proposal = create(:proposal, description: "in order to save the world one must think about...") + results = described_class.search("one must think") expect(results).to eq([proposal]) end it "searches by question" do - proposal = create(:proposal, question: 'to be or not to be') - results = described_class.search('to be or not to be') + proposal = create(:proposal, question: "to be or not to be") + results = described_class.search("to be or not to be") expect(results).to eq([proposal]) end it "searches by author name" do - author = create(:user, username: 'Danny Trejo') + author = create(:user, username: "Danny Trejo") proposal = create(:proposal, author: author) - results = described_class.search('Danny') + results = described_class.search("Danny") expect(results).to eq([proposal]) end it "searches by geozone" do - geozone = create(:geozone, name: 'California') + geozone = create(:geozone, name: "California") proposal = create(:proposal, geozone: geozone) - results = described_class.search('California') + results = described_class.search("California") expect(results).to eq([proposal]) end @@ -516,15 +516,15 @@ describe Proposal do context "stemming" do it "searches word stems" do - proposal = create(:proposal, summary: 'Economía') + proposal = create(:proposal, summary: "Economía") - results = described_class.search('economía') + results = described_class.search("economía") expect(results).to eq([proposal]) - results = described_class.search('econo') + results = described_class.search("econo") expect(results).to eq([proposal]) - results = described_class.search('eco') + results = described_class.search("eco") expect(results).to eq([proposal]) end @@ -532,26 +532,26 @@ describe Proposal do context "accents" do it "searches with accents" do - proposal = create(:proposal, summary: 'difusión') + proposal = create(:proposal, summary: "difusión") - results = described_class.search('difusion') + results = described_class.search("difusion") expect(results).to eq([proposal]) - proposal2 = create(:proposal, summary: 'estadisticas') - results = described_class.search('estadísticas') + proposal2 = create(:proposal, summary: "estadisticas") + results = described_class.search("estadísticas") expect(results).to eq([proposal2]) - proposal3 = create(:proposal, summary: 'público') - results = described_class.search('publico') + proposal3 = create(:proposal, summary: "público") + results = described_class.search("publico") expect(results).to eq([proposal3]) end end context "case" do it "searches case insensite" do - proposal = create(:proposal, title: 'SHOUT') + proposal = create(:proposal, title: "SHOUT") - results = described_class.search('shout') + results = described_class.search("shout") expect(results).to eq([proposal]) proposal2 = create(:proposal, title: "scream") @@ -562,12 +562,12 @@ describe Proposal do context "tags" do it "searches by tags" do - proposal = create(:proposal, tag_list: 'Latina') + proposal = create(:proposal, tag_list: "Latina") - results = described_class.search('Latina') + results = described_class.search("Latina") expect(results.first).to eq(proposal) - results = described_class.search('Latin') + results = described_class.search("Latin") expect(results.first).to eq(proposal) end end @@ -575,12 +575,12 @@ describe Proposal do context "order" do it "orders by weight" do - proposal_question = create(:proposal, question: 'stop corruption') - proposal_title = create(:proposal, title: 'stop corruption') - proposal_description = create(:proposal, description: 'stop corruption') - proposal_summary = create(:proposal, summary: 'stop corruption') + proposal_question = create(:proposal, question: "stop corruption") + proposal_title = create(:proposal, title: "stop corruption") + proposal_description = create(:proposal, description: "stop corruption") + proposal_summary = create(:proposal, summary: "stop corruption") - results = described_class.search('stop corruption') + results = described_class.search("stop corruption") expect(results.first).to eq(proposal_title) expect(results.second).to eq(proposal_question) @@ -589,13 +589,13 @@ describe Proposal do end it "orders by weight and then by votes" do - title_some_votes = create(:proposal, title: 'stop corruption', cached_votes_up: 5) - title_least_voted = create(:proposal, title: 'stop corruption', cached_votes_up: 2) - title_most_voted = create(:proposal, title: 'stop corruption', cached_votes_up: 10) + title_some_votes = create(:proposal, title: "stop corruption", cached_votes_up: 5) + title_least_voted = create(:proposal, title: "stop corruption", cached_votes_up: 2) + title_most_voted = create(:proposal, title: "stop corruption", cached_votes_up: 10) - summary_most_voted = create(:proposal, summary: 'stop corruption', cached_votes_up: 10) + summary_most_voted = create(:proposal, summary: "stop corruption", cached_votes_up: 10) - results = described_class.search('stop corruption') + results = described_class.search("stop corruption") expect(results.first).to eq(title_most_voted) expect(results.second).to eq(title_some_votes) @@ -604,10 +604,10 @@ describe Proposal do end it "gives much more weight to word matches than votes" do - exact_title_few_votes = create(:proposal, title: 'stop corruption', cached_votes_up: 5) - similar_title_many_votes = create(:proposal, title: 'stop some of the corruption', cached_votes_up: 500) + exact_title_few_votes = create(:proposal, title: "stop corruption", cached_votes_up: 5) + similar_title_many_votes = create(:proposal, title: "stop some of the corruption", cached_votes_up: 500) - results = described_class.search('stop corruption') + results = described_class.search("stop corruption") expect(results.first).to eq(exact_title_few_votes) expect(results.second).to eq(similar_title_many_votes) @@ -618,15 +618,15 @@ describe Proposal do context "reorder" do it "is able to reorder by hot_score after searching" do - lowest_score = create(:proposal, title: 'stop corruption', cached_votes_up: 1) - highest_score = create(:proposal, title: 'stop corruption', cached_votes_up: 2) - average_score = create(:proposal, title: 'stop corruption', cached_votes_up: 3) + lowest_score = create(:proposal, title: "stop corruption", cached_votes_up: 1) + highest_score = create(:proposal, title: "stop corruption", cached_votes_up: 2) + average_score = create(:proposal, title: "stop corruption", cached_votes_up: 3) lowest_score.update_column(:hot_score, 1) highest_score.update_column(:hot_score, 100) average_score.update_column(:hot_score, 10) - results = described_class.search('stop corruption') + results = described_class.search("stop corruption") expect(results.first).to eq(average_score) expect(results.second).to eq(highest_score) @@ -640,15 +640,15 @@ describe Proposal do end it "is able to reorder by confidence_score after searching" do - lowest_score = create(:proposal, title: 'stop corruption', cached_votes_up: 1) - highest_score = create(:proposal, title: 'stop corruption', cached_votes_up: 2) - average_score = create(:proposal, title: 'stop corruption', cached_votes_up: 3) + lowest_score = create(:proposal, title: "stop corruption", cached_votes_up: 1) + highest_score = create(:proposal, title: "stop corruption", cached_votes_up: 2) + average_score = create(:proposal, title: "stop corruption", cached_votes_up: 3) lowest_score.update_column(:confidence_score, 1) highest_score.update_column(:confidence_score, 100) average_score.update_column(:confidence_score, 10) - results = described_class.search('stop corruption') + results = described_class.search("stop corruption") expect(results.first).to eq(average_score) expect(results.second).to eq(highest_score) @@ -662,11 +662,11 @@ describe Proposal do end it "is able to reorder by created_at after searching" do - recent = create(:proposal, title: 'stop corruption', cached_votes_up: 1, created_at: 1.week.ago) - newest = create(:proposal, title: 'stop corruption', cached_votes_up: 2, created_at: Time.current) - oldest = create(:proposal, title: 'stop corruption', cached_votes_up: 3, created_at: 1.month.ago) + recent = create(:proposal, title: "stop corruption", cached_votes_up: 1, created_at: 1.week.ago) + newest = create(:proposal, title: "stop corruption", cached_votes_up: 2, created_at: Time.current) + oldest = create(:proposal, title: "stop corruption", cached_votes_up: 3, created_at: 1.month.ago) - results = described_class.search('stop corruption') + results = described_class.search("stop corruption") expect(results.first).to eq(oldest) expect(results.second).to eq(newest) @@ -680,11 +680,11 @@ describe Proposal do end it "is able to reorder by most commented after searching" do - least_commented = create(:proposal, title: 'stop corruption', cached_votes_up: 1, comments_count: 1) - most_commented = create(:proposal, title: 'stop corruption', cached_votes_up: 2, comments_count: 100) - some_comments = create(:proposal, title: 'stop corruption', cached_votes_up: 3, comments_count: 10) + least_commented = create(:proposal, title: "stop corruption", cached_votes_up: 1, comments_count: 1) + most_commented = create(:proposal, title: "stop corruption", cached_votes_up: 2, comments_count: 100) + some_comments = create(:proposal, title: "stop corruption", cached_votes_up: 3, comments_count: 10) - results = described_class.search('stop corruption') + results = described_class.search("stop corruption") expect(results.first).to eq(some_comments) expect(results.second).to eq(most_commented) @@ -702,30 +702,30 @@ describe Proposal do context "no results" do it "no words match" do - create(:proposal, title: 'save world') + create(:proposal, title: "save world") - results = described_class.search('destroy planet') + results = described_class.search("destroy planet") expect(results).to eq([]) end it "too many typos" do - create(:proposal, title: 'fantastic') + create(:proposal, title: "fantastic") - results = described_class.search('frantac') + results = described_class.search("frantac") expect(results).to eq([]) end it "too much stemming" do - create(:proposal, title: 'reloj') + create(:proposal, title: "reloj") - results = described_class.search('superrelojimetro') + results = described_class.search("superrelojimetro") expect(results).to eq([]) end it "empty" do - create(:proposal, title: 'great') + create(:proposal, title: "great") - results = described_class.search('') + results = described_class.search("") expect(results).to eq([]) end @@ -749,15 +749,15 @@ describe Proposal do context "categories" do it "returns proposals tagged with a category" do - create(:tag, :category, name: 'culture') - proposal = create(:proposal, tag_list: 'culture') + create(:tag, :category, name: "culture") + proposal = create(:proposal, tag_list: "culture") expect(described_class.for_summary.values.flatten).to include(proposal) end it "does not return proposals tagged without a category" do - create(:tag, :category, name: 'culture') - proposal = create(:proposal, tag_list: 'parks') + create(:tag, :category, name: "culture") + proposal = create(:proposal, tag_list: "parks") expect(described_class.for_summary.values.flatten).not_to include(proposal) end @@ -766,14 +766,14 @@ describe Proposal do context "districts" do it "returns proposals with a geozone" do - california = create(:geozone, name: 'california') + california = create(:geozone, name: "california") proposal = create(:proposal, geozone: california) expect(described_class.for_summary.values.flatten).to include(proposal) end it "does not return proposals without a geozone" do - create(:geozone, name: 'california') + create(:geozone, name: "california") proposal = create(:proposal) expect(described_class.for_summary.values.flatten).not_to include(proposal) @@ -781,22 +781,22 @@ describe Proposal do end it "returns proposals created this week" do - create(:tag, :category, name: 'culture') - proposal = create(:proposal, tag_list: 'culture') + create(:tag, :category, name: "culture") + proposal = create(:proposal, tag_list: "culture") expect(described_class.for_summary.values.flatten).to include(proposal) end it "does not return proposals created more than a week ago" do - create(:tag, :category, name: 'culture') - proposal = create(:proposal, tag_list: 'culture', created_at: 8.days.ago) + create(:tag, :category, name: "culture") + proposal = create(:proposal, tag_list: "culture", created_at: 8.days.ago) expect(described_class.for_summary.values.flatten).not_to include(proposal) end it "orders proposals by votes" do - create(:tag, :category, name: 'culture') - create(:proposal, tag_list: 'culture').update_column(:confidence_score, 2) - create(:proposal, tag_list: 'culture').update_column(:confidence_score, 10) - create(:proposal, tag_list: 'culture').update_column(:confidence_score, 5) + create(:tag, :category, name: "culture") + create(:proposal, tag_list: "culture").update_column(:confidence_score, 2) + create(:proposal, tag_list: "culture").update_column(:confidence_score, 10) + create(:proposal, tag_list: "culture").update_column(:confidence_score, 5) results = described_class.for_summary.values.flatten @@ -806,13 +806,13 @@ describe Proposal do end it "orders groups alphabetically" do - create(:tag, :category, name: 'health') - create(:tag, :category, name: 'culture') - create(:tag, :category, name: 'social services') + create(:tag, :category, name: "health") + create(:tag, :category, name: "culture") + create(:tag, :category, name: "social services") - health_proposal = create(:proposal, tag_list: 'health') - culture_proposal = create(:proposal, tag_list: 'culture') - social_proposal = create(:proposal, tag_list: 'social services') + health_proposal = create(:proposal, tag_list: "health") + culture_proposal = create(:proposal, tag_list: "culture") + social_proposal = create(:proposal, tag_list: "social services") results = described_class.for_summary.values.flatten @@ -822,18 +822,18 @@ describe Proposal do end it "returns proposals grouped by tag" do - create(:tag, :category, name: 'culture') - create(:tag, :category, name: 'health') + create(:tag, :category, name: "culture") + create(:tag, :category, name: "health") - proposal1 = create(:proposal, tag_list: 'culture') - proposal2 = create(:proposal, tag_list: 'culture') + proposal1 = create(:proposal, tag_list: "culture") + proposal2 = create(:proposal, tag_list: "culture") proposal2.update_column(:confidence_score, 100) - proposal3 = create(:proposal, tag_list: 'health') + proposal3 = create(:proposal, tag_list: "health") proposal1.update_column(:confidence_score, 10) proposal2.update_column(:confidence_score, 9) - expect(described_class.for_summary).to include('culture' => [proposal1, proposal2], 'health' => [proposal3]) + expect(described_class.for_summary).to include("culture" => [proposal1, proposal2], "health" => [proposal3]) end end @@ -891,13 +891,13 @@ describe Proposal do end end - describe 'public_for_api scope' do - it 'returns proposals' do + describe "public_for_api scope" do + it "returns proposals" do proposal = create(:proposal) expect(described_class.public_for_api).to include(proposal) end - it 'does not return hidden proposals' do + it "does not return hidden proposals" do proposal = create(:proposal, :hidden) expect(described_class.public_for_api).not_to include(proposal) end diff --git a/spec/models/related_content_spec.rb b/spec/models/related_content_spec.rb index 0c00ae251..2889c5a34 100644 --- a/spec/models/related_content_spec.rb +++ b/spec/models/related_content_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe RelatedContent do @@ -23,12 +23,12 @@ describe RelatedContent do expect(new_related_content).not_to be_valid end - describe 'create_opposite_related_content' do + describe "create_opposite_related_content" do let(:parent_relationable) { create(:proposal) } let(:child_relationable) { create(:debate) } let(:related_content) { build(:related_content, parent_relationable: parent_relationable, child_relationable: child_relationable, author: build(:user)) } - it 'creates an opposite related_content' do + it "creates an opposite related_content" do expect { related_content.save }.to change { described_class.count }.by(2) expect(related_content.opposite_related_content.child_relationable_id).to eq(parent_relationable.id) expect(related_content.opposite_related_content.child_relationable_type).to eq(parent_relationable.class.name) @@ -38,7 +38,7 @@ describe RelatedContent do end end - describe '#relationed_contents' do + describe "#relationed_contents" do before do related_content = create(:related_content, parent_relationable: parent_relationable, child_relationable: create(:proposal), author: build(:user)) create(:related_content, parent_relationable: parent_relationable, child_relationable: child_relationable, author: build(:user)) @@ -52,7 +52,7 @@ describe RelatedContent do end end - it 'returns not hidden by reports related contents' do + it "returns not hidden by reports related contents" do expect(parent_relationable.relationed_contents.count).to eq(1) expect(parent_relationable.relationed_contents.first.class.name).to eq(child_relationable.class.name) expect(parent_relationable.relationed_contents.first.id).to eq(child_relationable.id) diff --git a/spec/models/setting_spec.rb b/spec/models/setting_spec.rb index d65ab038a..244e25bf1 100644 --- a/spec/models/setting_spec.rb +++ b/spec/models/setting_spec.rb @@ -1,37 +1,37 @@ -require 'rails_helper' +require "rails_helper" describe Setting do before do - described_class["official_level_1_name"] = 'Stormtrooper' + described_class["official_level_1_name"] = "Stormtrooper" end it "returns the overriden setting" do - expect(described_class['official_level_1_name']).to eq('Stormtrooper') + expect(described_class["official_level_1_name"]).to eq("Stormtrooper") end it "shoulds return nil" do - expect(described_class['undefined_key']).to eq(nil) + expect(described_class["undefined_key"]).to eq(nil) end it "persists a setting on the db" do - expect(described_class.where(key: 'official_level_1_name', value: 'Stormtrooper')).to exist + expect(described_class.where(key: "official_level_1_name", value: "Stormtrooper")).to exist end describe "#feature_flag?" do it "is true if key starts with 'feature.'" do - setting = described_class.create(key: 'feature.whatever') + setting = described_class.create(key: "feature.whatever") expect(setting.feature_flag?).to eq true end it "is false if key does not start with 'feature.'" do - setting = described_class.create(key: 'whatever') + setting = described_class.create(key: "whatever") expect(setting.feature_flag?).to eq false end end describe "#enabled?" do it "is true if feature_flag and value present" do - setting = described_class.create(key: 'feature.whatever', value: 1) + setting = described_class.create(key: "feature.whatever", value: 1) expect(setting.enabled?).to eq true setting.value = "true" @@ -42,7 +42,7 @@ describe Setting do end it "is false if feature_flag and value blank" do - setting = described_class.create(key: 'feature.whatever') + setting = described_class.create(key: "feature.whatever") expect(setting.enabled?).to eq false setting.value = "" @@ -50,31 +50,31 @@ describe Setting do end it "is false if not feature_flag" do - setting = described_class.create(key: 'whatever', value: "whatever") + setting = described_class.create(key: "whatever", value: "whatever") expect(setting.enabled?).to eq false end end describe "#banner_style?" do it "is true if key starts with 'banner-style.'" do - setting = described_class.create(key: 'banner-style.whatever') + setting = described_class.create(key: "banner-style.whatever") expect(setting.banner_style?).to eq true end it "is false if key does not start with 'banner-style.'" do - setting = described_class.create(key: 'whatever') + setting = described_class.create(key: "whatever") expect(setting.banner_style?).to eq false end end describe "#banner_img?" do it "is true if key starts with 'banner-img.'" do - setting = described_class.create(key: 'banner-img.whatever') + setting = described_class.create(key: "banner-img.whatever") expect(setting.banner_img?).to eq true end it "is false if key does not start with 'banner-img.'" do - setting = described_class.create(key: 'whatever') + setting = described_class.create(key: "whatever") expect(setting.banner_img?).to eq false end end diff --git a/spec/models/signature_sheet_spec.rb b/spec/models/signature_sheet_spec.rb index f64cac6e6..263a94216 100644 --- a/spec/models/signature_sheet_spec.rb +++ b/spec/models/signature_sheet_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe SignatureSheet do @@ -82,13 +82,13 @@ describe SignatureSheet do it "returns an array after spliting document numbers by newlines or commas" do signature_sheet.document_numbers = "123A\r\n456B\n789C,123B" - expect(signature_sheet.parsed_document_numbers).to eq(['123A', '456B', '789C', '123B']) + expect(signature_sheet.parsed_document_numbers).to eq(["123A", "456B", "789C", "123B"]) end it "strips spaces between number and letter" do signature_sheet.document_numbers = "123 A\n456 B \n 789C" - expect(signature_sheet.parsed_document_numbers).to eq(['123A', '456B', '789C']) + expect(signature_sheet.parsed_document_numbers).to eq(["123A", "456B", "789C"]) end end diff --git a/spec/models/signature_spec.rb b/spec/models/signature_spec.rb index 6a27fc029..c6f53153c 100644 --- a/spec/models/signature_spec.rb +++ b/spec/models/signature_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Signature do diff --git a/spec/models/site_customization/content_block_spec.rb b/spec/models/site_customization/content_block_spec.rb index dd536425d..7cdc5b1b8 100644 --- a/spec/models/site_customization/content_block_spec.rb +++ b/spec/models/site_customization/content_block_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" RSpec.describe SiteCustomization::ContentBlock, type: :model do let(:block) { build(:site_customization_content_block) } diff --git a/spec/models/site_customization/page_spec.rb b/spec/models/site_customization/page_spec.rb index f9ac9b360..ccbe8bfa8 100644 --- a/spec/models/site_customization/page_spec.rb +++ b/spec/models/site_customization/page_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" RSpec.describe SiteCustomization::Page, type: :model do let(:custom_page) { build(:site_customization_page) } diff --git a/spec/models/tag_cloud_spec.rb b/spec/models/tag_cloud_spec.rb index 7eb669899..df04e9d5c 100644 --- a/spec/models/tag_cloud_spec.rb +++ b/spec/models/tag_cloud_spec.rb @@ -1,116 +1,116 @@ -require 'rails_helper' +require "rails_helper" describe TagCloud do describe "#tags" do it "returns proposal tags" do - create(:proposal, tag_list: 'participation') - create(:debate, tag_list: 'world hunger') + create(:proposal, tag_list: "participation") + create(:debate, tag_list: "world hunger") tag_cloud = described_class.new(Proposal) - expect(tag_names(tag_cloud)).to contain_exactly('participation') + expect(tag_names(tag_cloud)).to contain_exactly("participation") end it "returns debate tags" do - create(:proposal, tag_list: 'participation') - create(:debate, tag_list: 'world hunger') + create(:proposal, tag_list: "participation") + create(:debate, tag_list: "world hunger") tag_cloud = described_class.new(Debate) - expect(tag_names(tag_cloud)).to contain_exactly('world hunger') + expect(tag_names(tag_cloud)).to contain_exactly("world hunger") end it "returns budget investment tags" do - create(:budget_investment, tag_list: 'participation') - create(:debate, tag_list: 'world hunger') + create(:budget_investment, tag_list: "participation") + create(:debate, tag_list: "world hunger") tag_cloud = described_class.new(Budget::Investment) - expect(tag_names(tag_cloud)).to contain_exactly('participation') + expect(tag_names(tag_cloud)).to contain_exactly("participation") end it "returns tags from last week" do - create(:proposal, tag_list: 'participation', created_at: 1.day.ago) - create(:proposal, tag_list: 'corruption', created_at: 2.weeks.ago) + create(:proposal, tag_list: "participation", created_at: 1.day.ago) + create(:proposal, tag_list: "corruption", created_at: 2.weeks.ago) tag_cloud = described_class.new(Proposal) - expect(tag_names(tag_cloud)).to contain_exactly('participation') + expect(tag_names(tag_cloud)).to contain_exactly("participation") end it "does not return category tags" do - create(:tag, :category, name: 'Education') - create(:tag, :category, name: 'Participation') + create(:tag, :category, name: "Education") + create(:tag, :category, name: "Participation") - create(:proposal, tag_list: 'education, parks') - create(:proposal, tag_list: 'participation, water') + create(:proposal, tag_list: "education, parks") + create(:proposal, tag_list: "participation, water") tag_cloud = described_class.new(Proposal) - expect(tag_names(tag_cloud)).to contain_exactly('parks', 'water') + expect(tag_names(tag_cloud)).to contain_exactly("parks", "water") end it "does not return geozone names" do - create(:geozone, name: 'California') - create(:geozone, name: 'New York') + create(:geozone, name: "California") + create(:geozone, name: "New York") - create(:proposal, tag_list: 'parks, California') - create(:proposal, tag_list: 'water, New York') + create(:proposal, tag_list: "parks, California") + create(:proposal, tag_list: "water, New York") tag_cloud = described_class.new(Proposal) - expect(tag_names(tag_cloud)).to contain_exactly('parks', 'water') + expect(tag_names(tag_cloud)).to contain_exactly("parks", "water") end it "returns tags scoped by category" do - create(:tag, :category, name: 'Education') - create(:tag, :category, name: 'Participation') + create(:tag, :category, name: "Education") + create(:tag, :category, name: "Participation") - create(:proposal, tag_list: 'education, parks') - create(:proposal, tag_list: 'participation, water') + create(:proposal, tag_list: "education, parks") + create(:proposal, tag_list: "participation, water") - tag_cloud = described_class.new(Proposal, 'Education') + tag_cloud = described_class.new(Proposal, "Education") - expect(tag_names(tag_cloud)).to contain_exactly('parks') + expect(tag_names(tag_cloud)).to contain_exactly("parks") end it "returns tags scoped by geozone" do - create(:geozone, name: 'California') - create(:geozone, name: 'New York') + create(:geozone, name: "California") + create(:geozone, name: "New York") - create(:proposal, tag_list: 'parks, California') - create(:proposal, tag_list: 'water, New York') + create(:proposal, tag_list: "parks, California") + create(:proposal, tag_list: "water, New York") - tag_cloud = described_class.new(Proposal, 'California') + tag_cloud = described_class.new(Proposal, "California") - expect(tag_names(tag_cloud)).to contain_exactly('parks') + expect(tag_names(tag_cloud)).to contain_exactly("parks") end xit "returns tags scoped by category for debates" xit "returns tags scoped by geozone for debates" it "orders tags by count" do - 3.times { create(:proposal, tag_list: 'participation') } - create(:proposal, tag_list: 'corruption') + 3.times { create(:proposal, tag_list: "participation") } + create(:proposal, tag_list: "corruption") tag_cloud = described_class.new(Proposal) - expect(tag_names(tag_cloud).first).to eq 'participation' - expect(tag_names(tag_cloud).second).to eq 'corruption' + expect(tag_names(tag_cloud).first).to eq "participation" + expect(tag_names(tag_cloud).second).to eq "corruption" end it "orders tags by count and then by name" do - 3.times { create(:proposal, tag_list: 'participation') } - 3.times { create(:proposal, tag_list: 'health') } - create(:proposal, tag_list: 'corruption') + 3.times { create(:proposal, tag_list: "participation") } + 3.times { create(:proposal, tag_list: "health") } + create(:proposal, tag_list: "corruption") tag_cloud = described_class.new(Proposal) - expect(tag_names(tag_cloud).first).to eq 'health' - expect(tag_names(tag_cloud).second).to eq 'participation' - expect(tag_names(tag_cloud).third).to eq 'corruption' + expect(tag_names(tag_cloud).first).to eq "health" + expect(tag_names(tag_cloud).second).to eq "participation" + expect(tag_names(tag_cloud).third).to eq "corruption" end it "returns a maximum of 10 tags" do diff --git a/spec/models/topic_spec.rb b/spec/models/topic_spec.rb index 2add13bc5..8f2446340 100644 --- a/spec/models/topic_spec.rb +++ b/spec/models/topic_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Topic do let(:topic) { build(:topic) } @@ -76,6 +76,6 @@ describe Topic do end describe "notifications" do - it_behaves_like 'notifiable' + it_behaves_like "notifiable" end end diff --git a/spec/models/valuator_group_spec.rb b/spec/models/valuator_group_spec.rb index 98a1effd8..910fd7ec7 100644 --- a/spec/models/valuator_group_spec.rb +++ b/spec/models/valuator_group_spec.rb @@ -1,8 +1,8 @@ -require 'rails_helper' +require "rails_helper" describe ValuatorGroup do - describe 'Validations' do + describe "Validations" do it "should be valid" do expect(build(:valuator_group)).to be_valid end @@ -12,9 +12,9 @@ describe ValuatorGroup do end it "should not be valid with the same name as an existing one" do - create(:valuator_group, name: 'The Valuators') + create(:valuator_group, name: "The Valuators") - expect(build(:valuator_group, name: 'The Valuators')).not_to be_valid + expect(build(:valuator_group, name: "The Valuators")).not_to be_valid end end end diff --git a/spec/models/valuator_spec.rb b/spec/models/valuator_spec.rb index b895e9f35..854171a3b 100644 --- a/spec/models/valuator_spec.rb +++ b/spec/models/valuator_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Valuator do diff --git a/spec/models/verification/letter_spec.rb b/spec/models/verification/letter_spec.rb index 2e4121ad2..9831cb776 100644 --- a/spec/models/verification/letter_spec.rb +++ b/spec/models/verification/letter_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Verification::Letter do diff --git a/spec/models/verification/management/document_spec.rb b/spec/models/verification/management/document_spec.rb index 1767fec50..f50e0bf21 100644 --- a/spec/models/verification/management/document_spec.rb +++ b/spec/models/verification/management/document_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Verification::Management::Document do let(:min_age) { User.minimum_required_age } @@ -8,34 +8,34 @@ describe Verification::Management::Document do describe "#valid_age?" do it "returns false when the user is younger than the user's minimum required age" do - census_response = instance_double('CensusApi::Response', date_of_birth: under_minium_age_date_of_birth) + census_response = instance_double("CensusApi::Response", date_of_birth: under_minium_age_date_of_birth) expect(described_class.new.valid_age?(census_response)).to be false end it "returns true when the user has the user's minimum required age" do - census_response = instance_double('CensusApi::Response', date_of_birth: just_minium_age_date_of_birth) + census_response = instance_double("CensusApi::Response", date_of_birth: just_minium_age_date_of_birth) expect(described_class.new.valid_age?(census_response)).to be true end it "returns true when the user is older than the user's minimum required age" do - census_response = instance_double('CensusApi::Response', date_of_birth: over_minium_age_date_of_birth) + census_response = instance_double("CensusApi::Response", date_of_birth: over_minium_age_date_of_birth) expect(described_class.new.valid_age?(census_response)).to be true end end describe "#under_age?" do it "returns true when the user is younger than the user's minimum required age" do - census_response = instance_double('CensusApi::Response', date_of_birth: under_minium_age_date_of_birth) + census_response = instance_double("CensusApi::Response", date_of_birth: under_minium_age_date_of_birth) expect(described_class.new.under_age?(census_response)).to be true end it "returns false when the user is user's minimum required age" do - census_response = instance_double('CensusApi::Response', date_of_birth: just_minium_age_date_of_birth) + census_response = instance_double("CensusApi::Response", date_of_birth: just_minium_age_date_of_birth) expect(described_class.new.under_age?(census_response)).to be false end it "returns false when the user is older than user's minimum required age" do - census_response = instance_double('CensusApi::Response', date_of_birth: over_minium_age_date_of_birth) + census_response = instance_double("CensusApi::Response", date_of_birth: over_minium_age_date_of_birth) expect(described_class.new.under_age?(census_response)).to be false end end diff --git a/spec/models/verification/management/email_spec.rb b/spec/models/verification/management/email_spec.rb index f5077b900..d9fc532f9 100644 --- a/spec/models/verification/management/email_spec.rb +++ b/spec/models/verification/management/email_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Verification::Management::Email do diff --git a/spec/models/verification/residence_spec.rb b/spec/models/verification/residence_spec.rb index cb7075dfe..72cda3674 100644 --- a/spec/models/verification/residence_spec.rb +++ b/spec/models/verification/residence_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Verification::Residence do @@ -70,12 +70,12 @@ describe Verification::Residence do residence.save user.reload - expect(user.document_number).to eq('12345678Z') + expect(user.document_number).to eq("12345678Z") expect(user.document_type).to eq("1") expect(user.date_of_birth.year).to eq(1980) expect(user.date_of_birth.month).to eq(12) expect(user.date_of_birth.day).to eq(31) - expect(user.gender).to eq('male') + expect(user.gender).to eq("male") expect(user.geozone).to eq(geozone) end diff --git a/spec/models/verification/sms_spec.rb b/spec/models/verification/sms_spec.rb index e2fa0ebe1..4434bd341 100644 --- a/spec/models/verification/sms_spec.rb +++ b/spec/models/verification/sms_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Verification::Sms do it "is valid" do diff --git a/spec/models/vote_spec.rb b/spec/models/vote_spec.rb index 06ae2269b..ce70c6842 100644 --- a/spec/models/vote_spec.rb +++ b/spec/models/vote_spec.rb @@ -1,9 +1,9 @@ -require 'rails_helper' +require "rails_helper" describe Vote do - describe '#for_debates' do - it 'does not returns votes for other votables' do + describe "#for_debates" do + it "does not returns votes for other votables" do debate = create(:debate) comment = create(:comment) create(:vote, votable: comment) @@ -11,7 +11,7 @@ describe Vote do expect(described_class.for_debates(debate).count).to eq(0) end - it 'returns votes only for debates in parameters' do + it "returns votes only for debates in parameters" do debate1 = create(:debate) debate2 = create(:debate) create(:vote, votable: debate1) @@ -20,7 +20,7 @@ describe Vote do expect(described_class.for_debates(debate2).count).to eq(0) end - it 'accepts more than 1 debate' do + it "accepts more than 1 debate" do debate1 = create(:debate) debate2 = create(:debate) debate3 = create(:debate) @@ -31,8 +31,8 @@ describe Vote do end end - describe '#value' do - it 'returns vote flag' do + describe "#value" do + it "returns vote flag" do vote = create(:vote, vote_flag: true) expect(vote.value).to eq(true) @@ -41,50 +41,50 @@ describe Vote do end end - describe 'public_for_api scope' do - it 'returns votes on debates' do + describe "public_for_api scope" do + it "returns votes on debates" do debate = create(:debate) vote = create(:vote, votable: debate) expect(described_class.public_for_api).to include(vote) end - it 'blocks votes on hidden debates' do + it "blocks votes on hidden debates" do debate = create(:debate, :hidden) vote = create(:vote, votable: debate) expect(described_class.public_for_api).not_to include(vote) end - it 'returns votes on proposals' do + it "returns votes on proposals" do proposal = create(:proposal) vote = create(:vote, votable: proposal) expect(described_class.public_for_api).to include(vote) end - it 'blocks votes on hidden proposals' do + it "blocks votes on hidden proposals" do proposal = create(:proposal, :hidden) vote = create(:vote, votable: proposal) expect(described_class.public_for_api).not_to include(vote) end - it 'returns votes on comments' do + it "returns votes on comments" do comment = create(:comment) vote = create(:vote, votable: comment) expect(described_class.public_for_api).to include(vote) end - it 'blocks votes on hidden comments' do + it "blocks votes on hidden comments" do comment = create(:comment, :hidden) vote = create(:vote, votable: comment) expect(described_class.public_for_api).not_to include(vote) end - it 'blocks votes on comments on hidden proposals' do + it "blocks votes on comments on hidden proposals" do hidden_proposal = create(:proposal, :hidden) comment_on_hidden_proposal = create(:comment, commentable: hidden_proposal) vote = create(:vote, votable: comment_on_hidden_proposal) @@ -92,7 +92,7 @@ describe Vote do expect(described_class.public_for_api).not_to include(vote) end - it 'blocks votes on comments on hidden debates' do + it "blocks votes on comments on hidden debates" do hidden_debate = create(:debate, :hidden) comment_on_hidden_debate = create(:comment, commentable: hidden_debate) vote = create(:vote, votable: comment_on_hidden_debate) @@ -100,14 +100,14 @@ describe Vote do expect(described_class.public_for_api).not_to include(vote) end - it 'blocks any other kind of votes' do + it "blocks any other kind of votes" do spending_proposal = create(:spending_proposal) vote = create(:vote, votable: spending_proposal) expect(described_class.public_for_api).not_to include(vote) end - it 'blocks votes without votable' do + it "blocks votes without votable" do vote = build(:vote, votable: nil).save!(validate: false) expect(described_class.public_for_api).not_to include(vote) diff --git a/spec/models/widget/card_spec.rb b/spec/models/widget/card_spec.rb index b9816f213..85c489d22 100644 --- a/spec/models/widget/card_spec.rb +++ b/spec/models/widget/card_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Widget::Card do diff --git a/spec/models/widget/feed_spec.rb b/spec/models/widget/feed_spec.rb index b35f338f7..f8b881a0b 100644 --- a/spec/models/widget/feed_spec.rb +++ b/spec/models/widget/feed_spec.rb @@ -1,4 +1,4 @@ -require 'rails_helper' +require "rails_helper" describe Widget::Feed do @@ -15,16 +15,16 @@ describe Widget::Feed do describe "#proposals" do it "returns the most active proposals" do - best_proposal = create(:proposal, title: 'Best proposal') + best_proposal = create(:proposal, title: "Best proposal") best_proposal.update_column(:hot_score, 10) - worst_proposal = create(:proposal, title: 'Worst proposal') + worst_proposal = create(:proposal, title: "Worst proposal") worst_proposal.update_column(:hot_score, 2) - even_worst_proposal = create(:proposal, title: 'Worst proposal') + even_worst_proposal = create(:proposal, title: "Worst proposal") even_worst_proposal.update_column(:hot_score, 1) - medium_proposal = create(:proposal, title: 'Medium proposal') + medium_proposal = create(:proposal, title: "Medium proposal") medium_proposal.update_column(:hot_score, 5) feed = build(:widget_feed, kind: "proposals") @@ -37,16 +37,16 @@ describe Widget::Feed do describe "#debates" do it "returns the most active debates" do - best_debate = create(:debate, title: 'Best debate') + best_debate = create(:debate, title: "Best debate") best_debate.update_column(:hot_score, 10) - worst_debate = create(:debate, title: 'Worst debate') + worst_debate = create(:debate, title: "Worst debate") worst_debate.update_column(:hot_score, 2) - even_worst_debate = create(:debate, title: 'Worst debate') + even_worst_debate = create(:debate, title: "Worst debate") even_worst_debate.update_column(:hot_score, 1) - medium_debate = create(:debate, title: 'Medium debate') + medium_debate = create(:debate, title: "Medium debate") medium_debate.update_column(:hot_score, 5) feed = build(:widget_feed, kind: "debates") diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index c3772d5d8..4be75fc2b 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -1,16 +1,16 @@ -ENV['RAILS_ENV'] ||= 'test' -if ENV['TRAVIS'] - require 'coveralls' - Coveralls.wear!('rails') +ENV["RAILS_ENV"] ||= "test" +if ENV["TRAVIS"] + require "coveralls" + Coveralls.wear!("rails") end -require File.expand_path('../../config/environment', __FILE__) +require File.expand_path("../../config/environment", __FILE__) abort("The Rails environment is running in production mode!") if Rails.env.production? -require 'rspec/rails' -require 'spec_helper' -require 'capybara/rails' -require 'capybara/rspec' -require 'selenium/webdriver' +require "rspec/rails" +require "spec_helper" +require "capybara/rails" +require "capybara/rspec" +require "selenium/webdriver" Rails.application.load_tasks if Rake::Task.tasks.empty? I18n.default_locale = :en diff --git a/spec/shared/features/admin_milestoneable.rb b/spec/shared/features/admin_milestoneable.rb index ece014689..cb60fba52 100644 --- a/spec/shared/features/admin_milestoneable.rb +++ b/spec/shared/features/admin_milestoneable.rb @@ -6,7 +6,7 @@ shared_examples "admin_milestoneable" do |factory_name, path_name| let(:path) { send(path_name, *resource_hierarchy_for(milestoneable)) } context "Index" do - scenario 'Displaying milestones' do + scenario "Displaying milestones" do milestone = create(:milestone, milestoneable: milestoneable) create(:image, imageable: milestone) document = create(:document, documentable: milestone) @@ -18,11 +18,11 @@ shared_examples "admin_milestoneable" do |factory_name, path_name| expect(page).to have_content(milestone.id) expect(page).to have_content(milestone.publication_date.to_date) expect(page).to have_content(milestone.status.name) - expect(page).to have_link 'Show image' + expect(page).to have_link "Show image" expect(page).to have_link document.title end - scenario 'Displaying no_milestones text' do + scenario "Displaying no_milestones text" do visit path expect(page).to have_content("Milestone") @@ -35,15 +35,15 @@ shared_examples "admin_milestoneable" do |factory_name, path_name| status = create(:milestone_status) visit path - click_link 'Create new milestone' + click_link "Create new milestone" - select status.name, from: 'milestone_status_id' - fill_in 'Description', with: 'New description milestone' - fill_in 'milestone_publication_date', with: Date.current + select status.name, from: "milestone_status_id" + fill_in "Description", with: "New description milestone" + fill_in "milestone_publication_date", with: Date.current - click_button 'Create milestone' + click_button "Create milestone" - expect(page).to have_content 'New description milestone' + expect(page).to have_content "New description milestone" expect(page).to have_content Date.current expect(page).to have_content status.name end @@ -51,22 +51,22 @@ shared_examples "admin_milestoneable" do |factory_name, path_name| scenario "Status select is disabled if there are no statuses available" do visit path - click_link 'Create new milestone' + click_link "Create new milestone" expect(find("#milestone_status_id").disabled?).to be true end scenario "Show validation errors on milestone form" do visit path - click_link 'Create new milestone' + click_link "Create new milestone" - fill_in 'Description', with: 'New description milestone' + fill_in "Description", with: "New description milestone" - click_button 'Create milestone' + click_button "Create milestone" within "#new_milestone" do expect(page).to have_content "can't be blank", count: 1 - expect(page).to have_content 'New description milestone' + expect(page).to have_content "New description milestone" end end @@ -96,16 +96,16 @@ shared_examples "admin_milestoneable" do |factory_name, path_name| expect(page).to have_css("img[alt='#{milestone.image.title}']") - fill_in 'Description', with: 'Changed description' - fill_in 'milestone_publication_date', with: Date.current - fill_in 'milestone_documents_attributes_0_title', with: 'New document title' + fill_in "Description", with: "Changed description" + fill_in "milestone_publication_date", with: Date.current + fill_in "milestone_documents_attributes_0_title", with: "New document title" - click_button 'Update milestone' + click_button "Update milestone" - expect(page).to have_content 'Changed description' + expect(page).to have_content "Changed description" expect(page).to have_content Date.current - expect(page).to have_link 'Show image' - expect(page).to have_link 'New document title' + expect(page).to have_link "Show image" + expect(page).to have_link "New document title" end end @@ -117,7 +117,7 @@ shared_examples "admin_milestoneable" do |factory_name, path_name| click_link "Delete milestone" - expect(page).not_to have_content 'Title will it remove' + expect(page).not_to have_content "Title will it remove" end end end diff --git a/spec/shared/features/documentable.rb b/spec/shared/features/documentable.rb index cb0122a8e..e3be2c869 100644 --- a/spec/shared/features/documentable.rb +++ b/spec/shared/features/documentable.rb @@ -70,11 +70,11 @@ shared_examples "documentable" do |documentable_factory_name, describe "When allow attached documents setting is enabled" do before do - Setting['feature.allow_attached_documents'] = true + Setting["feature.allow_attached_documents"] = true end after do - Setting['feature.allow_attached_documents'] = false + Setting["feature.allow_attached_documents"] = false end scenario "Documents list should be available" do @@ -97,11 +97,11 @@ shared_examples "documentable" do |documentable_factory_name, describe "When allow attached documents setting is disabled" do before do - Setting['feature.allow_attached_documents'] = false + Setting["feature.allow_attached_documents"] = false end after do - Setting['feature.allow_attached_documents'] = true + Setting["feature.allow_attached_documents"] = true end scenario "Documents list should not be available" do diff --git a/spec/shared/features/followable.rb b/spec/shared/features/followable.rb index 276d80d25..e0a94b3e9 100644 --- a/spec/shared/features/followable.rb +++ b/spec/shared/features/followable.rb @@ -3,7 +3,7 @@ shared_examples "followable" do |followable_class_name, followable_path, followa let!(:arguments) { {} } let!(:followable) { create(followable_class_name) } - let!(:followable_dom_name) { followable_class_name.tr('_', '-') } + let!(:followable_dom_name) { followable_class_name.tr("_", "-") } before do followable_path_arguments.each do |argument_name, path_to_value| diff --git a/spec/shared/features/mappable.rb b/spec/shared/features/mappable.rb index 1ae371e8d..ecbc5789b 100644 --- a/spec/shared/features/mappable.rb +++ b/spec/shared/features/mappable.rb @@ -15,7 +15,7 @@ shared_examples "mappable" do |mappable_factory_name, let(:management) { management } before do - Setting['feature.map'] = true + Setting["feature.map"] = true end describe "At #{mappable_new_path}" do @@ -69,7 +69,7 @@ shared_examples "mappable" do |mappable_factory_name, end scenario "Can not display map on #{mappable_factory_name} when feature.map is disabled", :js do - Setting['feature.map'] = false + Setting["feature.map"] = false do_login_for user visit send(mappable_new_path, arguments) @@ -80,7 +80,7 @@ shared_examples "mappable" do |mappable_factory_name, expect(page).not_to have_css(".map_location") end - scenario 'Errors on create' do + scenario "Errors on create" do do_login_for user visit send(mappable_new_path, arguments) @@ -89,7 +89,7 @@ shared_examples "mappable" do |mappable_factory_name, expect(page).to have_content "Map location can't be blank" end - scenario 'Skip map', :js do + scenario "Skip map", :js do do_login_for user visit send(mappable_new_path, arguments) @@ -100,7 +100,7 @@ shared_examples "mappable" do |mappable_factory_name, expect(page).not_to have_content "Map location can't be blank" end - scenario 'Toggle map', :js do + scenario "Toggle map", :js do do_login_for user visit send(mappable_new_path, arguments) @@ -168,7 +168,7 @@ shared_examples "mappable" do |mappable_factory_name, end scenario "Can not display map on #{mappable_factory_name} edit when feature.map is disabled", :js do - Setting['feature.map'] = false + Setting["feature.map"] = false do_login_for mappable.author visit send(mappable_edit_path, id: mappable.id) @@ -178,7 +178,7 @@ shared_examples "mappable" do |mappable_factory_name, expect(page).not_to have_css(".map_location") end - scenario 'No errors on update', :js do + scenario "No errors on update", :js do skip "" do_login_for mappable.author @@ -189,7 +189,7 @@ shared_examples "mappable" do |mappable_factory_name, expect(page).not_to have_content "Map location can't be blank" end - scenario 'No need to skip map on update' do + scenario "No need to skip map on update" do do_login_for mappable.author visit send(mappable_edit_path, id: mappable.id) @@ -227,7 +227,7 @@ shared_examples "mappable" do |mappable_factory_name, end scenario "Should not display map on #{mappable_factory_name} show page when feature.map is disable", :js do - Setting['feature.map'] = false + Setting["feature.map"] = false arguments[:id] = mappable.id visit send(mappable_show_path, arguments) @@ -249,17 +249,17 @@ def do_login_for(user) end def fill_in_proposal_form - fill_in 'proposal_title', with: 'Help refugees' - fill_in 'proposal_question', with: '¿Would you like to give assistance to war refugees?' - fill_in 'proposal_summary', with: 'In summary, what we want is...' + fill_in "proposal_title", with: "Help refugees" + fill_in "proposal_question", with: "¿Would you like to give assistance to war refugees?" + fill_in "proposal_summary", with: "In summary, what we want is..." end def submit_proposal_form check :proposal_terms_of_service - click_button 'Create proposal' + click_button "Create proposal" - if page.has_content?('Not now, go to my proposal') - click_link 'Not now, go to my proposal' + if page.has_content?("Not now, go to my proposal") + click_link "Not now, go to my proposal" end end @@ -279,7 +279,7 @@ end def submit_budget_investment_form check :budget_investment_terms_of_service - click_button 'Create Investment' + click_button "Create Investment" end def set_arguments(arguments, mappable, mappable_path_arguments) diff --git a/spec/shared/features/milestoneable.rb b/spec/shared/features/milestoneable.rb index 10b2cb578..75897b286 100644 --- a/spec/shared/features/milestoneable.rb +++ b/spec/shared/features/milestoneable.rb @@ -24,22 +24,22 @@ shared_examples "milestoneable" do |factory_name, path_name| find("#tab-milestones-label").click within("#tab-milestones") do - expect(first_milestone.description).to appear_before('Last milestone with a link to https://consul.dev') + expect(first_milestone.description).to appear_before("Last milestone with a link to https://consul.dev") expect(page).to have_content(Date.tomorrow) expect(page).to have_content(Date.yesterday) expect(page).not_to have_content(Date.current) - expect(page.find("#image_#{first_milestone.id}")['alt']).to have_content(image.title) + expect(page.find("#image_#{first_milestone.id}")["alt"]).to have_content(image.title) expect(page).to have_link(document.title) expect(page).to have_link("https://consul.dev") expect(page).to have_content(first_milestone.status.name) end - select('Español', from: 'locale-switcher') + select("Español", from: "locale-switcher") find("#tab-milestones-label").click within("#tab-milestones") do - expect(page).to have_content('Último hito con el link https://consul.dev') + expect(page).to have_content("Último hito con el link https://consul.dev") expect(page).to have_link("https://consul.dev") end end diff --git a/spec/shared/features/nested_documentable.rb b/spec/shared/features/nested_documentable.rb index 6d1700347..6597692ef 100644 --- a/spec/shared/features/nested_documentable.rb +++ b/spec/shared/features/nested_documentable.rb @@ -52,11 +52,11 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na login_as user_to_login visit send(path, arguments) documentable.class.max_documents_allowed.times.each do - documentable_attach_new_file(Rails.root.join('spec/fixtures/files/empty.pdf')) + documentable_attach_new_file(Rails.root.join("spec/fixtures/files/empty.pdf")) end expect(page).to have_css ".max-documents-notice", visible: true - expect(page).to have_content 'Remove document' + expect(page).to have_content "Remove document" end scenario "Should hide max documents warning after any document removal", :js do @@ -81,7 +81,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na document = find(".document input[type=file]", visible: false) attach_file( document[:id], - Rails.root.join('spec/fixtures/files/empty.pdf'), + Rails.root.join("spec/fixtures/files/empty.pdf"), make_visible: true ) end @@ -94,7 +94,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na login_as user_to_login visit send(path, arguments) - documentable_attach_new_file(Rails.root.join('spec/fixtures/files/empty.pdf')) + documentable_attach_new_file(Rails.root.join("spec/fixtures/files/empty.pdf")) expect_document_has_title(0, "empty.pdf") end @@ -111,7 +111,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na document_input = find("input[type=file]", visible: false) attach_file( document_input[:id], - Rails.root.join('spec/fixtures/files/empty.pdf'), + Rails.root.join("spec/fixtures/files/empty.pdf"), make_visible: true ) end @@ -123,7 +123,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na login_as user_to_login visit send(path, arguments) - documentable_attach_new_file(Rails.root.join('spec/fixtures/files/empty.pdf')) + documentable_attach_new_file(Rails.root.join("spec/fixtures/files/empty.pdf")) expect(page).to have_css ".loading-bar.complete" end @@ -133,7 +133,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na visit send(path, arguments) documentable_attach_new_file( - Rails.root.join('spec/fixtures/files/logo_header.png'), + Rails.root.join("spec/fixtures/files/logo_header.png"), false ) @@ -144,7 +144,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na login_as user_to_login visit send(path, arguments) - documentable_attach_new_file(Rails.root.join('spec/fixtures/files/empty.pdf')) + documentable_attach_new_file(Rails.root.join("spec/fixtures/files/empty.pdf")) expect_document_has_cached_attachment(0, ".pdf") end @@ -154,7 +154,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na visit send(path, arguments) documentable_attach_new_file( - Rails.root.join('spec/fixtures/files/logo_header.png'), + Rails.root.join("spec/fixtures/files/logo_header.png"), false ) @@ -178,7 +178,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na login_as user_to_login visit send(path, arguments) - documentable_attach_new_file(Rails.root.join('spec/fixtures/files/empty.pdf')) + documentable_attach_new_file(Rails.root.join("spec/fixtures/files/empty.pdf")) click_link "Remove document" expect(page).not_to have_css("#nested-documents .document") @@ -201,7 +201,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na visit send(path, arguments) send(fill_resource_method_name) if fill_resource_method_name - documentable_attach_new_file(Rails.root.join('spec/fixtures/files/empty.pdf')) + documentable_attach_new_file(Rails.root.join("spec/fixtures/files/empty.pdf")) click_on submit_button expect(page).to have_content documentable_success_notice @@ -212,7 +212,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na visit send(path, arguments) send(fill_resource_method_name) if fill_resource_method_name - documentable_attach_new_file(Rails.root.join('spec/fixtures/files/empty.pdf')) + documentable_attach_new_file(Rails.root.join("spec/fixtures/files/empty.pdf")) click_on submit_button documentable_redirected_to_resource_show_or_navigate_to @@ -287,11 +287,11 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na describe "When allow attached documents setting is disabled" do before do - Setting['feature.allow_attached_documents'] = false + Setting["feature.allow_attached_documents"] = false end after do - Setting['feature.allow_attached_documents'] = true + Setting["feature.allow_attached_documents"] = true end scenario "Add new document button should not be available" do diff --git a/spec/shared/features/nested_imageable.rb b/spec/shared/features/nested_imageable.rb index f508366fc..a4a37adb2 100644 --- a/spec/shared/features/nested_imageable.rb +++ b/spec/shared/features/nested_imageable.rb @@ -13,7 +13,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, before do - Setting['feature.allow_images'] = true + Setting["feature.allow_images"] = true imageable_path_arguments&.each do |argument_name, path_to_value| arguments.merge!("#{argument_name}": imageable.send(path_to_value)) @@ -23,7 +23,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, end after do - Setting['feature.allow_images'] = nil + Setting["feature.allow_images"] = nil end describe "at #{path}" do @@ -52,7 +52,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, image_input = find(".image").find("input[type=file]", visible: false) attach_file( image_input[:id], - Rails.root.join('spec/fixtures/files/clippy.jpg'), + Rails.root.join("spec/fixtures/files/clippy.jpg"), make_visible: true ) @@ -65,7 +65,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_attach_new_file( imageable_factory_name, - Rails.root.join('spec/fixtures/files/clippy.jpg') + Rails.root.join("spec/fixtures/files/clippy.jpg") ) expect_image_has_title("clippy.jpg") @@ -81,7 +81,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, image_input = find(".image").find("input[type=file]", visible: false) attach_file( image_input[:id], - Rails.root.join('spec/fixtures/files/clippy.jpg'), + Rails.root.join("spec/fixtures/files/clippy.jpg"), make_visible: true ) @@ -98,7 +98,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_attach_new_file( imageable_factory_name, - Rails.root.join('spec/fixtures/files/clippy.jpg') + Rails.root.join("spec/fixtures/files/clippy.jpg") ) expect(page).to have_selector ".loading-bar.complete" @@ -110,7 +110,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_attach_new_file( imageable_factory_name, - Rails.root.join('spec/fixtures/files/logo_header.png'), + Rails.root.join("spec/fixtures/files/logo_header.png"), false ) @@ -123,7 +123,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_attach_new_file( imageable_factory_name, - Rails.root.join('spec/fixtures/files/clippy.jpg') + Rails.root.join("spec/fixtures/files/clippy.jpg") ) expect_image_has_cached_attachment(".jpg") @@ -135,7 +135,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_attach_new_file( imageable_factory_name, - Rails.root.join('spec/fixtures/files/logo_header.png'), + Rails.root.join("spec/fixtures/files/logo_header.png"), false ) @@ -164,7 +164,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_attach_new_file( imageable_factory_name, - Rails.root.join('spec/fixtures/files/clippy.jpg') + Rails.root.join("spec/fixtures/files/clippy.jpg") ) within "#nested-image .image" do @@ -194,7 +194,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_attach_new_file( imageable_factory_name, - Rails.root.join('spec/fixtures/files/clippy.jpg') + Rails.root.join("spec/fixtures/files/clippy.jpg") ) click_on submit_button @@ -209,7 +209,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_attach_new_file( imageable_factory_name, - Rails.root.join('spec/fixtures/files/clippy.jpg') + Rails.root.join("spec/fixtures/files/clippy.jpg") ) click_on submit_button diff --git a/spec/shared/features/relationable.rb b/spec/shared/features/relationable.rb index d2e1c4cdb..f7bdba175 100644 --- a/spec/shared/features/relationable.rb +++ b/spec/shared/features/relationable.rb @@ -1,11 +1,11 @@ shared_examples "relationable" do |relationable_model_name| - let(:relationable) { create(relationable_model_name.name.parameterize('_').to_sym) } + let(:relationable) { create(relationable_model_name.name.parameterize("_").to_sym) } let(:related1) { create([:proposal, :debate, :budget_investment].sample) } let(:related2) { create([:proposal, :debate, :budget_investment].sample) } let(:user) { create(:user) } - scenario 'related contents are listed' do + scenario "related contents are listed" do related_content = create(:related_content, parent_relationable: relationable, child_relationable: related1, author: build(:user)) visit relationable.url @@ -19,21 +19,21 @@ shared_examples "relationable" do |relationable_model_name| end end - scenario 'related contents list is not rendered if there are no relations' do + scenario "related contents list is not rendered if there are no relations" do visit relationable.url expect(page).not_to have_css("#related-content-list") end - scenario 'related contents can be added' do + scenario "related contents can be added" do login_as(user) visit relationable.url - expect(page).to have_selector('#related_content', visible: false) + expect(page).to have_selector("#related_content", visible: false) click_on("Add related content") - expect(page).to have_selector('#related_content', visible: true) + expect(page).to have_selector("#related_content", visible: true) within("#related_content") do - fill_in 'url', with: "#{Setting['url'] + related1.url}" + fill_in "url", with: "#{Setting["url"] + related1.url}" click_button "Add" end @@ -57,21 +57,21 @@ shared_examples "relationable" do |relationable_model_name| end end - scenario 'if related content URL is invalid returns error' do + scenario "if related content URL is invalid returns error" do login_as(user) visit relationable.url click_on("Add related content") within("#related_content") do - fill_in 'url', with: "http://invalidurl.com" + fill_in "url", with: "http://invalidurl.com" click_button "Add" end expect(page).to have_content("Link not valid. Remember to start with #{Setting[:url]}.") end - scenario 'returns error when relating content URL to itself' do + scenario "returns error when relating content URL to itself" do login_as(user) visit relationable.url @@ -85,7 +85,7 @@ shared_examples "relationable" do |relationable_model_name| expect(page).to have_content("Link not valid. You cannot relate a content to itself") end - scenario 'related content can be scored positively', :js do + scenario "related content can be scored positively", :js do related_content = create(:related_content, parent_relationable: relationable, child_relationable: related1, author: build(:user)) login_as(user) @@ -102,7 +102,7 @@ shared_examples "relationable" do |relationable_model_name| end - scenario 'related content can be scored negatively', :js do + scenario "related content can be scored negatively", :js do related_content = create(:related_content, parent_relationable: relationable, child_relationable: related1, author: build(:user)) login_as(user) @@ -118,7 +118,7 @@ shared_examples "relationable" do |relationable_model_name| expect(related_content.opposite_related_content.related_content_scores.find_by(user_id: user.id, related_content_id: related_content.opposite_related_content.id).value).to eq(-1) end - scenario 'if related content has negative score it will be hidden' do + scenario "if related content has negative score it will be hidden" do related_content = create(:related_content, parent_relationable: relationable, child_relationable: related1, author: build(:user)) 2.times do diff --git a/spec/shared/features/translatable.rb b/spec/shared/features/translatable.rb index eec8356bd..8a310ef13 100644 --- a/spec/shared/features/translatable.rb +++ b/spec/shared/features/translatable.rb @@ -104,7 +104,7 @@ shared_examples "translatable" do |factory_name, path_name, input_fields, textar expect_page_to_have_translatable_field field, :en, with: text_for(field, :en) - select('Español', from: 'locale-switcher') + select("Español", from: "locale-switcher") expect_page_to_have_translatable_field field, :es, with: updated_text end @@ -190,7 +190,7 @@ shared_examples "translatable" do |factory_name, path_name, input_fields, textar expect_page_to_have_translatable_field field, :es, with: text_for(field, :es) end - scenario 'Change value of a translated field to blank', :js do + scenario "Change value of a translated field to blank", :js do skip("can't have translatable blank fields") if optional_fields.empty? field = optional_fields.sample @@ -198,11 +198,11 @@ shared_examples "translatable" do |factory_name, path_name, input_fields, textar visit path expect_page_to_have_translatable_field field, :en, with: text_for(field, :en) - fill_in_field field, :en, with: '' + fill_in_field field, :en, with: "" click_button update_button_text visit path - expect_page_to_have_translatable_field field, :en, with: '' + expect_page_to_have_translatable_field field, :en, with: "" end scenario "Add a translation for a locale with non-underscored name", :js do @@ -214,7 +214,7 @@ shared_examples "translatable" do |factory_name, path_name, input_fields, textar visit path - select('Português brasileiro', from: 'locale-switcher') + select("Português brasileiro", from: "locale-switcher") field = fields.sample expect_page_to_have_translatable_field field, :"pt-BR", with: text_for(field, :"pt-BR") @@ -227,7 +227,7 @@ shared_examples "translatable" do |factory_name, path_name, input_fields, textar expect(find("a.js-globalize-locale-link.is-active")).to have_content "English" - select('Español', from: 'locale-switcher') + select("Español", from: "locale-switcher") expect(find("a.js-globalize-locale-link.is-active")).to have_content "Español" end diff --git a/spec/shared/models/acts_as_imageable.rb b/spec/shared/models/acts_as_imageable.rb index 6bb1ec363..8186283c8 100644 --- a/spec/shared/models/acts_as_imageable.rb +++ b/spec/shared/models/acts_as_imageable.rb @@ -47,19 +47,19 @@ shared_examples "acts as imageable" do |imageable_factory| describe "title" do it "is not valid when correct image attached but no image title provided" do - image.title = '' + image.title = "" expect(image).not_to be_valid end it "is not valid when image title is too short" do - image.title = 'a' * 3 + image.title = "a" * 3 expect(image).not_to be_valid end it "is not valid when image title is too long" do - image.title = 'a' * 81 + image.title = "a" * 81 expect(image).not_to be_valid end @@ -69,7 +69,7 @@ shared_examples "acts as imageable" do |imageable_factory| it "image destroy should remove image from file storage" do image.save image_url = image.attachment.url - new_url = '/attachments/original/missing.png' + new_url = "/attachments/original/missing.png" expect{ image.attachment.destroy }.to change{ image.attachment.url }.from(image_url).to(new_url) end diff --git a/spec/shared/models/document_validations.rb b/spec/shared/models/document_validations.rb index 21d43ba62..c0717d87b 100644 --- a/spec/shared/models/document_validations.rb +++ b/spec/shared/models/document_validations.rb @@ -32,7 +32,7 @@ shared_examples "document validations" do |documentable_factory| end end - it 'is not valid for attachments larger than documentable max_file_size definition' do + it "is not valid for attachments larger than documentable max_file_size definition" do allow(document).to receive(:attachment_file_size).and_return(maxfilesize.megabytes + 1.byte) max_size_error_message = "must be in between 0 Bytes and #{maxfilesize} MB" diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c7b723b4d..90a85ea3c 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,8 +1,8 @@ -require 'factory_bot_rails' -require 'database_cleaner' -require 'email_spec' -require 'devise' -require 'knapsack_pro' +require "factory_bot_rails" +require "database_cleaner" +require "email_spec" +require "devise" +require "knapsack_pro" Dir["./spec/models/concerns/*.rb"].each { |f| require f } Dir["./spec/support/**/*.rb"].sort.each { |f| require f } @@ -44,7 +44,7 @@ RSpec.configure do |config| DatabaseCleaner.strategy = :transaction I18n.locale = :en Globalize.locale = I18n.locale - load Rails.root.join('db', 'seeds.rb').to_s + load Rails.root.join("db", "seeds.rb").to_s Setting["feature.user.skip_verification"] = nil end @@ -113,7 +113,7 @@ RSpec.configure do |config| # Use the documentation formatter for detailed output, # unless a formatter has already been configured # (e.g. via a command-line flag). - config.default_formatter = 'doc' + config.default_formatter = "doc" end # Print the 10 slowest examples and example groups at the diff --git a/spec/support/common_actions.rb b/spec/support/common_actions.rb index 881685354..4972d215e 100644 --- a/spec/support/common_actions.rb +++ b/spec/support/common_actions.rb @@ -13,12 +13,12 @@ module CommonActions include Verifications include Votes - def fill_in_signup_form(email = 'manuela@consul.dev', password = 'judgementday') - fill_in 'user_username', with: "Manuela Carmena #{rand(99999)}" - fill_in 'user_email', with: email - fill_in 'user_password', with: password - fill_in 'user_password_confirmation', with: password - check 'user_terms_of_service' + def fill_in_signup_form(email = "manuela@consul.dev", password = "judgementday") + fill_in "user_username", with: "Manuela Carmena #{rand(99999)}" + fill_in "user_email", with: email + fill_in "user_password", with: password + fill_in "user_password_confirmation", with: password + check "user_terms_of_service" end end diff --git a/spec/support/common_actions/budgets.rb b/spec/support/common_actions/budgets.rb index 97d4a53d5..5f3f3c0a3 100644 --- a/spec/support/common_actions/budgets.rb +++ b/spec/support/common_actions/budgets.rb @@ -1,12 +1,12 @@ module Budgets def expect_message_organizations_cannot_vote - expect(page).to have_content 'Organization' - expect(page).to have_selector('.in-favor a', visible: false) + expect(page).to have_content "Organization" + expect(page).to have_selector(".in-favor a", visible: false) end def add_to_ballot(budget_investment) within("#budget_investment_#{budget_investment.id}") do - find('.add a').click + find(".add a").click expect(page).to have_content "Remove" end end diff --git a/spec/support/common_actions/comments.rb b/spec/support/common_actions/comments.rb index 16683649b..1c8a60b7c 100644 --- a/spec/support/common_actions/comments.rb +++ b/spec/support/common_actions/comments.rb @@ -17,10 +17,10 @@ module Comments 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 - expect(page).to have_content 'It will be done next week.' + expect(page).to have_content "It will be done next week." end def avatar(name) diff --git a/spec/support/common_actions/emails.rb b/spec/support/common_actions/emails.rb index cbf3ec441..015be69a0 100644 --- a/spec/support/common_actions/emails.rb +++ b/spec/support/common_actions/emails.rb @@ -7,8 +7,8 @@ module Emails expect(page).to have_content "Send private message to #{receiver.name}" - fill_in 'direct_message_title', with: "Hey #{receiver.name}!" - fill_in 'direct_message_body', with: "How are you doing? This is #{sender.name}" + fill_in "direct_message_title", with: "Hey #{receiver.name}!" + fill_in "direct_message_body", with: "How are you doing? This is #{sender.name}" click_button "Send message" @@ -18,7 +18,7 @@ module Emails def fill_in_newsletter_form(options = {}) fill_in "newsletter_subject", with: (options[:subject] || "This is a different subject") - select (options[:segment_recipient] || 'All users'), from: 'newsletter_segment_recipient' + select (options[:segment_recipient] || "All users"), from: "newsletter_segment_recipient" fill_in "newsletter_from", with: (options[:from] || "no-reply@consul.dev") fill_in "newsletter_body", with: (options[:body] || "This is a different body") end diff --git a/spec/support/common_actions/notifications.rb b/spec/support/common_actions/notifications.rb index 4730ae42f..0aa0d9a82 100644 --- a/spec/support/common_actions/notifications.rb +++ b/spec/support/common_actions/notifications.rb @@ -10,7 +10,7 @@ module Notifications end def comment_body(resource) - "comment-body-#{resource.class.name.parameterize('_').to_sym}_#{resource.id}" + "comment-body-#{resource.class.name.parameterize("_").to_sym}_#{resource.id}" end def create_proposal_notification(proposal) @@ -23,8 +23,8 @@ module Notifications click_link "Send notification" end - fill_in 'proposal_notification_title', with: "Thanks for supporting proposal: #{proposal.title}" - fill_in 'proposal_notification_body', with: "Please share it with others! #{proposal.summary}" + fill_in "proposal_notification_title", with: "Thanks for supporting proposal: #{proposal.title}" + fill_in "proposal_notification_body", with: "Please share it with others! #{proposal.summary}" click_button "Send message" expect(page).to have_content "Your message has been sent correctly." @@ -37,14 +37,14 @@ module Notifications def error_message(resource_model = nil) resource_model ||= "(.*)" - field_check_message = 'Please check the marked fields to know how to correct them:' + field_check_message = "Please check the marked fields to know how to correct them:" /\d errors? prevented this #{resource_model} from being saved. #{field_check_message}/ end def fill_in_admin_notification_form(options = {}) - select (options[:segment_recipient] || 'All users'), from: :admin_notification_segment_recipient - fill_in 'Title', with: (options[:title] || 'This is the notification title') - fill_in 'Text', with: (options[:body] || 'This is the notification body') - fill_in :admin_notification_link, with: (options[:link] || 'https://www.decide.madrid.es/vota') + select (options[:segment_recipient] || "All users"), from: :admin_notification_segment_recipient + fill_in "Title", with: (options[:title] || "This is the notification title") + fill_in "Text", with: (options[:body] || "This is the notification body") + fill_in :admin_notification_link, with: (options[:link] || "https://www.decide.madrid.es/vota") end end diff --git a/spec/support/common_actions/polls.rb b/spec/support/common_actions/polls.rb index e98c9c5f3..b097c4355 100644 --- a/spec/support/common_actions/polls.rb +++ b/spec/support/common_actions/polls.rb @@ -23,14 +23,14 @@ module Polls def confirm_phone(user = nil) user ||= User.last - fill_in 'sms_phone', with: "611111111" - click_button 'Send' + fill_in "sms_phone", with: "611111111" + click_button "Send" - expect(page).to have_content 'Enter the confirmation code sent to you by text message' + expect(page).to have_content "Enter the confirmation code sent to you by text message" - fill_in 'sms_confirmation_code', with: user.reload.sms_confirmation_code - click_button 'Send' + fill_in "sms_confirmation_code", with: user.reload.sms_confirmation_code + click_button "Send" - expect(page).to have_content 'Code correct' + expect(page).to have_content "Code correct" end end diff --git a/spec/support/common_actions/users.rb b/spec/support/common_actions/users.rb index 7638caea8..690bdbfdf 100644 --- a/spec/support/common_actions/users.rb +++ b/spec/support/common_actions/users.rb @@ -1,46 +1,46 @@ module Users - def sign_up(email = 'manuela@consul.dev', password = 'judgementday') - visit '/' + def sign_up(email = "manuela@consul.dev", password = "judgementday") + visit "/" - click_link 'Register' + click_link "Register" - fill_in 'user_username', with: "Manuela Carmena #{rand(99999)}" - fill_in 'user_email', with: email - fill_in 'user_password', with: password - fill_in 'user_password_confirmation', with: password - check 'user_terms_of_service' + fill_in "user_username", with: "Manuela Carmena #{rand(99999)}" + fill_in "user_email", with: email + fill_in "user_password", with: password + fill_in "user_password_confirmation", with: password + check "user_terms_of_service" - click_button 'Register' + click_button "Register" end - def login_through_form_with_email_and_password(email='manuela@consul.dev', password='judgementday') + def login_through_form_with_email_and_password(email="manuela@consul.dev", password="judgementday") visit root_path - click_link 'Sign in' + click_link "Sign in" - fill_in 'user_login', with: email - fill_in 'user_password', with: password + fill_in "user_login", with: email + fill_in "user_password", with: password - click_button 'Enter' + click_button "Enter" end def login_through_form_as(user) visit root_path - click_link 'Sign in' + click_link "Sign in" - fill_in 'user_login', with: user.email - fill_in 'user_password', with: user.password + fill_in "user_login", with: user.email + fill_in "user_password", with: user.password - click_button 'Enter' + click_button "Enter" end def login_through_form_as_officer(user) visit root_path - click_link 'Sign in' + click_link "Sign in" - fill_in 'user_login', with: user.email - fill_in 'user_password', with: user.password + fill_in "user_login", with: user.email + fill_in "user_password", with: user.password - click_button 'Enter' + click_button "Enter" visit new_officing_residence_path end @@ -65,21 +65,21 @@ module Users end def reset_password - create(:user, email: 'manuela@consul.dev') + create(:user, email: "manuela@consul.dev") - visit '/' - click_link 'Sign in' - click_link 'Forgotten your password?' + visit "/" + click_link "Sign in" + click_link "Forgotten your password?" - fill_in 'user_email', with: 'manuela@consul.dev' - click_button 'Send instructions' + fill_in "user_email", with: "manuela@consul.dev" + click_button "Send instructions" end def expect_to_be_signed_in - expect(find('.top-bar-right')).to have_content 'My account' + expect(find(".top-bar-right")).to have_content "My account" end def expect_not_to_be_signed_in - expect(find('.top-bar-right')).not_to have_content 'My account' + expect(find(".top-bar-right")).not_to have_content "My account" end end diff --git a/spec/support/common_actions/verifications.rb b/spec/support/common_actions/verifications.rb index 9e5e8ed79..1d402522c 100644 --- a/spec/support/common_actions/verifications.rb +++ b/spec/support/common_actions/verifications.rb @@ -8,26 +8,26 @@ module Verifications end def verify_residence - select 'DNI', from: 'residence_document_type' - fill_in 'residence_document_number', with: "12345678Z" + select "DNI", from: "residence_document_type" + fill_in "residence_document_number", with: "12345678Z" select_date "31-#{I18n.l(Date.current.at_end_of_year, format: "%B")}-1980", from: "residence_date_of_birth" - fill_in 'residence_postal_code', with: '28013' - check 'residence_terms_of_service' + fill_in "residence_postal_code", with: "28013" + check "residence_terms_of_service" click_button "new_residence_submit" expect(page).to have_content I18n.t("verification.residence.create.flash.success") end def officing_verify_residence - select 'DNI', from: 'residence_document_type' - fill_in 'residence_document_number', with: "12345678Z" - fill_in 'residence_year_of_birth', with: "1980" + select "DNI", from: "residence_document_type" + fill_in "residence_document_number", with: "12345678Z" + fill_in "residence_year_of_birth", with: "1980" - click_button 'Validate document' + click_button "Validate document" - expect(page).to have_content 'Document verified with Census' + expect(page).to have_content "Document verified with Census" end def expect_badge_for(resource_name, resource) @@ -53,11 +53,11 @@ module Verifications # @param [String] locator label text for the textarea or textarea id def fill_in_ckeditor(locator, params = {}) # Find out ckeditor id at runtime using its label - locator = find('label', text: locator)[:for] if page.has_css?('label', text: locator) + locator = find("label", text: locator)[:for] if page.has_css?("label", text: locator) # Fill the editor content page.execute_script <<-SCRIPT var ckeditor = CKEDITOR.instances.#{locator} - ckeditor.setData('#{params[:with]}') + ckeditor.setData("#{params[:with]}") ckeditor.focus() ckeditor.updateElement() SCRIPT diff --git a/spec/support/common_actions/votes.rb b/spec/support/common_actions/votes.rb index 30cf8bd2e..6eff866a8 100644 --- a/spec/support/common_actions/votes.rb +++ b/spec/support/common_actions/votes.rb @@ -1,27 +1,27 @@ module Votes def expect_message_you_need_to_sign_in - expect(page).to have_content 'You must Sign in or Sign up to continue' - expect(page).to have_selector('.in-favor', visible: false) + expect(page).to have_content "You must Sign in or Sign up to continue" + expect(page).to have_selector(".in-favor", visible: false) end def expect_message_you_need_to_sign_in_to_vote_comments - expect(page).to have_content 'You must Sign in or Sign up to vote' - expect(page).to have_selector('.participation-allowed', visible: false) - expect(page).to have_selector('.participation-not-allowed', visible: true) + expect(page).to have_content "You must Sign in or Sign up to vote" + expect(page).to have_selector(".participation-allowed", visible: false) + expect(page).to have_selector(".participation-not-allowed", visible: true) end def expect_message_to_many_anonymous_votes - expect(page).to have_content 'Too many anonymous votes to admit vote' - expect(page).to have_selector('.in-favor a', visible: false) + expect(page).to have_content "Too many anonymous votes to admit vote" + expect(page).to have_selector(".in-favor a", visible: false) end def expect_message_only_verified_can_vote_proposals - expect(page).to have_content 'Only verified users can vote on proposals' - expect(page).to have_selector('.in-favor', visible: false) + expect(page).to have_content "Only verified users can vote on proposals" + expect(page).to have_selector(".in-favor", visible: false) end def expect_message_voting_not_allowed - expect(page).to have_content 'Voting phase is closed' - expect(page).not_to have_selector('.in-favor a') + expect(page).to have_content "Voting phase is closed" + expect(page).not_to have_selector(".in-favor a") end end diff --git a/spec/support/verifiable.rb b/spec/support/verifiable.rb index dec01cddb..53070da4d 100644 --- a/spec/support/verifiable.rb +++ b/spec/support/verifiable.rb @@ -90,7 +90,7 @@ shared_examples_for "verifiable" do end end - describe '#sms_verified?' do + describe "#sms_verified?" do it "is true only if confirmed_phone" do user = create(:user, confirmed_phone: "123456789") expect(user.sms_verified?).to eq(true) @@ -100,7 +100,7 @@ shared_examples_for "verifiable" do end end - describe '#level_two_verified?' do + describe "#level_two_verified?" do it "is true if manually set, or if residence_verified_at and confirmed_phone" do user = create(:user, level_two_verified_at: Time.current) expect(user.level_two_verified?).to eq(true) @@ -116,7 +116,7 @@ shared_examples_for "verifiable" do end end - describe '#level_three_verified?' do + describe "#level_three_verified?" do it "is true only if verified_at" do user = create(:user, verified_at: Time.current) expect(user.level_three_verified?).to eq(true) @@ -126,7 +126,7 @@ shared_examples_for "verifiable" do end end - describe '#unverified?' do + describe "#unverified?" do it "is true only if not level_three_verified and not level_two_verified" do user = create(:user, verified_at: nil, confirmed_phone: nil) expect(user.unverified?).to eq(true) @@ -137,7 +137,7 @@ shared_examples_for "verifiable" do end end - describe '#verification_email_sent?' do + describe "#verification_email_sent?" do it "is true only if user has email_verification_token" do user = create(:user, email_verification_token: "xxxxxxx") expect(user.verification_email_sent?).to eq(true) @@ -147,7 +147,7 @@ shared_examples_for "verifiable" do end end - describe '#verification_sms_sent?' do + describe "#verification_sms_sent?" do it "is true if user has unconfirmed_phone & sms_confirmation_code" do user = create(:user, unconfirmed_phone: "666666666", sms_confirmation_code: "666") expect(user.verification_sms_sent?).to eq(true) @@ -163,7 +163,7 @@ shared_examples_for "verifiable" do end end - describe '#verification_letter_sent?' do + describe "#verification_letter_sent?" do it "is true if user has letter_requested_at & letter_verification_code" do user = create(:user, letter_requested_at: Time.current, letter_verification_code: "666") expect(user.verification_letter_sent?).to eq(true) @@ -184,7 +184,7 @@ shared_examples_for "verifiable" do let(:user) {create(:user)} before do - Setting["feature.user.skip_verification"] = 'true' + Setting["feature.user.skip_verification"] = "true" end after do diff --git a/spec/views/welcome/index.html.erb_spec.rb b/spec/views/welcome/index.html.erb_spec.rb index 7d01dede0..d5a3a1683 100644 --- a/spec/views/welcome/index.html.erb_spec.rb +++ b/spec/views/welcome/index.html.erb_spec.rb @@ -2,7 +2,7 @@ require "rails_helper" RSpec.describe "welcome#index" do - it 'Display images on orbit carrousel when we have defined image_default' do + it "Display images on orbit carrousel when we have defined image_default" do debate = create(:debate) render template: "welcome/_recommended_carousel.html.erb", @@ -21,7 +21,7 @@ RSpec.describe "welcome#index" do end - it 'Not display images on orbit carrousel when we have not defined image_default' do + it "Not display images on orbit carrousel when we have not defined image_default" do debate = create(:debate) render template: "welcome/_recommended_carousel.html.erb",