Remove all unnecesary extra spacing and Layout/ExtraSpacing list from rubocop file

This commit is contained in:
Bertocq
2017-06-25 16:02:32 +02:00
parent 775da2d581
commit c9bc028524
35 changed files with 59 additions and 65 deletions

View File

@@ -216,12 +216,6 @@ Style/EmptyCaseCondition:
Exclude: Exclude:
- 'app/models/concerns/verification.rb' - 'app/models/concerns/verification.rb'
# Offense count: 29
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment, ForceEqualSignAlignment.
Layout/ExtraSpacing:
Enabled: false
# Offense count: 1 # Offense count: 1
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. # Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.

View File

@@ -88,10 +88,10 @@ group :development, :test do
gem 'quiet_assets' gem 'quiet_assets'
gem 'letter_opener_web', '~> 1.3.1' gem 'letter_opener_web', '~> 1.3.1'
gem 'i18n-tasks', '~> 0.9.15' gem 'i18n-tasks', '~> 0.9.15'
gem 'capistrano', '~> 3.8.1', require: false gem 'capistrano', '~> 3.8.1', require: false
gem 'capistrano-bundler', '~> 1.2', require: false gem 'capistrano-bundler', '~> 1.2', require: false
gem "capistrano-rails", '~> 1.2.3', require: false gem "capistrano-rails", '~> 1.2.3', require: false
gem 'rvm1-capistrano3', require: false gem 'rvm1-capistrano3', require: false
gem 'capistrano3-delayed-job', '~> 1.7.3' gem 'capistrano3-delayed-job', '~> 1.7.3'
gem "bullet", '~> 5.5.1' gem "bullet", '~> 5.5.1'
gem "faker", '~> 1.7.3' gem "faker", '~> 1.7.3'

View File

@@ -1,7 +1,7 @@
class Admin::SettingsController < Admin::BaseController class Admin::SettingsController < Admin::BaseController
def index def index
all_settings = (Setting.all).group_by { |s| s.type } all_settings = (Setting.all).group_by { |s| s.type }
@settings = all_settings['common'] @settings = all_settings['common']
@feature_flags = all_settings['feature'] @feature_flags = all_settings['feature']
@banner_styles = all_settings['banner-style'] @banner_styles = all_settings['banner-style']

View File

@@ -36,7 +36,7 @@ class GraphqlController < ApplicationController
def query_string def query_string
if request.headers["CONTENT_TYPE"] == 'application/graphql' if request.headers["CONTENT_TYPE"] == 'application/graphql'
request.body.string # request.body.class => StringIO request.body.string # request.body.class => StringIO
else else
params[:query] params[:query]
end end

View File

@@ -25,7 +25,7 @@ class UsersController < ApplicationController
when "proposals" then load_proposals when "proposals" then load_proposals
when "debates" then load_debates when "debates" then load_debates
when "budget_investments" then load_budget_investments when "budget_investments" then load_budget_investments
when "comments" then load_comments when "comments" then load_comments
else load_available_activity else load_available_activity
end end
end end

View File

@@ -48,7 +48,7 @@ module Abilities
can :create, Budget::Investment, budget: { phase: "accepting" } can :create, Budget::Investment, budget: { phase: "accepting" }
can :suggest, Budget::Investment, budget: { phase: "accepting" } can :suggest, Budget::Investment, budget: { phase: "accepting" }
can :destroy, Budget::Investment, budget: { phase: ["accepting", "reviewing"] }, author_id: user.id can :destroy, Budget::Investment, budget: { phase: ["accepting", "reviewing"] }, author_id: user.id
can :vote, Budget::Investment, budget: { phase: "selecting" } can :vote, Budget::Investment, budget: { phase: "selecting" }
can [:show, :create], Budget::Ballot, budget: { phase: "balloting" } can [:show, :create], Budget::Ballot, budget: { phase: "balloting" }
can [:create, :destroy], Budget::Ballot::Line, budget: { phase: "balloting" } can [:create, :destroy], Budget::Ballot::Line, budget: { phase: "balloting" }

