repia 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,6 +6,23 @@ class RepiaTest < ActiveSupport::TestCase
6
6
  obj.save()
7
7
  assert_not_nil obj.uuid
8
8
  end
9
+
10
+ test "HttpMethodNotAllowed middleware throws 405 for invalid HTTP method" do
11
+ app = lambda {|env| [200, {}, [""]]}
12
+ stack = Repia::HttpMethodNotAllowed.new(app)
13
+ request = Rack::MockRequest.new(stack)
14
+ response = request.request("DOESNOTEXIST", "/users")
15
+ assert response.headers["Content-Type"].include?("application/json")
16
+ assert_equal 405, response.status.to_i
17
+ end
18
+
19
+ test "HttpMethodNotAllowed middleware does not throw 405 for valid HTTP method" do
20
+ app = lambda {|env| [200, {}, [""]]}
21
+ stack = Repia::HttpMethodNotAllowed.new(app)
22
+ request = Rack::MockRequest.new(stack)
23
+ response = request.request("GET", "/users")
24
+ assert_equal 200, response.status.to_i
25
+ end
9
26
  end
10
27
 
11
28
  class DummiesControllerTest < ActionController::TestCase
@@ -34,4 +51,21 @@ class DummiesControllerTest < ActionController::TestCase
34
51
  post :create
35
52
  assert_response 500
36
53
  end
54
+
55
+ test "find_object will error if object does not exist" do
56
+ patch :update, id: "blah"
57
+ assert_response 404
58
+ end
59
+
60
+ test "find_object will find object if exists" do
61
+ obj = UniqueModel.new()
62
+ obj.save()
63
+ patch :update, id: obj.uuid
64
+ assert_response 200
65
+ end
66
+
67
+ test "exceptions_app" do
68
+ delete :destroy, id: "blah"
69
+ assert_response 404
70
+ end
37
71
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: repia
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David An
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-29 00:00:00.000000000 Z
11
+ date: 2016-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails