Skip to content

Instantly share code, notes, and snippets.

@wilson
Forked from mmower/gist:11034
Created September 16, 2008 13:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wilson/11036 to your computer and use it in GitHub Desktop.
Save wilson/11036 to your computer and use it in GitHub Desktop.
# Used to modify the relationship tags applied to the specified contact
#
# PUT /users/bob/contacts/alice/tags?friend=t&family=f
#
# Sets the tags on the relationship that 'bob' has with 'alice' to be 'friend' and not 'family'
#
def tags
@contact = user.contacts.with_login( params[:id] )
@relationship = user.relationships.with( @contact )
@relationship.set( tags_from_params( params ) )
end
# Goes in your spec_helper, or wherever
def be_friends_with(friend)
return simple_matcher("a user with friends") do |actual|
actual.relationships.whatever.detect {|r| r.blah == friend}.should_not be_nil
end
it "PUT #tags (html) should tag a contact as a friend" do
u1, u2 = User.generate, User.generate
r = u1.add_contact( u2 )
put :tags, :user_id => u2.login, :id => u1.login, :friend => 't'
u1.reload; u2.reload
u1.should be_friends_with(u2)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment