Skip to content

Commit 0b45910

Browse files
committed
Allow passing a user class to the test app generator
Currently, solidus_auth_devise is tested with a dummy app that specifies `Spree::LegacyUser` in its `spree.rb initializer. That's not great, but there's no way of fixing it if the rake task install does not pass through the user class option. The way to use this feature would be in an extension's Rakefile: ```rb SolidusDevSupport::RakeTasks.install(user_class: "Spree::User") ```
1 parent d02696e commit 0b45910

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

lib/solidus_dev_support/rake_tasks.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ module SolidusDevSupport
77
class RakeTasks
88
include Rake::DSL
99

10-
def self.install(*args)
11-
new(*args).tap(&:install)
10+
def self.install(**args)
11+
new(**args).tap(&:install)
1212
end
1313

14-
def initialize(root: Dir.pwd)
14+
def initialize(root: Dir.pwd, user_class: "Spree::LegacyUser")
1515
@root = Pathname(root)
1616
@test_app_path = @root.join(ENV.fetch('DUMMY_PATH', 'spec/dummy'))
1717
@gemspec = Bundler.load_gemspec(@root.glob("{,*}.gemspec").first)
18+
@user_class = user_class
1819
end
1920

2021
attr_reader :test_app_path, :root, :gemspec
@@ -39,12 +40,12 @@ def install_test_app_task
3940
# We need to go back to the gem root since the upstream
4041
# extension:test_app changes the working directory to be the dummy app.
4142
task :test_app do
42-
Rake::Task['extension:test_app'].invoke
43+
Rake::Task['extension:test_app'].invoke(@user_class)
4344
cd root
4445
end
4546

4647
directory ENV.fetch('DUMMY_PATH', nil) do
47-
Rake::Task['extension:test_app'].invoke
48+
Rake::Task['extension:test_app'].invoke(@user_class)
4849
end
4950
end
5051
end

0 commit comments

Comments
 (0)