Merge branch 'master' into dashboard
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
describe AdminHelper do
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
describe ApplicationHelper do
|
||||
|
||||
|
||||
47
spec/helpers/budget_investments_helper_spec.rb
Normal file
47
spec/helpers/budget_investments_helper_spec.rb
Normal file
@@ -0,0 +1,47 @@
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe BudgetInvestmentsHelper, type: :helper do
|
||||
|
||||
describe "#set_direction" do
|
||||
|
||||
it "returns ASC if current_direction is DESC" do
|
||||
expect(set_direction("desc")).to eq "asc"
|
||||
end
|
||||
|
||||
it "returns DESC if current_direction is ASC" do
|
||||
expect(set_direction("asc")).to eq "desc"
|
||||
end
|
||||
|
||||
it "returns DESC if current_direction is nil" do
|
||||
expect(set_direction(nil)).to eq "desc"
|
||||
end
|
||||
end
|
||||
|
||||
describe "#set_sorting_icon" do
|
||||
let(:sort_by) { "title" }
|
||||
let(:params) { { sort_by: sort_by } }
|
||||
|
||||
it "returns arrow down if current direction is ASC" do
|
||||
expect(set_sorting_icon("asc", sort_by)).to eq "asc"
|
||||
end
|
||||
|
||||
it "returns arrow top if current direction is DESC" do
|
||||
expect(set_sorting_icon("desc", sort_by)).to eq "desc"
|
||||
end
|
||||
|
||||
it "returns arrow down if sort_by present, but no direction" do
|
||||
expect(set_sorting_icon(nil, sort_by)).to eq "asc"
|
||||
end
|
||||
|
||||
it "returns no icon if sort_by and direction is missing" do
|
||||
params[:sort_by] = nil
|
||||
expect(set_sorting_icon(nil, sort_by)).to eq ""
|
||||
end
|
||||
|
||||
it "returns no icon if sort_by is incorrect" do
|
||||
params[:sort_by] = "random"
|
||||
expect(set_sorting_icon("asc", sort_by)).to eq ""
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,4 +1,4 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
# Specs in this file have access to a helper object that includes
|
||||
# the CommentsHelper. For example:
|
||||
@@ -12,51 +12,51 @@ require 'rails_helper'
|
||||
# end
|
||||
RSpec.describe CommentsHelper, type: :helper do
|
||||
|
||||
describe '#user_level_class' do
|
||||
describe "#user_level_class" do
|
||||
|
||||
def comment_double(as_administrator: false, as_moderator: false, official: false)
|
||||
user = instance_double('User', official?: official, official_level: 'Y')
|
||||
instance_double('Comment', as_administrator?: as_administrator, as_moderator?: as_moderator, user: user)
|
||||
user = instance_double("User", official?: official, official_level: "Y")
|
||||
instance_double("Comment", as_administrator?: as_administrator, as_moderator?: as_moderator, user: user)
|
||||
end
|
||||
|
||||
it 'returns is-admin for comment done as administrator' do
|
||||
it "returns is-admin for comment done as administrator" do
|
||||
comment = comment_double(as_administrator: true)
|
||||
|
||||
expect(helper.user_level_class(comment)).to eq('is-admin')
|
||||
expect(helper.user_level_class(comment)).to eq("is-admin")
|
||||
end
|
||||
|
||||
it 'returns is-moderator for comment done as moderator' do
|
||||
it "returns is-moderator for comment done as moderator" do
|
||||
comment = comment_double(as_moderator: true)
|
||||
|
||||
expect(helper.user_level_class(comment)).to eq('is-moderator')
|
||||
expect(helper.user_level_class(comment)).to eq("is-moderator")
|
||||
end
|
||||
|
||||
it 'returns level followed by official level if user is official' do
|
||||
it "returns level followed by official level if user is official" do
|
||||
comment = comment_double(official: true)
|
||||
|
||||
expect(helper.user_level_class(comment)).to eq('level-Y')
|
||||
expect(helper.user_level_class(comment)).to eq("level-Y")
|
||||
end
|
||||
|
||||
it 'returns an empty class otherwise' do
|
||||
it "returns an empty class otherwise" do
|
||||
comment = comment_double
|
||||
|
||||
expect(helper.user_level_class(comment)).to eq('')
|
||||
expect(helper.user_level_class(comment)).to eq("")
|
||||
end
|
||||
end
|
||||
|
||||
describe '#comment_author_class' do
|
||||
it 'returns is-author if author is the commenting user' do
|
||||
describe "#comment_author_class" do
|
||||
it "returns is-author if author is the commenting user" do
|
||||
author_id = 42
|
||||
comment = instance_double('Comment', user_id: author_id)
|
||||
comment = instance_double("Comment", user_id: author_id)
|
||||
|
||||
expect(helper.comment_author_class(comment, author_id)).to eq('is-author')
|
||||
expect(helper.comment_author_class(comment, author_id)).to eq("is-author")
|
||||
end
|
||||
|
||||
it 'returns an empty string if commenter is not the author' do
|
||||
it "returns an empty string if commenter is not the author" do
|
||||
author_id = 42
|
||||
comment = instance_double('Comment', user_id: author_id - 1)
|
||||
comment = instance_double("Comment", user_id: author_id - 1)
|
||||
|
||||
expect(helper.comment_author_class(comment, author_id)).to eq('')
|
||||
expect(helper.comment_author_class(comment, author_id)).to eq("")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
describe GeozonesHelper do
|
||||
|
||||
|
||||
31
spec/helpers/legislation_helper_spec.rb
Normal file
31
spec/helpers/legislation_helper_spec.rb
Normal file
@@ -0,0 +1,31 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe LegislationHelper do
|
||||
let(:process) { build(:legislation_process) }
|
||||
|
||||
it "is valid" do
|
||||
expect(process).to be_valid
|
||||
end
|
||||
|
||||
describe "banner colors presence" do
|
||||
it "background and font color exist" do
|
||||
@process = build(:legislation_process, background_color: "#944949", font_color: "#ffffff")
|
||||
expect(banner_color?).to eq(true)
|
||||
end
|
||||
|
||||
it "background color exist and font color not exist" do
|
||||
@process = build(:legislation_process, background_color: "#944949", font_color: "")
|
||||
expect(banner_color?).to eq(false)
|
||||
end
|
||||
|
||||
it "background color not exist and font color exist" do
|
||||
@process = build(:legislation_process, background_color: "", font_color: "#944949")
|
||||
expect(banner_color?).to eq(false)
|
||||
end
|
||||
|
||||
it "background and font color not exist" do
|
||||
@process = build(:legislation_process, background_color: "", font_color: "")
|
||||
expect(banner_color?).to eq(false)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,4 +1,4 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
describe LocalesHelper do
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
describe ProposalsHelper do
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe SettingsHelper, type: :helper do
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
describe TextHelper do
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
describe UsersHelper do
|
||||
|
||||
describe '#humanize_document_type' do
|
||||
describe "#humanize_document_type" do
|
||||
it "returns a humanized document type" do
|
||||
expect(humanize_document_type("1")).to eq "DNI"
|
||||
expect(humanize_document_type("2")).to eq "Passport"
|
||||
@@ -10,14 +10,14 @@ describe UsersHelper do
|
||||
end
|
||||
end
|
||||
|
||||
describe '#deleted_commentable_text' do
|
||||
describe "#deleted_commentable_text" do
|
||||
it "returns the appropriate message for deleted debates" do
|
||||
debate = create(:debate)
|
||||
comment = create(:comment, commentable: debate)
|
||||
|
||||
debate.hide
|
||||
|
||||
expect(comment_commentable_title(comment)).to eq('<del>' + comment.commentable.title +
|
||||
expect(comment_commentable_title(comment)).to eq("<del>" + comment.commentable.title +
|
||||
'</del> <span class="small">(This debate has been deleted)</span>')
|
||||
end
|
||||
|
||||
@@ -27,7 +27,7 @@ describe UsersHelper do
|
||||
|
||||
proposal.hide
|
||||
|
||||
expect(comment_commentable_title(comment)).to eq('<del>' + comment.commentable.title +
|
||||
expect(comment_commentable_title(comment)).to eq("<del>" + comment.commentable.title +
|
||||
'</del> <span class="small">(This proposal has been deleted)</span>')
|
||||
end
|
||||
|
||||
@@ -37,12 +37,12 @@ describe UsersHelper do
|
||||
|
||||
investment.hide
|
||||
|
||||
expect(comment_commentable_title(comment)).to eq('<del>' + comment.commentable.title +
|
||||
expect(comment_commentable_title(comment)).to eq("<del>" + comment.commentable.title +
|
||||
'</del> <span class="small">(This investment project has been deleted)</span>')
|
||||
end
|
||||
end
|
||||
|
||||
describe '#comment_commentable_title' do
|
||||
describe "#comment_commentable_title" do
|
||||
it "returns a link to the comment" do
|
||||
comment = create(:comment)
|
||||
expect(comment_commentable_title(comment)).to eq link_to comment.commentable.title, comment
|
||||
@@ -51,7 +51,7 @@ describe UsersHelper do
|
||||
it "returns a hint if the commentable has been deleted" do
|
||||
comment = create(:comment)
|
||||
comment.commentable.hide
|
||||
expect(comment_commentable_title(comment)).to eq('<del>' + comment.commentable.title +
|
||||
expect(comment_commentable_title(comment)).to eq("<del>" + comment.commentable.title +
|
||||
'</del> <span class="small">(This debate has been deleted)</span>')
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
describe VerificationHelper do
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
require 'rails_helper'
|
||||
require "rails_helper"
|
||||
|
||||
describe VotesHelper do
|
||||
|
||||
@@ -24,8 +24,8 @@ describe VotesHelper do
|
||||
create_list(:vote, 8, votable: debate, vote_flag: true)
|
||||
create_list(:vote, 3, votable: debate, vote_flag: false)
|
||||
|
||||
expect(votes_percentage('likes', debate)).to eq("72%")
|
||||
expect(votes_percentage('dislikes', debate)).to eq("28%")
|
||||
expect(votes_percentage("likes", debate)).to eq("72%")
|
||||
expect(votes_percentage("dislikes", debate)).to eq("28%")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user