Skip to content

Commit

Permalink
#198 - Fitting to codeclimate
Browse files Browse the repository at this point in the history
  • Loading branch information
zarbielli committed Oct 20, 2018
1 parent 9a2d849 commit dee146b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 24 deletions.
2 changes: 1 addition & 1 deletion indicaAi/app/models/local.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ def self.find_by_name(params)

def self.find_local_ratings(local_id)
Local.find(local_id).local_ratings
end
end
end
49 changes: 26 additions & 23 deletions indicaAi/spec/models/local_rating_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,33 @@
rating.local = local
assert rating.save == false
end
end
end

it 'Must exist a local' do
user = UserIdentifier.create(identifier: 345)
user.save
rating = LocalRating.new
rating.value = 4
rating.user_identifier = user
assert rating.save == false
end
RSpec.describe LocalRating, type: :model do
it 'Must exist a local' do
user = UserIdentifier.create(identifier: 345)
user.save
rating = LocalRating.new
rating.value = 4
rating.user_identifier = user
assert rating.save == false
end

it 'Must exist a value' do
local = Local.create(name: 'Teste')
local.save
user = UserIdentifier.create(identifier: 345)
user.save
rating = LocalRating.new
rating.user_identifier = user
rating.local = local
assert rating.save == false
end
it { should belong_to(:user_identifier) }
it { should belong_to(:local) }
it { should validate_presence_of(:value) }
it { should validate_numericality_of(:value) }
it { should validate_numericality_of(:value).is_less_than_or_equal_to(5) }
it 'Must exist a value' do
local = Local.create(name: 'Teste')
local.save
user = UserIdentifier.create(identifier: 345)
user.save
rating = LocalRating.new
rating.user_identifier = user
rating.local = local
assert rating.save == false
end

it { should belong_to(:user_identifier) }
it { should belong_to(:local) }
it { should validate_presence_of(:value) }
it { should validate_numericality_of(:value) }
it { should validate_numericality_of(:value).is_less_than_or_equal_to(5) }
end

0 comments on commit dee146b

Please sign in to comment.