View File

@@ -1,5 +1,5 @@
class Activity < ActiveRecord::Base class Activity < ActiveRecord::Base
belongs_to :actionable, -> { with_hidden }, polymorphic: true belongs_to :actionable, -> { with_hidden }, polymorphic: true
belongs_to :user, -> { with_hidden } belongs_to :user, -> { with_hidden }
VALID_ACTIONS = %w(hide block restore valuate) VALID_ACTIONS = %w(hide block restore valuate)

View File

@@ -5,7 +5,7 @@ class Banner < ActiveRecord::Base
validates :title, presence: true, validates :title, presence: true,
length: { minimum: 2 } length: { minimum: 2 }
validates :description, presence: true validates :description, presence: true
validates :target_url, presence: true validates :target_url, presence: true
validates :style, presence: true validates :style, presence: true
validates :image, presence: true validates :image, presence: true

View File

@@ -60,7 +60,7 @@ class Budget
scope :by_tag, ->(tag_name) { tagged_with(tag_name) } scope :by_tag, ->(tag_name) { tagged_with(tag_name) }
scope :by_valuator, ->(valuator_id) { where("budget_valuator_assignments.valuator_id = ?", valuator_id).joins(:valuator_assignments) } scope :by_valuator, ->(valuator_id) { where("budget_valuator_assignments.valuator_id = ?", valuator_id).joins(:valuator_assignments) }
scope :for_render, -> { includes(:heading) } scope :for_render, -> { includes(:heading) }
before_save :calculate_confidence_score before_save :calculate_confidence_score
before_validation :set_responsible_name before_validation :set_responsible_name

View File

@@ -7,7 +7,7 @@ module Verification
scope :level_two_verified, -> { where("users.level_two_verified_at IS NOT NULL OR (users.confirmed_phone IS NOT NULL AND users.residence_verified_at IS NOT NULL) AND verified_at IS NULL") } scope :level_two_verified, -> { where("users.level_two_verified_at IS NOT NULL OR (users.confirmed_phone IS NOT NULL AND users.residence_verified_at IS NOT NULL) AND verified_at IS NULL") }
scope :level_two_or_three_verified, -> { where("users.verified_at IS NOT NULL OR users.level_two_verified_at IS NOT NULL OR (users.confirmed_phone IS NOT NULL AND users.residence_verified_at IS NOT NULL)") } scope :level_two_or_three_verified, -> { where("users.verified_at IS NOT NULL OR users.level_two_verified_at IS NOT NULL OR (users.confirmed_phone IS NOT NULL AND users.residence_verified_at IS NOT NULL)") }
scope :unverified, -> { where("users.verified_at IS NULL AND (users.level_two_verified_at IS NULL AND (users.residence_verified_at IS NULL OR users.confirmed_phone IS NULL))") } scope :unverified, -> { where("users.verified_at IS NULL AND (users.level_two_verified_at IS NULL AND (users.residence_verified_at IS NULL OR users.confirmed_phone IS NULL))") }
scope :incomplete_verification, -> { where("(users.residence_verified_at IS NULL AND users.failed_census_calls_count > ?) OR (users.residence_verified_at IS NOT NULL AND (users.unconfirmed_phone IS NULL OR users.confirmed_phone IS NULL))", 0) } scope :incomplete_verification, -> { where("(users.residence_verified_at IS NULL AND users.failed_census_calls_count > ?) OR (users.residence_verified_at IS NOT NULL AND (users.unconfirmed_phone IS NULL OR users.confirmed_phone IS NULL))", 0) }
end end
def verification_email_sent? def verification_email_sent?

View File

