Skip to content

Commit d2a1096

Browse files
committed
Update to the latest solidus_dev_support defaults
An additional install generator has been added using the extension's namespace for consistency with the other extensions and for easier future upgrades.
1 parent 32059ba commit d2a1096

17 files changed

Lines changed: 299 additions & 138 deletions

File tree

.gem_release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
bump:
22
recurse: false
3-
file: 'lib/spree/auth/version.rb'
3+
file: 'lib/solidus_auth_devise/version.rb'
44
message: Bump SolidusAuthDevise to %{version}
55
tag: true

.github/stale.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
# Number of days of inactivity before an issue becomes stale
22
daysUntilStale: 60
33
# Number of days of inactivity before a stale issue is closed
4-
daysUntilClose: 7
4+
daysUntilClose: false
55
# Issues with these labels will never be considered stale
66
exemptLabels:
77
- pinned
88
- security
99
# Label to use when marking an issue as stale
10-
staleLabel: wontfix
10+
staleLabel: stale
1111
# Comment to post when marking an issue as stale. Set to `false` to disable
1212
markComment: >
1313
This issue has been automatically marked as stale because it has not had
14-
recent activity. It will be closed if no further activity occurs. Thank you
14+
recent activity. It might be closed if no further activity occurs. Thank you
1515
for your contributions.
1616
# Comment to post when closing a stale issue. Set to `false` to disable
17-
closeComment: false
17+
closeComment: false

.github_changelog_generator

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
issues=false
2+
exclude-labels=infrastructure

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,7 @@ pkg
1515
*.swp
1616
spec/dummy
1717
spec/examples.txt
18+
/sandbox
19+
.rvmrc
20+
.ruby-version
21+
.ruby-gemset

Gemfile

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,14 @@ source 'https://rubygems.org'
44
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
55

66
branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
7+
gem 'solidus', github: 'solidusio/solidus', branch: branch
8+
gem 'solidus_backend', github: 'solidusio/solidus', branch: branch
79

8-
solidus_git, solidus_frontend_git = if (branch == 'master') || (branch >= 'v3.2')
9-
%w[solidusio/solidus solidusio/solidus_frontend]
10-
else
11-
%w[solidusio/solidus] * 2
12-
end
10+
# The solidus_frontend gem has been pulled out since v3.2
11+
gem 'solidus_frontend', github: 'solidusio/solidus_frontend' if branch == 'master'
12+
gem 'solidus_frontend' if branch >= 'v3.2' # rubocop:disable Bundler/DuplicatedGem
1313

14-
gem 'solidus_api', github: solidus_git, branch: branch
15-
gem 'solidus_backend', github: solidus_git, branch: branch
16-
gem 'solidus_core', github: solidus_git, branch: branch
17-
gem 'solidus_frontend', github: solidus_frontend_git, branch: branch
18-
gem 'solidus_sample', github: solidus_git, branch: branch
19-
20-
gem 'rails', ENV.fetch('RAILS_VERSION', nil)
21-
22-
case ENV['DB']
14+
case ENV.fetch('DB', nil)
2315
when 'mysql'
2416
gem 'mysql2'
2517
when 'postgresql'
@@ -43,5 +35,8 @@ end
4335
gemspec
4436

4537
# Use a local Gemfile to include development dependencies that might not be
46-
# relevant for the project or for other contributors, e.g.: `gem 'pry-debug'`.
47-
eval_gemfile 'Gemfile-local' if File.exist? 'Gemfile-local'
38+
# relevant for the project or for other contributors, e.g. pry-byebug.
39+
#
40+
# We use `send` instead of calling `eval_gemfile` to work around an issue with
41+
# how Dependabot parses projects: https://github.com/dependabot/dependabot-core/issues/1658.
42+
send(:eval_gemfile, 'Gemfile-local') if File.exist? 'Gemfile-local'

README.md

Lines changed: 70 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
1-
Solidus Auth (Devise)
2-
=====================
1+
# Solidus Auth Devise
32

