Fix all Layout/SpaceAroundOperators rubocop issues and remove file list from rubocop_todo list

This commit is contained in:
Bertocq
2017-06-26 18:04:20 +02:00
parent d7b8777395
commit f6fe9cc7d2
34 changed files with 80 additions and 86 deletions

View File

@@ -557,12 +557,6 @@ Style/RescueModifier:
- 'app/controllers/concerns/commentable_actions.rb' - 'app/controllers/concerns/commentable_actions.rb'
- 'app/controllers/verification/sms_controller.rb' - 'app/controllers/verification/sms_controller.rb'
# Offense count: 66
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment.
Layout/SpaceAroundOperators:
Enabled: false
# Offense count: 9 # Offense count: 9
# Cop supports --auto-correct. # Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles. # Configuration parameters: EnforcedStyle, SupportedStyles.

View File

@@ -93,7 +93,7 @@ module Budgets
def set_random_seed def set_random_seed
if params[:order] == 'random' || params[:order].blank? if params[:order] == 'random' || params[:order].blank?
params[:random_seed] ||= rand(99)/100.0 params[:random_seed] ||= rand(99) / 100.0
seed = Float(params[:random_seed]) rescue 0 seed = Float(params[:random_seed]) rescue 0
Budget::Investment.connection.execute("select setseed(#{seed})") Budget::Investment.connection.execute("select setseed(#{seed})")
else else

View File

@@ -20,7 +20,7 @@ class Management::Budgets::InvestmentsController < Management::BaseController
@investment.author = managed_user @investment.author = managed_user
if @investment.save if @investment.save
notice= t('flash.actions.create.notice', resource_name: Budget::Investment.model_name.human, count: 1) notice = t('flash.actions.create.notice', resource_name: Budget::Investment.model_name.human, count: 1)
redirect_to management_budget_investment_path(@budget, @investment), notice: notice redirect_to management_budget_investment_path(@budget, @investment), notice: notice
else else
render :new render :new

View File

@@ -1,7 +1,7 @@
module BallotsHelper module BallotsHelper
def progress_bar_width(amount_available, amount_spent) def progress_bar_width(amount_available, amount_spent)
(amount_spent/amount_available.to_f * 100).to_s + "%" (amount_spent / amount_available.to_f * 100).to_s + "%"
end end
end end

View File

