Skip to content
This repository has been archived by the owner on Jun 30, 2022. It is now read-only.

Commit

Permalink
Don't assume other object is a User in User#==.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmycuadra committed Jun 24, 2013
1 parent e64b470 commit c65e520
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.1.2 (June 23, 2013)

* Fixed a bug where User objects would raise an exception when compared against non-User objects.

## 1.1.1 (June 23, 2013)

* Fixed broken internals in the authorization API. Auth commands will now correctly detect the user making the command and will normalize group names so that capitalization and white space don't matter.
Expand Down
3 changes: 2 additions & 1 deletion lib/lita/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ def save
end

def ==(other)
id == other.id && name == other.name
other.respond_to?(:id) && id == other.id &&
other.respond_to?(:name) && name == other.name
end

private
Expand Down
2 changes: 1 addition & 1 deletion lib/lita/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Lita
VERSION = "1.1.1"
VERSION = "1.1.2"
end
5 changes: 5 additions & 0 deletions spec/lita/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,10 @@
user2 = described_class.new(1, name: "Carl")
expect(user1).to eq(user2)
end

it "doesn't assume the comparison object is a Lita::User" do
user = described_class.new(1, name: "Carl")
expect(user).not_to eq("not a Lita::User object")
end
end
end

0 comments on commit c65e520

Please sign in to comment.