giraffesoft-classy_resources 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :patch: 0
2
+ :patch: 1
3
3
  :major: 0
4
4
  :minor: 2
@@ -87,7 +87,10 @@ module ClassyResources
87
87
  post collection_url_for(resource, format, parent) do
88
88
  set_content_type(format)
89
89
  object = create_object(resource, params[resource.to_s.singularize] || {}, parent)
90
- redirect object_url_for(resource, format, object)
90
+
91
+ response['location'] = object_url_for(resource, format, object)
92
+ response.status = 201
93
+ serialize(object, format)
91
94
  end
92
95
  end
93
96
 
@@ -32,10 +32,11 @@ class ActiveRecordTest < Test::Unit::TestCase
32
32
  post '/posts.xml', :post => {:title => "whatever"}
33
33
  end
34
34
 
35
- expect { assert_equal 302, @response.status }
35
+ expect { assert_equal 201, @response.status }
36
36
  expect { assert_equal "/posts/#{Post.first.id}.xml", @response.location }
37
37
  expect { assert_equal "whatever", Post.first.title }
38
38
  expect { assert_equal "application/xml", @response.content_type }
39
+ expect { assert_equal Post.first.to_xml, @response.body }
39
40
  end
40
41
 
41
42
  context "on GET to /posts/id" do
@@ -93,14 +94,16 @@ class ActiveRecordTest < Test::Unit::TestCase
93
94
 
94
95
  context "on POST to /posts/id/comments" do
95
96
  setup do
97
+ Comment.destroy_all
96
98
  @post = create_post
97
99
  post "/posts/#{@post.id}/comments.xml", :comment => hash_for_comment
98
100
  end
99
101
 
100
- expect { assert_equal 302, @response.status }
102
+ expect { assert_equal 201, @response.status }
101
103
  expect { assert_equal "application/xml", @response.content_type }
102
104
  expect { assert_equal "/comments/#{@post.comments.reload.first.id}.xml", @response.location }
103
105
  expect { assert_equal 1, @post.comments.reload.count }
106
+ expect { assert_equal Comment.first.to_xml, @response.body }
104
107
  end
105
108
 
106
109
  context "on POST to /posts/id/comments with a JSON post body" do
@@ -110,7 +113,7 @@ class ActiveRecordTest < Test::Unit::TestCase
110
113
  :content_type => 'application/json'
111
114
  end
112
115
 
113
- expect { assert_equal 302, @response.status }
116
+ expect { assert_equal 201, @response.status }
114
117
  expect { assert_equal "application/xml", @response.content_type }
115
118
  expect { assert_equal "/comments/#{@post.comments.reload.first.id}.xml", @response.location }
116
119
  expect { assert_equal 1, @post.comments.reload.count }
@@ -124,7 +127,7 @@ class ActiveRecordTest < Test::Unit::TestCase
124
127
  :content_type => 'application/xml'
125
128
  end
126
129
 
127
- expect { assert_equal 302, @response.status }
130
+ expect { assert_equal 201, @response.status }
128
131
  expect { assert_equal "application/xml", @response.content_type }
129
132
  expect { assert_equal "/comments/#{@post.comments.reload.first.id}.xml", @response.location }
130
133
  expect { assert_equal 1, @post.comments.reload.count }
data/test/sequel_test.rb CHANGED
@@ -28,7 +28,7 @@ class SequelTest < Test::Unit::TestCase
28
28
  post '/users.xml', :user => {:name => "whatever"}
29
29
  end
30
30
 
31
- expect { assert_equal 302, @response.status }
31
+ expect { assert_equal 201, @response.status }
32
32
  expect { assert_equal "/users/#{User.first.id}.xml", @response.location }
33
33
  expect { assert_equal "whatever", User.first.name }
34
34
  expect { assert_equal "application/xml", @response.content_type }
@@ -93,7 +93,7 @@ class SequelTest < Test::Unit::TestCase
93
93
  post "/users/#{@user.id}/subscriptions.xml", :subscription => hash_for_subscription
94
94
  end
95
95
 
96
- expect { assert_equal 302, @response.status }
96
+ expect { assert_equal 201, @response.status }
97
97
  expect { assert_equal "application/xml", @response.content_type }
98
98
  expect { assert_equal "/subscriptions/#{@user.reload.subscriptions.first.id}.xml", @response.location }
99
99
  expect { assert_equal 1, @user.reload.subscriptions.length }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: giraffesoft-classy_resources
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Golick