@@ -11,7 +11,7 @@ module EmbedVideosHelper
if server == "Vimeo" if server == "Vimeo"
reg_exp = /vimeo.*(staffpicks\/|channels\/|videos\/|video\/|\/)([^#\&\?]*).*/ reg_exp = /vimeo.*(staffpicks\/|channels\/|videos\/|video\/|\/)([^#\&\?]*).*/
src = "https://player.vimeo.com/video/" src = "https://player.vimeo.com/video/"
elsif server == "YouTube" elsif server == "YouTube"
reg_exp = /youtu.*(be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/ reg_exp = /youtu.*(be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/
src = "https://www.youtube.com/embed/" src = "https://www.youtube.com/embed/"

View File

@@ -13,7 +13,7 @@ module OfficingHelper
officer_assignments.each do |oa| officer_assignments.each do |oa|
options << [oa.booth_assignment.booth.name.to_s, oa.id] options << [oa.booth_assignment.booth.name.to_s, oa.id]
end end
options.sort! {|x, y| x[0]<=>y[0]} options.sort! {|x, y| x[0] <=> y[0]}
options_for_select(options, params[:oa]) options_for_select(options, params[:oa])
end end

View File

@@ -9,7 +9,7 @@ module PollRecountsHelper
end end
def booth_assignment_sum_final_recounts(ba) def booth_assignment_sum_final_recounts(ba)
ba.final_recounts.any? ? ba.final_recounts.to_a.sum(&:count) :nil ba.final_recounts.any? ? ba.final_recounts.to_a.sum(&:count) : nil
end end
end end

View File

@@ -18,7 +18,7 @@ module VerificationHelper
data_to_mask = match[2] data_to_mask = match[2]
email_provider = match[3] email_provider = match[3]
data_to_display + "*"*data_to_mask.size + "@" + email_provider data_to_display + "*" * data_to_mask.size + "@" + email_provider
end end
end end

View File

@@ -205,8 +205,8 @@ class Budget
end end
def should_show_aside? def should_show_aside?
(budget.selecting? && !unfeasible?) || (budget.selecting? && !unfeasible?) ||
(budget.balloting? && feasible?) || (budget.balloting? && feasible?) ||
(budget.valuating? && !unfeasible?) (budget.valuating? && !unfeasible?)
end end

View File

@@ -64,7 +64,7 @@ class Comment < ActiveRecord::Base
end end
def author=(author) def author=(author)
self.user= author self.user = author
end end
def total_votes def total_votes

View File

@@ -3,7 +3,7 @@ module Conflictable
def conflictive? def conflictive?
return false unless flags_count > 0 && cached_votes_up > 0 return false unless flags_count > 0 && cached_votes_up > 0
cached_votes_up/flags_count.to_f < 5 cached_votes_up / flags_count.to_f < 5
end end
end end

View File

@@ -35,7 +35,7 @@ class Legislation::Annotation < ActiveRecord::Base
selector_end = "/html/body/#{range_end}" selector_end = "/html/body/#{range_end}"
el_end = doc.at_xpath(selector_end) el_end = doc.at_xpath(selector_end)
remainder_el_start = el_start.text[0 .. range_start_offset-1] unless range_start_offset.zero? remainder_el_start = el_start.text[0 .. range_start_offset - 1] unless range_start_offset.zero?
remainder_el_end = el_end.text[range_end_offset .. -1] remainder_el_end = el_end.text[range_end_offset .. -1]
self.context = "#{remainder_el_start}<span class=annotator-hl>#{quote}</span>#{remainder_el_end}" self.context = "#{remainder_el_start}<span class=annotator-hl>#{quote}</span>#{remainder_el_end}"

View File

@@ -1,7 +1,7 @@
module ScoreCalculator module ScoreCalculator
EPOC = Time.new(2015, 6, 15).in_time_zone 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
def self.hot_score(date, votes_total, votes_up, comments_count) def self.hot_score(date, votes_total, votes_up, comments_count)
@@ -13,7 +13,7 @@ module ScoreCalculator
sign = score <=> 0 sign = score <=> 0
seconds = ((date || Time.current) - EPOC).to_f seconds = ((date || Time.current) - EPOC).to_f
(((offset * sign) + (seconds/TIME_UNIT)) * 10000000).round (((offset * sign) + (seconds / TIME_UNIT)) * 10000000).round
end end
def self.confidence_score(votes_total, votes_up) def self.confidence_score(votes_total, votes_up)

View File

@@ -38,7 +38,7 @@ class SMSApi
end end
def stubbed_response def stubbed_response
{:respuesta_sms=>{:identificador_mensaje=>"1234567", :fecha_respuesta=>"Thu, 20 Aug 2015 16:28:05 +0200", :respuesta_pasarela=>{:codigo_pasarela=>"0000", :descripcion_pasarela=>"Operación ejecutada correctamente."}, :respuesta_servicio_externo=>{:codigo_respuesta=>"1000", :texto_respuesta=>"Success"}}} {:respuesta_sms => {:identificador_mensaje => "1234567", :fecha_respuesta => "Thu, 20 Aug 2015 16:28:05 +0200", :respuesta_pasarela => {:codigo_pasarela => "0000", :descripcion_pasarela => "Operación ejecutada correctamente."}, :respuesta_servicio_externo => {:codigo_respuesta => "1000", :texto_respuesta => "Success"}}}
end end
end end

View File

@@ -36,7 +36,7 @@ describe Admin::Api::StatsController do
expect(response).to be_ok expect(response).to be_ok
data = JSON.parse(response.body) data = JSON.parse(response.body)
expect(data).to eq "x"=>["2015-01-01", "2015-01-02"], "Foo"=>[2, 1] expect(data).to eq "x" => ["2015-01-01", "2015-01-02"], "Foo" => [2, 1]
end end
it 'should return combined comma separated events formated for working with c3.js' do it 'should return combined comma separated events formated for working with c3.js' do
@@ -46,7 +46,7 @@ describe Admin::Api::StatsController do
expect(response).to be_ok expect(response).to be_ok
data = JSON.parse(response.body) data = JSON.parse(response.body)
expect(data).to eq "x"=>["2015-01-01", "2015-01-02", "2015-01-03"], "Foo"=>[2, 1, 0], "Bar"=>[1, 0, 2] expect(data).to eq "x" => ["2015-01-01", "2015-01-02", "2015-01-03"], "Foo" => [2, 1, 0], "Bar" => [1, 0, 2]
end end
end end
@@ -65,7 +65,7 @@ describe Admin::Api::StatsController do
expect(response).to be_ok expect(response).to be_ok
data = JSON.parse(response.body) data = JSON.parse(response.body)
expect(data).to eq "x"=>["2015-01-01", "2015-01-02"], "Visits"=>[2, 1] expect(data).to eq "x" => ["2015-01-01", "2015-01-02"], "Visits" => [2, 1]
end end
end end
@@ -88,7 +88,7 @@ describe Admin::Api::StatsController do
expect(response).to be_ok expect(response).to be_ok
data = JSON.parse(response.body) data = JSON.parse(response.body)
expect(data).to eq "x"=>["2015-01-01", "2015-01-02"], "Foo"=>[1, 2], "Visits"=>[2, 1] expect(data).to eq "x" => ["2015-01-01", "2015-01-02"], "Foo" => [1, 2], "Visits" => [2, 1]
end end
end end
@@ -107,7 +107,7 @@ describe Admin::Api::StatsController do
expect(response).to be_ok expect(response).to be_ok
data = JSON.parse(response.body) data = JSON.parse(response.body)
expect(data).to eq "x"=>["2017-04-01", "2017-04-02"], "Budget Investments"=>[1, 2] expect(data).to eq "x" => ["2017-04-01", "2017-04-02"], "Budget Investments" => [1, 2]
end end
end end
end end

View File

@@ -16,8 +16,8 @@ describe Legislation::AnnotationsController do
post :create, process_id: @process.id, post :create, process_id: @process.id,
draft_version_id: @draft_version.id, draft_version_id: @draft_version.id,
legislation_annotation: { legislation_annotation: {
"quote"=>"ipsum", "quote" => "ipsum",
"ranges"=>[{"start"=>"/p[1]", "startOffset"=>6, "end"=>"/p[1]", "endOffset"=>11}], "ranges" => [{"start" => "/p[1]", "startOffset" => 6, "end" => "/p[1]", "endOffset" => 11}],
"text": "una anotacion" "text": "una anotacion"
} }
expect(Ahoy::Event.where(name: :legislation_annotation_created).count).to eq 1 expect(Ahoy::Event.where(name: :legislation_annotation_created).count).to eq 1
@@ -30,8 +30,8 @@ describe Legislation::AnnotationsController do
post :create, process_id: @process.id, post :create, process_id: @process.id,
draft_version_id: @final_version.id, draft_version_id: @final_version.id,
legislation_annotation: { legislation_annotation: {
"quote"=>"ipsum", "quote" => "ipsum",
"ranges"=>[{"start"=>"/p[1]", "startOffset"=>6, "end"=>"/p[1]", "endOffset"=>11}], "ranges" => [{"start" => "/p[1]", "startOffset" => 6, "end" => "/p[1]", "endOffset" => 11}],
"text": "una anotacion" "text": "una anotacion"
} }
@@ -45,8 +45,8 @@ describe Legislation::AnnotationsController do
xhr :post, :create, process_id: @process.id, xhr :post, :create, process_id: @process.id,
draft_version_id: @draft_version.id, draft_version_id: @draft_version.id,
legislation_annotation: { legislation_annotation: {
"quote"=>"ipsum", "quote" => "ipsum",
"ranges"=>[{"start"=>"/p[1]", "startOffset"=>6, "end"=>"/p[1]", "endOffset"=>11}], "ranges" => [{"start" => "/p[1]", "startOffset" => 6, "end" => "/p[1]", "endOffset" => 11}],
"text": "una anotacion" "text": "una anotacion"
} }
end.to change { @draft_version.annotations.count }.by(1) end.to change { @draft_version.annotations.count }.by(1)
@@ -60,8 +60,8 @@ describe Legislation::AnnotationsController do
xhr :post, :create, process_id: @process.id, xhr :post, :create, process_id: @process.id,
draft_version_id: @draft_version.id, draft_version_id: @draft_version.id,
legislation_annotation: { legislation_annotation: {
"quote"=>"ipsum", "quote" => "ipsum",
"ranges"=>[{"start"=>"/p[1]", "startOffset"=>6, "end"=>"/p[1]", "endOffset"=>11}], "ranges" => [{"start" => "/p[1]", "startOffset" => 6, "end" => "/p[1]", "endOffset" => 11}],
"text": "una anotacion" "text": "una anotacion"
} }
end.to_not change { @draft_version.annotations.count } end.to_not change { @draft_version.annotations.count }
@@ -74,8 +74,8 @@ describe Legislation::AnnotationsController do
xhr :post, :create, process_id: @process.id, xhr :post, :create, process_id: @process.id,
draft_version_id: @draft_version.id, draft_version_id: @draft_version.id,
legislation_annotation: { legislation_annotation: {
"quote"=>"ipsum", "quote" => "ipsum",
"ranges"=>[{"start"=>"/p[1]", "startOffset"=>6, "end"=>"/p[1]", "endOffset"=>11}].to_json, "ranges" => [{"start" => "/p[1]", "startOffset" => 6, "end" => "/p[1]", "endOffset" => 11}].to_json,
"text": "una anotacion" "text": "una anotacion"
} }
end.to change { @draft_version.annotations.count }.by(1) end.to change { @draft_version.annotations.count }.by(1)
@@ -83,7 +83,7 @@ describe Legislation::AnnotationsController do
it 'should create a new comment on an existing annotation when range is the same' do it 'should create a new comment on an existing annotation when range is the same' do
annotation = create(:legislation_annotation, draft_version: @draft_version, text: "my annotation", annotation = create(:legislation_annotation, draft_version: @draft_version, text: "my annotation",
ranges: [{"start"=>"/p[1]", "startOffset"=>6, "end"=>"/p[1]", "endOffset"=>11}], 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) range_start: "/p[1]", range_start_offset: 6, range_end: "/p[1]", range_end_offset: 11)
sign_in @user sign_in @user
@@ -91,8 +91,8 @@ describe Legislation::AnnotationsController do
xhr :post, :create, process_id: @process.id, xhr :post, :create, process_id: @process.id,
draft_version_id: @draft_version.id, draft_version_id: @draft_version.id,
legislation_annotation: { legislation_annotation: {
"quote"=>"ipsum", "quote" => "ipsum",
"ranges"=>[{"start"=>"/p[1]", "startOffset"=>6, "end"=>"/p[1]", "endOffset"=>11}], "ranges" => [{"start" => "/p[1]", "startOffset" => 6, "end" => "/p[1]", "endOffset" => 11}],
"text": "una anotacion" "text": "una anotacion"
} }
end.to_not change { @draft_version.annotations.count } end.to_not change { @draft_version.annotations.count }

View File

@@ -378,7 +378,7 @@ FactoryGirl.define do
factory :annotation do factory :annotation do
quote "ipsum" quote "ipsum"
text "Loremp ipsum dolor" text "Loremp ipsum dolor"
ranges [{"start"=>"/div[1]", "startOffset"=>5, "end"=>"/div[1]", "endOffset"=>10}] ranges [{"start" => "/div[1]", "startOffset" => 5, "end" => "/div[1]", "endOffset" => 10}]
legacy_legislation legacy_legislation
user user
end end
@@ -701,7 +701,7 @@ LOREM_IPSUM
author factory: :user author factory: :user
quote "ipsum" quote "ipsum"
text "a comment" text "a comment"
ranges [{"start"=>"/p[1]", "startOffset"=>6, "end"=>"/p[1]", "endOffset"=>11}] ranges [{"start" => "/p[1]", "startOffset" => 6, "end" => "/p[1]", "endOffset" => 11}]
range_start "/p[1]" range_start "/p[1]"
range_start_offset 6 range_start_offset 6
range_end "/p[1]" range_end "/p[1]"

View File

@@ -395,7 +395,7 @@ feature 'Commenting Budget::Investments' do
end end
scenario "can not comment as a moderator" do scenario "can not comment as a moderator" do
admin = create(:administrator) admin = create(:administrator)
login_as(admin.user) login_as(admin.user)
visit budget_investment_path(investment.budget, investment) visit budget_investment_path(investment.budget, investment)

View File

@@ -407,7 +407,7 @@ feature 'Commenting debates' do
end end
scenario "can not comment as a moderator" do scenario "can not comment as a moderator" do
admin = create(:administrator) admin = create(:administrator)
login_as(admin.user) login_as(admin.user)
visit debate_path(debate) visit debate_path(debate)

View File

@@ -409,7 +409,7 @@ feature 'Commenting legislation questions' do
end end
scenario "can not comment as a moderator" do scenario "can not comment as a moderator" do
admin = create(:administrator) admin = create(:administrator)
login_as(admin.user) login_as(admin.user)
visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process, legislation_annotation.draft_version, legislation_annotation) visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process, legislation_annotation.draft_version, legislation_annotation)
@@ -510,8 +510,8 @@ feature 'Commenting legislation questions' do
feature "Merged comment threads", :js do feature "Merged comment threads", :js do
let!(:draft_version) { create(:legislation_draft_version, :published) } let!(:draft_version) { create(:legislation_draft_version, :published) }
let!(:annotation1) { create(:legislation_annotation, draft_version: draft_version, text: "my annotation", ranges: [{"start"=>"/p[1]", "startOffset"=>1, "end"=>"/p[1]", "endOffset"=>5}]) } let!(:annotation1) { create(:legislation_annotation, draft_version: draft_version, text: "my annotation", ranges: [{"start" => "/p[1]", "startOffset" => 1, "end" => "/p[1]", "endOffset" => 5}]) }
let!(:annotation2) { create(:legislation_annotation, draft_version: draft_version, text: "my other annotation", ranges: [{"start"=>"/p[1]", "startOffset"=>1, "end"=>"/p[1]", "endOffset"=>10}]) } let!(:annotation2) { create(:legislation_annotation, draft_version: draft_version, text: "my other annotation", ranges: [{"start" => "/p[1]", "startOffset" => 1, "end" => "/p[1]", "endOffset" => 10}]) }
background do background do
login_as user login_as user

View File

@@ -424,7 +424,7 @@ feature 'Commenting legislation questions' do
end end
scenario "can not comment as a moderator" do scenario "can not comment as a moderator" do
admin = create(:administrator) admin = create(:administrator)
login_as(admin.user) login_as(admin.user)
visit legislation_process_question_path(legislation_question.process, legislation_question) visit legislation_process_question_path(legislation_question.process, legislation_question)

View File

@@ -395,7 +395,7 @@ feature 'Commenting proposals' do
end end
scenario "can not comment as a moderator" do scenario "can not comment as a moderator" do
admin = create(:administrator) admin = create(:administrator)
login_as(admin.user) login_as(admin.user)
visit proposal_path(proposal) visit proposal_path(proposal)

View File

@@ -77,8 +77,8 @@ feature 'Legacy Legislation' do
scenario 'Search' do scenario 'Search' do
legacy_legislation = create(:legacy_legislation) legacy_legislation = create(:legacy_legislation)
annotation1 = create(:annotation, legacy_legislation: legacy_legislation, text: "my annotation", ranges: [{"start"=>"/div[1]", "startOffset"=>5, "end"=>"/div[1]", "endOffset"=>10}]) annotation1 = create(:annotation, legacy_legislation: legacy_legislation, text: "my annotation", ranges: [{"start" => "/div[1]", "startOffset" => 5, "end" => "/div[1]", "endOffset" => 10}])
annotation2 = create(:annotation, legacy_legislation: legacy_legislation, text: "my other annotation", ranges: [{"start"=>"/div[1]", "startOffset"=>12, "end"=>"/div[1]", "endOffset"=>19}]) annotation2 = create(:annotation, legacy_legislation: legacy_legislation, text: "my other annotation", ranges: [{"start" => "/div[1]", "startOffset" => 12, "end" => "/div[1]", "endOffset" => 19}])
visit legacy_legislation_path(legacy_legislation) visit legacy_legislation_path(legacy_legislation)

View File

@@ -173,8 +173,8 @@ feature 'Legislation Draft Versions' do
scenario 'View annotations and comments' do scenario 'View annotations and comments' do
draft_version = create(:legislation_draft_version, :published) 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}]) annotation1 = create(:legislation_annotation, draft_version: draft_version, text: "my annotation", ranges: [{"start" => "/p[1]", "startOffset" => 5, "end" => "/p[1]", "endOffset" => 10}])
annotation2 = create(:legislation_annotation, draft_version: draft_version, text: "my other annotation", ranges: [{"start"=>"/p[1]", "startOffset"=>12, "end"=>"/p[1]", "endOffset"=>19}]) annotation2 = create(:legislation_annotation, draft_version: draft_version, text: "my other annotation", ranges: [{"start" => "/p[1]", "startOffset" => 12, "end" => "/p[1]", "endOffset" => 19}])
comment = create(:comment, commentable: annotation1) comment = create(:comment, commentable: annotation1)
visit legislation_process_draft_version_path(draft_version.process, draft_version) visit legislation_process_draft_version_path(draft_version.process, draft_version)
@@ -190,7 +190,7 @@ feature 'Legislation Draft Versions' do
scenario "Publish new comment for an annotation from comments box" do scenario "Publish new comment for an annotation from comments box" do
draft_version = create(:legislation_draft_version, :published) draft_version = create(:legislation_draft_version, :published)
annotation = create(:legislation_annotation, draft_version: draft_version, text: "my annotation", ranges: [{"start"=>"/p[1]", "startOffset"=>6, "end"=>"/p[1]", "endOffset"=>11}]) annotation = create(:legislation_annotation, draft_version: draft_version, text: "my annotation", ranges: [{"start" => "/p[1]", "startOffset" => 6, "end" => "/p[1]", "endOffset" => 11}])
visit legislation_process_draft_version_path(draft_version.process, draft_version) visit legislation_process_draft_version_path(draft_version.process, draft_version)
@@ -212,8 +212,8 @@ feature 'Legislation Draft Versions' do
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) 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}]) annotation1 = create(:legislation_annotation, draft_version: draft_version, text: "my annotation", ranges: [{"start" => "/p[1]", "startOffset" => 1, "end" => "/p[1]", "endOffset" => 5}])
annotation2 = create(:legislation_annotation, draft_version: draft_version, text: "my other annotation", ranges: [{"start"=>"/p[1]", "startOffset"=>1, "end"=>"/p[1]", "endOffset"=>10}]) annotation2 = create(:legislation_annotation, draft_version: draft_version, text: "my other annotation", ranges: [{"start" => "/p[1]", "startOffset" => 1, "end" => "/p[1]", "endOffset" => 10}])
visit legislation_process_draft_version_path(draft_version.process, draft_version) visit legislation_process_draft_version_path(draft_version.process, draft_version)
@@ -232,8 +232,8 @@ feature 'Legislation Draft Versions' do
context "Annotations page" do context "Annotations page" do
background do background do
@draft_version = create(:legislation_draft_version, :published) @draft_version = create(:legislation_draft_version, :published)
@annotation_1 = create(:legislation_annotation, draft_version: @draft_version, text: "my annotation", quote: "ipsum", ranges: [{"start"=>"/p[1]", "startOffset"=>6, "end"=>"/p[1]", "endOffset"=>11}]) @annotation_1 = create(:legislation_annotation, draft_version: @draft_version, text: "my annotation", quote: "ipsum", ranges: [{"start" => "/p[1]", "startOffset" => 6, "end" => "/p[1]", "endOffset" => 11}])
@annotation_2 = create(:legislation_annotation, draft_version: @draft_version, text: "my other annotation", quote: "audiam", ranges: [{"start"=>"/p[3]", "startOffset"=>6, "end"=>"/p[3]", "endOffset"=>11}]) @annotation_2 = create(:legislation_annotation, draft_version: @draft_version, text: "my other annotation", quote: "audiam", ranges: [{"start" => "/p[3]", "startOffset" => 6, "end" => "/p[3]", "endOffset" => 11}])
end end
scenario "See all annotations for a draft version" do scenario "See all annotations for a draft version" do
@@ -247,9 +247,9 @@ feature 'Legislation Draft Versions' do
background do background do
@process = create(:legislation_process) @process = create(:legislation_process)
@draft_version_1 = create(:legislation_draft_version, :published, process: @process, title: "Version 1", body: "Text with quote for version 1") @draft_version_1 = create(:legislation_draft_version, :published, process: @process, title: "Version 1", body: "Text with quote for version 1")
@annotation_1 = create(:legislation_annotation, draft_version: @draft_version_1, text: "annotation for version 1", quote: "quote for version 1", ranges: [{"start"=>"/p[1]", "startOffset"=>11, "end"=>"/p[1]", "endOffset"=>30}]) @annotation_1 = create(:legislation_annotation, draft_version: @draft_version_1, text: "annotation for version 1", quote: "quote for version 1", ranges: [{"start" => "/p[1]", "startOffset" => 11, "end" => "/p[1]", "endOffset" => 30}])
@draft_version_2 = create(:legislation_draft_version, :published, process: @process, title: "Version 2", body: "Text with quote for version 2") @draft_version_2 = create(:legislation_draft_version, :published, process: @process, title: "Version 2", body: "Text with quote for version 2")
@annotation_1 = create(:legislation_annotation, draft_version: @draft_version_2, text: "annotation for version 2", quote: "quote for version 2", ranges: [{"start"=>"/p[1]", "startOffset"=>11, "end"=>"/p[1]", "endOffset"=>30}]) @annotation_1 = create(:legislation_annotation, draft_version: @draft_version_2, text: "annotation for version 2", quote: "quote for version 2", ranges: [{"start" => "/p[1]", "startOffset" => 11, "end" => "/p[1]", "endOffset" => 30}])
end end
scenario "without js" do scenario "without js" do
@@ -278,8 +278,8 @@ feature 'Legislation Draft Versions' do
context "Annotation comments page" do context "Annotation comments page" do
background do background do
@draft_version = create(:legislation_draft_version, :published) @draft_version = create(:legislation_draft_version, :published)
@annotation_1 = create(:legislation_annotation, draft_version: @draft_version, text: "my annotation", quote: "ipsum", ranges: [{"start"=>"/p[1]", "startOffset"=>6, "end"=>"/p[1]", "endOffset"=>11}]) @annotation_1 = create(:legislation_annotation, draft_version: @draft_version, text: "my annotation", quote: "ipsum", ranges: [{"start" => "/p[1]", "startOffset" => 6, "end" => "/p[1]", "endOffset" => 11}])
@annotation_2 = create(:legislation_annotation, draft_version: @draft_version, text: "my other annotation", quote: "audiam", ranges: [{"start"=>"/p[3]", "startOffset"=>6, "end"=>"/p[3]", "endOffset"=>11}]) @annotation_2 = create(:legislation_annotation, draft_version: @draft_version, text: "my other annotation", quote: "audiam", ranges: [{"start" => "/p[3]", "startOffset" => 6, "end" => "/p[3]", "endOffset" => 11}])
end end
scenario "See one annotation with replies for a draft version" do scenario "See one annotation with replies for a draft version" do