4-
[![CircleCI](https://circleci.com/gh/solidusio/solidus_auth_devise.svg?style=svg)](https://circleci.com/gh/solidusio/solidus_auth_devise)
3+
[![CircleCI](https://circleci.com/gh/solidusio/solidus_auth_devise.svg?style=shield)](https://circleci.com/gh/solidusio/solidus_auth_devise)
4+
[![codecov](https://codecov.io/gh/solidusio/solidus_auth_devise/branch/master/graph/badge.svg)](https://codecov.io/gh/solidusio/solidus_auth_devise)
55

66
Provides authentication services for Solidus, using the Devise gem.
77

8-
Installation
9-
------------
8+
## Usage
109

11-
Just add this line to your `Gemfile`:
10+
### Installation
1211

13-
```ruby
14-
gem "solidus_auth_devise"
12+
Add solidus_auth_devise to your Gemfile:
1513

16-
# For Solidus versions < 2.5
17-
# gem 'deface'
14+
```ruby
15+
gem 'solidus_auth_devise'
1816
```
1917

2018
Then, run `bundle install`.
@@ -27,11 +25,11 @@ bundle exec rake db:migrate
2725
bundle exec rake db:seed
2826
```
2927

30-
### Default Username/Password
28+
#### Default Username/Password
3129

3230
As part of running the above installation steps, you will be asked to set an admin email/password combination. The default values are `admin@example.com` and `test123`, respectively.
3331

34-
### Confirmable
32+
#### Confirmable
3533

3634
To enable Devise's Confirmable module, which will send the user an email with a link to confirm their account, you must do the following:
3735

@@ -52,8 +50,7 @@ Devise.setup do |config|
5250
end
5351
```
5452

55-
Using in an existing application
56-
--------------------------------
53+
### Using in an existing application
5754

5855
If you are installing Solidus inside of a host application in which you want your own permission setup, you can do this using the `register_ability` method.
5956

@@ -87,15 +84,69 @@ Inside of your host application you can then use CanCan like you normally would.
8784
<% end %>
8885
```
8986

90-
Testing
91-
-------
87+
## Development
88+
89+
### Testing the extension
90+
91+
First bundle your dependencies, then run `bin/rake`. `bin/rake` will default to building the dummy
92+
app if it does not exist, then it will run specs. The dummy app can be regenerated by using
93+
`bin/rake extension:test_app`.
94+
95+
```shell
96+
bin/rake
97+
```
98+
99+
To run [Rubocop](https://github.com/bbatsov/rubocop) static code analysis run
100+
101+
```shell
102+
bundle exec rubocop
103+
```
104+
105+
When testing your application's integration with this extension you may use its factories.
106+
Simply add this require statement to your `spec/spec_helper.rb`:
107+
108+
```ruby
109+
require 'solidus_auth_devise/testing_support/factories'
110+
```
111+
112+
Or, if you are using `FactoryBot.definition_file_paths`, you can load Solidus core
113+
factories along with this extension's factories using this statement:
114+
115+
```ruby
116+
SolidusDevSupport::TestingSupport::Factories.load_for(SolidusAuthDevise::Engine)
117+
```
118+
119+
### Running the sandbox
120+
121+
To run this extension in a sandboxed Solidus application, you can run `bin/sandbox`. The path for
122+
the sandbox app is `./sandbox` and `bin/rails` will forward any Rails commands to
123+
`sandbox/bin/rails`.
124+
125+
Here's an example:
126+
127+
```
128+
$ bin/rails server
129+
=> Booting Puma
130+
=> Rails 6.0.2.1 application starting in development
131+
* Listening on tcp://127.0.0.1:3000
132+
Use Ctrl-C to stop
133+
```
134+
135+
### Updating the changelog
92136

93-
Run the following to automatically build a dummy app if necessary and run the tests:
137+
Before and after releases the changelog should be updated to reflect the up-to-date status of
138+
the project:
94139

95140
```shell
96-
bundle exec rake
141+
bin/rake changelog
142+
git add CHANGELOG.md
143+
git commit -m "Update the changelog"
97144
```
98145

99-
## Releasing a new version
146+
### Releasing new versions
100147

101148
Please refer to the dedicated [page](https://github.com/solidusio/solidus/wiki/How-to-release-extensions) on Solidus wiki.
149+
150+
## License
151+
152+
Copyright (c) 2022 Solidus Team, released under the New BSD License.

Rakefile

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,7 @@
33
# Don't build a dummy app with solidus_bolt enabled
44
ENV['SKIP_SOLIDUS_BOLT'] = 'true'
55

6-
require 'bundler'
7-
Bundler::GemHelper.install_tasks
8-
9-
require 'rake/clean'
10-
require 'spree/testing_support/common_rake'
11-
ENV['DUMMY_PATH'] = "spec/dummy"
12-
ENV['LIB_NAME'] = "solidus/auth"
13-
::CLOBBER.include ENV['DUMMY_PATH']
14-
15-
namespace :extension do
16-
# We need to go back to the gem root since the upstream
17-
# extension:test_app changes the working directory to be the dummy app.
18-
task :test_app do
19-
Rake::Task['extension:test_app'].invoke
20-
cd __dir__
21-
end
22-
23-
directory ENV['DUMMY_PATH'] do
24-
Rake::Task['common:test_app'].invoke("Spree::User")
25-
end
26-
27-
require 'rspec/core/rake_task'
28-
RSpec::Core::RakeTask.new(:specs, [] => FileList[ENV['DUMMY_PATH']]) do |t|
29-
# Ref: https://circleci.com/docs/2.0/configuration-reference#store_test_results
30-
# Ref: https://github.com/solidusio/circleci-orbs-extensions#test-results-rspec
31-
if ENV['TEST_RESULTS_PATH']
32-
t.rspec_opts =
33-
"--format progress " \
34-
"--format RspecJunitFormatter --out #{ENV['TEST_RESULTS_PATH']}"
35-
end
36-
end
37-
end
6+
require 'solidus_dev_support/rake_tasks'
7+
SolidusDevSupport::RakeTasks.install
388

399
task default: 'extension:specs'
40-
41-
# DEPRECATED:
42-
task test_app: 'extension:test_app'
43-
task spec: 'extension:specs'

bin/rails

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
#!/usr/bin/env ruby
22

3-
# frozen_string_literal: true
4-
5-
app_root = 'spec/dummy'
6-
7-
unless File.exist? "#{app_root}/bin/rails"
8-
system "bin/rake", app_root or begin # rubocop:disable Style/AndOr
9-
warn "Automatic creation of the dummy app failed"
10-
exit 1
11-
end
3+
if %w[g generate].include? ARGV.first
4+
exec "#{__dir__}/rails-engine", *ARGV
5+
else
6+
exec "#{__dir__}/rails-sandbox", *ARGV
127
end
13-
14-
Dir.chdir app_root
15-
exec 'bin/rails', *ARGV

bin/rails-engine

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env ruby
2+
# This command will automatically be run when you run "rails" with Rails gems
3+
# installed from the root of your application.
4+
5+
ENGINE_ROOT = File.expand_path('..', __dir__)
6+
ENGINE_PATH = File.expand_path('../lib/spree/auth/engine', __dir__)
7+
8+
# Set up gems listed in the Gemfile.
9+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
10+
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
11+
12+
require 'rails/all'
13+
require 'rails/engine/commands'

bin/rails-sandbox

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env ruby
2+
3+
app_root = 'sandbox'
4+
5+
unless File.exist? "#{app_root}/bin/rails"
6+
warn 'Creating the sandbox app...'
7+
Dir.chdir "#{__dir__}/.." do
8+
system "#{__dir__}/sandbox" or begin
9+
warn 'Automatic creation of the sandbox app failed'
10+
exit 1
11+
end
12+
end
13+
end
14+
15+
Dir.chdir app_root
16+
exec 'bin/rails', *ARGV

0 commit comments

Comments
 (0)