wor-simple_crud 0.7.0 → 0.8.0
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 +4 -4
- data/CHANGELOG.md +11 -0
- data/README.md +27 -2
- data/lib/simple_crud/rspec/config.rb +2 -0
- data/lib/simple_crud/rspec/helpers/policies.rb +3 -3
- data/lib/simple_crud/rspec/helpers/requests.rb +4 -1
- data/lib/simple_crud/rspec/helpers/settings.rb +10 -1
- data/lib/simple_crud/rspec.rb +4 -0
- data/lib/simple_crud/version.rb +1 -1
- data/lib/spec/matchers/render_or_redirect.rb +7 -0
- data/lib/spec/shared_examples/simple_crud_for_create.rb +1 -1
- data/lib/spec/shared_examples/simple_crud_for_create_with_block.rb +2 -2
- data/lib/spec/shared_examples/simple_crud_for_create_with_build.rb +8 -2
- data/lib/spec/shared_examples/simple_crud_for_destroy.rb +11 -9
- data/lib/spec/shared_examples/simple_crud_for_destroy_with_block.rb +1 -1
- data/lib/spec/shared_examples/simple_crud_for_edit.rb +16 -14
- data/lib/spec/shared_examples/simple_crud_for_edit_with_block.rb +22 -0
- data/lib/spec/shared_examples/simple_crud_for_edit_with_finder.rb +34 -0
- data/lib/spec/shared_examples/simple_crud_for_index_with_scope.rb +15 -12
- data/lib/spec/shared_examples/simple_crud_for_new_with_block.rb +1 -1
- data/lib/spec/shared_examples/simple_crud_for_new_with_build.rb +11 -5
- data/lib/spec/shared_examples/simple_crud_for_owned_resource.rb +17 -7
- data/lib/spec/shared_examples/simple_crud_for_show.rb +10 -8
- data/lib/spec/shared_examples/simple_crud_for_show_with_block.rb +1 -1
- data/lib/spec/shared_examples/simple_crud_for_update.rb +14 -12
- data/lib/spec/shared_examples/simple_crud_for_update_with_block.rb +40 -0
- data/lib/spec/shared_examples/simple_crud_for_update_with_finder.rb +7 -4
- data/lib/spec/shared_examples/simple_crud_not_found_with_finder.rb +9 -7
- data/spec/block_create_redirect/dummy_models_controller_spec.rb +11 -0
- data/spec/block_edit/dummy_models_controller_spec.rb +7 -0
- data/spec/block_finder/dummy_models_controller_spec.rb +2 -0
- data/spec/block_policy_show/dummy_models_controller_spec.rb +7 -0
- data/spec/block_redirect/dummy_models_controller_spec.rb +1 -0
- data/spec/block_update/dummy_models_controller_spec.rb +11 -0
- data/spec/dummy/app/controllers/block_create_redirect/dummy_models_controller.rb +13 -0
- data/spec/dummy/app/controllers/block_edit/dummy_models_controller.rb +9 -0
- data/spec/dummy/app/controllers/block_policy_show/dummy_models_controller.rb +12 -0
- data/spec/dummy/app/controllers/block_update/dummy_models_controller.rb +9 -0
- data/spec/dummy/app/controllers/parented/dummy_models_controller.rb +1 -0
- data/spec/dummy/app/controllers/scoped_order/dummy_models_controller.rb +11 -0
- data/spec/dummy/app/controllers/singular/dummy_models_controller.rb +12 -0
- data/spec/dummy/app/views/block_edit/dummy_models/edit.html.erb +1 -0
- data/spec/dummy/app/views/block_policy_show/dummy_models/show.html.erb +1 -0
- data/spec/dummy/config/routes.rb +24 -0
- data/spec/finder/dummy_models_controller_spec.rb +6 -0
- data/spec/html_finder/dummy_models_controller_spec.rb +1 -0
- data/spec/parented/dummy_models_controller_spec.rb +10 -0
- data/spec/scoped_order/dummy_models_controller_spec.rb +10 -0
- data/spec/singular/dummy_models_controller_spec.rb +10 -0
- metadata +20 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 31af4e1bcfb9f45e6bcbe33a2454c96b27b2adab13ff87674a9bde462d21d2f4
|
|
4
|
+
data.tar.gz: 7fadec0262d373a35c02cd015e566a97d312c5afb110abe34f58e3ca99d88d2e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 56aa1239c57e89eaa7a3944bf2c6303033806815e9671357249958b0eb954b431a9798898fdffa4e8d70432ee650ecad9a3ab6888aff38f0398ea69454302cb3
|
|
7
|
+
data.tar.gz: 69f04e8600f4e4d10b7687c94a14a3f06b4434d12572ab969ce5f67bbb9b886e4e6ffe1d572e9a7e89f936fe999ffc435bbcc358eda12fefb0108d4f2756e67e
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
## Change log
|
|
2
2
|
|
|
3
|
+
### V0.8.0
|
|
4
|
+
|
|
5
|
+
Shared examples:
|
|
6
|
+
* New examples: `update with block`, `edit with finder` and `edit with block`.
|
|
7
|
+
* `required_attribute: nil` skips the invalid-attribute cases in `create`, `update` and their block variants, for models with nothing to validate. `update with finder` and `owned resource` skip their `required_attribute` assertions as well.
|
|
8
|
+
* `singular: true` covers singular resources. Requests carry no id, the "does not exist" examples are skipped, and the controller's own finder loads the record.
|
|
9
|
+
* `index with scope` handles scopes that exclude nothing. With `other_scoped_attributes: nil` it asserts every scoped record comes back, and `scoped_order: ->(records) { ... }` asserts their order.
|
|
10
|
+
* `create with block` and `destroy with block` accept a redirect or a 2xx render, so a block that redirects on success (the README's HTML example) passes. `edit` and `update with finder` accept the same when they use a block.
|
|
11
|
+
* `new with build` and `create with build` assert ownership by the current user only when an `owner_association` is configured. For `parent:`-built records they check that the hook built the record.
|
|
12
|
+
* `make_policies_succeed` takes `permissive: true`. The `show`, `new` and `edit` "with block" examples use it, so a block can ask the policy about other actions, such as `update?`, without failing the strict double.
|
|
13
|
+
|
|
3
14
|
### V0.7.0
|
|
4
15
|
|
|
5
16
|
Serializer support:
|
data/README.md
CHANGED
|
@@ -511,11 +511,14 @@ The `create` and `update` examples cover the `422` response with validation erro
|
|
|
511
511
|
```ruby
|
|
512
512
|
include_examples 'simple crud for new' # the :new action
|
|
513
513
|
include_examples 'simple crud for edit' # the :edit action
|
|
514
|
+
include_examples 'simple crud for edit with finder' # finder on :edit
|
|
515
|
+
include_examples 'simple crud for edit with block' # render block on :edit
|
|
514
516
|
include_examples 'simple crud for index with block' # render block
|
|
515
517
|
include_examples 'simple crud for index with scope' # scope: ->(user) { ... }
|
|
516
518
|
include_examples 'simple crud for show with block' # render block on :show
|
|
517
519
|
include_examples 'simple crud for new with block' # render block on :new
|
|
518
520
|
include_examples 'simple crud for create with block' # render block on :create
|
|
521
|
+
include_examples 'simple crud for update with block' # render block on :update
|
|
519
522
|
include_examples 'simple crud for destroy with block' # render block on :destroy
|
|
520
523
|
include_examples 'simple crud for show with finder' # finder on :show
|
|
521
524
|
include_examples 'simple crud for update with finder' # finder on :update
|
|
@@ -524,6 +527,8 @@ include_examples 'simple crud for new with build' # build: -> { ... } on
|
|
|
524
527
|
include_examples 'simple crud for create with build' # build: -> { ... } on :create
|
|
525
528
|
```
|
|
526
529
|
|
|
530
|
+
The `create with block`, `destroy with block`, `edit` and `update with finder` examples accept a 2xx render or a redirect. The `show`, `new` and `edit` block examples let the block ask the policy about other actions, such as `update?`. `new with build` and `create with build` check ownership by the current user only when you configure an `owner_association`.
|
|
531
|
+
|
|
527
532
|
It's not needed to specify paginate: true and such, since the shared examples will use the configuration that was originally passed to simple_crud_for
|
|
528
533
|
|
|
529
534
|
#### Adopting the shared examples
|
|
@@ -548,7 +553,7 @@ SimpleCrud::RSpec.configure do |config|
|
|
|
548
553
|
# override model_attributes directly for multi-key or non-user-owned models).
|
|
549
554
|
config.owner_association = :owner
|
|
550
555
|
config.model_attributes = -> { { owner: current_user } }
|
|
551
|
-
config.required_attribute = :title
|
|
556
|
+
config.required_attribute = :title # nil skips the invalid-attribute cases
|
|
552
557
|
config.required_error = "Title can't be blank"
|
|
553
558
|
|
|
554
559
|
# Redirect-based apps: unauthenticated requests get a redirect, not a 401.
|
|
@@ -587,7 +592,7 @@ SimpleCrud::RSpec.configure do |config|
|
|
|
587
592
|
end
|
|
588
593
|
```
|
|
589
594
|
|
|
590
|
-
Each setting has a sensible default, so you only override what differs. Callable settings (`current_user`, `authenticate`, `create_record`, `create_records`, `params_for`, `model_attributes`, `scoped_attributes`, `other_scoped_attributes`, `policy_class`, `serializer_class`) run in the example-group context, so they can call `request`, `create`, `current_user`, etc.; `created_record_check` receives the persisted record. The examples are controller-agnostic (they issue requests by action name, not hardcoded paths), so they work for namespaced and nested controllers alike. If you keep `assert_html_template` on (the default), add `gem 'rails-controller-testing'` for the `render_template` matcher.
|
|
595
|
+
Each setting has a sensible default, so you only override what differs. Callable settings (`current_user`, `authenticate`, `create_record`, `create_records`, `params_for`, `model_attributes`, `scoped_attributes`, `other_scoped_attributes`, `policy_class`, `serializer_class`) run in the example-group context, so they can call `request`, `create`, `current_user`, etc.; `created_record_check` receives the persisted record and `scoped_order` the created records. The examples are controller-agnostic (they issue requests by action name, not hardcoded paths), so they work for namespaced and nested controllers alike. If you keep `assert_html_template` on (the default), add `gem 'rails-controller-testing'` for the `render_template` matcher.
|
|
591
596
|
|
|
592
597
|
#### Per-controller overrides via metadata
|
|
593
598
|
|
|
@@ -606,6 +611,26 @@ end
|
|
|
606
611
|
|
|
607
612
|
Callable settings resolve in the example context, so their lambdas can close over the spec's `let`s; that's how records land in the same project the route params point at.
|
|
608
613
|
|
|
614
|
+
A scope that only orders excludes nothing. Set `other_scoped_attributes: nil` and `simple crud for index with scope` asserts that every scoped record comes back. `scoped_order` also asserts the order. It takes the created records and returns them in the expected order:
|
|
615
|
+
|
|
616
|
+
```ruby
|
|
617
|
+
RSpec.describe UsersController, type: :controller, simple_crud: {
|
|
618
|
+
other_scoped_attributes: nil,
|
|
619
|
+
scoped_order: ->(records) { records.sort_by(&:email) }
|
|
620
|
+
} do
|
|
621
|
+
include_examples 'simple crud for index with scope'
|
|
622
|
+
end
|
|
623
|
+
```
|
|
624
|
+
|
|
625
|
+
`singular: true` is a per-controller setting for singular resources (`resource :profile`). Requests carry no id, the "model does not exist" examples are skipped, and the controller's own finder, such as `finder: ->(_params) { current_user.profile }`, loads the record:
|
|
626
|
+
|
|
627
|
+
```ruby
|
|
628
|
+
RSpec.describe ProfilesController, type: :controller, simple_crud: { singular: true } do
|
|
629
|
+
include_examples 'simple crud for show'
|
|
630
|
+
include_examples 'simple crud for update'
|
|
631
|
+
end
|
|
632
|
+
```
|
|
633
|
+
|
|
609
634
|
## Contributing
|
|
610
635
|
|
|
611
636
|
1. Fork it
|
|
@@ -15,9 +15,9 @@ module SimpleCrud
|
|
|
15
15
|
.and_return(instance_double(policy_class_object, "#{method}?" => false))
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
def make_policies_succeed(method)
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
def make_policies_succeed(method, permissive: false)
|
|
19
|
+
policy = instance_double(policy_class_object, "#{method}?" => true)
|
|
20
|
+
allow(policy_class_object).to receive(:new).and_return(permissive ? policy.as_null_object : policy)
|
|
21
21
|
end
|
|
22
22
|
end
|
|
23
23
|
end
|
|
@@ -29,8 +29,11 @@ module SimpleCrud
|
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
# The params that identify a record for the given action, using the
|
|
32
|
-
# configured finder_key when the action has a custom finder.
|
|
32
|
+
# configured finder_key when the action has a custom finder. A singular
|
|
33
|
+
# resource has no id, so it identifies nothing.
|
|
33
34
|
def record_param(action, record, not_found: false)
|
|
35
|
+
return {} if singular
|
|
36
|
+
|
|
34
37
|
key = check_finder(action) ? finder_key : :id
|
|
35
38
|
value = not_found ? "nonexistent-#{key}" : record.public_send(key)
|
|
36
39
|
{ key => value }
|
|
@@ -24,10 +24,19 @@ module SimpleCrud
|
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
%i[owner_association required_attribute required_error finder_key params_key invalid_status
|
|
27
|
-
unauthenticated_status assert_html_template scoped_attributes other_scoped_attributes
|
|
27
|
+
unauthenticated_status assert_html_template scoped_attributes other_scoped_attributes
|
|
28
|
+
singular].each do |name|
|
|
28
29
|
define_method(name) { resolve(setting(name)) }
|
|
29
30
|
end
|
|
30
31
|
|
|
32
|
+
def invalid_case?(action)
|
|
33
|
+
!required_attribute.nil? && !check_raise_on_invalid(action)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def scoped_order
|
|
37
|
+
setting(:scoped_order)
|
|
38
|
+
end
|
|
39
|
+
|
|
31
40
|
def created_record_check
|
|
32
41
|
setting(:created_record_check)
|
|
33
42
|
end
|
data/lib/simple_crud/rspec.rb
CHANGED
|
@@ -11,6 +11,9 @@ require_relative '../spec/shared_examples/simple_crud_for_destroy'
|
|
|
11
11
|
require_relative '../spec/shared_examples/simple_crud_for_create'
|
|
12
12
|
require_relative '../spec/shared_examples/simple_crud_for_new'
|
|
13
13
|
require_relative '../spec/shared_examples/simple_crud_for_edit'
|
|
14
|
+
require_relative '../spec/shared_examples/simple_crud_for_edit_with_finder'
|
|
15
|
+
require_relative '../spec/shared_examples/simple_crud_for_edit_with_block'
|
|
16
|
+
require_relative '../spec/shared_examples/simple_crud_for_update_with_block'
|
|
14
17
|
require_relative '../spec/shared_examples/unauthorized_when_not_logged_in'
|
|
15
18
|
require_relative '../spec/shared_examples/simple_crud_renders_template'
|
|
16
19
|
require_relative '../spec/shared_examples/simple_crud_without_authenticated_user'
|
|
@@ -31,6 +34,7 @@ require_relative '../spec/shared_examples/simple_crud_for_owned_resource'
|
|
|
31
34
|
require_relative '../spec/shared_examples/simple_crud_for_nested_resource'
|
|
32
35
|
require_relative '../spec/shared_examples/authorization_adapter_authorize'
|
|
33
36
|
require_relative '../spec/matchers/have_been_serialized_with'
|
|
37
|
+
require_relative '../spec/matchers/render_or_redirect'
|
|
34
38
|
|
|
35
39
|
module SimpleCrud
|
|
36
40
|
# Opt-in wiring for the shared examples: see .install!
|
data/lib/simple_crud/version.rb
CHANGED
|
@@ -53,7 +53,7 @@ RSpec.shared_examples 'simple crud for create' do
|
|
|
53
53
|
end
|
|
54
54
|
end
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
if invalid_case?(:create)
|
|
57
57
|
context 'when creating with invalid attributes' do
|
|
58
58
|
include_context 'with authenticated user' if check_authenticate(:create)
|
|
59
59
|
|
|
@@ -11,7 +11,7 @@ RSpec.shared_examples 'simple crud for create with block' do
|
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
it 'passes the saved record to the block' do
|
|
14
|
-
expect(response).to
|
|
14
|
+
expect(response).to render_or_redirect
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
it 'creates the record' do
|
|
@@ -19,7 +19,7 @@ RSpec.shared_examples 'simple crud for create with block' do
|
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
if invalid_case?(:create)
|
|
23
23
|
context 'when creating with invalid attributes' do
|
|
24
24
|
include_context 'with authenticated user' if check_authenticate(:create)
|
|
25
25
|
|
|
@@ -8,8 +8,14 @@ RSpec.shared_examples 'simple crud for create with build' do
|
|
|
8
8
|
post :create, params: with_route_params(body_params(params_for(model_class))), format: format_param(:create)
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
if owner_association
|
|
12
|
+
it 'creates the record owned by the current user' do
|
|
13
|
+
expect(model_class_object.last.public_send(owner_association)).to eq(current_user)
|
|
14
|
+
end
|
|
15
|
+
else
|
|
16
|
+
it 'creates the record through the hook' do
|
|
17
|
+
expect(model_class_object.count).to eq(1)
|
|
18
|
+
end
|
|
13
19
|
end
|
|
14
20
|
end
|
|
15
21
|
end
|
|
@@ -71,17 +71,19 @@ RSpec.shared_examples 'simple crud for destroy' do
|
|
|
71
71
|
end
|
|
72
72
|
end
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
unless singular
|
|
75
|
+
context 'when ID is invalid' do
|
|
76
|
+
include_context 'with authenticated user' if check_authenticate(:destroy)
|
|
76
77
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
before do
|
|
79
|
+
model
|
|
80
|
+
delete :destroy, params: with_route_params(record_param(:destroy, nil, not_found: true)),
|
|
81
|
+
format: format_param(:destroy)
|
|
82
|
+
end
|
|
82
83
|
|
|
83
|
-
|
|
84
|
-
|
|
84
|
+
it 'responds with not found status' do
|
|
85
|
+
expect(response).to have_http_status(:not_found)
|
|
86
|
+
end
|
|
85
87
|
end
|
|
86
88
|
end
|
|
87
89
|
|
|
@@ -41,38 +41,40 @@ RSpec.shared_examples 'simple crud for edit' do
|
|
|
41
41
|
|
|
42
42
|
before do
|
|
43
43
|
model
|
|
44
|
-
make_policies_succeed(:edit) if check_authorize(:edit)
|
|
44
|
+
make_policies_succeed(:edit, permissive: check_block(:edit)) if check_authorize(:edit)
|
|
45
45
|
edit_request
|
|
46
46
|
end
|
|
47
47
|
|
|
48
|
-
it 'responds with ok status' do
|
|
49
|
-
expect(response).to have_http_status(:ok)
|
|
50
|
-
end
|
|
51
|
-
|
|
52
48
|
if check_block(:edit)
|
|
53
49
|
it 'renders the asked model through the block' do
|
|
54
|
-
expect(response).to
|
|
50
|
+
expect(response).to render_or_redirect
|
|
55
51
|
end
|
|
56
52
|
elsif check_html(:edit)
|
|
57
53
|
include_examples 'simple crud renders template', :edit
|
|
58
54
|
else
|
|
55
|
+
it 'responds with ok status' do
|
|
56
|
+
expect(response).to have_http_status(:ok)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
59
|
it 'returns the asked model' do
|
|
60
60
|
expect(response_body['id']).to eq(model.id)
|
|
61
61
|
end
|
|
62
62
|
end
|
|
63
63
|
end
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
unless singular
|
|
66
|
+
context 'when the model does not exist' do
|
|
67
|
+
include_context 'with authenticated user'
|
|
67
68
|
|
|
68
|
-
|
|
69
|
+
let(:edit_params) { record_param(:edit, nil, not_found: true) }
|
|
69
70
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
before do
|
|
72
|
+
edit_request
|
|
73
|
+
end
|
|
73
74
|
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
it 'responds with not found status' do
|
|
76
|
+
expect(response).to have_http_status(:not_found)
|
|
77
|
+
end
|
|
76
78
|
end
|
|
77
79
|
end
|
|
78
80
|
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.shared_examples 'simple crud for edit with block' do
|
|
4
|
+
describe 'GET #edit with a render block' do
|
|
5
|
+
include_context 'with authenticated user' if check_authenticate(:edit)
|
|
6
|
+
|
|
7
|
+
let!(:record) { model }
|
|
8
|
+
|
|
9
|
+
before do
|
|
10
|
+
make_policies_succeed(:edit, permissive: true) if check_authorize(:edit)
|
|
11
|
+
get :edit, params: with_route_params(record_param(:edit, record)), format: format_param(:edit)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
if check_html(:edit)
|
|
15
|
+
include_examples 'simple crud renders template', :edit
|
|
16
|
+
else
|
|
17
|
+
it 'renders the record through the block' do
|
|
18
|
+
expect(response).to render_or_redirect
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.shared_examples 'simple crud for edit with finder' do
|
|
4
|
+
describe 'GET #edit with a custom finder' do
|
|
5
|
+
include_context 'with authenticated user' if check_authenticate(:edit)
|
|
6
|
+
|
|
7
|
+
context 'when the model exists' do
|
|
8
|
+
before do
|
|
9
|
+
model
|
|
10
|
+
make_policies_succeed(:edit, permissive: check_block(:edit)) if check_authorize(:edit)
|
|
11
|
+
get :edit, params: with_route_params(finder_key => model.public_send(finder_key)),
|
|
12
|
+
format: format_param(:edit)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
if check_block(:edit)
|
|
16
|
+
it 'finds the asked model' do
|
|
17
|
+
expect(rendered_record.id).to eq(model.id)
|
|
18
|
+
end
|
|
19
|
+
elsif check_html(:edit)
|
|
20
|
+
include_examples 'simple crud renders template', :edit
|
|
21
|
+
else
|
|
22
|
+
it 'responds with ok status' do
|
|
23
|
+
expect(response).to have_http_status(:ok)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it 'returns the asked model' do
|
|
27
|
+
expect(response_body['id']).to eq(model.id)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
include_examples 'simple crud not found with finder', :get, :edit
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -3,7 +3,14 @@
|
|
|
3
3
|
RSpec.shared_examples 'simple crud for index with scope' do
|
|
4
4
|
let(:request_params) { {} }
|
|
5
5
|
let(:my_models) { create_records(model_class, 2, scoped_attributes) }
|
|
6
|
-
let(:other_models) { create_records(model_class, 3, other_scoped_attributes) }
|
|
6
|
+
let(:other_models) { create_records(model_class, 3, other_scoped_attributes) if other_scoped_attributes }
|
|
7
|
+
let(:listed_ids) do
|
|
8
|
+
if check_html(:index)
|
|
9
|
+
rendered_records.map(&:id)
|
|
10
|
+
else
|
|
11
|
+
(check_paginate(:index) ? response_body['page'] : response_body).map { |m| m['id'] }
|
|
12
|
+
end
|
|
13
|
+
end
|
|
7
14
|
|
|
8
15
|
# Hooks stay inside this context so co-including the example never
|
|
9
16
|
# authenticates or stubs policies for sibling examples.
|
|
@@ -16,17 +23,13 @@ RSpec.shared_examples 'simple crud for index with scope' do
|
|
|
16
23
|
get :index, params: with_route_params(request_params), format: format_param(:index)
|
|
17
24
|
end
|
|
18
25
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
it 'returns
|
|
25
|
-
expect(
|
|
26
|
-
end
|
|
27
|
-
else
|
|
28
|
-
it 'returns only the unpaginated scoped records' do
|
|
29
|
-
expect(response_body.map { |m| m['id'] }).to match_array(my_models.map(&:id))
|
|
26
|
+
it 'returns the scoped records' do
|
|
27
|
+
expect(listed_ids).to match_array(my_models.map(&:id))
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
if scoped_order
|
|
31
|
+
it 'returns the scoped records in order' do
|
|
32
|
+
expect(listed_ids).to eq(instance_exec(my_models, &scoped_order).map(&:id))
|
|
30
33
|
end
|
|
31
34
|
end
|
|
32
35
|
end
|
|
@@ -5,7 +5,7 @@ RSpec.shared_examples 'simple crud for new with block' do
|
|
|
5
5
|
include_context 'with authenticated user' if check_authenticate(:new)
|
|
6
6
|
|
|
7
7
|
before do
|
|
8
|
-
make_policies_succeed(:new) if check_authorize(:new)
|
|
8
|
+
make_policies_succeed(:new, permissive: true) if check_authorize(:new)
|
|
9
9
|
get :new, params: with_route_params({}), format: format_param(:new)
|
|
10
10
|
end
|
|
11
11
|
|
|
@@ -8,11 +8,17 @@ RSpec.shared_examples 'simple crud for new with build' do
|
|
|
8
8
|
get :new, params: with_route_params({}), format: format_param(:new)
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
if owner_association
|
|
12
|
+
it 'builds the record owned by the current user', :aggregate_failures do
|
|
13
|
+
if check_html(:new) || check_block(:new)
|
|
14
|
+
expect(rendered_record.public_send(owner_foreign_key)).to eq(current_user.id)
|
|
15
|
+
else
|
|
16
|
+
expect(response_body[owner_foreign_key.to_s]).to eq(current_user.id)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
else
|
|
20
|
+
it 'builds the record through the hook' do
|
|
21
|
+
expect(response).to be_successful
|
|
16
22
|
end
|
|
17
23
|
end
|
|
18
24
|
end
|
|
@@ -15,13 +15,23 @@ RSpec.shared_examples 'simple crud for owned resource' do
|
|
|
15
15
|
expect(response).to have_http_status(:not_found)
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
context 'when updating a record owned by another user' do
|
|
19
|
+
let!(:original_value) { required_attribute && someone_elses_model.public_send(required_attribute) }
|
|
20
|
+
|
|
21
|
+
before do
|
|
22
|
+
params = with_route_params(record_param(:update, someone_elses_model)).merge(body_params(model_params))
|
|
23
|
+
patch :update, params: params, format: format_param(:update)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it 'responds with not found' do
|
|
27
|
+
expect(response).to have_http_status(:not_found)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
if required_attribute
|
|
31
|
+
it 'leaves the record untouched' do
|
|
32
|
+
expect(someone_elses_model.reload.public_send(required_attribute)).to eq(original_value)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
25
35
|
end
|
|
26
36
|
|
|
27
37
|
it 'attributes a created record to the current user regardless of the request', :aggregate_failures do
|
|
@@ -39,16 +39,18 @@ RSpec.shared_examples 'simple crud for show' do
|
|
|
39
39
|
end
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
unless singular
|
|
43
|
+
describe 'when the model does not exist' do
|
|
44
|
+
include_context 'with authenticated user'
|
|
45
|
+
let(:show_params) { record_param(:show, nil, not_found: true) }
|
|
45
46
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
before do
|
|
48
|
+
show_request
|
|
49
|
+
end
|
|
49
50
|
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
it 'responds with not found status' do
|
|
52
|
+
expect(response).to have_http_status(:not_found)
|
|
53
|
+
end
|
|
52
54
|
end
|
|
53
55
|
end
|
|
54
56
|
end
|
|
@@ -7,7 +7,7 @@ RSpec.shared_examples 'simple crud for show with block' do
|
|
|
7
7
|
let!(:record) { model }
|
|
8
8
|
|
|
9
9
|
before do
|
|
10
|
-
make_policies_succeed(:show) if check_authorize(:show)
|
|
10
|
+
make_policies_succeed(:show, permissive: true) if check_authorize(:show)
|
|
11
11
|
get :show, params: with_route_params(record_param(:show, record)), format: format_param(:show)
|
|
12
12
|
end
|
|
13
13
|
|
|
@@ -61,24 +61,26 @@ RSpec.shared_examples 'simple crud for update' do
|
|
|
61
61
|
end
|
|
62
62
|
end
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
unless singular
|
|
65
|
+
context 'when updating a model that doesn\'t exist' do
|
|
66
|
+
include_context 'with authenticated user'
|
|
66
67
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
before do
|
|
69
|
+
put :update, params: with_route_params(record_param(:update, nil, not_found: true)),
|
|
70
|
+
format: format_param(:update)
|
|
71
|
+
end
|
|
71
72
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
it 'response with 404 status code' do
|
|
74
|
+
expect(response).to have_http_status(:not_found)
|
|
75
|
+
end
|
|
75
76
|
|
|
76
|
-
|
|
77
|
-
|
|
77
|
+
it 'doesn\'t create an model' do
|
|
78
|
+
expect(model_class_object.count).to be 0
|
|
79
|
+
end
|
|
78
80
|
end
|
|
79
81
|
end
|
|
80
82
|
|
|
81
|
-
|
|
83
|
+
if invalid_case?(:update)
|
|
82
84
|
context 'when updating with invalid attributes' do
|
|
83
85
|
include_context 'with authenticated user' if check_authenticate(:update)
|
|
84
86
|
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.shared_examples 'simple crud for update with block' do
|
|
4
|
+
describe 'PUT #update with a render block' do
|
|
5
|
+
include_context 'with authenticated user' if check_authenticate(:update)
|
|
6
|
+
|
|
7
|
+
let!(:record) { model }
|
|
8
|
+
|
|
9
|
+
context 'when successfully updating a record' do
|
|
10
|
+
before do
|
|
11
|
+
make_policies_succeed(:update, permissive: true) if check_authorize(:update)
|
|
12
|
+
put :update, params: with_route_params(body_params(model_params).merge(record_param(:update, record))),
|
|
13
|
+
format: format_param(:update)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'passes the saved record to the block' do
|
|
17
|
+
expect(response).to render_or_redirect
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it 'updates the record' do
|
|
21
|
+
expect(record.reload).to have_attributes(model_params)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
if invalid_case?(:update)
|
|
26
|
+
context 'when updating with invalid attributes' do
|
|
27
|
+
before do
|
|
28
|
+
make_policies_succeed(:update, permissive: true) if check_authorize(:update)
|
|
29
|
+
put :update, params: with_route_params(body_params({ required_attribute => nil }.merge(owner_params))
|
|
30
|
+
.merge(record_param(:update, record))),
|
|
31
|
+
format: format_param(:update)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it 'does not change the record' do
|
|
35
|
+
expect(record.reload.public_send(required_attribute)).not_to be_nil
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -5,8 +5,9 @@ RSpec.shared_examples 'simple crud for update with finder' do
|
|
|
5
5
|
include_context 'with authenticated user' if check_authenticate(:update)
|
|
6
6
|
|
|
7
7
|
context 'when successfully updating a model' do
|
|
8
|
+
let(:updated_attributes) { required_attribute ? { required_attribute => 'Updated' } : model_params }
|
|
8
9
|
let(:update_params) do
|
|
9
|
-
with_route_params(body_params(
|
|
10
|
+
with_route_params(body_params(updated_attributes).merge(owner_params))
|
|
10
11
|
.merge(finder_key => model.public_send(finder_key))
|
|
11
12
|
end
|
|
12
13
|
|
|
@@ -15,13 +16,15 @@ RSpec.shared_examples 'simple crud for update with finder' do
|
|
|
15
16
|
put :update, params: update_params, format: format_param(:update)
|
|
16
17
|
end
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
if required_attribute
|
|
20
|
+
it 'updates the model' do
|
|
21
|
+
expect(model.reload.public_send(required_attribute)).to eq('Updated')
|
|
22
|
+
end
|
|
20
23
|
end
|
|
21
24
|
|
|
22
25
|
if check_block(:update)
|
|
23
26
|
it 'passes the updated model to the block' do
|
|
24
|
-
expect(
|
|
27
|
+
expect(response).to render_or_redirect
|
|
25
28
|
end
|
|
26
29
|
elsif check_html(:update)
|
|
27
30
|
it 'redirects to the updated record' do
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
RSpec.shared_examples 'simple crud not found with finder' do |http_method, action|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
unless singular
|
|
5
|
+
context 'when the model does not exist' do
|
|
6
|
+
before do
|
|
7
|
+
send(http_method, action, params: with_route_params(finder_key => "nonexistent-#{finder_key}"),
|
|
8
|
+
format: format_param(action))
|
|
9
|
+
end
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
it 'responds with not found status' do
|
|
12
|
+
expect(response).to have_http_status(:not_found)
|
|
13
|
+
end
|
|
12
14
|
end
|
|
13
15
|
end
|
|
14
16
|
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe BlockCreateRedirect::DummyModelsController, type: :controller do
|
|
6
|
+
include_examples 'simple crud for create with block'
|
|
7
|
+
|
|
8
|
+
describe 'without a validated attribute', simple_crud: { required_attribute: nil } do
|
|
9
|
+
include_examples 'simple crud for create with block'
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -4,6 +4,8 @@ require 'spec_helper'
|
|
|
4
4
|
|
|
5
5
|
describe BlockFinder::DummyModelsController, type: :controller do
|
|
6
6
|
include_examples 'simple crud for edit'
|
|
7
|
+
include_examples 'simple crud for edit with finder'
|
|
8
|
+
include_examples 'simple crud for edit with block'
|
|
7
9
|
include_examples 'simple crud for show with finder'
|
|
8
10
|
include_examples 'simple crud for update with finder'
|
|
9
11
|
include_examples 'simple crud for destroy with finder'
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe BlockUpdate::DummyModelsController, type: :controller do
|
|
6
|
+
include_examples 'simple crud for update with block'
|
|
7
|
+
|
|
8
|
+
describe 'without a validated attribute', simple_crud: { required_attribute: nil } do
|
|
9
|
+
include_examples 'simple crud for update with block'
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module BlockCreateRedirect
|
|
4
|
+
class DummyModelsController < HtmlModes::BaseController
|
|
5
|
+
simple_crud_for :create, html: true, authenticate: false, authorize: false do |record, saved|
|
|
6
|
+
if saved
|
|
7
|
+
redirect_to action: :show, id: record.id
|
|
8
|
+
else
|
|
9
|
+
render json: { errors: record.errors.full_messages }, status: :unprocessable_entity
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module BlockPolicyShow
|
|
4
|
+
# The block consults the policy again (as an app picking a page by role would).
|
|
5
|
+
class DummyModelsController < BlockModes::BaseController
|
|
6
|
+
include Pundit::Authorization
|
|
7
|
+
|
|
8
|
+
simple_crud_for :show, html: true, authenticate: false do |record|
|
|
9
|
+
render_model(record, :show) if policy(record).update?
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module ScopedOrder
|
|
4
|
+
class DummyModelsController < ApplicationController
|
|
5
|
+
include Wor::Paginate
|
|
6
|
+
include Pundit::Authorization
|
|
7
|
+
extend SimpleCrudController
|
|
8
|
+
|
|
9
|
+
simple_crud_for :index, scope: ->(_user) { DummyModel.order(:name, :id) }, authorize: false
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Singular
|
|
4
|
+
class DummyModelsController < HtmlModes::BaseController
|
|
5
|
+
FIRST_RECORD = ->(_params) { DummyModel.first! }
|
|
6
|
+
|
|
7
|
+
simple_crud_for :show, html: false, authenticate: false, authorize: false, finder: FIRST_RECORD
|
|
8
|
+
simple_crud_for :edit, html: false, authenticate: false, authorize: false, finder: FIRST_RECORD
|
|
9
|
+
simple_crud_for :update, html: false, authenticate: false, authorize: false, finder: FIRST_RECORD
|
|
10
|
+
simple_crud_for :destroy, html: false, authenticate: false, authorize: false, finder: FIRST_RECORD
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<span class="record"><%= model.name %></span>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<span class="record"><%= model.name %></span>
|
data/spec/dummy/config/routes.rb
CHANGED
|
@@ -36,6 +36,18 @@ Rails.application.routes.draw do
|
|
|
36
36
|
resources :dummy_models, only: %i[show edit update destroy], param: :slug
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
+
namespace :block_update do
|
|
40
|
+
resources :dummy_models, only: :update
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
namespace :singular do
|
|
44
|
+
resource :dummy_model, only: %i[show edit update destroy]
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
namespace :scoped_order do
|
|
48
|
+
resources :dummy_models, only: :index
|
|
49
|
+
end
|
|
50
|
+
|
|
39
51
|
namespace :scoped do
|
|
40
52
|
resources :dummy_models, only: :index
|
|
41
53
|
end
|
|
@@ -64,10 +76,22 @@ Rails.application.routes.draw do
|
|
|
64
76
|
resources :dummy_models, only: :show
|
|
65
77
|
end
|
|
66
78
|
|
|
79
|
+
namespace :block_edit do
|
|
80
|
+
resources :dummy_models, only: :edit
|
|
81
|
+
end
|
|
82
|
+
|
|
67
83
|
namespace :block_show do
|
|
68
84
|
resources :dummy_models, only: :show
|
|
69
85
|
end
|
|
70
86
|
|
|
87
|
+
namespace :block_policy_show do
|
|
88
|
+
resources :dummy_models, only: :show
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
namespace :block_create_redirect do
|
|
92
|
+
resources :dummy_models, only: %i[show create]
|
|
93
|
+
end
|
|
94
|
+
|
|
71
95
|
namespace :html_new do
|
|
72
96
|
resources :dummy_models, only: :new
|
|
73
97
|
end
|
|
@@ -4,10 +4,16 @@ require 'spec_helper'
|
|
|
4
4
|
|
|
5
5
|
describe Finder::DummyModelsController, type: :controller do
|
|
6
6
|
include_examples 'simple crud for edit'
|
|
7
|
+
include_examples 'simple crud for edit with finder'
|
|
7
8
|
include_examples 'simple crud for show with finder'
|
|
8
9
|
include_examples 'simple crud for update with finder'
|
|
9
10
|
include_examples 'simple crud for destroy with finder'
|
|
10
11
|
include_examples 'simple crud for show'
|
|
11
12
|
include_examples 'simple crud for update'
|
|
12
13
|
include_examples 'simple crud for destroy'
|
|
14
|
+
|
|
15
|
+
describe 'without a validated attribute', simple_crud: { required_attribute: nil } do
|
|
16
|
+
include_examples 'simple crud for update'
|
|
17
|
+
include_examples 'simple crud for update with finder'
|
|
18
|
+
end
|
|
13
19
|
end
|
|
@@ -4,6 +4,7 @@ require 'spec_helper'
|
|
|
4
4
|
|
|
5
5
|
describe HtmlFinder::DummyModelsController, type: :controller do
|
|
6
6
|
include_examples 'simple crud for edit'
|
|
7
|
+
include_examples 'simple crud for edit with finder'
|
|
7
8
|
include_examples 'simple crud for show with finder'
|
|
8
9
|
include_examples 'simple crud for update with finder'
|
|
9
10
|
include_examples 'simple crud for destroy with finder'
|
|
@@ -19,6 +19,16 @@ describe Parented::DummyModelsController, simple_crud: {
|
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
+
describe 'new with a build hook and no owner association',
|
|
23
|
+
simple_crud: { owner_association: nil, route_params: -> { { owner_id: current_user.id } } } do
|
|
24
|
+
include_examples 'simple crud for new with build'
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe 'create with a build hook and no owner association',
|
|
28
|
+
simple_crud: { owner_association: nil, route_params: -> { { owner_id: current_user.id } } } do
|
|
29
|
+
include_examples 'simple crud for create with build'
|
|
30
|
+
end
|
|
31
|
+
|
|
22
32
|
describe 'POST #create with parent: and owned_by: together' do
|
|
23
33
|
it 'raises, they are the same relation source' do
|
|
24
34
|
expect do
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe ScopedOrder::DummyModelsController, simple_crud: {
|
|
6
|
+
other_scoped_attributes: nil,
|
|
7
|
+
scoped_order: ->(records) { records.sort_by { |r| [r.name, r.id] } }
|
|
8
|
+
}, type: :controller do
|
|
9
|
+
include_examples 'simple crud for index with scope'
|
|
10
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe Singular::DummyModelsController, simple_crud: { singular: true }, type: :controller do
|
|
6
|
+
include_examples 'simple crud for show'
|
|
7
|
+
include_examples 'simple crud for edit'
|
|
8
|
+
include_examples 'simple crud for update'
|
|
9
|
+
include_examples 'simple crud for destroy'
|
|
10
|
+
end
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: wor-simple_crud
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- icoluccio
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-
|
|
10
|
+
date: 2026-10-15 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: rails
|
|
@@ -83,6 +83,7 @@ files:
|
|
|
83
83
|
- lib/simple_crud/update_context.rb
|
|
84
84
|
- lib/simple_crud/version.rb
|
|
85
85
|
- lib/spec/matchers/have_been_serialized_with.rb
|
|
86
|
+
- lib/spec/matchers/render_or_redirect.rb
|
|
86
87
|
- lib/spec/response_helper.rb
|
|
87
88
|
- lib/spec/shared_contexts/authenticate_user.rb
|
|
88
89
|
- lib/spec/shared_examples/authorization_adapter_authorize.rb
|
|
@@ -93,6 +94,8 @@ files:
|
|
|
93
94
|
- lib/spec/shared_examples/simple_crud_for_destroy_with_block.rb
|
|
94
95
|
- lib/spec/shared_examples/simple_crud_for_destroy_with_finder.rb
|
|
95
96
|
- lib/spec/shared_examples/simple_crud_for_edit.rb
|
|
97
|
+
- lib/spec/shared_examples/simple_crud_for_edit_with_block.rb
|
|
98
|
+
- lib/spec/shared_examples/simple_crud_for_edit_with_finder.rb
|
|
96
99
|
- lib/spec/shared_examples/simple_crud_for_index.rb
|
|
97
100
|
- lib/spec/shared_examples/simple_crud_for_index_with_block.rb
|
|
98
101
|
- lib/spec/shared_examples/simple_crud_for_index_with_scope.rb
|
|
@@ -105,6 +108,7 @@ files:
|
|
|
105
108
|
- lib/spec/shared_examples/simple_crud_for_show_with_block.rb
|
|
106
109
|
- lib/spec/shared_examples/simple_crud_for_show_with_finder.rb
|
|
107
110
|
- lib/spec/shared_examples/simple_crud_for_update.rb
|
|
111
|
+
- lib/spec/shared_examples/simple_crud_for_update_with_block.rb
|
|
108
112
|
- lib/spec/shared_examples/simple_crud_for_update_with_finder.rb
|
|
109
113
|
- lib/spec/shared_examples/simple_crud_not_found_with_finder.rb
|
|
110
114
|
- lib/spec/shared_examples/simple_crud_renders_template.rb
|
|
@@ -114,12 +118,16 @@ files:
|
|
|
114
118
|
- pull_request_template.md
|
|
115
119
|
- spec/block/dummy_models_controller_spec.rb
|
|
116
120
|
- spec/block_create/dummy_models_controller_spec.rb
|
|
121
|
+
- spec/block_create_redirect/dummy_models_controller_spec.rb
|
|
117
122
|
- spec/block_destroy/dummy_models_controller_spec.rb
|
|
123
|
+
- spec/block_edit/dummy_models_controller_spec.rb
|
|
118
124
|
- spec/block_finder/dummy_models_controller_spec.rb
|
|
119
125
|
- spec/block_json/dummy_models_controller_spec.rb
|
|
120
126
|
- spec/block_new/dummy_models_controller_spec.rb
|
|
127
|
+
- spec/block_policy_show/dummy_models_controller_spec.rb
|
|
121
128
|
- spec/block_redirect/dummy_models_controller_spec.rb
|
|
122
129
|
- spec/block_show/dummy_models_controller_spec.rb
|
|
130
|
+
- spec/block_update/dummy_models_controller_spec.rb
|
|
123
131
|
- spec/blueprint/dummy_models_controller_spec.rb
|
|
124
132
|
- spec/blueprint_unpaginated/dummy_models_controller_spec.rb
|
|
125
133
|
- spec/built/dummy_models_controller_spec.rb
|
|
@@ -131,13 +139,17 @@ files:
|
|
|
131
139
|
- spec/dummy/app/controllers/application_controller.rb
|
|
132
140
|
- spec/dummy/app/controllers/block/dummy_models_controller.rb
|
|
133
141
|
- spec/dummy/app/controllers/block_create/dummy_models_controller.rb
|
|
142
|
+
- spec/dummy/app/controllers/block_create_redirect/dummy_models_controller.rb
|
|
134
143
|
- spec/dummy/app/controllers/block_destroy/dummy_models_controller.rb
|
|
144
|
+
- spec/dummy/app/controllers/block_edit/dummy_models_controller.rb
|
|
135
145
|
- spec/dummy/app/controllers/block_finder/dummy_models_controller.rb
|
|
136
146
|
- spec/dummy/app/controllers/block_json/dummy_models_controller.rb
|
|
137
147
|
- spec/dummy/app/controllers/block_modes/base_controller.rb
|
|
138
148
|
- spec/dummy/app/controllers/block_new/dummy_models_controller.rb
|
|
149
|
+
- spec/dummy/app/controllers/block_policy_show/dummy_models_controller.rb
|
|
139
150
|
- spec/dummy/app/controllers/block_redirect/dummy_models_controller.rb
|
|
140
151
|
- spec/dummy/app/controllers/block_show/dummy_models_controller.rb
|
|
152
|
+
- spec/dummy/app/controllers/block_update/dummy_models_controller.rb
|
|
141
153
|
- spec/dummy/app/controllers/blueprint/dummy_models_controller.rb
|
|
142
154
|
- spec/dummy/app/controllers/blueprint_unpaginated/dummy_models_controller.rb
|
|
143
155
|
- spec/dummy/app/controllers/built/dummy_models_controller.rb
|
|
@@ -163,8 +175,10 @@ files:
|
|
|
163
175
|
- spec/dummy/app/controllers/redirect/dummy_models_controller.rb
|
|
164
176
|
- spec/dummy/app/controllers/redirect_auth/dummy_models_controller.rb
|
|
165
177
|
- spec/dummy/app/controllers/scoped/dummy_models_controller.rb
|
|
178
|
+
- spec/dummy/app/controllers/scoped_order/dummy_models_controller.rb
|
|
166
179
|
- spec/dummy/app/controllers/scoped_params/dummy_models_controller.rb
|
|
167
180
|
- spec/dummy/app/controllers/scoped_symbol/dummy_models_controller.rb
|
|
181
|
+
- spec/dummy/app/controllers/singular/dummy_models_controller.rb
|
|
168
182
|
- spec/dummy/app/controllers/strict/dummy_models_controller.rb
|
|
169
183
|
- spec/dummy/app/controllers/unpaginated_scoped/dummy_models_controller.rb
|
|
170
184
|
- spec/dummy/app/controllers/without_pagination/dummy_models_controller.rb
|
|
@@ -176,7 +190,9 @@ files:
|
|
|
176
190
|
- spec/dummy/app/serializers/dummy_model_plain_serializer.rb
|
|
177
191
|
- spec/dummy/app/serializers/dummy_model_serializer.rb
|
|
178
192
|
- spec/dummy/app/views/block/dummy_models/index.html.erb
|
|
193
|
+
- spec/dummy/app/views/block_edit/dummy_models/edit.html.erb
|
|
179
194
|
- spec/dummy/app/views/block_new/dummy_models/new.html.erb
|
|
195
|
+
- spec/dummy/app/views/block_policy_show/dummy_models/show.html.erb
|
|
180
196
|
- spec/dummy/app/views/block_show/dummy_models/show.html.erb
|
|
181
197
|
- spec/dummy/app/views/html/dummy_models/index.html.erb
|
|
182
198
|
- spec/dummy/app/views/html_create/dummy_models/new.html.erb
|
|
@@ -242,6 +258,7 @@ files:
|
|
|
242
258
|
- spec/redirect/dummy_models_controller_spec.rb
|
|
243
259
|
- spec/redirect_auth/dummy_models_controller_spec.rb
|
|
244
260
|
- spec/scoped/dummy_models_controller_spec.rb
|
|
261
|
+
- spec/scoped_order/dummy_models_controller_spec.rb
|
|
245
262
|
- spec/scoped_params/dummy_models_controller_spec.rb
|
|
246
263
|
- spec/scoped_symbol/dummy_models_controller_spec.rb
|
|
247
264
|
- spec/simple_crud/action_context_spec.rb
|
|
@@ -256,6 +273,7 @@ files:
|
|
|
256
273
|
- spec/simple_crud/show_context_spec.rb
|
|
257
274
|
- spec/simple_crud_configuration_spec.rb
|
|
258
275
|
- spec/simple_crud_controller_spec.rb
|
|
276
|
+
- spec/singular/dummy_models_controller_spec.rb
|
|
259
277
|
- spec/spec_helper.rb
|
|
260
278
|
- spec/spy.rb
|
|
261
279
|
- spec/strict/dummy_models_controller_spec.rb
|