View File

@@ -289,10 +289,10 @@ feature 'Valuation budget investments' do
end end
scenario 'Feasibility selection makes proper fields visible', :js do scenario 'Feasibility selection makes proper fields visible', :js do
feasible_fields = ['Price (€)', 'Cost during the first year (€)', 'Price explanation', 'Time scope'] feasible_fields = ['Price (€)', 'Cost during the first year (€)', 'Price explanation', 'Time scope']
unfeasible_fields = ['Feasibility explanation'] unfeasible_fields = ['Feasibility explanation']
any_feasibility_fields = ['Valuation finished', 'Internal comments'] any_feasibility_fields = ['Valuation finished', 'Internal comments']
undecided_fields = feasible_fields + unfeasible_fields + any_feasibility_fields undecided_fields = feasible_fields + unfeasible_fields + any_feasibility_fields
visit edit_valuation_budget_budget_investment_path(@budget, @investment) visit edit_valuation_budget_budget_investment_path(@budget, @investment)

View File

@@ -403,7 +403,7 @@ feature 'Valuation spending proposals' do
end end
scenario "Summary table" do scenario "Summary table" do
scarlett = create(:valuator) scarlett = create(:valuator)
john = create(:valuator) john = create(:valuator)
finished_and_feasible1 = create(:spending_proposal, valuation_finished: true, feasible: true, price: '3000000') finished_and_feasible1 = create(:spending_proposal, valuation_finished: true, feasible: true, price: '3000000')
@@ -452,7 +452,7 @@ feature 'Valuation spending proposals' do
scenario "Order by investment project count" do scenario "Order by investment project count" do
isabel = create(:valuator) isabel = create(:valuator)
john = create(:valuator) john = create(:valuator)
scarlett = create(:valuator) scarlett = create(:valuator)
3.times { create(:spending_proposal, valuators: [scarlett])} 3.times { create(:spending_proposal, valuators: [scarlett])}
1.times { create(:spending_proposal, valuators: [john])} 1.times { create(:spending_proposal, valuators: [john])}