@@ -18,7 +18,7 @@ class Poll < ActiveRecord::Base
scope :current, -> { where('starts_at <= ? and ? <= ends_at', Time.current, Time.current) } scope :current, -> { where('starts_at <= ? and ? <= ends_at', Time.current, Time.current) }
scope :incoming, -> { where('? < starts_at', Time.current) } scope :incoming, -> { where('? < starts_at', Time.current) }
scope :expired, -> { where('ends_at < ?', Time.current) } scope :expired, -> { where('ends_at < ?', Time.current) }
scope :published, -> { where('published = ?', true) } scope :published, -> { where('published = ?', true) }
scope :by_geozone_id, ->(geozone_id) { where(geozones: {id: geozone_id}.joins(:geozones)) } scope :by_geozone_id, ->(geozone_id) { where(geozones: {id: geozone_id}.joins(:geozones)) }
scope :sort_for_list, -> { order(:geozone_restricted, :starts_at, :name) } scope :sort_for_list, -> { order(:geozone_restricted, :starts_at, :name) }

View File

@@ -2,7 +2,7 @@ class Poll::NullResult < ActiveRecord::Base
VALID_ORIGINS = %w{web booth} VALID_ORIGINS = %w{web booth}
belongs_to :author, -> { with_hidden }, class_name: 'User', foreign_key: 'author_id' belongs_to :author, -> { with_hidden }, class_name: 'User', foreign_key: 'author_id'
belongs_to :booth_assignment belongs_to :booth_assignment
belongs_to :officer_assignment belongs_to :officer_assignment

View File

@@ -19,7 +19,7 @@ class Poll::Question < ActiveRecord::Base
validates :title, length: { minimum: 4 } validates :title, length: { minimum: 4 }
validates :description, length: { maximum: Poll::Question.description_max_length } validates :description, length: { maximum: Poll::Question.description_max_length }
scope :by_poll_id, ->(poll_id) { where(poll_id: poll_id) } scope :by_poll_id, ->(poll_id) { where(poll_id: poll_id) }
scope :sort_for_list, -> { order('poll_questions.proposal_id IS NULL', :created_at)} scope :sort_for_list, -> { order('poll_questions.proposal_id IS NULL', :created_at)}
scope :for_render, -> { includes(:author, :proposal) } scope :for_render, -> { includes(:author, :proposal) }

View File

@@ -2,7 +2,7 @@ class Poll::WhiteResult < ActiveRecord::Base
VALID_ORIGINS = %w{web booth} VALID_ORIGINS = %w{web booth}
belongs_to :author, -> { with_hidden }, class_name: 'User', foreign_key: 'author_id' belongs_to :author, -> { with_hidden }, class_name: 'User', foreign_key: 'author_id'
belongs_to :booth_assignment belongs_to :booth_assignment
belongs_to :officer_assignment belongs_to :officer_assignment

View File

@@ -38,8 +38,8 @@ class Proposal < ActiveRecord::Base
before_save :calculate_hot_score, :calculate_confidence_score before_save :calculate_hot_score, :calculate_confidence_score
scope :for_render, -> { includes(:tags) } scope :for_render, -> { includes(:tags) }
scope :sort_by_hot_score, -> { reorder(hot_score: :desc) } scope :sort_by_hot_score, -> { reorder(hot_score: :desc) }
scope :sort_by_confidence_score, -> { reorder(confidence_score: :desc) } scope :sort_by_confidence_score, -> { reorder(confidence_score: :desc) }
scope :sort_by_created_at, -> { reorder(created_at: :desc) } scope :sort_by_created_at, -> { reorder(created_at: :desc) }
scope :sort_by_most_commented, -> { reorder(comments_count: :desc) } scope :sort_by_most_commented, -> { reorder(comments_count: :desc) }

View File

@@ -2,8 +2,8 @@ class Setting < ActiveRecord::Base
validates :key, presence: true, uniqueness: true validates :key, presence: true, uniqueness: true
default_scope { order(id: :asc) } default_scope { order(id: :asc) }
scope :banner_style, -> { where("key ilike ?", "banner-style.%")} scope :banner_style, -> { where("key ilike ?", "banner-style.%")}
scope :banner_img, -> { where("key ilike ?", "banner-img.%")} scope :banner_img, -> { where("key ilike ?", "banner-img.%")}
def type def type
if feature_flag? if feature_flag?

View File

