Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Namespace generator under `open_project:`

Aaron Contreras8a72aa8c6dba
diff --git a/lib/generators/rspec/service/USAGE b/lib/generators/open_project/rspec/service/USAGE
similarity index 72%
rename from lib/generators/rspec/service/USAGE
rename to lib/generators/open_project/rspec/service/USAGE
index 8e295019458..7fddcad8abc 100644
--- a/lib/generators/rspec/service/USAGE
+++ b/lib/generators/open_project/rspec/service/USAGE
@@ -4,13 +4,13 @@ Description:
the service spec file in the root /specs directory.
Example:
- bin/rails generate rspec:service Some::Service
+ bin/rails generate open_project:rspec:service Some::Service
This will create:
/specs/services/some/service_spec.rb
Example:
- bin/rails generate rspec:service Some::Service -m meetings
+ bin/rails generate open_project:rspec:service Some::Service -m meetings
This will create:
/modules/meetings/specs/services/some/service_spec.rb
diff --git a/lib/generators/rspec/service/service_generator.rb b/lib/generators/open_project/rspec/service/service_generator.rb
similarity index 52%
rename from lib/generators/rspec/service/service_generator.rb
rename to lib/generators/open_project/rspec/service/service_generator.rb
index eb87960d209..fab5a6216ea 100644
--- a/lib/generators/rspec/service/service_generator.rb
+++ b/lib/generators/open_project/rspec/service/service_generator.rb
@@ -28,42 +28,44 @@
# See COPYRIGHT and LICENSE files for more details.
# ++
-module Rspec
- module Generators
- class ServiceGenerator < Rails::Generators::Base
- source_root File.expand_path("templates", __dir__)
+module OpenProject
+ module Rspec
+ module Generators
+ class ServiceGenerator < Rails::Generators::Base
+ source_root File.expand_path("templates", __dir__)
- argument :service_name,
- type: :string,
- required: true,
- desc: 'Constant of the service the spec is being generated for'
+ argument :service_name,
+ type: :string,
+ required: true,
+ desc: 'Constant of the service the spec is being generated for'
- class_option :module_name,
- aliases: %i[m],
- type: :string,
- optional: true,
- desc: 'Module to generate the service spec file for'
+ class_option :module_name,
+ aliases: %i[m],
+ type: :string,
+ optional: true,
+ desc: 'Module to generate the service spec file for'
- def generate_service_spec
- template 'service_spec.rb', file_path
- end
+ def generate_service_spec
+ template 'service_spec.rb', file_path
+ end
- private
+ private
- def file_path
- namespace = service_name.deconstantize.underscore
- file_name = "#{service_name.demodulize.underscore}_spec.rb"
+ def file_path
+ namespace = service_name.deconstantize.underscore
+ file_name = "#{service_name.demodulize.underscore}_spec.rb"
- Rails.root.join(service_specs_root_directory,
- namespace,
- file_name)
- end
+ Rails.root.join(service_specs_root_directory,
+ namespace,
+ file_name)
+ end
- def service_specs_root_directory
- if options[:module_name]
- "modules/#{options[:module_name]}/spec/services"
- else
- "spec/services"
+ def service_specs_root_directory
+ if options[:module_name]
+ "modules/#{options[:module_name]}/spec/services"
+ else
+ "spec/services"
+ end
end
end
end
diff --git a/lib/generators/rspec/service/templates/service_spec.rb.tt b/lib/generators/open_project/rspec/service/templates/service_spec.rb.tt
similarity index 100%
rename from lib/generators/rspec/service/templates/service_spec.rb.tt
rename to lib/generators/open_project/rspec/service/templates/service_spec.rb.tt