cyrax 0.5.10 → 0.5.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fa224ef5fcdb82a5b84c3cae2ba9610786adebe7
4
- data.tar.gz: 58fee3b429113b3c126bfdfff2b9b28c3b361a30
3
+ metadata.gz: 5a7df346477f2df952f07d3aecb3424e19b13309
4
+ data.tar.gz: 1a68816f86ebeaf1690af84048f9f98b54b27848
5
5
  SHA512:
6
- metadata.gz: e66a19508b14e76304f412aba9fe31ad64c888bf3c7dc341d8ef0e6d31ced4419200b84938baf1dd27d770f3ed7612dd4a85a244bacc8a7d593c392ac726f101
7
- data.tar.gz: 576af687893e5a621b302c7819628a90b281513251e3317b4c0dfd31e6357ddd0fbdfd76b638f72fccf591f2f5a7620358fc072306403d862beb78f1973f2b7a
6
+ metadata.gz: 2318b14712827861174e716805c80b7e57d2793c2b7ae73b8cb0555302d7fe5a4e6f84611686c62a23c00734c7c2180e1528cff069d2cad09097c4e91b19ea50
7
+ data.tar.gz: b1c2c7e0dc9df63514c7f768e138391f9124af658bea032b71b72246d8ead5347809d53de89ae72004ab9bac9118cebf08be7e899f560b0d261064b6c50abef9
@@ -1,5 +1,6 @@
1
1
  module Cyrax::Extensions
2
2
  module HasService
3
+ VALIDATION_ERROR_STATUS = 422
3
4
  extend ActiveSupport::Concern
4
5
 
5
6
  # Builds and returns a collection response for Rails
@@ -35,6 +36,8 @@ module Cyrax::Extensions
35
36
  if save_resource(resource)
36
37
  set_message(:created)
37
38
  block.call(resource) if block_given?
39
+ else
40
+ set_status VALIDATION_ERROR_STATUS
38
41
  end
39
42
  end
40
43
  respond_with(resource)
@@ -63,6 +66,8 @@ module Cyrax::Extensions
63
66
  if save_resource(resource)
64
67
  set_message(:updated)
65
68
  block.call(resource) if block_given?
69
+ else
70
+ set_status VALIDATION_ERROR_STATUS
66
71
  end
67
72
  end
68
73
  respond_with(resource)
@@ -27,7 +27,7 @@ module Cyrax::ControllerHelper
27
27
  super(result, options, &block)
28
28
  end
29
29
  format.json do
30
- render json: MultiJson.dump(response.as_json)
30
+ render json: MultiJson.dump(response.as_json), status: options[:status] || 200
31
31
  end
32
32
  end
33
33
  else
@@ -1,3 +1,3 @@
1
1
  module Cyrax
2
- VERSION = "0.5.10"
2
+ VERSION = "0.5.11"
3
3
  end
@@ -103,6 +103,11 @@ module Cyrax
103
103
  subject.should_not_receive(:set_message).with(:created)
104
104
  subject.create(params)
105
105
  end
106
+
107
+ it "sets 422 status" do
108
+ subject.should_receive(:set_status).with(422)
109
+ subject.create(params)
110
+ end
106
111
  end
107
112
  end
108
113
 
@@ -129,7 +134,12 @@ module Cyrax
129
134
 
130
135
  it 'does not set message' do
131
136
  subject.should_not_receive(:set_message).with(:created)
132
- subject.create(params)
137
+ subject.update(params)
138
+ end
139
+
140
+ it "sets 422 status" do
141
+ subject.should_receive(:set_status).with(422)
142
+ subject.update(params)
133
143
  end
134
144
  end
135
145
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cyrax
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.10
4
+ version: 0.5.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Droidlabs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-23 00:00:00.000000000 Z
11
+ date: 2016-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -151,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
151
  version: '0'
152
152
  requirements: []
153
153
  rubyforge_project:
154
- rubygems_version: 2.4.3
154
+ rubygems_version: 2.2.2
155
155
  signing_key:
156
156
  specification_version: 4
157
157
  summary: Small library for adding service layer to Rails projects