@@ -35,7 +35,7 @@ class SpendingProposal < ActiveRecord::Base
scope :by_tag, ->(tag_name) { tagged_with(tag_name) } scope :by_tag, ->(tag_name) { tagged_with(tag_name) }
scope :by_valuator, ->(valuator) { where("valuation_assignments.valuator_id = ?", valuator.presence).joins(:valuation_assignments) } scope :by_valuator, ->(valuator) { where("valuation_assignments.valuator_id = ?", valuator.presence).joins(:valuation_assignments) }
scope :for_render, -> { includes(:geozone) } scope :for_render, -> { includes(:geozone) }
before_validation :set_responsible_name before_validation :set_responsible_name

View File

@@ -2,7 +2,7 @@
require 'pathname' require 'pathname'
# path to your application root. # path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
Dir.chdir APP_ROOT do Dir.chdir APP_ROOT do
# This script is a starting point to setup your application. # This script is a starting point to setup your application.

View File

@@ -44,7 +44,7 @@ describe Management::SessionsController do
describe 'Sign out' do describe 'Sign out' do
it "should destroy the session data and redirect" do it "should destroy the session data and redirect" do
session[:manager] = {user_key: "31415926", date: "20151031135905", login: "JJB033"} session[:manager] = {user_key: "31415926", date: "20151031135905", login: "JJB033"}
session[:document_type] = "1" session[:document_type] = "1"
session[:document_number] = "12345678Z" session[:document_number] = "12345678Z"
delete :destroy delete :destroy

View File

@@ -5,7 +5,7 @@ describe Management::UsersController do
describe 'logout' do describe 'logout' do
it "should remove user data from the session" do it "should remove user data from the session" do
session[:manager] = {user_key: "31415926", date: "20151031135905", login: "JJB033"} session[:manager] = {user_key: "31415926", date: "20151031135905", login: "JJB033"}
session[:document_type] = "1" session[:document_type] = "1"
session[:document_number] = "12345678Z" session[:document_number] = "12345678Z"
get :logout get :logout

View File

@@ -258,7 +258,7 @@ FactoryGirl.define do
end end
factory :budget_investment, class: 'Budget::Investment' do factory :budget_investment, class: 'Budget::Investment' do
sequence(:title) { |n| "Budget Investment #{n} title" } sequence(:title) { |n| "Budget Investment #{n} title" }
association :heading, factory: :budget_heading association :heading, factory: :budget_heading
association :author, factory: :user association :author, factory: :user
description 'Spend money on this' description 'Spend money on this'
@@ -585,7 +585,7 @@ FactoryGirl.define do
factory :banner do factory :banner do
sequence(:title) { |n| "Banner title #{n}" } sequence(:title) { |n| "Banner title #{n}" }
sequence(:description) { |n| "This is the text of Banner #{n}" } sequence(:description) { |n| "This is the text of Banner #{n}" }
style {["banner-style-one", "banner-style-two", "banner-style-three"].sample} style {["banner-style-one", "banner-style-two", "banner-style-three"].sample}
image {["banner.banner-img-one", "banner.banner-img-two", "banner.banner-img-three"].sample} image {["banner.banner-img-one", "banner.banner-img-two", "banner.banner-img-three"].sample}
target_url {["/proposals", "/debates" ].sample} target_url {["/proposals", "/debates" ].sample}

View File

