Skip to content

Commit 2b30715

Browse files
committed
Merge pull request #168 from intercom/jo/fix-untag
fix untag
2 parents efe5c7b + 2c851e1 commit 2b30715

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/intercom/service/tag.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,17 @@ def tag(params)
2323

2424
def untag(params)
2525
params['tag_or_untag'] = 'untag'
26+
users_or_companies.each do |user_or_company|
27+
user_or_company[:untag] = true
28+
end
2629
create(params)
2730
end
31+
32+
private
33+
34+
def users_or_companies
35+
params[:users] || params[:companies]
36+
end
2837
end
2938
end
3039
end

spec/unit/intercom/tag_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
end
2424

2525
it 'untags users' do
26-
client.expects(:post).with("/tags", {'name' => "Test Tag", 'users' => [ { user_id: 'abc123' }, { user_id: 'def456' } ], 'tag_or_untag' => 'untag'}).returns(test_tag)
26+
client.expects(:post).with("/tags", {'name' => "Test Tag", 'users' => [ { user_id: 'abc123', untag: true }, { user_id: 'def456', untag: true } ], 'tag_or_untag' => 'untag'}).returns(test_tag)
2727
client.tags.untag(:name => "Test Tag", :users => [ { user_id: "abc123" }, { user_id: "def456" } ])
2828
end
2929
end

0 commit comments

Comments
 (0)