View File

@@ -9,12 +9,12 @@ describe ProposalsHelper do
end end
it "should be a between 1 and 100 if there are votes but less than needed" do it "should be a between 1 and 100 if there are votes but less than needed" do
proposal = create(:proposal, cached_votes_up: Proposal.votes_needed_for_success/2) proposal = create(:proposal, cached_votes_up: Proposal.votes_needed_for_success / 2)
expect(progress_bar_percentage(proposal)).to eq 50 expect(progress_bar_percentage(proposal)).to eq 50
end end
it "should be 100 if there are more votes than needed" do it "should be 100 if there are more votes than needed" do
proposal = create(:proposal, cached_votes_up: Proposal.votes_needed_for_success*2) proposal = create(:proposal, cached_votes_up: Proposal.votes_needed_for_success * 2)
expect(progress_bar_percentage(proposal)).to eq 100 expect(progress_bar_percentage(proposal)).to eq 100
end end
end end
@@ -31,12 +31,12 @@ describe ProposalsHelper do
end end
it "should be a between 1 and 100 if there are votes but less than needed" do it "should be a between 1 and 100 if there are votes but less than needed" do
proposal = create(:proposal, cached_votes_up: Proposal.votes_needed_for_success/2) proposal = create(:proposal, cached_votes_up: Proposal.votes_needed_for_success / 2)
expect(supports_percentage(proposal)).to eq "50%" expect(supports_percentage(proposal)).to eq "50%"
end end
it "should be 100 if there are more votes than needed" do it "should be 100 if there are more votes than needed" do
proposal = create(:proposal, cached_votes_up: Proposal.votes_needed_for_success*2) proposal = create(:proposal, cached_votes_up: Proposal.votes_needed_for_success * 2)
expect(supports_percentage(proposal)).to eq "100%" expect(supports_percentage(proposal)).to eq "100%"
end end