@@ -5,7 +5,7 @@ feature 'Budget Investments' 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(:budget) { create(:budget, name: "Big Budget") }
let(:other_budget) { create(:budget, name: "What a Budget!") } let(:other_budget) { create(:budget, name: "What a Budget!") }
let(:group) { create(:budget_group, name: "Health", budget: budget) } let(:group) { create(:budget_group, name: "Health", budget: budget) }
let!(:heading) { create(:budget_heading, name: "More hospitals", group: group) } let!(:heading) { create(:budget_heading, name: "More hospitals", group: group) }
scenario 'Index' do scenario 'Index' do
@@ -641,11 +641,11 @@ feature 'Budget Investments' do
carabanchel_heading = create(:budget_heading, group: group, name: "Carabanchel") carabanchel_heading = create(:budget_heading, group: group, name: "Carabanchel")
new_york_heading = create(:budget_heading, group: group, name: "New York") new_york_heading = create(:budget_heading, group: group, name: "New York")
sp1 = create(:budget_investment, :selected, price: 1, heading: global_heading) sp1 = create(:budget_investment, :selected, price: 1, heading: global_heading)
sp2 = create(:budget_investment, :selected, price: 10, heading: global_heading) sp2 = create(:budget_investment, :selected, price: 10, heading: global_heading)
sp3 = create(:budget_investment, :selected, price: 100, heading: global_heading) sp3 = create(:budget_investment, :selected, price: 100, heading: global_heading)
sp4 = create(:budget_investment, :selected, price: 1000, heading: carabanchel_heading) sp4 = create(:budget_investment, :selected, price: 1000, heading: carabanchel_heading)
sp5 = create(:budget_investment, :selected, price: 10000, heading: carabanchel_heading) sp5 = create(:budget_investment, :selected, price: 10000, heading: carabanchel_heading)
sp6 = create(:budget_investment, :selected, price: 100000, heading: new_york_heading) sp6 = create(:budget_investment, :selected, price: 100000, heading: new_york_heading)
login_as(user) login_as(user)

View File

@@ -2,7 +2,7 @@ require 'rails_helper'
include ActionView::Helpers::DateHelper include ActionView::Helpers::DateHelper
feature 'Commenting Budget::Investments' do feature 'Commenting Budget::Investments' do
let(:user) { create :user } let(:user) { create :user }
let(:investment) { create :budget_investment } let(:investment) { create :budget_investment }
scenario 'Index' do scenario 'Index' do

View File

@@ -2,7 +2,7 @@ require 'rails_helper'
include ActionView::Helpers::DateHelper include ActionView::Helpers::DateHelper
feature 'Commenting legislation questions' do feature 'Commenting legislation questions' do
let(:user) { create :user } let(:user) { create :user }
let(:legislation_annotation) { create :legislation_annotation, author: user } let(:legislation_annotation) { create :legislation_annotation, author: user }
scenario 'Index' do scenario 'Index' do

View File

@@ -2,7 +2,7 @@ require 'rails_helper'
include ActionView::Helpers::DateHelper include ActionView::Helpers::DateHelper
feature 'Commenting legislation questions' do feature 'Commenting legislation questions' do
let(:user) { create :user, :level_two } let(:user) { create :user, :level_two }
let(:process) { create :legislation_process, :in_debate_phase } let(:process) { create :legislation_process, :in_debate_phase }
let(:legislation_question) { create :legislation_question, process: process } let(:legislation_question) { create :legislation_question, process: process }

View File

@@ -2,7 +2,7 @@ require 'rails_helper'
include ActionView::Helpers::DateHelper include ActionView::Helpers::DateHelper
feature 'Commenting proposals' do feature 'Commenting proposals' do
let(:user) { create :user } let(:user) { create :user }
let(:proposal) { create :proposal } let(:proposal) { create :proposal }
scenario 'Index' do scenario 'Index' do

View File

@@ -674,7 +674,7 @@ feature 'Debates' do
click_link "Advanced search" click_link "Advanced search"
fill_in "Write the text", with: "Schwifty" 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" select "Last 24 hours", from: "js-advanced-search-date-min"
click_button "Filter" click_button "Filter"
@@ -866,10 +866,10 @@ feature 'Debates' do
login_as(author) login_as(author)
debate1 = create(:debate, title: "First debate has 1 vote", cached_votes_up: 1) debate1 = create(:debate, title: "First debate has 1 vote", cached_votes_up: 1)
debate2 = create(:debate, title: "Second debate has 2 votes", cached_votes_up: 2) debate2 = create(:debate, title: "Second debate has 2 votes", cached_votes_up: 2)
debate3 = create(:debate, title: "Third debate has 3 votes", cached_votes_up: 3) 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) 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) 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) 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) debate7 = create(:debate, title: "This has seven votes, and is not suggest", description: 'This is the seven', cached_votes_up: 7)

