Permalink
Browse files

PubSub::ServiceHelper#set_affiliations: allow role as symbol, test

  • Loading branch information...
1 parent 01bf673 commit 516778e70c793ab139aca706b461e0c46c9b4c08 @astro astro committed Dec 12, 2008
Showing with 21 additions and 2 deletions.
  1. +2 −2 lib/xmpp4r/pubsub/helper/servicehelper.rb
  2. +19 −0 test/pubsub/tc_helper.rb
View
4 lib/xmpp4r/pubsub/helper/servicehelper.rb
@@ -303,8 +303,8 @@ def set_affiliations(node, jid, role = 'publisher')
affiliations = iq.pubsub.add(REXML::Element.new('affiliations'))
affiliations.attributes['node'] = node
affiliation = affiliations.add(REXML::Element.new('affiliation'))
- affiliation.attributes['jid'] = jid
- affiliation.attributes['affiliation'] = role
+ affiliation.attributes['jid'] = jid.to_s
+ affiliation.attributes['affiliation'] = role.to_s
res = nil
@stream.send_with_id(iq) { |reply|
true
View
19 test/pubsub/tc_helper.rb
@@ -487,6 +487,25 @@ def test_affiliations
wait_state
end
+ # http://xmpp.org/extensions/xep-0060.html#owner-affiliations-modify
+ def test_affiliations
+ h = PubSub::ServiceHelper.new(@client,'pubsub.shakespeare.lit')
+
+ state { |iq|
+ assert_kind_of(Jabber::Iq, iq)
+ assert_equal(:set, iq.type)
+ assert_equal(1, iq.pubsub.children.size)
+ assert_equal('affiliations', iq.pubsub.children[0].name)
+ assert_equal('affiliation', iq.pubsub.children[0].children[0].name)
+ assert_equal('bard@shakespeare.lit', iq.pubsub.children[0].children[0].attributes['jid'])
+ assert_equal('publisher', iq.pubsub.children[0].children[0].attributes['affiliation'])
+ send("<iq type='result' to='#{iq.from}' from='#{iq.to}' id='#{iq.id}'/>")
+ }
+
+ a = h.set_affiliations('princely_musings', 'bard@shakespeare.lit', :publisher)
+ wait_state
+ end
+
##
# get_subscriptions_from
# example 171 and 172 from

0 comments on commit 516778e

Please sign in to comment.