base_editing_bootstrap 0.5.0 → 0.6.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f75c92251f46045d20902120b1796ad0804dbfd632b0ddd77669a6f4f7ab35c
|
4
|
+
data.tar.gz: 9e87df84d2fc30d8f981095cc3304479c1629b25cf0daa14746a78d83dba5245
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ded9cc6fbff9ae4515f98530596a444f3b18760dc5677b0ae9f5c9b96056287d08500f5a691fb2bcf926709151e79d7af7d4da235dbcd129aa7db4d3d4f520d
|
7
|
+
data.tar.gz: 6d22f81c4ecf3db3a7413f0fa42ac35b01ffa1e36a570d9cbc412e5daa5a49c9abc3659f63613e7c194cac8b3a417b52de0e5dc2d243799b7faf9dfc5d255213
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,18 @@
|
|
2
2
|
All notable changes to this project will be documented in this file. See [conventional commits](https://www.conventionalcommits.org/) for commit guidelines.
|
3
3
|
|
4
4
|
- - -
|
5
|
+
## 0.6.0 - 2024-05-29
|
6
|
+
#### Bug Fixes
|
7
|
+
- Add dependency in generator - (b911b1a) - Marino Bonetti
|
8
|
+
#### Documentation
|
9
|
+
- Add documentation for specs - (42a88ca) - Marino Bonetti
|
10
|
+
#### Features
|
11
|
+
- Add Capacity to skip un-authorization - (c83c51c) - Marino Bonetti
|
12
|
+
#### Tests
|
13
|
+
- Add spec for test env - (b8611d7) - Marino Bonetti
|
14
|
+
|
15
|
+
- - -
|
16
|
+
|
5
17
|
## 0.5.0 - 2024-05-22
|
6
18
|
#### Bug Fixes
|
7
19
|
- Correct initializer commented examples - (ba90fba) - Marino Bonetti
|
data/README.md
CHANGED
@@ -170,6 +170,50 @@ Utilizzo per modello base, in questo esempio prendiamo come modello Post come es
|
|
170
170
|
#...
|
171
171
|
```
|
172
172
|
|
173
|
+
## Testing helpers
|
174
|
+
|
175
|
+
### Requirements(installed with generators)
|
176
|
+
```ruby
|
177
|
+
group :test do
|
178
|
+
gem 'rails-controller-testing'
|
179
|
+
end
|
180
|
+
```
|
181
|
+
### Usage
|
182
|
+
Controllers:
|
183
|
+
```ruby
|
184
|
+
require 'rails_helper'
|
185
|
+
RSpec.describe "ServiceControllers", type: :request do
|
186
|
+
it_behaves_like "as logged in user" do
|
187
|
+
it_behaves_like "base editing controller", factory: :service
|
188
|
+
end
|
189
|
+
end
|
190
|
+
```
|
191
|
+
Model:
|
192
|
+
```ruby
|
193
|
+
require 'rails_helper'
|
194
|
+
RSpec.describe Service, type: :model do
|
195
|
+
it_behaves_like "a base model",
|
196
|
+
ransack_permitted_attributes: %w[created_at id last_status name stack_id updated_at],
|
197
|
+
ransack_permitted_associations: []
|
198
|
+
end
|
199
|
+
```
|
200
|
+
Policy
|
201
|
+
```ruby
|
202
|
+
require 'rails_helper'
|
203
|
+
##
|
204
|
+
# - check_default_responses default false, to check default responses
|
205
|
+
# TODO should be configurable
|
206
|
+
# [:show?, false],
|
207
|
+
# [:destroy?, true],
|
208
|
+
# [:update?, true],
|
209
|
+
# [:create?, true],
|
210
|
+
# [:index?, true],
|
211
|
+
#
|
212
|
+
RSpec.describe ServicePolicy, type: :policy do
|
213
|
+
it_behaves_like "a standard base model policy", :service, check_default_responses: false
|
214
|
+
end
|
215
|
+
```
|
216
|
+
|
173
217
|
|
174
218
|
## Contributing
|
175
219
|
Contribution directions go here.
|
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.6.0
|
@@ -18,6 +18,7 @@ module BaseEditingBootstrap
|
|
18
18
|
|
19
19
|
def prepare_test_environment
|
20
20
|
gem "factory_bot_rails", group: :test, version: '~> 6.4', comment: "Necessary for spec"
|
21
|
+
gem 'rails-controller-testing',group: :test,comment:"Required if used with controllers spec"
|
21
22
|
inject_into_class "config/application.rb", "Application", <<~RUBY
|
22
23
|
config.generators do |g|
|
23
24
|
g.test_framework :rspec
|
@@ -20,6 +20,7 @@ end
|
|
20
20
|
# - index
|
21
21
|
# @!attribute expect [Array[Symbol]] -> nome delle action da non controllare
|
22
22
|
# @!attribute skip_invalid_checks [Boolean] -> se serve saltare il check delle azioni con dati non validi
|
23
|
+
# @!attribute skip_authorization_check [Boolean] -> se skippare controllo delle autorizzazioni nel caso non siano azioni non autorizzabili
|
23
24
|
#
|
24
25
|
# Sono poi disponibili diversi let per poter fare l'override arbitrario degli url,
|
25
26
|
# tutti abbastanza auto-descrittivi
|
@@ -36,7 +37,7 @@ end
|
|
36
37
|
# :url_for_update
|
37
38
|
#
|
38
39
|
#
|
39
|
-
RSpec.shared_examples "base editing controller" do |factory: nil, only: [], except: [], skip_invalid_checks: false|
|
40
|
+
RSpec.shared_examples "base editing controller" do |factory: nil, only: [], except: [], skip_invalid_checks: false, skip_authorization_check: false|
|
40
41
|
if factory
|
41
42
|
let(:inside_factory) { factory }
|
42
43
|
else
|
@@ -78,7 +79,9 @@ RSpec.shared_examples "base editing controller" do |factory: nil, only: [], exce
|
|
78
79
|
nested_attributes_for(inside_factory)
|
79
80
|
}
|
80
81
|
|
81
|
-
|
82
|
+
unless skip_authorization_check
|
83
|
+
it_behaves_like "fail with unauthorized", request: -> { get url_for(url_for_unauthorized) }
|
84
|
+
end
|
82
85
|
|
83
86
|
if check_if_should_execute(only, except, :index)
|
84
87
|
describe "index" do
|
@@ -186,7 +189,7 @@ end
|
|
186
189
|
default_unathorized_failure = -> { raise "TODO - passare proc con richiesta che dovrà fallire" }
|
187
190
|
|
188
191
|
RSpec.shared_examples "fail with unauthorized" do |request: default_unathorized_failure|
|
189
|
-
it "
|
192
|
+
it "is expected to redirect to root" do
|
190
193
|
expect(Pundit).to receive(:authorize).with(user, any_args).and_raise(Pundit::NotAuthorizedError)
|
191
194
|
instance_exec(&request)
|
192
195
|
expect(response).to redirect_to(root_path)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: base_editing_bootstrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marino Bonetti
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-05-
|
11
|
+
date: 2024-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|