View File

@@ -23,14 +23,14 @@ describe Ahoy::DataSource do
it 'should work with single data sources' do it 'should work with single data sources' do
ds = Ahoy::DataSource.new ds = Ahoy::DataSource.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] expect(ds.build).to eq :x => ["2015-01-01", "2015-01-02"], "foo" => [2, 1]
end end
it 'should combine data sources' do it 'should combine data sources' do
ds = Ahoy::DataSource.new ds = Ahoy::DataSource.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
ds.add 'bar', Ahoy::Event.where(name: 'bar').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] 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
end end
end end

View File

@@ -545,7 +545,7 @@ describe Debate do
title_some_votes = create(:debate, title: 'stop corruption', cached_votes_up: 5) 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_least_voted = create(:debate, title: 'stop corruption', cached_votes_up: 2)
title_most_voted = create(:debate, title: 'stop corruption', cached_votes_up: 10) title_most_voted = create(:debate, title: 'stop corruption', cached_votes_up: 10)
description_most_voted = create(:debate, description: 'stop corruption', cached_votes_up: 10) description_most_voted = create(:debate, description: 'stop corruption', cached_votes_up: 10)
results = Debate.search('stop corruption') results = Debate.search('stop corruption')

View File

@@ -17,7 +17,7 @@ RSpec.describe Legislation::Annotation, type: :model do
Expetenda tincidunt in sed, ex partem placerat sea, porro commodo ex eam. His putant aeterno interesset at. Usu ea mundi tincidunt, omnium virtute aliquando ius ex. Ea aperiri sententiae duo. Usu nullam dolorum quaestio ei, sit vidit facilisis ea. Per ne impedit iracundia neglegentur. Consetetur neglegentur eum ut, vis animal legimus inimicus id. Expetenda tincidunt in sed, ex partem placerat sea, porro commodo ex eam. His putant aeterno interesset at. Usu ea mundi tincidunt, omnium virtute aliquando ius ex. Ea aperiri sententiae duo. Usu nullam dolorum quaestio ei, sit vidit facilisis ea. Per ne impedit iracundia neglegentur. Consetetur neglegentur eum ut, vis animal legimus inimicus id.
His audiam", His audiam",
ranges: [{"start"=>"/p[1]", "startOffset"=>6, "end"=>"/p[3]", "endOffset"=>11}] ranges: [{"start" => "/p[1]", "startOffset" => 6, "end" => "/p[3]", "endOffset" => 11}]
) )
expect(annotation.context).to eq("Lorem <span class=annotator-hl>ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.\n\nExpetenda tincidunt in sed, ex partem placerat sea, porro commodo ex eam. His putant aeterno interesset at. Usu ea mundi tincidunt, omnium virtute aliquando ius ex. Ea aperiri sententiae duo. Usu nullam dolorum quaestio ei, sit vidit facilisis ea. Per ne impedit iracundia neglegentur. Consetetur neglegentur eum ut, vis animal legimus inimicus id.\n\nHis audiam</span>deserunt in, eum ubique voluptatibus te. In reque dicta usu. Ne rebum dissentiet eam, vim omnis deseruisse id. Ullum deleniti vituperata at quo, insolens complectitur te eos, ea pri dico munere propriae. Vel ferri facilis ut, qui paulo ridens praesent ad. Possim alterum qui cu. Accusamus consulatu ius te, cu decore soleat appareat usu.") expect(annotation.context).to eq("Lorem <span class=annotator-hl>ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.\n\nExpetenda tincidunt in sed, ex partem placerat sea, porro commodo ex eam. His putant aeterno interesset at. Usu ea mundi tincidunt, omnium virtute aliquando ius ex. Ea aperiri sententiae duo. Usu nullam dolorum quaestio ei, sit vidit facilisis ea. Per ne impedit iracundia neglegentur. Consetetur neglegentur eum ut, vis animal legimus inimicus id.\n\nHis audiam</span>deserunt in, eum ubique voluptatibus te. In reque dicta usu. Ne rebum dissentiet eam, vim omnis deseruisse id. Ullum deleniti vituperata at quo, insolens complectitur te eos, ea pri dico munere propriae. Vel ferri facilis ut, qui paulo ridens praesent ad. Possim alterum qui cu. Accusamus consulatu ius te, cu decore soleat appareat usu.")
@@ -27,7 +27,7 @@ His audiam",
annotation = create(:legislation_annotation, annotation = create(:legislation_annotation,
draft_version: draft_version, draft_version: draft_version,
quote: "Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.\r\n\r\nExpetenda tincidunt in sed, ex partem placerat sea, porro commodo ex eam. His putant aeterno interesset at. Usu ea mundi tincidunt, omnium virtute aliquando ius ex. Ea aperiri sententiae duo", quote: "Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.\r\n\r\nExpetenda tincidunt in sed, ex partem placerat sea, porro commodo ex eam. His putant aeterno interesset at. Usu ea mundi tincidunt, omnium virtute aliquando ius ex. Ea aperiri sententiae duo",
ranges: [{"start"=>"/p[1]", "startOffset"=>273, "end"=>"/p[2]", "endOffset"=>190}] ranges: [{"start" => "/p[1]", "startOffset" => 273, "end" => "/p[2]", "endOffset" => 190}]
) )
expect(annotation.context).to eq("Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. <span class=annotator-hl>Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.\r\n\r\nExpetenda tincidunt in sed, ex partem placerat sea, porro commodo ex eam. His putant aeterno interesset at. Usu ea mundi tincidunt, omnium virtute aliquando ius ex. Ea aperiri sententiae duo</span>. Usu nullam dolorum quaestio ei, sit vidit facilisis ea. Per ne impedit iracundia neglegentur. Consetetur neglegentur eum ut, vis animal legimus inimicus id.") expect(annotation.context).to eq("Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. <span class=annotator-hl>Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.\r\n\r\nExpetenda tincidunt in sed, ex partem placerat sea, porro commodo ex eam. His putant aeterno interesset at. Usu ea mundi tincidunt, omnium virtute aliquando ius ex. Ea aperiri sententiae duo</span>. Usu nullam dolorum quaestio ei, sit vidit facilisis ea. Per ne impedit iracundia neglegentur. Consetetur neglegentur eum ut, vis animal legimus inimicus id.")
@@ -39,7 +39,7 @@ His audiam",
annotation = create(:legislation_annotation, annotation = create(:legislation_annotation,
draft_version: draft_version, draft_version: draft_version,
quote: "By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users.\r\n\r\nWhen we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish)", quote: "By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users.\r\n\r\nWhen we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish)",
ranges: [{"start"=>"/p[2]", "startOffset"=>127, "end"=>"/p[3]", "endOffset"=>223}] ranges: [{"start" => "/p[2]", "startOffset" => 127, "end" => "/p[3]", "endOffset" => 223}]
) )
expect(annotation.context).to eq("The licenses for most software and other practical works are designed to take away your freedom to share and change the works. <span class=annotator-hl>By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users.\r\n\r\nWhen we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish)</span>, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.") expect(annotation.context).to eq("The licenses for most software and other practical works are designed to take away your freedom to share and change the works. <span class=annotator-hl>By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users.\r\n\r\nWhen we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish)</span>, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.")

