Skip to content

Commit

Permalink
add require 'squeel' to spec_helper and change the likes and likes?…
Browse files Browse the repository at this point in the history
… methods back to squeel
  • Loading branch information
acmetech committed Feb 13, 2014
1 parent 8f42d3e commit 90d2a3c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/models/socializer/person.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ def contact_of
def likes
activity_obj_id = activity_object.id
verbs_of_interest = %w(like unlike)
query = Activity.joins(:verb).where(actor_id: activity_obj_id, target_id: nil, socializer_verbs: { name: verbs_of_interest })
@likes ||= query.group(:activity_object_id).having('COUNT(1) % 2 == 1')
query = Activity.joins { verb }.where { actor_id.eq(activity_obj_id) & target_id.eq(nil) & verb.name.in(verbs_of_interest) }
@likes ||= query.group { activity_object_id }.having('COUNT(1) % 2 == 1')
end

def likes?(object)
activity_obj_id = activity_object.id
verbs_of_interest = %w(like unlike)
query = Activity.joins(:verb).where(activity_object_id: object.id, actor_id: activity_obj_id, socializer_verbs: { name: verbs_of_interest })
query = Activity.joins { verb }.where { activity_object_id.eq(object.id) & actor_id.eq(activity_obj_id) & verb.name.in(verbs_of_interest) }
query.count.odd?
end

Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
require 'factory_girl_rails'
require 'database_cleaner'
require 'shoulda-matchers'
require 'squeel'

ENGINE_RAILS_ROOT = File.join(File.dirname(__FILE__), '../')

Expand Down

0 comments on commit 90d2a3c

Please sign in to comment.