Skip to content

Commit

Permalink
Merge bdb1209 into 53ddadf
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinGoulet committed Feb 14, 2014
2 parents 53ddadf + bdb1209 commit 97297d5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 65 deletions.
81 changes: 17 additions & 64 deletions spec/models/socializer/activity_object_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,22 @@ module Socializer
end

context 'mass assignment' do
it { expect(activity_object).to allow_mass_assignment_of(:scope) }
it { expect(activity_object).to allow_mass_assignment_of(:object_ids) }
it { expect(activity_object).to allow_mass_assignment_of(:activitable_id) }
it { expect(activity_object).to allow_mass_assignment_of(:activitable_type) }
it { expect(activity_object).to allow_mass_assignment_of(:like_count) }
it { expect(activity_object).to allow_mass_assignment_of(:unread_notifications_count) }
it { expect(activity_object).to allow_mass_assignment_of(:object_ids) }
assignments = [:scope, :object_ids, :activitable_id, :activitable_type,
:like_count, :unread_notifications_count, :object_ids]
assignments.each do |assign|
it { expect(activity_object).to allow_mass_assignment_of(assign) }
end
end

context 'relationships' do
has_many_rel = [:notifications, :audiences, :actor_activities, :object_activities,
:target_activities, :notes, :comments, :groups, :circles, :ties]
has_many_rel.each do |relation|
it { expect(activity_object).to have_many(relation) }
end

it { expect(activity_object).to belong_to(:activitable) }
it { expect(activity_object).to have_many(:notifications) }
it { expect(activity_object).to have_many(:audiences) }
it { expect(activity_object).to have_many(:activities).through(:audiences) }
it { expect(activity_object).to have_many(:actor_activities) }
it { expect(activity_object).to have_many(:object_activities) }
it { expect(activity_object).to have_many(:target_activities) }
it { expect(activity_object).to have_many(:notes) }
it { expect(activity_object).to have_many(:comments) }
it { expect(activity_object).to have_many(:groups) }
it { expect(activity_object).to have_many(:circles) }
it { expect(activity_object).to have_many(:ties) }
it { expect(activity_object).to have_many(:memberships).conditions(active: true) }
end

Expand All @@ -44,7 +38,6 @@ module Socializer
end

it { expect(liked_activity_object.like_count).to eq(1) }
# it { expect(liked_activity_object.likes.size).to eq(1) }

context 'and unliked' do
before do
Expand All @@ -53,56 +46,16 @@ module Socializer
end

it { expect(liked_activity_object.like_count).to eq(0) }
# it { expect(liked_activity_object.likes.size).to eq(0) }
end
end

it '#scope' do
expect(activity_object).to respond_to(:scope)
end
context 'attribute accessors' do
accessors = [:scope, :like_count, :note?, :activity?, :comment?, :person?,
:group?, :circle?, :likes, :like!, :unlike!, :share!]

it '#like_count' do
expect(activity_object).to respond_to(:like_count)
end

it '#note?' do
expect(activity_object).to respond_to(:note?)
end

it '#activity?' do
expect(activity_object).to respond_to(:activity?)
end

it '#comment?' do
expect(activity_object).to respond_to(:comment?)
end

it '#person?' do
expect(activity_object).to respond_to(:person?)
end

it '#group?' do
expect(activity_object).to respond_to(:group?)
end

it '#circle?' do
expect(activity_object).to respond_to(:circle?)
end

it '#likes' do
expect(activity_object).to respond_to(:likes)
end

it '#like!' do
expect(activity_object).to respond_to(:like!)
end

it '#unlike!' do
expect(activity_object).to respond_to(:unlike!)
end

it '#share!' do
expect(activity_object).to respond_to(:share!)
accessors.each do |attr|
it { expect(activity_object).to respond_to(attr) }
end
end

%w(Person Activity Note Comment Group Circle).each do |type|
Expand Down
5 changes: 4 additions & 1 deletion spec/models/socializer/activity_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ module Socializer
end

context 'relationships' do
it { expect(activity).to have_many(:notifications) }
relations = [:audiences, :notifications, :activity_objects, :children]
relations.each do |relation|
it { expect(activity).to have_many(relation) }
end
end

end
Expand Down

0 comments on commit 97297d5

Please sign in to comment.