View File

@@ -32,7 +32,7 @@ describe :officer do
poll_2 = create(:poll) poll_2 = create(:poll)
booth_assignment_1 = create(:poll_booth_assignment, poll: poll_1) booth_assignment_1 = create(:poll_booth_assignment, poll: poll_1)
booth_assignment_2 = create(:poll_booth_assignment, poll: poll_2) booth_assignment_2 = create(:poll_booth_assignment, poll: poll_2)
create(:poll_officer_assignment, booth_assignment: booth_assignment_1, officer: officer, date: poll_1.starts_at) create(:poll_officer_assignment, booth_assignment: booth_assignment_1, officer: officer, date: poll_1.starts_at)
create(:poll_officer_assignment, booth_assignment: booth_assignment_2, officer: officer, final: true) create(:poll_officer_assignment, booth_assignment: booth_assignment_2, officer: officer, final: true)
@@ -92,7 +92,7 @@ describe :officer do
poll_2 = create(:poll) poll_2 = create(:poll)
booth_assignment_1 = create(:poll_booth_assignment, poll: poll_1) booth_assignment_1 = create(:poll_booth_assignment, poll: poll_1)
booth_assignment_2 = create(:poll_booth_assignment, poll: poll_2) booth_assignment_2 = create(:poll_booth_assignment, poll: poll_2)
create(:poll_officer_assignment, booth_assignment: booth_assignment_1, officer: officer, date: poll_1.starts_at) create(:poll_officer_assignment, booth_assignment: booth_assignment_1, officer: officer, date: poll_1.starts_at)
create(:poll_officer_assignment, booth_assignment: booth_assignment_2, officer: officer, final: true) create(:poll_officer_assignment, booth_assignment: booth_assignment_2, officer: officer, final: true)