View File

@@ -8,7 +8,7 @@ feature 'Organizations' do
visit new_organization_registration_path visit new_organization_registration_path
fill_in 'user_organization_attributes_name', with: 'Greenpeace' fill_in 'user_organization_attributes_name', with: 'Greenpeace'
fill_in 'user_organization_attributes_responsible_name', with: 'Dorothy Stowe' fill_in 'user_organization_attributes_responsible_name', with: 'Dorothy Stowe'
fill_in 'user_email', with: 'green@peace.com' fill_in 'user_email', with: 'green@peace.com'
fill_in 'user_password', with: 'greenpeace' fill_in 'user_password', with: 'greenpeace'
@@ -45,7 +45,7 @@ feature 'Organizations' do
scenario 'Create organization too fast' do scenario 'Create organization too fast' do
allow(InvisibleCaptcha).to receive(:timestamp_threshold).and_return(Float::INFINITY) allow(InvisibleCaptcha).to receive(:timestamp_threshold).and_return(Float::INFINITY)
visit new_organization_registration_path visit new_organization_registration_path
fill_in 'user_organization_attributes_name', with: 'robot' 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_organization_attributes_responsible_name', with: 'Robots are more responsible than humans'
fill_in 'user_email', with: 'robot@robot.com' fill_in 'user_email', with: 'robot@robot.com'
fill_in 'user_password', with: 'destroyallhumans' fill_in 'user_password', with: 'destroyallhumans'

View File

@@ -89,7 +89,7 @@ feature 'Proposals' do
end end
end end
context "Embedded video" do context "Embedded video" do
scenario "Show YouTube video" do scenario "Show YouTube video" do
proposal = create(:proposal, video_url: "http://www.youtube.com/watch?v=a7UFm6ErMPU") proposal = create(:proposal, video_url: "http://www.youtube.com/watch?v=a7UFm6ErMPU")
@@ -1072,7 +1072,7 @@ feature 'Proposals' do
click_link "Advanced search" click_link "Advanced search"
fill_in "Write the text", with: "Schwifty" 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" select "Last 24 hours", from: "js-advanced-search-date-min"
click_button "Filter" click_button "Filter"

View File

