Skip to content

Commit

Permalink
test object_ids should either be a string or an array
Browse files Browse the repository at this point in the history
  • Loading branch information
acmetech committed Jun 6, 2017
1 parent d47a959 commit f9d8224
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
2 changes: 1 addition & 1 deletion spec/concepts/socializer/activity/services/share_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ module Services
let(:public_audience) { results.audiences.where(privacy: "public") }
let(:circles_audience) { results.audiences.where(privacy: "circles") }

it { expect(results.persisted?).to eq(true) }
it { expect(public_audience.present?).to eq(true) }
it { expect(circles_audience.present?).to eq(true) }
it { expect(results.persisted?).to eq(true) }
end
end
end
Expand Down
43 changes: 41 additions & 2 deletions spec/services/socializer/create_activity_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
module Socializer
RSpec.describe CreateActivity, type: :model do
let(:ac) { CreateActivity.new }
let(:activity_object) { create(:activity_object) }
let(:person) { create(:person) }

let(:activity_attributes) do
{ actor_id: person.id,
Expand All @@ -27,14 +29,51 @@ module Socializer
end

context "with the required attributes" do
let(:person) { create(:person) }
let(:activity_object) { create(:activity_object) }
let(:ac) { CreateActivity.new(activity_attributes) }

it { expect(ac.valid?).to be true }
it { expect(ac.call).to be_kind_of(Activity) }
it { expect(ac.call.persisted?).to be true }
end

context "#object_ids" do
let(:ac) { CreateActivity.new(activity_attributes) }

let(:public_privacy) do
Socializer::Audience.privacy.find_value(:public).value
end

let(:circles_privacy) do
Socializer::Audience.privacy.find_value(:circles).value
end

let(:activity_attributes) do
{ actor_id: person.id,
activity_object_id: activity_object.id,
object_ids: object_ids,
verb: "post" }
end

let(:results) { ac.call }
let(:public_audience) { results.audiences.where(privacy: "public") }
let(:circles_audience) { results.audiences.where(privacy: "circles") }

context "as a String" do
let(:object_ids) { public_privacy }

it { expect(results.persisted?).to eq(true) }
it { expect(public_audience.present?).to eq(true) }
it { expect(circles_audience.present?).to eq(false) }
end

context "as an Array" do
let(:object_ids) { [public_privacy, circles_privacy] }

it { expect(results.persisted?).to eq(true) }
it { expect(public_audience.present?).to eq(true) }
it { expect(circles_audience.present?).to eq(true) }
end
end
end
end
end

0 comments on commit f9d8224

Please sign in to comment.