test/sequel_test.rb in giraffesoft-classy_resources-0.0.1 vs test/sequel_test.rb in giraffesoft-classy_resources-0.1.0

- old
+ new

@@ -71,6 +71,40 @@ should "destroy the user" do assert_nil User.find(:id => @user.id) end end + + context "on GET to /users/id/comments" do + setup do + @user = create_user + 2.times { @user.add_subscription(create_subscription) } + 2.times { create_subscription } + get "/users/#{@user.id}/subscriptions.xml" + end + + expect { assert_equal 200, @response.status } + expect { assert_equal "application/xml", @response.content_type } + expect { assert_equal @user.subscriptions.to_xml, @response.body } + end + + context "on POST to /users/id/subscriptions" do + setup do + @user = create_user + post "/users/#{@user.id}/subscriptions.xml", :subscription => hash_for_subscription + end + + expect { assert_equal 302, @response.status } + expect { assert_equal "application/xml", @response.content_type } + expect { assert_equal "/subscriptions/#{@user.reload.subscriptions.first.id}.xml", @response.location } + expect { assert_equal 1, @user.reload.subscriptions.length } + end + + context "on POST to /users/id/subscriptions with no params" do + should "not raise" do + @user = create_user + assert_nothing_raised { + post "/users/#{@user.id}/subscriptions.xml", :subscription => {} + } + end + end end