@@ -17,7 +17,7 @@ describe Age do
d = Date.new(1980, 12, 31) d = Date.new(1980, 12, 31)
expect(Age.in_years(d, Date.new(2000, 12, 30))).to eq(19) expect(Age.in_years(d, Date.new(2000, 12, 30))).to eq(19)
expect(Age.in_years(d, Date.new(2000, 12, 31))).to eq(20) expect(Age.in_years(d, Date.new(2000, 12, 31))).to eq(20)
expect(Age.in_years(d, Date.new(2001, 1, 1))).to eq(20) expect(Age.in_years(d, Date.new(2001, 1, 1))).to eq(20)
d = Date.new(1980, 1, 1) d = Date.new(1980, 1, 1)
expect(Age.in_years(d, Date.new(2000, 12, 31))).to eq(20) expect(Age.in_years(d, Date.new(2000, 12, 31))).to eq(20)
@@ -31,28 +31,28 @@ describe Age do
expect(Age.in_years(d, Date.new(2000, 2, 27))).to eq(19) expect(Age.in_years(d, Date.new(2000, 2, 27))).to eq(19)
expect(Age.in_years(d, Date.new(2000, 2, 28))).to eq(19) expect(Age.in_years(d, Date.new(2000, 2, 28))).to eq(19)
expect(Age.in_years(d, Date.new(2000, 2, 29))).to eq(20) expect(Age.in_years(d, Date.new(2000, 2, 29))).to eq(20)
expect(Age.in_years(d, Date.new(2000, 3, 1))).to eq(20) expect(Age.in_years(d, Date.new(2000, 3, 1))).to eq(20)
expect(Age.in_years(d, Date.new(2001, 2, 27))).to eq(20) expect(Age.in_years(d, Date.new(2001, 2, 27))).to eq(20)
expect(Age.in_years(d, Date.new(2001, 2, 28))).to eq(20) expect(Age.in_years(d, Date.new(2001, 2, 28))).to eq(20)
expect(Age.in_years(d, Date.new(2001, 3, 1))).to eq(21) expect(Age.in_years(d, Date.new(2001, 3, 1))).to eq(21)
d = Date.new(1980, 2, 28) d = Date.new(1980, 2, 28)
expect(Age.in_years(d, Date.new(2000, 2, 27))).to eq(19) expect(Age.in_years(d, Date.new(2000, 2, 27))).to eq(19)
expect(Age.in_years(d, Date.new(2000, 2, 28))).to eq(20) expect(Age.in_years(d, Date.new(2000, 2, 28))).to eq(20)
expect(Age.in_years(d, Date.new(2000, 2, 29))).to eq(20) expect(Age.in_years(d, Date.new(2000, 2, 29))).to eq(20)
expect(Age.in_years(d, Date.new(2000, 3, 1))).to eq(20) expect(Age.in_years(d, Date.new(2000, 3, 1))).to eq(20)
expect(Age.in_years(d, Date.new(2001, 2, 27))).to eq(20) expect(Age.in_years(d, Date.new(2001, 2, 27))).to eq(20)
expect(Age.in_years(d, Date.new(2001, 2, 28))).to eq(21) expect(Age.in_years(d, Date.new(2001, 2, 28))).to eq(21)
expect(Age.in_years(d, Date.new(2001, 3, 1))).to eq(21) expect(Age.in_years(d, Date.new(2001, 3, 1))).to eq(21)
d = Date.new(1980, 3, 1) d = Date.new(1980, 3, 1)
expect(Age.in_years(d, Date.new(2000, 2, 27))).to eq(19) expect(Age.in_years(d, Date.new(2000, 2, 27))).to eq(19)
expect(Age.in_years(d, Date.new(2000, 2, 28))).to eq(19) expect(Age.in_years(d, Date.new(2000, 2, 28))).to eq(19)
expect(Age.in_years(d, Date.new(2000, 2, 29))).to eq(19) expect(Age.in_years(d, Date.new(2000, 2, 29))).to eq(19)
expect(Age.in_years(d, Date.new(2000, 3, 1))).to eq(20) expect(Age.in_years(d, Date.new(2000, 3, 1))).to eq(20)
expect(Age.in_years(d, Date.new(2001, 2, 27))).to eq(20) expect(Age.in_years(d, Date.new(2001, 2, 27))).to eq(20)
expect(Age.in_years(d, Date.new(2001, 2, 28))).to eq(20) expect(Age.in_years(d, Date.new(2001, 2, 28))).to eq(20)
expect(Age.in_years(d, Date.new(2001, 3, 1))).to eq(21) expect(Age.in_years(d, Date.new(2001, 3, 1))).to eq(21)
end end
end end
end end

View File

@@ -7,7 +7,7 @@ describe GraphQL::QueryTypeCreator do
Proposal => { fields: { id: :integer, title: :string } } Proposal => { fields: { id: :integer, title: :string } }
} }
end end
let(:api_types) { GraphQL::ApiTypesCreator.create(api_type_definitions) } let(:api_types) { GraphQL::ApiTypesCreator.create(api_type_definitions) }
describe "::create" do describe "::create" do
let(:query_type) { GraphQL::QueryTypeCreator.create(api_types) } let(:query_type) { GraphQL::QueryTypeCreator.create(api_types) }

View File

