Merge pull request #1680 from consul/chore/small_rubocop_cleanup

Chore/small rubocop cleanup
This commit is contained in:
Raimond Garcia
2017-06-26 17:42:10 +02:00
committed by GitHub
31 changed files with 60 additions and 103 deletions

View File

@@ -31,6 +31,9 @@ Style/FrozenStringLiteralComment:
Style/PercentLiteralDelimiters: Style/PercentLiteralDelimiters:
Enabled: false Enabled: false
Style/SymbolArray:
Enabled: false
Layout/EmptyLinesAroundClassBody: Layout/EmptyLinesAroundClassBody:
Enabled: false Enabled: false

View File

@@ -86,14 +86,6 @@ Performance/RedundantMatch:
- 'app/controllers/valuation/spending_proposals_controller.rb' - 'app/controllers/valuation/spending_proposals_controller.rb'
- 'app/helpers/embed_videos_helper.rb' - 'app/helpers/embed_videos_helper.rb'
# Offense count: 2
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: strict, flexible
Rails/Date:
Exclude:
- 'app/controllers/concerns/commentable_actions.rb'
- 'app/models/direct_message.rb'
# Offense count: 4 # Offense count: 4
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: Whitelist. # Configuration parameters: Whitelist.
@@ -138,35 +130,6 @@ Rails/OutputSafety:
- 'app/helpers/users_helper.rb' - 'app/helpers/users_helper.rb'
- 'app/helpers/valuation_helper.rb' - 'app/helpers/valuation_helper.rb'
# Offense count: 6
# Cop supports --auto-correct.
Rails/PluralizationGrammar:
Exclude:
- 'spec/features/admin/banners_spec.rb'
- 'spec/features/debates_spec.rb'
- 'spec/features/proposals_spec.rb'
- 'spec/models/residence_spec.rb'
# Offense count: 11
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: strict, flexible
Rails/TimeZone:
Exclude:
- 'lib/score_calculator.rb'
- 'spec/controllers/admin/api/stats_controller_spec.rb'
- 'spec/models/ahoy/data_source_spec.rb'
# Offense count: 7
# Cop supports --auto-correct.
# Configuration parameters: Include.
# Include: app/models/**/*.rb
Rails/Validation:
Exclude:
- 'app/models/comment.rb'
- 'app/models/spending_proposal.rb'
- 'app/models/verification/residence.rb'
- 'app/models/verification/sms.rb'
# Offense count: 9 # Offense count: 9
Style/AccessorMethodName: Style/AccessorMethodName:
Exclude: Exclude:
@@ -202,13 +165,6 @@ Layout/AlignParameters:
- 'spec/models/user_spec.rb' - 'spec/models/user_spec.rb'
- 'spec/rails_helper.rb' - 'spec/rails_helper.rb'
# Offense count: 2
# Cop supports --auto-correct.
Layout/BlockEndNewline:
Exclude:
- 'app/models/banner.rb'
- 'spec/features/users_auth_spec.rb'
# Offense count: 19 # Offense count: 19
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles. # Configuration parameters: EnforcedStyle, SupportedStyles.
@@ -290,12 +246,6 @@ Layout/EmptyLines:
- 'spec/features/verification/verified_user_spec.rb' - 'spec/features/verification/verified_user_spec.rb'
- 'spec/support/verifiable.rb' - 'spec/support/verifiable.rb'
# Offense count: 1
# Cop supports --auto-correct.
Layout/EmptyLinesAroundAccessModifier:
Exclude:
- 'app/controllers/users_controller.rb'
# Offense count: 29 # Offense count: 29
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment, ForceEqualSignAlignment. # Configuration parameters: AllowForAlignment, ForceEqualSignAlignment.

View File

@@ -67,6 +67,7 @@ class Admin::Poll::PollsController < Admin::BaseController
end end
private private
def load_geozones def load_geozones
@geozones = Geozone.all.order(:name) @geozones = Geozone.all.order(:name)
end end

View File

