mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-18 23:49:42 +00:00
Fix Rails/WhereExists
cop in app/validators (#28854)
This commit is contained in:
parent
e2d9635074
commit
67f54c4e75
|
@ -88,8 +88,6 @@ Rails/WhereExists:
|
||||||
- 'app/serializers/rest/announcement_serializer.rb'
|
- 'app/serializers/rest/announcement_serializer.rb'
|
||||||
- 'app/services/activitypub/fetch_remote_status_service.rb'
|
- 'app/services/activitypub/fetch_remote_status_service.rb'
|
||||||
- 'app/services/vote_service.rb'
|
- 'app/services/vote_service.rb'
|
||||||
- 'app/validators/reaction_validator.rb'
|
|
||||||
- 'app/validators/vote_validator.rb'
|
|
||||||
- 'app/workers/move_worker.rb'
|
- 'app/workers/move_worker.rb'
|
||||||
- 'lib/tasks/tests.rake'
|
- 'lib/tasks/tests.rake'
|
||||||
- 'spec/models/account_spec.rb'
|
- 'spec/models/account_spec.rb'
|
||||||
|
|
|
@ -19,7 +19,7 @@ class ReactionValidator < ActiveModel::Validator
|
||||||
end
|
end
|
||||||
|
|
||||||
def new_reaction?(reaction)
|
def new_reaction?(reaction)
|
||||||
!reaction.announcement.announcement_reactions.where(name: reaction.name).exists?
|
!reaction.announcement.announcement_reactions.exists?(name: reaction.name)
|
||||||
end
|
end
|
||||||
|
|
||||||
def limit_reached?(reaction)
|
def limit_reached?(reaction)
|
||||||
|
|
|
@ -35,7 +35,7 @@ class VoteValidator < ActiveModel::Validator
|
||||||
if vote.persisted?
|
if vote.persisted?
|
||||||
account_votes_on_same_poll(vote).where(choice: vote.choice).where.not(poll_votes: { id: vote }).exists?
|
account_votes_on_same_poll(vote).where(choice: vote.choice).where.not(poll_votes: { id: vote }).exists?
|
||||||
else
|
else
|
||||||
account_votes_on_same_poll(vote).where(choice: vote.choice).exists?
|
account_votes_on_same_poll(vote).exists?(choice: vote.choice)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue