Skip to content
Browse files

Dup the data so it doesn't have outside side effect

  • Loading branch information...
1 parent 2ec61f8 commit 1d3d0b4b6d52d7c0991199c9b0bd353bf08a2a52 @fredwu committed
Showing with 8 additions and 1 deletion.
  1. +2 −0 lib/bustle/activities.rb
  2. +6 −1 spec/bustle/activities_spec.rb
View
2 lib/bustle/activities.rb
@@ -7,6 +7,8 @@ class Activities
class << self
def add(publisher, data = {})
+ data = data.dup
+
if resource = data.delete(:resource)
data[:resource_class] = resource.class.name
data[:resource_id] = resource.id
View
7 spec/bustle/activities_spec.rb
@@ -10,18 +10,23 @@ module Bustle
let(:subscriber2) { Subscribers.add user }
it "creates an activity" do
- Activities.add publisher, {
+ data = {
:action => 'show',
:resource => comment,
:data => 'hello world'
}
+ data2 = data.dup
+
+ Activities.add publisher, data
+
activity = Activity.to_adapter.get(1)
activity.resource_class.should == 'Bustle::Dummy::Comment'
activity.resource_id.should == 101
activity.action.should == 'show'
activity.data.should == 'hello world'
activity.publisher_id.should == publisher.id
+ data.should == data2
end
context "multiple activities" do

0 comments on commit 1d3d0b4

Please sign in to comment.
Something went wrong with that request. Please try again.