Skip to content
Browse files

get rid of parent tests, so we can remove that feature

  • Loading branch information...
1 parent f5fa0b6 commit 632e09c3343e50f8cb355be15905fc1b832e3899 @jamesgolick committed Jan 30, 2009
Showing with 14 additions and 77 deletions.
  1. +12 −39 test/active_record_test.rb
  2. +1 −2 test/fixtures/active_record_test_app.rb
  3. +1 −2 test/fixtures/sequel_test_app.rb
  4. +0 −34 test/sequel_test.rb
View
51 test/active_record_test.rb
@@ -109,58 +109,31 @@ class ActiveRecordTest < Test::Unit::TestCase
expect { assert @response.body.empty? }
end
- context "on GET to /posts/id/comments" do
- setup do
- @post = create_post
- 2.times { @post.comments.create!(hash_for_comment) }
- 2.times { create_comment }
- get "/posts/#{@post.id}/comments.xml"
- end
-
- expect { assert_equal 200, @response.status }
- expect { assert_equal "application/xml", @response.content_type }
- expect { assert_equal @post.comments.to_xml, @response.body }
- end
-
- context "on POST to /posts/id/comments" do
+ context "on POST to /comments with a JSON post body" do
setup do
Comment.destroy_all
- @post = create_post
- post "/posts/#{@post.id}/comments.xml", :comment => hash_for_comment
+ post "/comments.xml", {:comment => hash_for_comment(:author => 'james')}.to_json,
+ :content_type => 'application/json'
end
expect { assert_equal 201, @response.status }
expect { assert_equal "application/xml", @response.content_type }
- expect { assert_equal "/comments/#{@post.comments.reload.first.id}.xml", @response.location }
- expect { assert_equal 1, @post.comments.reload.count }
- expect { assert_equal Comment.first.to_xml, @response.body }
- end
-
- context "on POST to /posts/id/comments with a JSON post body" do
- setup do
- @post = create_post
- post "/posts/#{@post.id}/comments.xml", {:comment => hash_for_comment(:author => 'james')}.to_json,
- :content_type => 'application/json'
- end
-
- expect { assert_equal 201, @response.status }
- expect { assert_equal "application/xml", @response.content_type }
- expect { assert_equal "/comments/#{@post.comments.reload.first.id}.xml", @response.location }
- expect { assert_equal 1, @post.comments.reload.count }
- expect { assert_equal 'james', @post.comments.first.author }
+ expect { assert_equal "/comments/#{Comment.first.id}.xml", @response.location }
+ expect { assert_equal 1, Comment.count }
+ expect { assert_equal 'james', Comment.first.author }
end
context "on POST to /posts/id/comments with a XML post body" do
setup do
- @post = create_post
- post "/posts/#{@post.id}/comments.xml", Comment.new(:author => 'james').to_xml,
- :content_type => 'application/xml'
+ Comment.destroy_all
+ post "/comments.xml", Comment.new(:author => 'james').to_xml,
+ :content_type => 'application/xml'
end
expect { assert_equal 201, @response.status }
expect { assert_equal "application/xml", @response.content_type }
- expect { assert_equal "/comments/#{@post.comments.reload.first.id}.xml", @response.location }
- expect { assert_equal 1, @post.comments.reload.count }
- expect { assert_equal 'james', @post.comments.first.author }
+ expect { assert_equal "/comments/#{Comment.first.id}.xml", @response.location }
+ expect { assert_equal 1, Comment.count }
+ expect { assert_equal 'james', Comment.first.author }
end
end
View
3 test/fixtures/active_record_test_app.rb
@@ -35,8 +35,7 @@ class Comment < ActiveRecord::Base
:member => [:get, :put, :delete],
:formats => [:xml, :json]
-define_resource :comments, :collection => [:get, :post],
- :parent => :posts
+define_resource :comments, :collection => [:get, :post]
use ClassyResources::PostBodyParams
View
3 test/fixtures/sequel_test_app.rb
@@ -32,5 +32,4 @@ class Subscription < Sequel::Model(:subscriptions)
define_resource :users, :collection => [:get, :post],
:member => [:put, :delete, :get]
-define_resource :subscriptions, :collection => [:get, :post],
- :parent => :users
+define_resource :subscriptions, :collection => [:get, :post]
View
34 test/sequel_test.rb
@@ -103,38 +103,4 @@ class SequelTest < Test::Unit::TestCase
expect { assert_equal "application/xml", @response.content_type }
expect { assert @response.body.empty? }
end
-
- context "on GET to /users/id/comments" do
- setup do
- @user = create_user
- 2.times { @user.add_subscription(Subscription.new(hash_for_subscription)) }
- 2.times { create_subscription(:user_id => 9) }
- 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 201, @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

0 comments on commit 632e09c

Please sign in to comment.
Something went wrong with that request. Please try again.