diff --git a/app/models/user.rb b/app/models/user.rb index 04ca708a9..03f2db27b 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -244,10 +244,6 @@ class User < ActiveRecord::Base end delegate :can?, :cannot?, to: :ability - def age_range - AgeRangeCalculator::range_from_birthday(self.date_of_birth).to_s - end - private def clean_document_number diff --git a/spec/lib/graphql_spec.rb b/spec/lib/graphql_spec.rb index 99597c690..b2a9ed477 100644 --- a/spec/lib/graphql_spec.rb +++ b/spec/lib/graphql_spec.rb @@ -1,17 +1,12 @@ require 'rails_helper' -# ------------------------------------------------------------------------------ -api_types_creator = GraphQL::ApiTypesCreator.new(API_TYPE_DEFINITIONS) -created_api_types = api_types_creator.create - -query_type_creator = GraphQL::QueryTypeCreator.new(created_api_types) -QueryType = query_type_creator.create +api_types = GraphQL::ApiTypesCreator.new(API_TYPE_DEFINITIONS).create +query_type = GraphQL::QueryTypeCreator.new(api_types).create ConsulSchema = GraphQL::Schema.define do - query QueryType + query query_type max_depth 12 end -# ------------------------------------------------------------------------------ def execute(query_string, context = {}, variables = {}) ConsulSchema.execute(query_string, context: context, variables: variables) diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb index 09e6a9900..db68a9e4e 100644 --- a/spec/models/comment_spec.rb +++ b/spec/models/comment_spec.rb @@ -4,7 +4,6 @@ describe Comment do let(:comment) { build(:comment) } - it_behaves_like "public_voters_stats" it_behaves_like "has_public_author" it "is valid" do diff --git a/spec/models/concerns/public_voters_stats_spec.rb b/spec/models/concerns/public_voters_stats_spec.rb deleted file mode 100644 index eaa923599..000000000 --- a/spec/models/concerns/public_voters_stats_spec.rb +++ /dev/null @@ -1,39 +0,0 @@ -require 'spec_helper' - -shared_examples_for 'public_voters_stats' do - let(:model) { described_class } # the class that includes the concern - - describe 'votes_above_threshold?' do - let(:votable) { create(model.to_s.underscore.to_sym) } - - context 'with default threshold value' do - it 'is true when votes are above threshold' do - 200.times { create(:vote, votable: votable) } - - expect(votable.votes_above_threshold?).to be_truthy - end - - it 'is false when votes are under threshold' do - 199.times { create(:vote, votable: votable) } - - expect(votable.votes_above_threshold?).to be_falsey - end - end - - context 'with custom threshold value' do - it 'is true when votes are above threshold' do - create(:setting, key: "#{model.to_s.underscore}_api_votes_threshold", value: '2') - 2.times { create(:vote, votable: votable) } - - expect(votable.votes_above_threshold?).to be_truthy - end - - it 'is false when votes are under threshold' do - create(:setting, key: "#{model.to_s.underscore}_api_votes_threshold", value: '2') - create(:vote, votable: votable) - - expect(votable.votes_above_threshold?).to be_falsey - end - end - end -end diff --git a/spec/models/debate_spec.rb b/spec/models/debate_spec.rb index 4db0e5f0a..5272b6e7a 100644 --- a/spec/models/debate_spec.rb +++ b/spec/models/debate_spec.rb @@ -4,7 +4,6 @@ require 'rails_helper' describe Debate do let(:debate) { build(:debate) } - it_behaves_like "public_voters_stats" it_behaves_like "has_public_author" it "should be valid" do diff --git a/spec/models/proposal_spec.rb b/spec/models/proposal_spec.rb index 08ed6b384..50df57963 100644 --- a/spec/models/proposal_spec.rb +++ b/spec/models/proposal_spec.rb @@ -4,7 +4,6 @@ require 'rails_helper' describe Proposal do let(:proposal) { build(:proposal) } - it_behaves_like "public_voters_stats" it_behaves_like "has_public_author" it "should be valid" do diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index ca59cb288..ed0bac164 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -469,10 +469,4 @@ describe User do end - describe "#age_range" do - it 'returns string representation of age range' do - user = create(:user, date_of_birth: Time.current - 41.years) - expect(user.age_range).to eq('41..60') - end - end end diff --git a/spec/models/vote_spec.rb b/spec/models/vote_spec.rb index 9dc30d95a..8e5db0ce7 100644 --- a/spec/models/vote_spec.rb +++ b/spec/models/vote_spec.rb @@ -92,25 +92,6 @@ describe 'Vote' do end end - describe 'public_voter' do - it 'only returns voter if votable has enough votes' do - create(:setting, key: 'proposal_api_votes_threshold', value: '2') - - proposal_1 = create(:proposal) - proposal_2 = create(:proposal) - - voter_1 = create(:user) - voter_2 = create(:user) - - vote_1 = create(:vote, votable: proposal_1, voter: voter_1) - vote_2 = create(:vote, votable: proposal_2, voter: voter_1) - vote_3 = create(:vote, votable: proposal_2, voter: voter_2) - - expect(vote_1.public_voter).to be_nil - expect(vote_2.public_voter).to eq(voter_1) - end - end - describe '#public_timestamp' do it "truncates created_at timestamp up to minutes" do vote = create(:vote, created_at: Time.zone.parse('2016-02-10 15:30:45'))