View File

@@ -33,7 +33,7 @@ describe :voter do
user = create(:user, :level_two) user = create(:user, :level_two)
voter1 = create(:poll_voter, user: user, poll: poll) voter1 = create(:poll_voter, user: user, poll: poll)
voter2 = build(:poll_voter, user: user, poll: poll) voter2 = build(:poll_voter, user: user, poll: poll)
expect(voter2).to_not be_valid expect(voter2).to_not be_valid
expect(voter2.errors.messages[:document_number]).to eq(["User has already voted"]) expect(voter2.errors.messages[:document_number]).to eq(["User has already voted"])
@@ -43,7 +43,7 @@ describe :voter do
user = create(:user, :level_two) user = create(:user, :level_two)
voter1 = create(:poll_voter, user: user, poll: poll, booth_assignment: booth_assignment) voter1 = create(:poll_voter, user: user, poll: poll, booth_assignment: booth_assignment)
voter2 = build(:poll_voter, user: user, poll: poll, booth_assignment: booth_assignment) voter2 = build(:poll_voter, user: user, poll: poll, booth_assignment: booth_assignment)
expect(voter2).to_not be_valid expect(voter2).to_not be_valid
expect(voter2.errors.messages[:document_number]).to eq(["User has already voted"]) expect(voter2.errors.messages[:document_number]).to eq(["User has already voted"])
@@ -56,7 +56,7 @@ describe :voter do
user = create(:user, :level_two) user = create(:user, :level_two)
voter1 = create(:poll_voter, user: user, poll: poll, booth_assignment: booth_assignment1) voter1 = create(:poll_voter, user: user, poll: poll, booth_assignment: booth_assignment1)
voter2 = build(:poll_voter, user: user, poll: poll, booth_assignment: booth_assignment2) voter2 = build(:poll_voter, user: user, poll: poll, booth_assignment: booth_assignment2)
expect(voter2).to_not be_valid expect(voter2).to_not be_valid
expect(voter2.errors.messages[:document_number]).to eq(["User has already voted"]) expect(voter2.errors.messages[:document_number]).to eq(["User has already voted"])
@@ -69,7 +69,7 @@ describe :voter do
user = create(:user, :level_two) user = create(:user, :level_two)
voter1 = create(:poll_voter, user: user, booth_assignment: booth_assignment1) voter1 = create(:poll_voter, user: user, booth_assignment: booth_assignment1)
voter2 = build(:poll_voter, user: user, booth_assignment: booth_assignment2) voter2 = build(:poll_voter, user: user, booth_assignment: booth_assignment2)
expect(voter2).to be_valid expect(voter2).to be_valid
end end

