Fix all Layout/SpaceAroundOperators rubocop issues and remove file list from rubocop_todo list
This commit is contained in:
@@ -557,12 +557,6 @@ Style/RescueModifier:
|
||||
- 'app/controllers/concerns/commentable_actions.rb'
|
||||
- 'app/controllers/verification/sms_controller.rb'
|
||||
|
||||
# Offense count: 66
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: AllowForAlignment.
|
||||
Layout/SpaceAroundOperators:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 9
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
||||
|
||||
@@ -93,7 +93,7 @@ module Budgets
|
||||
|
||||
def set_random_seed
|
||||
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
|
||||
Budget::Investment.connection.execute("select setseed(#{seed})")
|
||||
else
|
||||
|
||||
@@ -20,7 +20,7 @@ class Management::Budgets::InvestmentsController < Management::BaseController
|
||||
@investment.author = managed_user
|
||||
|
||||
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
|
||||
else
|
||||
render :new
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module BallotsHelper
|
||||
|
||||
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
|
||||
@@ -13,7 +13,7 @@ module OfficingHelper
|
||||
officer_assignments.each do |oa|
|
||||
options << [oa.booth_assignment.booth.name.to_s, oa.id]
|
||||
end
|
||||
options.sort! {|x, y| x[0]<=>y[0]}
|
||||
options.sort! {|x, y| x[0] <=> y[0]}
|
||||
options_for_select(options, params[:oa])
|
||||
end
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ module PollRecountsHelper
|
||||
end
|
||||
|
||||
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
|
||||
@@ -18,7 +18,7 @@ module VerificationHelper
|
||||
data_to_mask = match[2]
|
||||
email_provider = match[3]
|
||||
|
||||
data_to_display + "*"*data_to_mask.size + "@" + email_provider
|
||||
data_to_display + "*" * data_to_mask.size + "@" + email_provider
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -64,7 +64,7 @@ class Comment < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def author=(author)
|
||||
self.user= author
|
||||
self.user = author
|
||||
end
|
||||
|
||||
def total_votes
|
||||
|
||||
@@ -3,7 +3,7 @@ module Conflictable
|
||||
|
||||
def conflictive?
|
||||
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
|
||||
|
||||
@@ -35,7 +35,7 @@ class Legislation::Annotation < ActiveRecord::Base
|
||||
selector_end = "/html/body/#{range_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]
|
||||
|
||||
self.context = "#{remainder_el_start}<span class=annotator-hl>#{quote}</span>#{remainder_el_end}"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module ScoreCalculator
|
||||
|
||||
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
|
||||
|
||||
def self.hot_score(date, votes_total, votes_up, comments_count)
|
||||
@@ -13,7 +13,7 @@ module ScoreCalculator
|
||||
sign = score <=> 0
|
||||
seconds = ((date || Time.current) - EPOC).to_f
|
||||
|
||||
(((offset * sign) + (seconds/TIME_UNIT)) * 10000000).round
|
||||
(((offset * sign) + (seconds / TIME_UNIT)) * 10000000).round
|
||||
end
|
||||
|
||||
def self.confidence_score(votes_total, votes_up)
|
||||
|
||||
@@ -38,7 +38,7 @@ class SMSApi
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
@@ -36,7 +36,7 @@ describe Admin::Api::StatsController do
|
||||
expect(response).to be_ok
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
@@ -65,7 +65,7 @@ describe Admin::Api::StatsController do
|
||||
expect(response).to be_ok
|
||||
|
||||
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
|
||||
|
||||
@@ -88,7 +88,7 @@ describe Admin::Api::StatsController do
|
||||
expect(response).to be_ok
|
||||
|
||||
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
|
||||
|
||||
@@ -107,7 +107,7 @@ describe Admin::Api::StatsController do
|
||||
expect(response).to be_ok
|
||||
|
||||
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
|
||||
|
||||
@@ -16,8 +16,8 @@ describe Legislation::AnnotationsController do
|
||||
post :create, process_id: @process.id,
|
||||
draft_version_id: @draft_version.id,
|
||||
legislation_annotation: {
|
||||
"quote"=>"ipsum",
|
||||
"ranges"=>[{"start"=>"/p[1]", "startOffset"=>6, "end"=>"/p[1]", "endOffset"=>11}],
|
||||
"quote" => "ipsum",
|
||||
"ranges" => [{"start" => "/p[1]", "startOffset" => 6, "end" => "/p[1]", "endOffset" => 11}],
|
||||
"text": "una anotacion"
|
||||
}
|
||||
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,
|
||||
draft_version_id: @final_version.id,
|
||||
legislation_annotation: {
|
||||
"quote"=>"ipsum",
|
||||
"ranges"=>[{"start"=>"/p[1]", "startOffset"=>6, "end"=>"/p[1]", "endOffset"=>11}],
|
||||
"quote" => "ipsum",
|
||||
"ranges" => [{"start" => "/p[1]", "startOffset" => 6, "end" => "/p[1]", "endOffset" => 11}],
|
||||
"text": "una anotacion"
|
||||
}
|
||||
|
||||
@@ -45,8 +45,8 @@ describe Legislation::AnnotationsController do
|
||||
xhr :post, :create, process_id: @process.id,
|
||||
draft_version_id: @draft_version.id,
|
||||
legislation_annotation: {
|
||||
"quote"=>"ipsum",
|
||||
"ranges"=>[{"start"=>"/p[1]", "startOffset"=>6, "end"=>"/p[1]", "endOffset"=>11}],
|
||||
"quote" => "ipsum",
|
||||
"ranges" => [{"start" => "/p[1]", "startOffset" => 6, "end" => "/p[1]", "endOffset" => 11}],
|
||||
"text": "una anotacion"
|
||||
}
|
||||
end.to change { @draft_version.annotations.count }.by(1)
|
||||
@@ -60,8 +60,8 @@ describe Legislation::AnnotationsController do
|
||||
xhr :post, :create, process_id: @process.id,
|
||||
draft_version_id: @draft_version.id,
|
||||
legislation_annotation: {
|
||||
"quote"=>"ipsum",
|
||||
"ranges"=>[{"start"=>"/p[1]", "startOffset"=>6, "end"=>"/p[1]", "endOffset"=>11}],
|
||||
"quote" => "ipsum",
|
||||
"ranges" => [{"start" => "/p[1]", "startOffset" => 6, "end" => "/p[1]", "endOffset" => 11}],
|
||||
"text": "una anotacion"
|
||||
}
|
||||
end.to_not change { @draft_version.annotations.count }
|
||||
@@ -74,8 +74,8 @@ describe Legislation::AnnotationsController do
|
||||
xhr :post, :create, process_id: @process.id,
|
||||
draft_version_id: @draft_version.id,
|
||||
legislation_annotation: {
|
||||
"quote"=>"ipsum",
|
||||
"ranges"=>[{"start"=>"/p[1]", "startOffset"=>6, "end"=>"/p[1]", "endOffset"=>11}].to_json,
|
||||
"quote" => "ipsum",
|
||||
"ranges" => [{"start" => "/p[1]", "startOffset" => 6, "end" => "/p[1]", "endOffset" => 11}].to_json,
|
||||
"text": "una anotacion"
|
||||
}
|
||||
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
|
||||
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)
|
||||
sign_in @user
|
||||
|
||||
@@ -91,8 +91,8 @@ describe Legislation::AnnotationsController do
|
||||
xhr :post, :create, process_id: @process.id,
|
||||
draft_version_id: @draft_version.id,
|
||||
legislation_annotation: {
|
||||
"quote"=>"ipsum",
|
||||
"ranges"=>[{"start"=>"/p[1]", "startOffset"=>6, "end"=>"/p[1]", "endOffset"=>11}],
|
||||
"quote" => "ipsum",
|
||||
"ranges" => [{"start" => "/p[1]", "startOffset" => 6, "end" => "/p[1]", "endOffset" => 11}],
|
||||
"text": "una anotacion"
|
||||
}
|
||||
end.to_not change { @draft_version.annotations.count }
|
||||
|
||||
@@ -378,7 +378,7 @@ FactoryGirl.define do
|
||||
factory :annotation do
|
||||
quote "ipsum"
|
||||
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
|
||||
user
|
||||
end
|
||||
@@ -701,7 +701,7 @@ LOREM_IPSUM
|
||||
author factory: :user
|
||||
quote "ipsum"
|
||||
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_offset 6
|
||||
range_end "/p[1]"
|
||||
|
||||
@@ -510,8 +510,8 @@ feature 'Commenting legislation questions' do
|
||||
|
||||
feature "Merged comment threads", :js do
|
||||
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!(:annotation2) { create(:legislation_annotation, draft_version: draft_version, text: "my other annotation", ranges: [{"start"=>"/p[1]", "startOffset"=>1, "end"=>"/p[1]", "endOffset"=>10}]) }
|
||||
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}]) }
|
||||
|
||||
background do
|
||||
login_as user
|
||||
|
||||
@@ -77,8 +77,8 @@ feature 'Legacy Legislation' do
|
||||
|
||||
scenario 'Search' do
|
||||
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}])
|
||||
annotation2 = create(:annotation, legacy_legislation: legacy_legislation, text: "my other annotation", ranges: [{"start"=>"/div[1]", "startOffset"=>12, "end"=>"/div[1]", "endOffset"=>19}])
|
||||
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}])
|
||||
|
||||
visit legacy_legislation_path(legacy_legislation)
|
||||
|
||||
|
||||
@@ -173,8 +173,8 @@ feature 'Legislation Draft Versions' do
|
||||
|
||||
scenario 'View annotations and comments' do
|
||||
draft_version = create(:legislation_draft_version, :published)
|
||||
annotation1 = create(:legislation_annotation, draft_version: draft_version, text: "my annotation", ranges: [{"start"=>"/p[1]", "startOffset"=>5, "end"=>"/p[1]", "endOffset"=>10}])
|
||||
annotation2 = create(:legislation_annotation, draft_version: draft_version, text: "my other annotation", ranges: [{"start"=>"/p[1]", "startOffset"=>12, "end"=>"/p[1]", "endOffset"=>19}])
|
||||
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}])
|
||||
comment = create(:comment, commentable: annotation1)
|
||||
|
||||
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
|
||||
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)
|
||||
|
||||
@@ -212,8 +212,8 @@ feature 'Legislation Draft Versions' do
|
||||
|
||||
scenario 'View annotations and comments in an included range' do
|
||||
draft_version = create(:legislation_draft_version, :published)
|
||||
annotation1 = create(:legislation_annotation, draft_version: draft_version, text: "my annotation", ranges: [{"start"=>"/p[1]", "startOffset"=>1, "end"=>"/p[1]", "endOffset"=>5}])
|
||||
annotation2 = create(:legislation_annotation, draft_version: draft_version, text: "my other annotation", ranges: [{"start"=>"/p[1]", "startOffset"=>1, "end"=>"/p[1]", "endOffset"=>10}])
|
||||
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}])
|
||||
|
||||
visit legislation_process_draft_version_path(draft_version.process, draft_version)
|
||||
|
||||
@@ -232,8 +232,8 @@ feature 'Legislation Draft Versions' do
|
||||
context "Annotations page" do
|
||||
background do
|
||||
@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_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_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}])
|
||||
end
|
||||
|
||||
scenario "See all annotations for a draft version" do
|
||||
@@ -247,9 +247,9 @@ feature 'Legislation Draft Versions' do
|
||||
background do
|
||||
@process = create(:legislation_process)
|
||||
@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")
|
||||
@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
|
||||
|
||||
scenario "without js" do
|
||||
@@ -278,8 +278,8 @@ feature 'Legislation Draft Versions' do
|
||||
context "Annotation comments page" do
|
||||
background do
|
||||
@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_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_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}])
|
||||
end
|
||||
|
||||
scenario "See one annotation with replies for a draft version" do
|
||||
|
||||
@@ -9,12 +9,12 @@ describe ProposalsHelper do
|
||||
end
|
||||
|
||||
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
|
||||
end
|
||||
|
||||
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
|
||||
end
|
||||
end
|
||||
@@ -31,12 +31,12 @@ describe ProposalsHelper do
|
||||
end
|
||||
|
||||
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%"
|
||||
end
|
||||
|
||||
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%"
|
||||
end
|
||||
|
||||
|
||||
@@ -23,14 +23,14 @@ describe Ahoy::DataSource do
|
||||
it 'should work with single data sources' do
|
||||
ds = Ahoy::DataSource.new
|
||||
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
|
||||
|
||||
it 'should combine data sources' do
|
||||
ds = Ahoy::DataSource.new
|
||||
ds.add 'foo', Ahoy::Event.where(name: 'foo').group_by_day(:time).count
|
||||
ds.add 'bar', Ahoy::Event.where(name: 'bar').group_by_day(:time).count
|
||||
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
|
||||
|
||||
@@ -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.
|
||||
|
||||
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.")
|
||||
@@ -27,7 +27,7 @@ His audiam",
|
||||
annotation = create(:legislation_annotation,
|
||||
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",
|
||||
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.")
|
||||
@@ -39,7 +39,7 @@ His audiam",
|
||||
annotation = create(:legislation_annotation,
|
||||
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)",
|
||||
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.")
|
||||
|
||||
@@ -13,19 +13,19 @@ describe Verification::Residence do
|
||||
|
||||
describe "dates" 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)
|
||||
end
|
||||
|
||||
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.errors[:date_of_birth]).to include("can't be blank")
|
||||
end
|
||||
end
|
||||
|
||||
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.errors[:date_of_birth]).to include("You don't have the required age to participate")
|
||||
end
|
||||
|
||||
@@ -220,7 +220,7 @@ describe User do
|
||||
subject.username = nil
|
||||
expect(subject).to be_valid
|
||||
|
||||
subject.organization.name= nil
|
||||
subject.organization.name = nil
|
||||
expect(subject).to_not be_valid
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user