Skip to content

Commit

Permalink
[BUGFIX] Don't implicitly create an invite node when checking invite …
Browse files Browse the repository at this point in the history
…status

Fixes adhearsion#81
  • Loading branch information
benlangfeld committed Feb 27, 2012
1 parent d46d5d7 commit 68f1d8e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/blather/stanza/presence/muc_user.rb
Expand Up @@ -61,7 +61,7 @@ def password=(var)
end

def invite?
!!invite
!!find_invite_node
end

def muc_user
Expand Down Expand Up @@ -99,14 +99,18 @@ def find_password_node
end

def invite
if invite = muc_user.find_first('ns:invite', :ns => self.class.registered_ns)
if invite = find_invite_node
Invite.new invite
else
muc_user << (invite = Invite.new nil, nil, nil, self.document)
invite
end
end

def find_invite_node
muc_user.find_first 'ns:invite', :ns => self.class.registered_ns
end

class Item < XMPPNode
def self.new(affiliation = nil, role = nil, jid = nil, document = nil)
new_node = super :item, document
Expand Down
5 changes: 5 additions & 0 deletions spec/blather/stanza/presence/muc_user_spec.rb
Expand Up @@ -102,6 +102,11 @@ def muc_invite_xml
muc_user.password.must_equal 'hello_world'
end

it "should not be an #invite?" do
muc_user = Blather::Stanza::Presence::MUCUser.new
muc_user.invite?.must_equal false
end

describe "with an invite element" do
it "should be an #invite?" do
muc_user = Blather::XMPPNode.import(parse_stanza(muc_invite_xml).root)
Expand Down

0 comments on commit 68f1d8e

Please sign in to comment.