@@ -35,14 +35,14 @@ describe "Abilities::Common" do
let(:incoming_poll) { create(:poll, :incoming) } let(:incoming_poll) { create(:poll, :incoming) }
let(:incoming_poll_from_own_geozone) { create(:poll, :incoming, geozone_restricted: true, geozones: [geozone]) } let(:incoming_poll_from_own_geozone) { create(:poll, :incoming, geozone_restricted: true, geozones: [geozone]) }
let(:incoming_poll_from_other_geozone) { create(:poll, :incoming, geozone_restricted: true, geozones: [create(:geozone)]) } let(:incoming_poll_from_other_geozone) { create(:poll, :incoming, geozone_restricted: true, geozones: [create(:geozone)]) }
let(:expired_poll) { create(:poll, :expired) } let(:expired_poll) { create(:poll, :expired) }
let(:expired_poll_from_own_geozone) { create(:poll, :expired, geozone_restricted: true, geozones: [geozone]) } let(:expired_poll_from_own_geozone) { create(:poll, :expired, geozone_restricted: true, geozones: [geozone]) }
let(:expired_poll_from_other_geozone) { create(:poll, :expired, geozone_restricted: true, geozones: [create(:geozone)]) } let(:expired_poll_from_other_geozone) { create(:poll, :expired, geozone_restricted: true, geozones: [create(:geozone)]) }
let(:poll) { create(:poll, geozone_restricted: false) } let(:poll) { create(:poll, geozone_restricted: false) }
let(:poll_from_own_geozone) { create(:poll, geozone_restricted: true, geozones: [geozone]) } let(:poll_from_own_geozone) { create(:poll, geozone_restricted: true, geozones: [geozone]) }
let(:poll_from_other_geozone) { create(:poll, geozone_restricted: true, geozones: [create(:geozone)]) } let(:poll_from_other_geozone) { create(:poll, geozone_restricted: true, geozones: [create(:geozone)]) }
let(:poll_question_from_own_geozone) { create(:poll_question, poll: poll_from_own_geozone) } let(:poll_question_from_own_geozone) { create(:poll_question, poll: poll_from_own_geozone) }
let(:poll_question_from_other_geozone) { create(:poll_question, poll: poll_from_other_geozone) } let(:poll_question_from_other_geozone) { create(:poll_question, poll: poll_from_other_geozone) }
let(:poll_question_from_all_geozones) { create(:poll_question, poll: poll) } let(:poll_question_from_all_geozones) { create(:poll_question, poll: poll) }
@@ -222,7 +222,7 @@ describe "Abilities::Common" do
it { should be_able_to(:vote, Proposal) } it { should be_able_to(:vote, Proposal) }
it { should be_able_to(:vote_featured, Proposal) } it { should be_able_to(:vote_featured, Proposal) }
it { should be_able_to(:create, SpendingProposal) } it { should be_able_to(:create, SpendingProposal) }
it { should_not be_able_to(:destroy, create(:spending_proposal)) } it { should_not be_able_to(:destroy, create(:spending_proposal)) }
it { should_not be_able_to(:destroy, own_spending_proposal) } it { should_not be_able_to(:destroy, own_spending_proposal) }

View File

@@ -2,7 +2,7 @@ require 'rails_helper'
describe 'Verification::Letter' do describe 'Verification::Letter' do
let(:user) { create(:user) } let(:user) { create(:user) }
describe "validations" do describe "validations" do

View File

@@ -93,7 +93,7 @@ describe :poll do
let(:non_user) { nil } let(:non_user) { nil }
let(:level1) { create(:user) } let(:level1) { create(:user) }
let(:level2) { create(:user, :level_two) } let(:level2) { create(:user, :level_two) }
let(:level2_from_geozone) { create(:user, :level_two, geozone: geozone) } let(:level2_from_geozone) { create(:user, :level_two, geozone: geozone) }
let(:all_users) { [non_user, level1, level2, level2_from_geozone] } let(:all_users) { [non_user, level1, level2, level2_from_geozone] }
describe 'instance method' do describe 'instance method' do

View File

@@ -24,7 +24,7 @@ describe TagCloud do
it "returns budget investment tags" do it "returns budget investment tags" do
create(:budget_investment, tag_list: 'participation') create(:budget_investment, tag_list: 'participation')
create(:debate, tag_list: 'world hunger') create(:debate, tag_list: 'world hunger')
tag_cloud = TagCloud.new(Budget::Investment) tag_cloud = TagCloud.new(Budget::Investment)