@@ -26,6 +26,7 @@ class Legislation::AnswersController < Legislation::BaseController
end end
private private
def answer_params def answer_params
params.require(:legislation_answer).permit( params.require(:legislation_answer).permit(
:legislation_question_option_id, :legislation_question_option_id,

View File

@@ -28,6 +28,7 @@ class Officing::FinalRecountsController < Officing::BaseController
end end
private private
def load_poll def load_poll
@poll = Poll.expired.find(params[:poll_id]) @poll = Poll.expired.find(params[:poll_id])
end end

View File

@@ -27,6 +27,7 @@ class Officing::RecountsController < Officing::BaseController
end end
private private
def load_poll def load_poll
@poll = Poll.find(params[:poll_id]) @poll = Poll.find(params[:poll_id])
end end

View File

@@ -30,7 +30,7 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
identity = Identity.first_or_create_from_oauth(auth) identity = Identity.first_or_create_from_oauth(auth)
@user = current_user || identity.user || User.first_or_initialize_for_oauth(auth) @user = current_user || identity.user || User.first_or_initialize_for_oauth(auth)
if save_user(@user) if save_user
identity.update(user: @user) identity.update(user: @user)
sign_in_and_redirect @user, event: :authentication sign_in_and_redirect @user, event: :authentication
set_flash_message(:notice, :success, kind: "#{provider}".capitalize) if is_navigational_format? set_flash_message(:notice, :success, kind: "#{provider}".capitalize) if is_navigational_format?
@@ -40,7 +40,7 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
end end
end end
def save_user(user) def save_user
@user.save || @user.save_requiring_finish_signup @user.save || @user.save_requiring_finish_signup
end end

View File

@@ -10,6 +10,7 @@ class UsersController < ApplicationController
end end
private private
def set_activity_counts def set_activity_counts
@activity_counts = HashWithIndifferentAccess.new( @activity_counts = HashWithIndifferentAccess.new(
proposals: Proposal.where(author_id: @user.id).count, proposals: Proposal.where(author_id: @user.id).count,

View File

@@ -12,9 +12,8 @@ class Banner < ActiveRecord::Base
validates :post_started_at, presence: true validates :post_started_at, presence: true
validates :post_ended_at, presence: true validates :post_ended_at, presence: true
scope :with_active, -> {where("post_started_at <= ?", Time.current). scope :with_active, -> { where("post_started_at <= ?", Time.current).where("post_ended_at >= ?", Time.current) }
where("post_ended_at >= ?", Time.current) }
scope :with_inactive,-> {where("post_started_at > ? or post_ended_at < ?", Time.current, Time.current) } scope :with_inactive, -> { where("post_started_at > ? or post_ended_at < ?", Time.current, Time.current) }
end end

View File

@@ -26,8 +26,8 @@ class Budget
validates :author, presence: true validates :author, presence: true
validates :description, presence: true validates :description, presence: true
validates :heading_id, presence: true validates :heading_id, presence: true
validates_presence_of :unfeasibility_explanation, if: :unfeasibility_explanation_required? validates :unfeasibility_explanation, presence: { if: :unfeasibility_explanation_required? }
validates_presence_of :price, if: :price_required? validates :price, presence: { if: :price_required? }
validates :title, length: { in: 4..Budget::Investment.title_max_length } validates :title, length: { in: 4..Budget::Investment.title_max_length }
validates :description, length: { maximum: Budget::Investment.description_max_length } validates :description, length: { maximum: Budget::Investment.description_max_length }

View File

@@ -13,7 +13,7 @@ class Comment < ActiveRecord::Base
validates :body, presence: true validates :body, presence: true
validates :user, presence: true validates :user, presence: true
validates_inclusion_of :commentable_type, in: ["Debate", "Proposal", "Budget::Investment", "Poll::Question", "Legislation::Question", "Legislation::Annotation"] validates :commentable_type, inclusion: { in: ["Debate", "Proposal", "Budget::Investment", "Poll::Question", "Legislation::Question", "Legislation::Annotation"] }
validate :validate_body_length validate :validate_body_length

View File

@@ -6,9 +6,9 @@ class Officing::Residence
before_validation :call_census_api before_validation :call_census_api
validates_presence_of :document_number validates :document_number, presence: true
validates_presence_of :document_type validates :document_type, presence: true
validates_presence_of :year_of_birth validates :year_of_birth, presence: true
validate :allowed_age validate :allowed_age
validate :residence_in_madrid validate :residence_in_madrid

View File

@@ -15,7 +15,7 @@ class SpendingProposal < ActiveRecord::Base
validates :title, presence: true validates :title, presence: true
validates :author, presence: true validates :author, presence: true
validates :description, presence: true validates :description, presence: true
validates_presence_of :feasible_explanation, if: :feasible_explanation_required? validates :feasible_explanation, presence: { if: :feasible_explanation_required? }
validates :title, length: { in: 4..SpendingProposal.title_max_length } validates :title, length: { in: 4..SpendingProposal.title_max_length }
validates :description, length: { maximum: SpendingProposal.description_max_length } validates :description, length: { maximum: SpendingProposal.description_max_length }

View File

@@ -7,10 +7,10 @@ class Verification::Residence
before_validation :call_census_api before_validation :call_census_api
validates_presence_of :document_number validates :document_number, presence: true
validates_presence_of :document_type validates :document_type, presence: true
validates_presence_of :date_of_birth validates :date_of_birth, presence: true
validates_presence_of :postal_code validates :postal_code, presence: true
validates :terms_of_service, acceptance: { allow_nil: false } validates :terms_of_service, acceptance: { allow_nil: false }
validates :postal_code, length: { is: 5 } validates :postal_code, length: { is: 5 }

View File

@@ -3,7 +3,7 @@ class Verification::Sms
attr_accessor :user, :phone, :confirmation_code attr_accessor :user, :phone, :confirmation_code
validates_presence_of :phone validates :phone, presence: true
validates :phone, format: { with: /\A[\d \+]+\z/ } validates :phone, format: { with: /\A[\d \+]+\z/ }
validate :uniqness_phone validate :uniqness_phone

View File

@@ -1,6 +1,6 @@
module ScoreCalculator module ScoreCalculator
EPOC = Time.new(2015, 6, 15) EPOC = Time.new(2015, 6, 15).in_time_zone
COMMENT_WEIGHT = 1.0/5 # 1 positive vote / x comments COMMENT_WEIGHT = 1.0/5 # 1 positive vote / x comments
TIME_UNIT = 24.hours.to_f TIME_UNIT = 24.hours.to_f

View File

@@ -17,9 +17,9 @@ describe Admin::Api::StatsController do
context 'events present' do context 'events present' do
before :each do before :each do
time_1 = DateTime.parse("2015-01-01") time_1 = DateTime.parse("2015-01-01").in_time_zone
time_2 = DateTime.parse("2015-01-02") time_2 = DateTime.parse("2015-01-02").in_time_zone
time_3 = DateTime.parse("2015-01-03") time_3 = DateTime.parse("2015-01-03").in_time_zone
create :ahoy_event, name: 'foo', time: time_1 create :ahoy_event, name: 'foo', time: time_1
create :ahoy_event, name: 'foo', time: time_1 create :ahoy_event, name: 'foo', time: time_1
@@ -52,8 +52,8 @@ describe Admin::Api::StatsController do
context 'visits present' do context 'visits present' do
it 'should return visits formated for working with c3.js' do it 'should return visits formated for working with c3.js' do
time_1 = DateTime.parse("2015-01-01") time_1 = DateTime.parse("2015-01-01").in_time_zone
time_2 = DateTime.parse("2015-01-02") time_2 = DateTime.parse("2015-01-02").in_time_zone
create :visit, started_at: time_1 create :visit, started_at: time_1
create :visit, started_at: time_1 create :visit, started_at: time_1
@@ -71,8 +71,8 @@ describe Admin::Api::StatsController do
context 'visits and events present' do context 'visits and events present' do
it 'should return combined events and visits formated for working with c3.js' do it 'should return combined events and visits formated for working with c3.js' do
time_1 = DateTime.parse("2015-01-01") time_1 = DateTime.parse("2015-01-01").in_time_zone
time_2 = DateTime.parse("2015-01-02") time_2 = DateTime.parse("2015-01-02").in_time_zone
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: 'foo', time: time_2
@@ -94,8 +94,8 @@ describe Admin::Api::StatsController do
context 'budget investments present' do context 'budget investments present' do
it 'should return budget investments formated for working with c3.js' do it 'should return budget investments formated for working with c3.js' do
time_1 = DateTime.parse("2017-04-01") time_1 = DateTime.parse("2017-04-01").in_time_zone
time_2 = DateTime.parse("2017-04-02") time_2 = DateTime.parse("2017-04-02").in_time_zone
budget_investment1 = create(:budget_investment, budget: @budget, created_at: time_1) budget_investment1 = create(:budget_investment, budget: @budget, created_at: time_1)
budget_investment2 = create(:budget_investment, budget: @budget, created_at: time_2) budget_investment2 = create(:budget_investment, budget: @budget, created_at: time_2)

View File

@@ -4,7 +4,7 @@ describe CommentsController do
describe 'POST create' do describe 'POST create' do
before(:each) do before(:each) do
@process = create(:legislation_process, debate_start_date: Date.current - 3.day, debate_end_date: Date.current + 2.days) @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") @question = create(:legislation_question, process: @process, title: "Question 1")
@user = create(:user, :level_two) @user = create(:user, :level_two)
@unverified_user = create(:user) @unverified_user = create(:user)

View File

@@ -4,7 +4,7 @@ describe Legislation::AnnotationsController do
describe 'POST create' do describe 'POST create' do
before(:each) do before(:each) do
@process = create(:legislation_process, allegations_start_date: Date.current - 3.day, allegations_end_date: Date.current + 2.days) @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") @draft_version = create(:legislation_draft_version, :published, process: @process, title: "Version 1")
@final_version = create(:legislation_draft_version, :published, :final_version, process: @process, title: "Final version") @final_version = create(:legislation_draft_version, :published, :final_version, process: @process, title: "Final version")
@user = create(:user, :level_two) @user = create(:user, :level_two)

View File

@@ -4,7 +4,7 @@ describe Legislation::AnswersController do
describe 'POST create' do describe 'POST create' do
before(:each) do before(:each) do
@process = create(:legislation_process, debate_start_date: Date.current - 3.day, debate_end_date: Date.current + 2.days) @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") @question = create(:legislation_question, process: @process, title: "Question 1")
@question_option = create(:legislation_question_option, question: @question, value: "Yes") @question_option = create(:legislation_question_option, question: @question, value: "Yes")
@user = create(:user, :level_two) @user = create(:user, :level_two)

View File

@@ -638,7 +638,7 @@ FactoryGirl.define do
end_date Date.current + 8.days end_date Date.current + 8.days
debate_start_date Date.current + 2.days debate_start_date Date.current + 2.days
debate_end_date Date.current + 4.days debate_end_date Date.current + 4.days
draft_publication_date Date.current + 5.day draft_publication_date Date.current + 5.days
allegations_start_date Date.current + 5.days allegations_start_date Date.current + 5.days
allegations_end_date Date.current + 7.days allegations_end_date Date.current + 7.days
result_publication_date Date.current + 8.days result_publication_date Date.current + 8.days
@@ -649,7 +649,7 @@ FactoryGirl.define do
end_date Date.current - 2.days end_date Date.current - 2.days
debate_start_date Date.current - 12.days debate_start_date Date.current - 12.days
debate_end_date Date.current - 9.days debate_end_date Date.current - 9.days
draft_publication_date Date.current - 8.day draft_publication_date Date.current - 8.days
allegations_start_date Date.current - 8.days allegations_start_date Date.current - 8.days
allegations_end_date Date.current - 4.days allegations_end_date Date.current - 4.days
result_publication_date Date.current - 2.days result_publication_date Date.current - 2.days
@@ -659,7 +659,7 @@ FactoryGirl.define do
start_date Date.current - 5.days start_date Date.current - 5.days
end_date Date.current + 5.days end_date Date.current + 5.days
debate_start_date Date.current - 5.days debate_start_date Date.current - 5.days
debate_end_date Date.current + 1.days debate_end_date Date.current + 1.day
draft_publication_date Date.current + 1.day draft_publication_date Date.current + 1.day
allegations_start_date Date.current + 2.days allegations_start_date Date.current + 2.days
allegations_end_date Date.current + 3.days allegations_end_date Date.current + 3.days

View File

@@ -29,7 +29,7 @@ feature 'Admin banners magement' do
target_url: "http://www.url.com", target_url: "http://www.url.com",
style: "banner-style.banner-three", style: "banner-style.banner-three",
image: "banner-img.banner-three", image: "banner-img.banner-three",
post_started_at: (Time.current - 1.days), post_started_at: (Time.current - 1.day),
post_ended_at: (Time.current + 10.days)) post_ended_at: (Time.current + 10.days))
@banner4 = create(:banner, title: "Banner number four", @banner4 = create(:banner, title: "Banner number four",

View File

@@ -192,7 +192,7 @@ feature 'Commenting legislation questions' do
end end
scenario "Can't create comments if debate phase is not open", :js do scenario "Can't create comments if debate phase is not open", :js do
process.update_attributes(debate_start_date: Date.current - 2.days, debate_end_date: Date.current - 1.days) process.update_attributes(debate_start_date: Date.current - 2.days, debate_end_date: Date.current - 1.day)
login_as(user) login_as(user)
visit legislation_process_question_path(legislation_question.process, legislation_question) visit legislation_process_question_path(legislation_question.process, legislation_question)

View File

@@ -629,7 +629,7 @@ feature 'Debates' do
click_link "Advanced search" click_link "Advanced search"
select "Customized", from: "js-advanced-search-date-min" select "Customized", from: "js-advanced-search-date-min"
fill_in "advanced_search_date_min", with: 7.days.ago fill_in "advanced_search_date_min", with: 7.days.ago
fill_in "advanced_search_date_max", with: 1.days.ago fill_in "advanced_search_date_max", with: 1.day.ago
click_button "Filter" click_button "Filter"
within("#debates") do within("#debates") do
@@ -709,7 +709,7 @@ feature 'Debates' do
select "Customized", from: "js-advanced-search-date-min" select "Customized", from: "js-advanced-search-date-min"
fill_in "advanced_search_date_min", with: 7.days.ago fill_in "advanced_search_date_min", with: 7.days.ago
fill_in "advanced_search_date_max", with: 1.days.ago fill_in "advanced_search_date_max", with: 1.day.ago
click_button "Filter" click_button "Filter"
within "#js-advanced-search" do within "#js-advanced-search" do

View File

@@ -3,7 +3,7 @@ require 'rails_helper'
feature 'Legislation' do feature 'Legislation' do
context 'process debate page' do context 'process debate page' do
before(:each) do before(:each) do
@process = create(:legislation_process, debate_start_date: Date.current - 3.day, debate_end_date: Date.current + 2.days) @process = create(:legislation_process, debate_start_date: Date.current - 3.days, debate_end_date: Date.current + 2.days)
create(:legislation_question, process: @process, title: "Question 1") create(:legislation_question, process: @process, title: "Question 1")
create(:legislation_question, process: @process, title: "Question 2") create(:legislation_question, process: @process, title: "Question 2")
create(:legislation_question, process: @process, title: "Question 3") create(:legislation_question, process: @process, title: "Question 3")

View File

@@ -1025,7 +1025,7 @@ feature 'Proposals' do
click_link "Advanced search" click_link "Advanced search"
select "Customized", from: "js-advanced-search-date-min" select "Customized", from: "js-advanced-search-date-min"
fill_in "advanced_search_date_min", with: 7.days.ago fill_in "advanced_search_date_min", with: 7.days.ago
fill_in "advanced_search_date_max", with: 1.days.ago fill_in "advanced_search_date_max", with: 1.day.ago
click_button "Filter" click_button "Filter"
expect(page).to have_content("There are 2 citizen proposals") expect(page).to have_content("There are 2 citizen proposals")
@@ -1108,7 +1108,7 @@ feature 'Proposals' do
select "Customized", from: "js-advanced-search-date-min" select "Customized", from: "js-advanced-search-date-min"
fill_in "advanced_search_date_min", with: 7.days.ago.to_date fill_in "advanced_search_date_min", with: 7.days.ago.to_date
fill_in "advanced_search_date_max", with: 1.days.ago.to_date fill_in "advanced_search_date_max", with: 1.day.ago.to_date
click_button "Filter" click_button "Filter"
expect(page).to have_content("citizen proposals cannot be found") expect(page).to have_content("citizen proposals cannot be found")

View File

@@ -321,7 +321,7 @@ describe 'ConsulSchema' do
it 'does not include hidden comments' do it 'does not include hidden comments' do
visible_comment = create(:comment) visible_comment = create(:comment)
hidden_comment = create(:comment, hidden_at: Time.now) hidden_comment = create(:comment, hidden_at: Time.current)
response = execute('{ comments { edges { node { body } } } }') response = execute('{ comments { edges { node { body } } } }')
received_comments = extract_fields(response, 'comments', 'body') received_comments = extract_fields(response, 'comments', 'body')
@@ -331,7 +331,7 @@ describe 'ConsulSchema' do
it 'does not include comments from hidden proposals' do it 'does not include comments from hidden proposals' do
visible_proposal = create(:proposal) visible_proposal = create(:proposal)
hidden_proposal = create(:proposal, hidden_at: Time.now) hidden_proposal = create(:proposal, hidden_at: Time.current)
visible_proposal_comment = create(:comment, commentable: visible_proposal) visible_proposal_comment = create(:comment, commentable: visible_proposal)
hidden_proposal_comment = create(:comment, commentable: hidden_proposal) hidden_proposal_comment = create(:comment, commentable: hidden_proposal)
@@ -344,7 +344,7 @@ describe 'ConsulSchema' do
it 'does not include comments from hidden debates' do it 'does not include comments from hidden debates' do
visible_debate = create(:debate) visible_debate = create(:debate)
hidden_debate = create(:debate, hidden_at: Time.now) hidden_debate = create(:debate, hidden_at: Time.current)
visible_debate_comment = create(:comment, commentable: visible_debate) visible_debate_comment = create(:comment, commentable: visible_debate)
hidden_debate_comment = create(:comment, commentable: hidden_debate) hidden_debate_comment = create(:comment, commentable: hidden_debate)
@@ -567,7 +567,7 @@ describe 'ConsulSchema' do
it 'does not include votes of hidden proposals' do it 'does not include votes of hidden proposals' do
visible_proposal = create(:proposal) visible_proposal = create(:proposal)
hidden_proposal = create(:proposal, hidden_at: Time.now) hidden_proposal = create(:proposal, hidden_at: Time.current)
visible_proposal_vote = create(:vote, votable: visible_proposal) visible_proposal_vote = create(:vote, votable: visible_proposal)
hidden_proposal_vote = create(:vote, votable: hidden_proposal) hidden_proposal_vote = create(:vote, votable: hidden_proposal)
@@ -580,7 +580,7 @@ describe 'ConsulSchema' do
it 'does not include votes of hidden comments' do it 'does not include votes of hidden comments' do
visible_comment = create(:comment) visible_comment = create(:comment)
hidden_comment = create(:comment, hidden_at: Time.now) hidden_comment = create(:comment, hidden_at: Time.current)
visible_comment_vote = create(:vote, votable: visible_comment) visible_comment_vote = create(:vote, votable: visible_comment)
hidden_comment_vote = create(:vote, votable: hidden_comment) hidden_comment_vote = create(:vote, votable: hidden_comment)

View File

@@ -3,9 +3,9 @@ require 'rails_helper'
describe Ahoy::DataSource do describe Ahoy::DataSource do
describe '#build' do describe '#build' do
before :each do before :each do
time_1 = DateTime.parse("2015-01-01") time_1 = DateTime.parse("2015-01-01").in_time_zone
time_2 = DateTime.parse("2015-01-02") time_2 = DateTime.parse("2015-01-02").in_time_zone
time_3 = DateTime.parse("2015-01-03") time_3 = DateTime.parse("2015-01-03").in_time_zone
create :ahoy_event, name: 'foo', time: time_1 create :ahoy_event, name: 'foo', time: time_1
create :ahoy_event, name: 'foo', time: time_1 create :ahoy_event, name: 'foo', time: time_1

View File

@@ -71,7 +71,7 @@ RSpec.describe Legislation::Process, type: :model do
describe "filter scopes" do describe "filter scopes" do
before(:each) do before(:each) do
@process_1 = create(:legislation_process, start_date: Date.current - 2.days, end_date: Date.current + 1.day) @process_1 = create(:legislation_process, start_date: Date.current - 2.days, end_date: Date.current + 1.day)
@process_2 = create(:legislation_process, start_date: Date.current + 1.days, end_date: Date.current + 3.days) @process_2 = create(:legislation_process, start_date: Date.current + 1.day, end_date: Date.current + 3.days)
@process_3 = create(:legislation_process, start_date: Date.current - 4.days, end_date: Date.current - 3.days) @process_3 = create(:legislation_process, start_date: Date.current - 4.days, end_date: Date.current - 3.days)
end end

View File

@@ -48,7 +48,7 @@ describe :officer do
poll_1 = create(:poll, ends_at: 1.day.ago) poll_1 = create(:poll, ends_at: 1.day.ago)
poll_2 = create(:poll, ends_at: 10.days.from_now) poll_2 = create(:poll, ends_at: 10.days.from_now)
poll_3 = create(:poll, ends_at: 10.day.ago) poll_3 = create(:poll, ends_at: 10.days.ago)
[poll_1, poll_2, poll_3].each do |p| [poll_1, poll_2, poll_3].each do |p|
create(:poll_officer_assignment, officer: officer, booth_assignment: create(:poll_booth_assignment, poll: p)) create(:poll_officer_assignment, officer: officer, booth_assignment: create(:poll_booth_assignment, poll: p))
@@ -108,7 +108,7 @@ describe :officer do
poll_1 = create(:poll, ends_at: 1.day.ago) poll_1 = create(:poll, ends_at: 1.day.ago)
poll_2 = create(:poll, ends_at: 10.days.from_now) poll_2 = create(:poll, ends_at: 10.days.from_now)
poll_3 = create(:poll, ends_at: 10.day.ago) poll_3 = create(:poll, ends_at: 10.days.ago)
[poll_1, poll_2, poll_3].each do |p| [poll_1, poll_2, poll_3].each do |p|
create(:poll_officer_assignment, officer: officer, booth_assignment: create(:poll_booth_assignment, poll: p), final: true) create(:poll_officer_assignment, officer: officer, booth_assignment: create(:poll_booth_assignment, poll: p), final: true)

View File

@@ -25,7 +25,7 @@ describe Verification::Residence do
end end
it "should validate user has allowed age" do it "should validate user has allowed age" do
residence = Verification::Residence.new({"date_of_birth(3i)"=>"1", "date_of_birth(2i)"=>"1", "date_of_birth(1i)"=>"#{5.year.ago.year}"}) residence = Verification::Residence.new({"date_of_birth(3i)"=>"1", "date_of_birth(2i)"=>"1", "date_of_birth(1i)"=>"#{5.years.ago.year}"})
expect(residence).to_not be_valid expect(residence).to_not be_valid
expect(residence.errors[:date_of_birth]).to include("You don't have the required age to participate") expect(residence.errors[:date_of_birth]).to include("You don't have the required age to participate")
end end