View File

@@ -13,19 +13,19 @@ describe Verification::Residence do
describe "dates" do describe "dates" do
it "should be valid with a valid date of birth" do it "should be valid with a valid date of birth" do
residence = Verification::Residence.new({"date_of_birth(3i)"=>"1", "date_of_birth(2i)"=>"1", "date_of_birth(1i)"=>"1980"}) residence = Verification::Residence.new({"date_of_birth(3i)" => "1", "date_of_birth(2i)" => "1", "date_of_birth(1i)" => "1980"})
expect(residence.errors[:date_of_birth].size).to eq(0) expect(residence.errors[:date_of_birth].size).to eq(0)
end end
it "should not be valid without a date of birth" do it "should not be valid without a date of birth" do
residence = Verification::Residence.new({"date_of_birth(3i)"=>"", "date_of_birth(2i)"=>"", "date_of_birth(1i)"=>""}) residence = Verification::Residence.new({"date_of_birth(3i)" => "", "date_of_birth(2i)" => "", "date_of_birth(1i)" => ""})
expect(residence).to_not be_valid expect(residence).to_not be_valid
expect(residence.errors[:date_of_birth]).to include("can't be blank") expect(residence.errors[:date_of_birth]).to include("can't be blank")
end end
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.years.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

View File

@@ -220,7 +220,7 @@ describe User do
subject.username = nil subject.username = nil
expect(subject).to be_valid expect(subject).to be_valid
subject.organization.name= nil subject.organization.name = nil
expect(subject).to_not be_valid expect(subject).to_not be_valid
end end
end end