Remove obsolete specs
This commit is contained in:
@@ -244,10 +244,6 @@ class User < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
delegate :can?, :cannot?, to: :ability
|
delegate :can?, :cannot?, to: :ability
|
||||||
|
|
||||||
def age_range
|
|
||||||
AgeRangeCalculator::range_from_birthday(self.date_of_birth).to_s
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def clean_document_number
|
def clean_document_number
|
||||||
|
|||||||
@@ -1,17 +1,12 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
api_types = GraphQL::ApiTypesCreator.new(API_TYPE_DEFINITIONS).create
|
||||||
api_types_creator = GraphQL::ApiTypesCreator.new(API_TYPE_DEFINITIONS)
|
query_type = GraphQL::QueryTypeCreator.new(api_types).create
|
||||||
created_api_types = api_types_creator.create
|
|
||||||
|
|
||||||
query_type_creator = GraphQL::QueryTypeCreator.new(created_api_types)
|
|
||||||
QueryType = query_type_creator.create
|
|
||||||
|
|
||||||
ConsulSchema = GraphQL::Schema.define do
|
ConsulSchema = GraphQL::Schema.define do
|
||||||
query QueryType
|
query query_type
|
||||||
max_depth 12
|
max_depth 12
|
||||||
end
|
end
|
||||||
# ------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
def execute(query_string, context = {}, variables = {})
|
def execute(query_string, context = {}, variables = {})
|
||||||
ConsulSchema.execute(query_string, context: context, variables: variables)
|
ConsulSchema.execute(query_string, context: context, variables: variables)
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ describe Comment do
|
|||||||
|
|
||||||
let(:comment) { build(:comment) }
|
let(:comment) { build(:comment) }
|
||||||
|
|
||||||
it_behaves_like "public_voters_stats"
|
|
||||||
it_behaves_like "has_public_author"
|
it_behaves_like "has_public_author"
|
||||||
|
|
||||||
it "is valid" do
|
it "is valid" do
|
||||||
|
|||||||
@@ -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
|
|
||||||
@@ -4,7 +4,6 @@ require 'rails_helper'
|
|||||||
describe Debate do
|
describe Debate do
|
||||||
let(:debate) { build(:debate) }
|
let(:debate) { build(:debate) }
|
||||||
|
|
||||||
it_behaves_like "public_voters_stats"
|
|
||||||
it_behaves_like "has_public_author"
|
it_behaves_like "has_public_author"
|
||||||
|
|
||||||
it "should be valid" do
|
it "should be valid" do
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ require 'rails_helper'
|
|||||||
describe Proposal do
|
describe Proposal do
|
||||||
let(:proposal) { build(:proposal) }
|
let(:proposal) { build(:proposal) }
|
||||||
|
|
||||||
it_behaves_like "public_voters_stats"
|
|
||||||
it_behaves_like "has_public_author"
|
it_behaves_like "has_public_author"
|
||||||
|
|
||||||
it "should be valid" do
|
it "should be valid" do
|
||||||
|
|||||||
@@ -469,10 +469,4 @@ describe User do
|
|||||||
|
|
||||||
end
|
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
|
end
|
||||||
|
|||||||
@@ -92,25 +92,6 @@ describe 'Vote' do
|
|||||||
end
|
end
|
||||||
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
|
describe '#public_timestamp' do
|
||||||
it "truncates created_at timestamp up to minutes" do
|
it "truncates created_at timestamp up to minutes" do
|
||||||
vote = create(:vote, created_at: Time.zone.parse('2016-02-10 15:30:45'))
|
vote = create(:vote, created_at: Time.zone.parse('2016-02-10 15:30:45'))
|
||||||
|
|||||||
Reference in New Issue
Block a user