pragma-rails 2.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a6e2a68743a821815f7829d534b473c0d7ea6586c6090d2b238ec2de1e2b43fe
4
- data.tar.gz: 1ef22df33406ca6611526d3c080895c5ae1412ead86d4f2b9529bd5ab6a607fa
3
+ metadata.gz: e3c6c823a798c0c2f0a9cde03349efc78d22411f51d05931ee4a39d680c11dbf
4
+ data.tar.gz: 868e8e1dff5a12454eda592e9faa9179317650552d9e58ac365a78aad8246605
5
5
  SHA512:
6
- metadata.gz: 02c720a8770b02cc61ad7ee352b895c317f5d04c9871dd324a6e28048df8ab663bc86542dc6af1c550377ae31b1eb6904b8fd9d1f1b98ba735d255a3ea68b5f9
7
- data.tar.gz: 657e38ecf81f45f9cf98523a4e7eb20a60670116d48704881893d69bb1011c77a939235365ecdffa2ea796c5cca40d71a89a5e8f48977674e1d014d950587bae
6
+ metadata.gz: 572454fecc376c13338b95ddabf3ebaf2f83c33120d0361599205bf200eb3e824f179db98b7363be045fd6e9982a3a5b561cd1f79e9e9f56e45084cc7b06cdd5
7
+ data.tar.gz: ab4a7295d1d59de85b879374b2ce59eb9054d8bb96781e2e34fa067994ecf3fdbb8de7b39cd68da0e2c9af3c4687a02f78981d43c9e8fbd1938078a260e81021
data/.rubocop.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  require: rubocop-rspec
2
2
 
3
3
  AllCops:
4
- TargetRubyVersion: 2.3
4
+ TargetRubyVersion: 2.5
5
5
  Include:
6
6
  - '**/*.rb'
7
7
  - '**/Rakefile'
@@ -18,7 +18,7 @@ AllCops:
18
18
 
19
19
  RSpec/DescribeClass:
20
20
  Exclude:
21
- - 'spec/requests/**/*'
21
+ - 'spec/integration/**/*'
22
22
 
23
23
  Style/BlockDelimiters:
24
24
  Exclude:
@@ -98,7 +98,3 @@ RSpec/MessageExpectation:
98
98
 
99
99
  RSpec/MessageSpies:
100
100
  Enabled: false
101
-
102
- RSpec/DescribeClass:
103
- Exclude:
104
- - 'spec/integration/**/*'
data/CHANGELOG.md CHANGED
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [2.3.0]
11
+
12
+ ### Added
13
+
14
+ - `NoResponseError` is now raised if an operation doesn't return a `result.response` skill
15
+ - `rack.request` is now passed to operations
16
+
10
17
  ## [2.2.0]
11
18
 
12
19
  ## Added
@@ -41,7 +48,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
41
48
 
42
49
  First Pragma 2 release.
43
50
 
44
- [Unreleased]: https://github.com/pragmarb/pragma-rails/compare/v2.2.0...HEAD
51
+ [Unreleased]: https://github.com/pragmarb/pragma-rails/compare/v2.3.0...HEAD
52
+ [2.3.0]: https://github.com/pragmarb/pragma-rails/compare/v2.2.0...v2.3.0
45
53
  [2.2.0]: https://github.com/pragmarb/pragma-rails/compare/v2.1.1...v2.2.0
46
54
  [2.1.1]: https://github.com/pragmarb/pragma-rails/compare/v2.1.0...v2.1.1
47
55
  [2.1.0]: https://github.com/pragmarb/pragma-rails/compare/v2.0.0...v2.1.0
data/lib/pragma/rails.rb CHANGED
@@ -6,13 +6,12 @@ require 'rails'
6
6
  require 'pragma/rails/version'
7
7
  require 'pragma/rails/controller'
8
8
  require 'pragma/rails/resource_controller'
9
+ require 'pragma/rails/errors'
9
10
 
10
11
  require 'generators/pragma/resource_generator' if defined?(::Rails::Generators)
11
12
 
12
13
  module Pragma
13
14
  # Ruby on Rails integration for the Pragma architecture.
14
- #
15
- # @author Alessandro Desantis
16
15
  module Rails
17
16
  end
18
17
  end
@@ -4,8 +4,6 @@ module Pragma
4
4
  module Rails
5
5
  # This mixin should be included in a Rails controller to provide integration with Pragma
6
6
  # operations.
7
- #
8
- # @author Alessandro Desantis
9
7
  module Controller
10
8
  def self.included(klass)
11
9
  klass.include InstanceMethods
@@ -25,9 +23,12 @@ module Pragma
25
23
  result = operation_const.call(
26
24
  operation_params,
27
25
  'current_user' => operation_user,
28
- 'policy.context' => policy_context
26
+ 'policy.context' => policy_context,
27
+ 'rack.request' => Rack::Request.new(request.env)
29
28
  )
30
29
 
30
+ fail NoResponseError unless result['result.response']
31
+
31
32
  result['result.response'].headers.each_pair do |key, value|
32
33
  response.headers[key] = value
33
34
  end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pragma
4
+ module Rails
5
+ # Raised when an operation doesn't set a +result.response+ skill.
6
+ class NoResponseError < StandardError
7
+ def initialize
8
+ super <<~MESSAGE
9
+ Your operation did not return a `result.response` skill, which might mean one of the following:
10
+
11
+ * The execution of the operation halted early (maybe one of your steps returned a falsey value?).
12
+ * You forgot to set a `result.response` skill in a custom operation.
13
+ MESSAGE
14
+ end
15
+ end
16
+ end
17
+ end
@@ -3,8 +3,6 @@
3
3
  module Pragma
4
4
  module Rails
5
5
  # Exposes CRUD operations on a resource through a Rails controller.
6
- #
7
- # @author Alessandro Desantis
8
6
  module ResourceController
9
7
  def self.included(klass)
10
8
  klass.include Controller
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Pragma
4
4
  module Rails
5
- VERSION = '2.2.0'
5
+ VERSION = '2.3.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pragma-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alessandro Desantis
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-06-09 00:00:00.000000000 Z
11
+ date: 2018-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pragma
@@ -246,6 +246,7 @@ files:
246
246
  - lib/generators/pragma/templates/resource/spec.rb.tt
247
247
  - lib/pragma/rails.rb
248
248
  - lib/pragma/rails/controller.rb
249
+ - lib/pragma/rails/errors.rb
249
250
  - lib/pragma/rails/resource_controller.rb
250
251
  - lib/pragma/rails/version.rb
251
252
  - pragma-rails.gemspec