potassium 6.4.0 → 6.5.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/.circleci/config.yml +1 -1
- data/.node-version +1 -1
- data/CHANGELOG.md +12 -1
- data/README.md +0 -2
- data/lib/potassium/assets/.circleci/config.yml.erb +29 -11
- data/lib/potassium/assets/.pryrc +0 -6
- data/lib/potassium/assets/README.yml +44 -1
- data/lib/potassium/assets/active_admin/policies/admin_user_policy.rb +2 -0
- data/lib/potassium/assets/active_admin/policies/comment_policy.rb +2 -0
- data/lib/potassium/assets/active_admin/policies/default_policy.rb +49 -0
- data/lib/potassium/assets/active_admin/policies/page_policy.rb +2 -0
- data/lib/potassium/assets/testing/.rspec +1 -0
- data/lib/potassium/assets/testing/devise_config.rb +6 -0
- data/lib/potassium/assets/testing/factory_bot_config.rb +3 -0
- data/lib/potassium/assets/testing/faker_config.rb +1 -0
- data/lib/potassium/assets/testing/power_types_config.rb +1 -0
- data/lib/potassium/assets/testing/rails_helper.rb +130 -49
- data/lib/potassium/assets/testing/shoulda_matchers_config.rb +8 -0
- data/lib/potassium/assets/testing/simplecov_config.rb +64 -0
- data/lib/potassium/assets/testing/system_tests_config.rb +6 -0
- data/lib/potassium/cli_options.rb +8 -0
- data/lib/potassium/recipes/admin.rb +1 -1
- data/lib/potassium/recipes/api.rb +2 -1
- data/lib/potassium/recipes/coverage.rb +35 -0
- data/lib/potassium/recipes/heroku.rb +1 -2
- data/lib/potassium/recipes/pundit.rb +29 -10
- data/lib/potassium/recipes/rails.rb +0 -4
- data/lib/potassium/recipes/spring.rb +9 -0
- data/lib/potassium/recipes/testing.rb +75 -18
- data/lib/potassium/templates/application.rb +2 -0
- data/lib/potassium/version.rb +3 -3
- data/spec/features/ci_spec.rb +1 -1
- data/spec/features/coverage_spec.rb +26 -0
- data/spec/features/heroku_spec.rb +0 -4
- data/spec/features/node_spec.rb +1 -1
- data/spec/features/pundit_spec.rb +34 -0
- data/spec/features/testing_spec.rb +56 -0
- data/spec/support/potassium_test_helpers.rb +2 -2
- metadata +24 -8
- data/lib/potassium/assets/active_admin/admin_user_policy.rb +0 -2
- data/lib/potassium/assets/active_admin/comment_policy.rb +0 -2
- data/lib/potassium/assets/active_admin/pundit_page_policy.rb +0 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bf3d3969e70d29a2f2c15992c48f609ad389a486560fd6a16ea3a74871328a19
|
|
4
|
+
data.tar.gz: c1617bc3cba761408d2cba7419fbe4c68cb265a7438ea07b8c9b637944e3271d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 61cbdbbced51469867a32a83a97628f8ea4ccfb3290cc2b2e6e8a34f86e53a6e0478609326264b59324266b8db184cd449d921a9f17cc3f5a58be01eddb00e3b
|
|
7
|
+
data.tar.gz: '00900211ab3d5dcb75e4f45889778c752cda9f61a7e8d8cd0e264bb1ba678c50f8b9593f8bb98c3afd8b2fa554458cb639bfba202428a978976872cf45d291a5'
|
data/.circleci/config.yml
CHANGED
data/.node-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
14
|
data/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 6.5.0
|
|
4
|
+
|
|
5
|
+
Features
|
|
6
|
+
- Update node to latest LTS version, 14 [#363](https://github.com/platanus/potassium/pull/363)
|
|
7
|
+
- Update ActiveAdmin to 2.9 to fix CSV streaming issues [#384](https://github.com/platanus/potassium/pull/384)
|
|
8
|
+
- Separates Pundit's configuration for Active Admin from Application's configuration [#378](https://github.com/platanus/potassium/pull/378)
|
|
9
|
+
- Add SimpleCov recipe [#387](https://github.com/platanus/potassium/pull/387)
|
|
10
|
+
- Update Rails to 6.1 [#389](https://github.com/platanus/potassium/pull/389) & [#392](https://github.com/platanus/potassium/pull/392)
|
|
11
|
+
- Include `run_test` as a valid example group [#379](https://github.com/platanus/potassium/pull/379). This was added incorrectly in this [PR](https://github.com/platanus/potassium/pull/379).
|
|
12
|
+
|
|
13
|
+
Fixes
|
|
14
|
+
- Remove rails_stdout_logging gem because it is no longer needed after Rails 5 and it was generating a deprecation warning [#325](https://github.com/platanus/potassium/pull/325)
|
|
4
15
|
|
|
5
16
|
## 6.4.0
|
|
6
17
|
|
data/README.md
CHANGED
|
@@ -93,7 +93,6 @@ The optional API support includes:
|
|
|
93
93
|
|
|
94
94
|
When you choose to deploy to heroku a few extra things are added for the project.
|
|
95
95
|
|
|
96
|
-
- Adds the [Rails Stdout Logging][logging-gem] gem to configure the app to log to standard out, which is how [Heroku's logging][heroku-logging] works
|
|
97
96
|
- Adds a [Procfile][procfile] to define the processes to run in heroku
|
|
98
97
|
- Setup continuous integration using docker and herokuish to maintain better parity between testing and production environments
|
|
99
98
|
- Adds a `bin/release` file with the release phase script to run specific tasks before the app is deployed completely, for example `rails db:migrate:with_data`
|
|
@@ -129,7 +128,6 @@ Go to https://circleci.com/add-projects, choose the repository from the list and
|
|
|
129
128
|
|
|
130
129
|
In order to enable code linting via CircleCI and ReviewDog, you need to activate the **Only build pull requests** option under the `Advanced settings` section for your project.
|
|
131
130
|
|
|
132
|
-
[logging-gem]: https://github.com/heroku/rails_stdout_logging
|
|
133
131
|
[heroku-logging]: https://devcenter.heroku.com/articles/logging#writing-to-your-log
|
|
134
132
|
[procfile]: https://devcenter.heroku.com/articles/procfile
|
|
135
133
|
[heroku-buildpack-ruby-version]: http://github.com/platanus/heroku-buildpack-ruby-version
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
version: 2.1
|
|
2
2
|
|
|
3
|
-
ruby-image: &ruby-image
|
|
3
|
+
ruby-image: &ruby-image cimg/ruby:<%= ruby_version %>
|
|
4
4
|
<%- if selected?(:database, :postgresql) -%>
|
|
5
5
|
postgres-image: &postgres-image postgres:<%= Potassium::POSTGRES_VERSION %>
|
|
6
6
|
<%- end -%>
|
|
@@ -12,6 +12,9 @@ env-vars: &env-vars
|
|
|
12
12
|
BUNDLE_PATH: vendor/bundle
|
|
13
13
|
RAILS_ENV: test
|
|
14
14
|
|
|
15
|
+
orbs:
|
|
16
|
+
browser-tools: circleci/browser-tools@1.1
|
|
17
|
+
|
|
15
18
|
executors:
|
|
16
19
|
test-executor:
|
|
17
20
|
docker:
|
|
@@ -37,14 +40,19 @@ commands:
|
|
|
37
40
|
|
|
38
41
|
- restore_cache:
|
|
39
42
|
keys:
|
|
40
|
-
- bundle-dependencies-{{ checksum "Gemfile.lock" }}
|
|
43
|
+
- bundle-dependencies-{{ .Environment.BUNDLE_CACHE_VERSION }}-{{ checksum "Gemfile.lock" }}
|
|
41
44
|
- bundle-dependencies-
|
|
42
45
|
|
|
43
46
|
- restore_cache:
|
|
44
47
|
keys:
|
|
45
|
-
- yarn-dependencies-{{ checksum "yarn.lock" }}
|
|
48
|
+
- yarn-dependencies-{{ .Environment.YARN_CACHE_VERSION }}-{{ checksum "yarn.lock" }}
|
|
46
49
|
- yarn-dependencies-
|
|
47
50
|
|
|
51
|
+
- run:
|
|
52
|
+
name: Install reviewdog
|
|
53
|
+
command: |
|
|
54
|
+
curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b ./bin
|
|
55
|
+
|
|
48
56
|
- run:
|
|
49
57
|
name: Install bundle dependencies
|
|
50
58
|
command: |
|
|
@@ -62,12 +70,12 @@ commands:
|
|
|
62
70
|
yarn install --frozen-lockfile
|
|
63
71
|
|
|
64
72
|
- save_cache:
|
|
65
|
-
key: bundle-dependencies-{{ checksum "Gemfile.lock" }}
|
|
73
|
+
key: bundle-dependencies-{{ .Environment.BUNDLE_CACHE_VERSION }}-{{ checksum "Gemfile.lock" }}
|
|
66
74
|
paths:
|
|
67
75
|
- vendor/bundle
|
|
68
76
|
|
|
69
77
|
- save_cache:
|
|
70
|
-
key: yarn-dependencies-{{ checksum "yarn.lock" }}
|
|
78
|
+
key: yarn-dependencies-{{ .Environment.YARN_CACHE_VERSION }}-{{ checksum "yarn.lock" }}
|
|
71
79
|
paths:
|
|
72
80
|
- node_modules
|
|
73
81
|
|
|
@@ -76,6 +84,8 @@ jobs:
|
|
|
76
84
|
executor: test-executor
|
|
77
85
|
steps:
|
|
78
86
|
- setup
|
|
87
|
+
- browser-tools/install-chrome
|
|
88
|
+
- browser-tools/install-chromedriver
|
|
79
89
|
|
|
80
90
|
<%- if selected?(:background_processor) -%>
|
|
81
91
|
- run:
|
|
@@ -93,12 +103,25 @@ jobs:
|
|
|
93
103
|
<%- end -%>
|
|
94
104
|
|
|
95
105
|
- run:
|
|
96
|
-
name: Run
|
|
106
|
+
name: Run RSpec unit tests
|
|
97
107
|
command: |
|
|
98
108
|
RSPEC_JUNIT_ARGS="-r rspec_junit_formatter -f RspecJunitFormatter -o test_results/rspec.xml"
|
|
99
109
|
RSPEC_FORMAT_ARGS="-f progress --no-color -p 10"
|
|
100
110
|
bundle exec rspec spec $RSPEC_FORMAT_ARGS $RSPEC_JUNIT_ARGS
|
|
101
111
|
|
|
112
|
+
- run:
|
|
113
|
+
name: Run RSpec system tests
|
|
114
|
+
command: |
|
|
115
|
+
RSPEC_JUNIT_ARGS="-r rspec_junit_formatter -f RspecJunitFormatter -o test_results/rspec-system.xml"
|
|
116
|
+
RSPEC_FORMAT_ARGS="--tag type:system -f progress --no-color -p 10"
|
|
117
|
+
bundle exec rspec spec $RSPEC_FORMAT_ARGS $RSPEC_JUNIT_ARGS
|
|
118
|
+
|
|
119
|
+
- run:
|
|
120
|
+
name: Run simplecov
|
|
121
|
+
shell: /bin/bash
|
|
122
|
+
command: |
|
|
123
|
+
cat coverage/coverage.txt | ./bin/reviewdog -reporter=github-pr-review -efm="%f:%l:%c: %m"
|
|
124
|
+
|
|
102
125
|
<%- if selected?(:front_end, :vue) -%>
|
|
103
126
|
- run:
|
|
104
127
|
name: Run jest
|
|
@@ -113,11 +136,6 @@ jobs:
|
|
|
113
136
|
steps:
|
|
114
137
|
- setup
|
|
115
138
|
|
|
116
|
-
- run:
|
|
117
|
-
name: Install reviewdog
|
|
118
|
-
command: |
|
|
119
|
-
curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b ./bin
|
|
120
|
-
|
|
121
139
|
- run:
|
|
122
140
|
name: Get files to lint
|
|
123
141
|
command: git diff origin/master --name-only --diff-filter=d > tmp/files_to_lint
|
data/lib/potassium/assets/.pryrc
CHANGED
|
@@ -4,9 +4,3 @@ if defined?(PryByebug)
|
|
|
4
4
|
Pry.commands.alias_command 'n', 'next'
|
|
5
5
|
Pry.commands.alias_command 'f', 'finish'
|
|
6
6
|
end
|
|
7
|
-
|
|
8
|
-
if defined?(Rails)
|
|
9
|
-
require 'rails/console/app'
|
|
10
|
-
require 'rails/console/helpers'
|
|
11
|
-
include Rails::ConsoleMethods # rubocop:disable Style/MixinUsage
|
|
12
|
-
end
|
|
@@ -123,7 +123,7 @@ readme:
|
|
|
123
123
|
body: "This project uses [Draper](https://github.com/drapergem/draper) to add an object-oriented layer of presentation logic"
|
|
124
124
|
power_types:
|
|
125
125
|
title: "Rails pattern enforcing types"
|
|
126
|
-
body: "This
|
|
126
|
+
body: "This project uses [Power-Types](https://github.com/platanus/power-types) to generate Services, Commands, Utils and Values."
|
|
127
127
|
power_api:
|
|
128
128
|
title: "API Support"
|
|
129
129
|
body: "This projects uses [Power API](https://github.com/platanus/power_api). It's a Rails engine that gathers a set of gems and configurations designed to build incredible REST APIs."
|
|
@@ -153,8 +153,51 @@ readme:
|
|
|
153
153
|
```
|
|
154
154
|
- You can also use **any** vue bindings such as `v-for` , `:key` etc.
|
|
155
155
|
<% end %>
|
|
156
|
+
<% if get(:authorization) %>
|
|
157
|
+
It uses the [ActiveAdmin's Pundit adapter](https://activeadmin.info/13-authorization-adapter.html).
|
|
158
|
+
- Policies for admin resources must inherit from `BackOffice::DefaultPolicy` and be placed inside the `app/policies/back_office` directory.
|
|
159
|
+
- For example:
|
|
160
|
+
|
|
161
|
+
`app/admin/clients.rb`:
|
|
162
|
+
|
|
163
|
+
```ruby
|
|
164
|
+
ActiveAdmin.register Client do
|
|
165
|
+
# ...
|
|
166
|
+
end
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
`app/policies/back_office/client_policy.rb`:
|
|
170
|
+
|
|
171
|
+
```ruby
|
|
172
|
+
class BackOffice::ClientPolicy < BackOffice::DefaultPolicy
|
|
173
|
+
end
|
|
174
|
+
```
|
|
175
|
+
<% end %>
|
|
156
176
|
seeds:
|
|
157
177
|
title: "Seeds"
|
|
158
178
|
body: |
|
|
159
179
|
To populate your database with initial data you can add, inside the `/db/seeds.rb` file, the code to generate **only the necessary data** to run the application.
|
|
160
180
|
If you need to generate data with **development purposes**, you can customize the `lib/fake_data_loader.rb` module and then to run the `rake load_fake_data` task from your terminal.
|
|
181
|
+
testing:
|
|
182
|
+
title: "Testing"
|
|
183
|
+
body: |
|
|
184
|
+
We use:
|
|
185
|
+
- [RSpec](https://github.com/rspec/rspec-rails): the testing framework.
|
|
186
|
+
- [Shoulda Matchers](https://github.com/thoughtbot/shoulda-matchers): one-liners to test common Rails functionality that, if written by hand, would be much longer, more complex, and error-prone.
|
|
187
|
+
- [Factory Bot](https://github.com/thoughtbot/factory_bot_rails): a fixtures replacement with a straightforward definition syntax, support for multiple build strategies (saved instances, unsaved instances, attribute hashes, and stubbed objects), and support for multiple factories for the same class (user, admin_user, and so on), including factory inheritance.
|
|
188
|
+
- [Faker](https://github.com/faker-ruby/faker): a port of Perl's Data::Faker library that generates fake data.
|
|
189
|
+
- [Guard](https://github.com/guard/guard): automates various tasks by running custom rules whenever file or directories are modified. We use it to run RSpec when files change.
|
|
190
|
+
|
|
191
|
+
Place your unit tests inside the `spec` directory.
|
|
192
|
+
|
|
193
|
+
To run unit tests: `bin/guard`
|
|
194
|
+
|
|
195
|
+
#### System tests
|
|
196
|
+
|
|
197
|
+
We use, in addition to the previous gems:
|
|
198
|
+
- [Capybara](https://github.com/teamcapybara/capybara): helps you test web applications by simulating how a real user would interact with your app. It is agnostic about the driver running your tests and comes with Rack::Test and Selenium support built in. WebKit is supported through an external gem.
|
|
199
|
+
- [Webdrivers](https://github.com/titusfortner/webdrivers): run Selenium tests more easily with automatic installation and updates for all supported webdrivers.
|
|
200
|
+
|
|
201
|
+
Place your system tests inside the `spec/system` directory.
|
|
202
|
+
|
|
203
|
+
To run system tests: `bin/rspec --tag type:system`
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
class BackOffice::DefaultPolicy
|
|
2
|
+
attr_reader :admin_user, :record
|
|
3
|
+
|
|
4
|
+
def initialize(admin_user, record)
|
|
5
|
+
@admin_user = admin_user
|
|
6
|
+
@record = record
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def index?
|
|
10
|
+
true
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def show?
|
|
14
|
+
true
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def create?
|
|
18
|
+
true
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def new?
|
|
22
|
+
create?
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def update?
|
|
26
|
+
true
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def edit?
|
|
30
|
+
update?
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def destroy?
|
|
34
|
+
true
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
class Scope
|
|
38
|
+
attr_reader :admin_user, :scope
|
|
39
|
+
|
|
40
|
+
def initialize(admin_user, scope)
|
|
41
|
+
@admin_user = admin_user
|
|
42
|
+
@scope = scope
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def resolve
|
|
46
|
+
scope.all
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'faker'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
PowerTypes::Observable.observable_disabled = true
|
|
@@ -1,60 +1,141 @@
|
|
|
1
|
-
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
|
2
1
|
ENV['RACK_ENV'] ||= 'test'
|
|
3
2
|
require File.expand_path('../config/environment', __dir__)
|
|
4
3
|
require 'rspec/rails'
|
|
5
4
|
require 'spec_helper'
|
|
6
|
-
require 'shoulda/matchers'
|
|
7
|
-
require 'faker'
|
|
8
|
-
# Add additional requires below this line. Rails is not loaded until this point!
|
|
9
|
-
|
|
10
|
-
# Requires supporting ruby files with custom matchers and macros, etc, in
|
|
11
|
-
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
|
|
12
|
-
# run as spec files by default. This means that files in spec/support that end
|
|
13
|
-
# in _spec.rb will both be required and run as specs, causing the specs to be
|
|
14
|
-
# run twice. It is recommended that you do not name files matching this glob to
|
|
15
|
-
# end with _spec.rb. You can configure this pattern with the --pattern
|
|
16
|
-
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
|
|
17
|
-
#
|
|
18
|
-
# The following line is provided for convenience purposes. It has the downside
|
|
19
|
-
# of increasing the boot-up time by auto-requiring all files in the support
|
|
20
|
-
# directory. Alternatively, in the individual `*_spec.rb` files, manually
|
|
21
|
-
# require only the support files necessary.
|
|
22
|
-
#
|
|
23
|
-
Dir[Rails.root.join('spec', 'support', '**', '*.rb')].each { |f| require f }
|
|
24
|
-
|
|
25
|
-
# Checks for pending migrations before tests are run.
|
|
26
|
-
# If you are not using ActiveRecord, you can remove this line.
|
|
27
|
-
ActiveRecord::Migration.maintain_test_schema!
|
|
28
5
|
|
|
29
|
-
|
|
6
|
+
=begin
|
|
30
7
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
# examples within a transaction, remove the following line or assign false
|
|
34
|
-
# instead of true.
|
|
35
|
-
config.use_transactional_fixtures = true
|
|
8
|
+
General
|
|
9
|
+
=======
|
|
36
10
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
# You can disable this behaviour by removing the line below, and instead
|
|
42
|
-
# explicitly tag your specs with their type, e.g.:
|
|
43
|
-
#
|
|
44
|
-
# RSpec.describe UsersController, :type => :controller do
|
|
45
|
-
# # ...
|
|
46
|
-
# end
|
|
47
|
-
#
|
|
48
|
-
# The different available types are documented in the features, such as in
|
|
49
|
-
# https://relishapp.com/rspec/rspec-rails/docs
|
|
50
|
-
config.infer_spec_type_from_file_location!
|
|
11
|
+
1) Place your unit tests inside the "spec" directory.
|
|
12
|
+
2) Run unit tests executing `bin/guard`.
|
|
13
|
+
3) Use support directories to add helpers and settings.
|
|
14
|
+
You can only put RSpec configuration on this file.
|
|
51
15
|
|
|
52
|
-
|
|
53
|
-
|
|
16
|
+
Support
|
|
17
|
+
-------
|
|
18
|
+
|
|
19
|
+
* spec/support/configurations: put testing related gem settings here.
|
|
20
|
+
|
|
21
|
+
For example: spec/support/configurations/shoulda_matchers_config.rb
|
|
22
|
+
|
|
23
|
+
----------------------------------------
|
|
24
|
+
require 'shoulda/matchers'
|
|
25
|
+
|
|
26
|
+
Shoulda::Matchers.configure do |config|
|
|
27
|
+
config.integrate do |with|
|
|
28
|
+
with.test_framework :rspec
|
|
29
|
+
with.library :rails
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
----------------------------------------
|
|
33
|
+
|
|
34
|
+
* spec/support/helpers: place here helpers created by you to use in your unit tests.
|
|
35
|
+
|
|
36
|
+
For example: spec/support/helpers/attachments_helpers.rb
|
|
37
|
+
|
|
38
|
+
----------------------------------------------------------------------------------
|
|
39
|
+
module AttachmentsHelpers
|
|
40
|
+
extend ActiveSupport::Concern
|
|
41
|
+
|
|
42
|
+
included do
|
|
43
|
+
def create_attachment_file(filename: "pikachu.png", content_type: "image/png")
|
|
44
|
+
Rack::Test::UploadedFile.new(file_fixture(filename), content_type)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
RSpec.configure do |config|
|
|
50
|
+
config.fixture_path = "#{::Rails.root}/spec/assets"
|
|
51
|
+
config.file_fixture_path = "#{::Rails.root}/spec/assets"
|
|
52
|
+
|
|
53
|
+
config.include AttachmentsHelpers
|
|
54
|
+
end
|
|
55
|
+
----------------------------------------------------------------------------------
|
|
56
|
+
|
|
57
|
+
* spec/support/custom_matchers: place here your custom matchers
|
|
58
|
+
(https://relishapp.com/rspec/rspec-expectations/v/3-10/docs/custom-matchers)
|
|
59
|
+
|
|
60
|
+
* spec/support/shared_examples: place here your shared examples
|
|
61
|
+
(https://relishapp.com/rspec/rspec-core/v/3-10/docs/example-groups/shared-examples)
|
|
62
|
+
|
|
63
|
+
System Tests
|
|
64
|
+
============
|
|
65
|
+
|
|
66
|
+
1) Place your system tests inside the "spec/system" directory.
|
|
67
|
+
2) Run system tests executing `bin/rspec --tag type:system`.
|
|
68
|
+
|
|
69
|
+
Support
|
|
70
|
+
-------
|
|
71
|
+
|
|
72
|
+
* spec/support/configurations/system_tests_config.rb: on this file you will find the
|
|
73
|
+
general configuration of the system tests. Keep in mind that this type of test will
|
|
74
|
+
run with the `selenium_chrome_headless` driver unless you put the `no_js` tag.
|
|
54
75
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
76
|
+
For example: spec/system/login_spec.rb
|
|
77
|
+
|
|
78
|
+
----------------------------------------------------------------------------
|
|
79
|
+
require "rails_helper"
|
|
80
|
+
|
|
81
|
+
RSpec.describe "Login" do
|
|
82
|
+
let!(:user) { create(:user, email: "lean@platan.us") }
|
|
83
|
+
|
|
84
|
+
context "without logged user", :no_js do # will use :rack_test driver
|
|
85
|
+
before { visit("/") }
|
|
86
|
+
|
|
87
|
+
it { expect(page).to have_text("Ingresa") }
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
context "with logged user" do # will use :selenium_chrome_headless driver
|
|
91
|
+
before { sign_in(user) }
|
|
92
|
+
|
|
93
|
+
it { expect(page).to have_text("Hola!") }
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
----------------------------------------------------------------------------
|
|
97
|
+
|
|
98
|
+
* spec/support/helpers/system: place here helpers created by you
|
|
99
|
+
to use in your system tests.
|
|
100
|
+
|
|
101
|
+
For example: spec/support/helpers/login_helpers.rb
|
|
102
|
+
|
|
103
|
+
------------------------------------------------
|
|
104
|
+
module LoginHelpers
|
|
105
|
+
extend ActiveSupport::Concern
|
|
106
|
+
|
|
107
|
+
included do
|
|
108
|
+
def sign_in(email, password)
|
|
109
|
+
visit('/users/sign_in')
|
|
110
|
+
|
|
111
|
+
within(:xpath, '//*[@id="new_user"]') do
|
|
112
|
+
fill_in('Email', with: email)
|
|
113
|
+
fill_in('Contraseña', with: password)
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
click_button('Ingresar')
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def logout
|
|
120
|
+
visit('/users/sign_out')
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
RSpec.configure do |config|
|
|
126
|
+
config.include LoginHelpers, type: :system
|
|
59
127
|
end
|
|
128
|
+
------------------------------------------------
|
|
129
|
+
|
|
130
|
+
Remember to include the system helpers with the tag `type: :system`
|
|
131
|
+
=end
|
|
132
|
+
|
|
133
|
+
Dir[Rails.root.join("spec/support/**/*.rb")].sort.each { |f| require f }
|
|
134
|
+
|
|
135
|
+
ActiveRecord::Migration.maintain_test_schema!
|
|
136
|
+
|
|
137
|
+
RSpec.configure do |config|
|
|
138
|
+
config.use_transactional_fixtures = true
|
|
139
|
+
config.infer_spec_type_from_file_location!
|
|
140
|
+
config.filter_run_when_matching :focus unless Rails.env.production?
|
|
60
141
|
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
require 'simplecov'
|
|
2
|
+
require 'simplecov_text_formatter'
|
|
3
|
+
require 'simplecov_linter_formatter'
|
|
4
|
+
|
|
5
|
+
SimpleCovLinterFormatter.setup do |config|
|
|
6
|
+
config.scope = ENV.fetch(
|
|
7
|
+
"SIMPLE_COV_LINTER_SCOPE", :own_changes
|
|
8
|
+
)
|
|
9
|
+
config.json_filename = ENV.fetch(
|
|
10
|
+
"SIMPLE_COV_LINTER_JSON_FILENAME", ".resultset.json"
|
|
11
|
+
)
|
|
12
|
+
config.summary_enabled = ENV.fetch(
|
|
13
|
+
"SIMPLE_COV_LINTER_SUMMARY_ENABLED", true
|
|
14
|
+
)
|
|
15
|
+
config.summary_enabled_bg = ENV.fetch(
|
|
16
|
+
"SIMPLE_COV_LINTER_SUMMARY_BG_ENABLED", true
|
|
17
|
+
)
|
|
18
|
+
config.summary_covered_bg_color = ENV.fetch(
|
|
19
|
+
"SIMPLE_COV_LINTER_SUMMARY_COVERED_BG_COLOR", :darkgreen
|
|
20
|
+
)
|
|
21
|
+
config.summary_not_covered_bg_color = ENV.fetch(
|
|
22
|
+
"SIMPLE_COV_LINTER_SUMMARY_NOT_COVERED_BG_COLOR", :firebrick
|
|
23
|
+
)
|
|
24
|
+
config.summary_text_color = ENV.fetch(
|
|
25
|
+
"SIMPLE_COV_LINTER_SUMMARY_TEXT_COLOR", :white
|
|
26
|
+
)
|
|
27
|
+
config.summary_files_sorting = ENV.fetch(
|
|
28
|
+
"SIMPLE_COV_LINTER_SUMMARY_FILES_SORTING", :coverage
|
|
29
|
+
)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
SimpleCov.start 'rails' do
|
|
33
|
+
add_group 'Commands', 'app/commands'
|
|
34
|
+
add_group 'Services', 'app/services'
|
|
35
|
+
add_group 'Observers', 'app/observers'
|
|
36
|
+
add_group 'Policies', 'app/policies'
|
|
37
|
+
add_group 'Utils', 'app/utils'
|
|
38
|
+
add_group 'Extensions', 'app/extensions'
|
|
39
|
+
|
|
40
|
+
add_filter %r{app/controllers/([a-z]|_)*_controller.rb}
|
|
41
|
+
add_filter 'app/admin'
|
|
42
|
+
add_filter 'app/channels'
|
|
43
|
+
add_filter 'app/uploaders'
|
|
44
|
+
add_filter 'app/serializers'
|
|
45
|
+
add_filter 'app/clients'
|
|
46
|
+
add_filter 'app/helpers'
|
|
47
|
+
add_filter 'app/decorators'
|
|
48
|
+
add_filter 'app/responders'
|
|
49
|
+
add_filter 'lib/fake_data_loader.rb'
|
|
50
|
+
add_filter 'lib/vue_component.rb'
|
|
51
|
+
|
|
52
|
+
if ENV["CIRCLECI"]
|
|
53
|
+
formatter(SimpleCov::Formatter::TextFormatter)
|
|
54
|
+
else
|
|
55
|
+
formatter(
|
|
56
|
+
SimpleCov::Formatter::MultiFormatter.new(
|
|
57
|
+
[
|
|
58
|
+
SimpleCov::Formatter::LinterFormatter,
|
|
59
|
+
SimpleCov::Formatter::HTMLFormatter
|
|
60
|
+
]
|
|
61
|
+
)
|
|
62
|
+
)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
@@ -192,6 +192,14 @@ module Potassium::CliOptions # rubocop:disable Metrics/ModuleLength
|
|
|
192
192
|
negatable: true,
|
|
193
193
|
default_value: false,
|
|
194
194
|
default_test_value: true
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
type: :switch,
|
|
198
|
+
name: "spring",
|
|
199
|
+
desc: "Whether to use Spring",
|
|
200
|
+
negatable: true,
|
|
201
|
+
default_value: true,
|
|
202
|
+
default_test_value: false
|
|
195
203
|
}
|
|
196
204
|
]
|
|
197
205
|
|
|
@@ -32,7 +32,7 @@ class Recipes::Admin < Rails::AppBuilder
|
|
|
32
32
|
private
|
|
33
33
|
|
|
34
34
|
def add_active_admin
|
|
35
|
-
gather_gem 'activeadmin', '~> 2.
|
|
35
|
+
gather_gem 'activeadmin', '~> 2.9'
|
|
36
36
|
gather_gem 'activeadmin_addons'
|
|
37
37
|
add_readme_section :internal_dependencies, :active_admin
|
|
38
38
|
after(:gem_install, wrap_in_action: :admin_install) do
|
|
@@ -38,7 +38,8 @@ class Recipes::Api < Rails::AppBuilder
|
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
add_readme_section :internal_dependencies, :power_api
|
|
41
|
-
|
|
41
|
+
rubocop_example = "RSpec:\n Language:\n Includes:\n Examples:\n - run_test!"
|
|
42
|
+
append_to_file('.rubocop.yml', rubocop_example)
|
|
42
43
|
|
|
43
44
|
after(:gem_install) do
|
|
44
45
|
generate "power_api:install"
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
class Recipes::Coverage < Rails::AppBuilder
|
|
2
|
+
def create
|
|
3
|
+
load_gems
|
|
4
|
+
configure_rails_helper
|
|
5
|
+
append_to_file('.gitignore', "/coverage/*\n")
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def installed?
|
|
9
|
+
gem_exists?(/simplecov/)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def install
|
|
13
|
+
create
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
private
|
|
17
|
+
|
|
18
|
+
def load_gems
|
|
19
|
+
gather_gems(:test) do
|
|
20
|
+
gather_gem 'simplecov'
|
|
21
|
+
gather_gem 'simplecov_linter_formatter', '~> 0.2'
|
|
22
|
+
gather_gem 'simplecov_text_formatter'
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def configure_rails_helper
|
|
27
|
+
copy_file '../assets/testing/simplecov_config.rb', 'spec/simplecov_config.rb'
|
|
28
|
+
|
|
29
|
+
after(:gem_install) do
|
|
30
|
+
gsub_file 'spec/rails_helper.rb', "ENV['RACK_ENV'] ||= 'test'" do |match|
|
|
31
|
+
"#{match}\nrequire 'simplecov_config'"
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -24,14 +24,13 @@ class Recipes::Heroku < Rails::AppBuilder
|
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
def installed?
|
|
27
|
-
gem_exists?(/
|
|
27
|
+
gem_exists?(/heroku-stage/)
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
private
|
|
31
31
|
|
|
32
32
|
def add_heroku
|
|
33
33
|
gather_gems(:production) do
|
|
34
|
-
gather_gem('rails_stdout_logging')
|
|
35
34
|
gather_gem('heroku-stage')
|
|
36
35
|
end
|
|
37
36
|
|
|
@@ -31,20 +31,39 @@ class Recipes::Pundit < Rails::AppBuilder
|
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
def install_admin_pundit
|
|
34
|
+
configure_active_admin_initializer
|
|
35
|
+
copy_policies
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
private
|
|
39
|
+
|
|
40
|
+
def configure_active_admin_initializer
|
|
41
|
+
config_active_admin_option("authorization_adapter", "ActiveAdmin::PunditAdapter")
|
|
42
|
+
config_active_admin_option("pundit_default_policy", "'BackOffice::DefaultPolicy'")
|
|
43
|
+
config_active_admin_option("pundit_policy_namespace", ":back_office")
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def copy_policies
|
|
47
|
+
copy_policy("default_policy")
|
|
48
|
+
copy_policy("admin_user_policy")
|
|
49
|
+
copy_policy("page_policy", "active_admin")
|
|
50
|
+
copy_policy("comment_policy", "active_admin")
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def config_active_admin_option(option, value)
|
|
34
54
|
initializer = "config/initializers/active_admin.rb"
|
|
35
|
-
gsub_file initializer, /# config
|
|
36
|
-
"config
|
|
55
|
+
gsub_file initializer, /# config\.#{option} =[^\n]+\n/ do
|
|
56
|
+
"config.#{option} = #{value}\n"
|
|
37
57
|
end
|
|
38
|
-
|
|
39
|
-
template "../assets/active_admin/pundit_page_policy.rb",
|
|
40
|
-
"app/policies/active_admin/page_policy.rb"
|
|
41
|
-
template "../assets/active_admin/comment_policy.rb",
|
|
42
|
-
"app/policies/active_admin/comment_policy.rb"
|
|
43
|
-
template "../assets/active_admin/admin_user_policy.rb",
|
|
44
|
-
"app/policies/admin_user_policy.rb"
|
|
45
58
|
end
|
|
46
59
|
|
|
47
|
-
|
|
60
|
+
def copy_policy(policy_name, model_namespace = nil)
|
|
61
|
+
destination_path = [model_namespace, policy_name].compact.join("/")
|
|
62
|
+
template(
|
|
63
|
+
"../assets/active_admin/policies/#{policy_name}.rb",
|
|
64
|
+
"app/policies/back_office/#{destination_path}.rb"
|
|
65
|
+
)
|
|
66
|
+
end
|
|
48
67
|
|
|
49
68
|
def run_pundit_installer
|
|
50
69
|
gather_gem 'pundit'
|
|
@@ -1,5 +1,76 @@
|
|
|
1
1
|
class Recipes::Testing < Rails::AppBuilder
|
|
2
2
|
def create
|
|
3
|
+
add_gems
|
|
4
|
+
add_readme_header(:testing)
|
|
5
|
+
recipe = self
|
|
6
|
+
|
|
7
|
+
after(:gem_install) do
|
|
8
|
+
recipe.install_rspec
|
|
9
|
+
recipe.install_guard
|
|
10
|
+
recipe.create_rspec_binary
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
config_raise_delivery_errors_option
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def install_rspec
|
|
17
|
+
remove_dir 'test'
|
|
18
|
+
generate "rspec:install"
|
|
19
|
+
remove_file 'spec/rails_helper.rb'
|
|
20
|
+
copy_file '../assets/testing/rails_helper.rb', 'spec/rails_helper.rb'
|
|
21
|
+
remove_file '.rspec'
|
|
22
|
+
copy_file '../assets/testing/.rspec', '.rspec'
|
|
23
|
+
create_file 'spec/system/.keep'
|
|
24
|
+
create_support_directories
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def create_support_directories
|
|
28
|
+
%w{
|
|
29
|
+
custom_matchers
|
|
30
|
+
shared_examples
|
|
31
|
+
configurations
|
|
32
|
+
helpers
|
|
33
|
+
helpers/system
|
|
34
|
+
}.each do |directory|
|
|
35
|
+
path = "spec/support/#{directory}"
|
|
36
|
+
empty_directory(path)
|
|
37
|
+
create_file("#{path}/.keep")
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
add_support_configuration_modules
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def add_support_configuration_modules
|
|
44
|
+
files = %w{
|
|
45
|
+
faker_config
|
|
46
|
+
factory_bot_config
|
|
47
|
+
power_types_config
|
|
48
|
+
shoulda_matchers_config
|
|
49
|
+
system_tests_config
|
|
50
|
+
}
|
|
51
|
+
files << "devise_config" if selected?(:authentication)
|
|
52
|
+
files.each do |config_module|
|
|
53
|
+
copy_file(
|
|
54
|
+
"../assets/testing/#{config_module}.rb",
|
|
55
|
+
"spec/support/configurations/#{config_module}.rb"
|
|
56
|
+
)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def install_guard
|
|
61
|
+
run "bundle exec guard init"
|
|
62
|
+
run "bundle binstub guard"
|
|
63
|
+
line = /guard :rspec, cmd: "bundle exec rspec" do\n/
|
|
64
|
+
gsub_file 'Guardfile', line do
|
|
65
|
+
"guard :rspec, cmd: \"bin/rspec\" do\n"
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def create_rspec_binary
|
|
70
|
+
run "bundle binstubs rspec-core"
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def add_gems
|
|
3
74
|
gather_gems(:development, :test) do
|
|
4
75
|
gather_gem('rspec-rails')
|
|
5
76
|
gather_gem('factory_bot_rails')
|
|
@@ -10,26 +81,12 @@ class Recipes::Testing < Rails::AppBuilder
|
|
|
10
81
|
|
|
11
82
|
gather_gems(:test) do
|
|
12
83
|
gather_gem('shoulda-matchers', require: false)
|
|
84
|
+
gather_gem('capybara')
|
|
85
|
+
gather_gem('webdrivers')
|
|
13
86
|
end
|
|
87
|
+
end
|
|
14
88
|
|
|
15
|
-
|
|
16
|
-
remove_dir 'test'
|
|
17
|
-
|
|
18
|
-
generate "rspec:install"
|
|
19
|
-
|
|
20
|
-
remove_file 'spec/rails_helper.rb'
|
|
21
|
-
copy_file '../assets/testing/rails_helper.rb', 'spec/rails_helper.rb'
|
|
22
|
-
|
|
23
|
-
remove_file '.rspec'
|
|
24
|
-
copy_file '../assets/testing/.rspec', '.rspec'
|
|
25
|
-
|
|
26
|
-
empty_directory 'spec/support'
|
|
27
|
-
create_file 'spec/support/.keep'
|
|
28
|
-
|
|
29
|
-
run "bundle exec guard init"
|
|
30
|
-
run "bundle binstubs rspec-core"
|
|
31
|
-
end
|
|
32
|
-
|
|
89
|
+
def config_raise_delivery_errors_option
|
|
33
90
|
raise_delivery_errors_regexp = /config.action_mailer.raise_delivery_errors = false\n/
|
|
34
91
|
gsub_file 'config/environments/development.rb', raise_delivery_errors_regexp do
|
|
35
92
|
"config.action_mailer.raise_delivery_errors = true"
|
|
@@ -38,6 +38,7 @@ end
|
|
|
38
38
|
|
|
39
39
|
run_action(:recipe_loading) do
|
|
40
40
|
create :rails
|
|
41
|
+
create :spring
|
|
41
42
|
create :readme
|
|
42
43
|
create :heroku
|
|
43
44
|
create :ci
|
|
@@ -65,6 +66,7 @@ run_action(:recipe_loading) do
|
|
|
65
66
|
create :error_reporting
|
|
66
67
|
create :pundit
|
|
67
68
|
create :testing
|
|
69
|
+
create :coverage
|
|
68
70
|
create :secrets
|
|
69
71
|
create :api
|
|
70
72
|
create :draper
|
data/lib/potassium/version.rb
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
module Potassium
|
|
2
|
-
VERSION = "6.
|
|
2
|
+
VERSION = "6.5.0"
|
|
3
3
|
RUBY_VERSION = "2.7.0"
|
|
4
|
-
RAILS_VERSION = "~> 6.
|
|
4
|
+
RAILS_VERSION = "~> 6.1.4.4"
|
|
5
5
|
RUBOCOP_VERSION = "~> 1.9"
|
|
6
6
|
RUBOCOP_RSPEC_VERSION = "~> 2.2"
|
|
7
7
|
POSTGRES_VERSION = "11.3"
|
|
8
8
|
MYSQL_VERSION = "5.7"
|
|
9
|
-
NODE_VERSION = "
|
|
9
|
+
NODE_VERSION = "14"
|
|
10
10
|
TAILWINDCSS = "npm:@tailwindcss/postcss7-compat"
|
|
11
11
|
VUE_LOADER_VERSION = "^15.9.7"
|
|
12
12
|
end
|
data/spec/features/ci_spec.rb
CHANGED
|
@@ -12,6 +12,6 @@ RSpec.describe 'CI' do
|
|
|
12
12
|
yml_path = "#{project_path}/.circleci/config.yml"
|
|
13
13
|
content = IO.read(yml_path)
|
|
14
14
|
expect(File.exist?(yml_path)).to be true
|
|
15
|
-
expect(content).to include('
|
|
15
|
+
expect(content).to include('cimg/ruby', 'cache', 'rspec', 'reviewdog')
|
|
16
16
|
end
|
|
17
17
|
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
RSpec.describe "Coverage" do
|
|
4
|
+
before(:all) do
|
|
5
|
+
drop_dummy_database
|
|
6
|
+
remove_project_directory
|
|
7
|
+
create_dummy_project
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it "adds simplecov related gems to Gemfile" do
|
|
11
|
+
content = IO.read("#{project_path}/Gemfile")
|
|
12
|
+
expect(content).to include("gem 'simplecov'")
|
|
13
|
+
expect(content).to include("gem 'simplecov_linter_formatter'")
|
|
14
|
+
expect(content).to include("gem 'simplecov_text_formatter'")
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "requires simplecov config file before rails" do
|
|
18
|
+
content = IO.read("#{project_path}/spec/rails_helper.rb")
|
|
19
|
+
expect(content).to include("ENV['RACK_ENV'] ||= 'test'\nrequire 'simplecov_config'")
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it "adds simplecov config file" do
|
|
23
|
+
content = IO.read("#{project_path}/spec/simplecov_config.rb")
|
|
24
|
+
expect(content).to include("SimpleCov.start 'rails'")
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -10,10 +10,6 @@ RSpec.describe "Heroku" do
|
|
|
10
10
|
create_dummy_project("heroku" => true)
|
|
11
11
|
app_name = PotassiumTestHelpers::APP_NAME.dasherize
|
|
12
12
|
|
|
13
|
-
expect(FakeHeroku).to(
|
|
14
|
-
have_gem_included(project_path, "rails_stdout_logging")
|
|
15
|
-
)
|
|
16
|
-
|
|
17
13
|
procfile_path = "#{project_path}/Procfile"
|
|
18
14
|
procfile = IO.read(procfile_path)
|
|
19
15
|
|
data/spec/features/node_spec.rb
CHANGED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
RSpec.describe "Pundit" do
|
|
4
|
+
before :all do
|
|
5
|
+
drop_dummy_database
|
|
6
|
+
remove_project_directory
|
|
7
|
+
create_dummy_project("pundit" => true, "devise" => true, "admin" => true)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it "adds the Pundit gem to Gemfile" do
|
|
11
|
+
content = IO.read("#{project_path}/Gemfile")
|
|
12
|
+
|
|
13
|
+
expect(content).to include("gem 'pundit'")
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "setup active admin" do
|
|
17
|
+
content = IO.read("#{project_path}/config/initializers/active_admin.rb")
|
|
18
|
+
|
|
19
|
+
expect(content).to include("config.authorization_adapter = ActiveAdmin::PunditAdapter")
|
|
20
|
+
expect(content).to include("config.pundit_default_policy = 'BackOffice::DefaultPolicy'")
|
|
21
|
+
expect(content).to include("config.pundit_policy_namespace = :back_office")
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "creates default policy" do
|
|
25
|
+
content = IO.read("#{project_path}/app/policies/back_office/default_policy.rb")
|
|
26
|
+
|
|
27
|
+
expect(content).to include("class BackOffice::DefaultPolicy")
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "modifies the README file" do
|
|
31
|
+
readme = IO.read("#{project_path}/README.md")
|
|
32
|
+
expect(readme).to include("from `BackOffice::DefaultPolicy`")
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
RSpec.describe "Testing" do
|
|
4
|
+
let(:gemfile_content) { IO.read("#{project_path}/Gemfile") }
|
|
5
|
+
let(:rails_helper_content) { IO.read("#{project_path}/spec/rails_helper.rb") }
|
|
6
|
+
let(:rspec_content) { IO.read("#{project_path}/.rspec") }
|
|
7
|
+
|
|
8
|
+
let(:support_directories) do
|
|
9
|
+
%w{
|
|
10
|
+
custom_matchers
|
|
11
|
+
shared_examples
|
|
12
|
+
configurations
|
|
13
|
+
helpers
|
|
14
|
+
}
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
let(:conf_files) do
|
|
18
|
+
%w{
|
|
19
|
+
factory_bot_config.rb
|
|
20
|
+
power_types_config.rb
|
|
21
|
+
shoulda_matchers_config.rb
|
|
22
|
+
devise_config.rb
|
|
23
|
+
system_tests_config.rb
|
|
24
|
+
faker_config.rb
|
|
25
|
+
}
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
before(:all) do
|
|
29
|
+
drop_dummy_database
|
|
30
|
+
remove_project_directory
|
|
31
|
+
create_dummy_project(devise: true)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it { expect(gemfile_content).to include("gem 'rspec-rails'") }
|
|
35
|
+
it { expect(gemfile_content).to include('rspec-rails') }
|
|
36
|
+
it { expect(gemfile_content).to include('factory_bot_rails') }
|
|
37
|
+
it { expect(gemfile_content).to include('faker') }
|
|
38
|
+
it { expect(gemfile_content).to include('guard-rspec') }
|
|
39
|
+
it { expect(gemfile_content).to include('rspec-nc') }
|
|
40
|
+
it { expect(gemfile_content).to include('shoulda-matchers') }
|
|
41
|
+
it { expect(gemfile_content).to include('capybara') }
|
|
42
|
+
it { expect(gemfile_content).to include('webdrivers') }
|
|
43
|
+
|
|
44
|
+
it { expect(rails_helper_content).to include("require 'spec_helper'") }
|
|
45
|
+
it { expect(rails_helper_content).to include("config.filter_run_when_matching :focus") }
|
|
46
|
+
|
|
47
|
+
it { expect(rspec_content).to include("--require rails_helper") }
|
|
48
|
+
it { expect(Dir.entries("#{project_path}/spec/support")).to include(*support_directories) }
|
|
49
|
+
it { expect(Dir.entries("#{project_path}/spec/support/configurations")).to include(*conf_files) }
|
|
50
|
+
|
|
51
|
+
it { expect(IO.read("#{project_path}/bin/rspec")).to include('path("rspec-core", "rspec")') }
|
|
52
|
+
it { expect(IO.read("#{project_path}/Guardfile")).to include(':rspec, cmd: "bin/rspec"') }
|
|
53
|
+
it { expect(IO.read("#{project_path}/bin/guard")).to include('path("guard", "guard")') }
|
|
54
|
+
|
|
55
|
+
it { expect(IO.read("#{project_path}/README.md")).to include("To run unit test") }
|
|
56
|
+
end
|
|
@@ -17,7 +17,7 @@ module PotassiumTestHelpers
|
|
|
17
17
|
|
|
18
18
|
def create_dummy_project(arguments = {})
|
|
19
19
|
Dir.chdir(tmp_path) do
|
|
20
|
-
Bundler.
|
|
20
|
+
Bundler.with_unbundled_env do
|
|
21
21
|
add_fakes_to_path
|
|
22
22
|
add_project_bin_to_path
|
|
23
23
|
full_arguments = hash_to_arguments(create_arguments(true).merge(arguments))
|
|
@@ -46,7 +46,7 @@ module PotassiumTestHelpers
|
|
|
46
46
|
|
|
47
47
|
def on_project(&block)
|
|
48
48
|
Dir.chdir(project_path) do
|
|
49
|
-
Bundler.
|
|
49
|
+
Bundler.with_unbundled_env do
|
|
50
50
|
block.call
|
|
51
51
|
end
|
|
52
52
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: potassium
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 6.
|
|
4
|
+
version: 6.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- juliogarciag
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2022-01-28 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -212,14 +212,14 @@ dependencies:
|
|
|
212
212
|
requirements:
|
|
213
213
|
- - "~>"
|
|
214
214
|
- !ruby/object:Gem::Version
|
|
215
|
-
version: 6.
|
|
215
|
+
version: 6.1.4.4
|
|
216
216
|
type: :runtime
|
|
217
217
|
prerelease: false
|
|
218
218
|
version_requirements: !ruby/object:Gem::Requirement
|
|
219
219
|
requirements:
|
|
220
220
|
- - "~>"
|
|
221
221
|
- !ruby/object:Gem::Version
|
|
222
|
-
version: 6.
|
|
222
|
+
version: 6.1.4.4
|
|
223
223
|
- !ruby/object:Gem::Dependency
|
|
224
224
|
name: semantic
|
|
225
225
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -277,10 +277,11 @@ files:
|
|
|
277
277
|
- lib/potassium/assets/README.yml
|
|
278
278
|
- lib/potassium/assets/active_admin/admin-component.vue
|
|
279
279
|
- lib/potassium/assets/active_admin/admin_application.js
|
|
280
|
-
- lib/potassium/assets/active_admin/admin_user_policy.rb
|
|
281
|
-
- lib/potassium/assets/active_admin/comment_policy.rb
|
|
282
280
|
- lib/potassium/assets/active_admin/init_activeadmin_vue.rb
|
|
283
|
-
- lib/potassium/assets/active_admin/
|
|
281
|
+
- lib/potassium/assets/active_admin/policies/admin_user_policy.rb
|
|
282
|
+
- lib/potassium/assets/active_admin/policies/comment_policy.rb
|
|
283
|
+
- lib/potassium/assets/active_admin/policies/default_policy.rb
|
|
284
|
+
- lib/potassium/assets/active_admin/policies/page_policy.rb
|
|
284
285
|
- lib/potassium/assets/app/graphql/graphql_controller.rb
|
|
285
286
|
- lib/potassium/assets/app/graphql/mutations/login_mutation.rb
|
|
286
287
|
- lib/potassium/assets/app/graphql/queries/base_query.rb
|
|
@@ -325,8 +326,15 @@ files:
|
|
|
325
326
|
- lib/potassium/assets/sidekiq.rb.erb
|
|
326
327
|
- lib/potassium/assets/sidekiq.yml
|
|
327
328
|
- lib/potassium/assets/testing/.rspec
|
|
329
|
+
- lib/potassium/assets/testing/devise_config.rb
|
|
330
|
+
- lib/potassium/assets/testing/factory_bot_config.rb
|
|
331
|
+
- lib/potassium/assets/testing/faker_config.rb
|
|
328
332
|
- lib/potassium/assets/testing/platanus.png
|
|
333
|
+
- lib/potassium/assets/testing/power_types_config.rb
|
|
329
334
|
- lib/potassium/assets/testing/rails_helper.rb
|
|
335
|
+
- lib/potassium/assets/testing/shoulda_matchers_config.rb
|
|
336
|
+
- lib/potassium/assets/testing/simplecov_config.rb
|
|
337
|
+
- lib/potassium/assets/testing/system_tests_config.rb
|
|
330
338
|
- lib/potassium/cli.rb
|
|
331
339
|
- lib/potassium/cli/commands/create.rb
|
|
332
340
|
- lib/potassium/cli/commands/install.rb
|
|
@@ -354,6 +362,7 @@ files:
|
|
|
354
362
|
- lib/potassium/recipes/better_errors.rb
|
|
355
363
|
- lib/potassium/recipes/ci.rb
|
|
356
364
|
- lib/potassium/recipes/cleanup.rb
|
|
365
|
+
- lib/potassium/recipes/coverage.rb
|
|
357
366
|
- lib/potassium/recipes/data_migrate.rb
|
|
358
367
|
- lib/potassium/recipes/database.rb
|
|
359
368
|
- lib/potassium/recipes/database_container.rb
|
|
@@ -384,6 +393,7 @@ files:
|
|
|
384
393
|
- lib/potassium/recipes/script.rb
|
|
385
394
|
- lib/potassium/recipes/secrets.rb
|
|
386
395
|
- lib/potassium/recipes/seeds.rb
|
|
396
|
+
- lib/potassium/recipes/spring.rb
|
|
387
397
|
- lib/potassium/recipes/style.rb
|
|
388
398
|
- lib/potassium/recipes/testing.rb
|
|
389
399
|
- lib/potassium/recipes/tzinfo.rb
|
|
@@ -401,6 +411,7 @@ files:
|
|
|
401
411
|
- spec/features/api_spec.rb
|
|
402
412
|
- spec/features/background_processor_spec.rb
|
|
403
413
|
- spec/features/ci_spec.rb
|
|
414
|
+
- spec/features/coverage_spec.rb
|
|
404
415
|
- spec/features/data_migrate_spec.rb
|
|
405
416
|
- spec/features/database_container_spec.rb
|
|
406
417
|
- spec/features/database_spec.rb
|
|
@@ -417,7 +428,9 @@ files:
|
|
|
417
428
|
- spec/features/new_project_spec.rb
|
|
418
429
|
- spec/features/node_spec.rb
|
|
419
430
|
- spec/features/power_types_spec.rb
|
|
431
|
+
- spec/features/pundit_spec.rb
|
|
420
432
|
- spec/features/schedule_spec.rb
|
|
433
|
+
- spec/features/testing_spec.rb
|
|
421
434
|
- spec/features/vue_admin_spec.rb
|
|
422
435
|
- spec/spec_helper.rb
|
|
423
436
|
- spec/support/fake_github.rb
|
|
@@ -444,7 +457,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
444
457
|
- !ruby/object:Gem::Version
|
|
445
458
|
version: '0'
|
|
446
459
|
requirements: []
|
|
447
|
-
rubygems_version: 3.
|
|
460
|
+
rubygems_version: 3.2.22
|
|
448
461
|
signing_key:
|
|
449
462
|
specification_version: 4
|
|
450
463
|
summary: An application generator from Platanus
|
|
@@ -454,6 +467,7 @@ test_files:
|
|
|
454
467
|
- spec/features/api_spec.rb
|
|
455
468
|
- spec/features/background_processor_spec.rb
|
|
456
469
|
- spec/features/ci_spec.rb
|
|
470
|
+
- spec/features/coverage_spec.rb
|
|
457
471
|
- spec/features/data_migrate_spec.rb
|
|
458
472
|
- spec/features/database_container_spec.rb
|
|
459
473
|
- spec/features/database_spec.rb
|
|
@@ -470,7 +484,9 @@ test_files:
|
|
|
470
484
|
- spec/features/new_project_spec.rb
|
|
471
485
|
- spec/features/node_spec.rb
|
|
472
486
|
- spec/features/power_types_spec.rb
|
|
487
|
+
- spec/features/pundit_spec.rb
|
|
473
488
|
- spec/features/schedule_spec.rb
|
|
489
|
+
- spec/features/testing_spec.rb
|
|
474
490
|
- spec/features/vue_admin_spec.rb
|
|
475
491
|
- spec/spec_helper.rb
|
|
476
492
|
- spec/support/fake_github.rb
|