Module: Decidim::Dev
- Defined in:
- lib/decidim/dev.rb,
lib/decidim/dev/api.rb,
lib/decidim/dev/admin.rb,
lib/decidim/dev/engine.rb,
lib/decidim/dev/railtie.rb,
lib/decidim/dev/version.rb,
lib/decidim/dev/auth_engine.rb,
lib/decidim/dev/admin_engine.rb,
lib/decidim/dev/test/map_server.rb,
lib/decidim/dev/dummy_translator.rb,
lib/decidim/api/dummy_resource_type.rb,
app/models/decidim/dev/dummy_resource.rb,
app/permissions/decidim/dev/permissions.rb,
lib/decidim/dev/needs_development_tools.rb,
app/forms/decidim/dev/dummy_resource_form.rb,
app/models/decidim/dev/application_record.rb,
app/events/decidim/dev/dummy_resource_event.rb,
app/models/decidim/dev/nested_dummy_resource.rb,
app/serializers/decidim/dev/dummy_serializer.rb,
app/mailers/decidim/dev/dummy_resource_mailer.rb,
app/commands/decidim/dev/create_dummy_resource.rb,
app/models/decidim/dev/coauthorable_dummy_resource.rb,
app/jobs/decidim/dev/hide_all_created_by_author_job.rb,
app/presenters/decidim/dev/dummy_resource_presenter.rb,
app/presenters/decidim/dev/official_author_presenter.rb,
app/controllers/decidim/dev/dummy_resources_controller.rb,
app/events/decidim/dev/dummy_notification_only_resource_event.rb
Overview
This holds the decidim-dev version.
Defined Under Namespace
Modules: Admin, NeedsDevelopmentTools, Test Classes: AdminEngine, ApplicationRecord, AuthEngine, CoauthorableDummyResource, CreateDummyResource, DummyNotificationOnlyResourceEvent, DummyResource, DummyResourceEvent, DummyResourceForm, DummyResourceMailer, DummyResourcePresenter, DummyResourceType, DummyResourcesController, DummySerializer, DummyTranslator, Engine, HideAllCreatedByAuthorJob, NestedDummyResource, OfficialAuthorPresenter, Permissions, Railtie
Class Method Summary collapse
-
.asset(name) ⇒ Object
Public: Finds an asset.
-
.dummy_app_path ⇒ Object
Public: Get the dummy application path and raises an error if it is not set.
-
.dummy_app_path=(path) ⇒ Object
Public: Sets the dummy application path for testing.
-
.install_tasks ⇒ Object
Public: add rake tasks.
-
.test_file(filename, content_type) ⇒ Object
Public: Returns a file for testing, just like file fields expect it.
-
.uploaded_file(path, content_type, binary: false) ⇒ Rack::Test::UploadedFile
Public: Creates a safe uploaded file for tests.
- .version ⇒ Object
Class Method Details
.asset(name) ⇒ Object
Public: Finds an asset.
Returns a String with the path for a particular asset.
30 31 32 |
# File 'lib/decidim/dev.rb', line 30 def self.asset(name) File.(File.join(__dir__, "dev", "assets", name)) end |
.dummy_app_path ⇒ Object
Public: Get the dummy application path and raises an error if it is not set.
85 86 87 88 89 90 91 |
# File 'lib/decidim/dev.rb', line 85 def self.dummy_app_path unless @dummy_app_path raise StandardError, "Please, add Decidim::Dev::dummy_app_path = File.expand_path(File.join(\"..\", \"spec\", \"decidim_dummy_app\")) to\n your spec helper with the path to the generated dummy app" end @dummy_app_path end |
.dummy_app_path=(path) ⇒ Object
Public: Sets the dummy application path for testing.
path - A string value defining the path.
80 81 82 |
# File 'lib/decidim/dev.rb', line 80 def self.dummy_app_path=(path) @dummy_app_path = path end |
.install_tasks ⇒ Object
Public: add rake tasks
71 72 73 74 75 |
# File 'lib/decidim/dev.rb', line 71 def self.install_tasks Dir[File.join(__dir__, "../tasks/*.rake")].each do |file| load file end end |
.test_file(filename, content_type) ⇒ Object
Public: Returns a file for testing, just like file fields expect it
35 36 37 |
# File 'lib/decidim/dev.rb', line 35 def self.test_file(filename, content_type) uploaded_file(asset(filename), content_type) end |
.uploaded_file(path, content_type, binary: false) ⇒ Rack::Test::UploadedFile
Public: Creates a safe uploaded file for tests.
Creating instances of Rack::Test::UploadedFile directly from file paths may lead to 0-byte files created in the storage under specific configurations/kernels and specifically with Docker containers. This method creates a safe uploaded file that does not have this problem.
See: github.com/rails/rails/issues/41991 github.com/docker/for-mac/issues/5570 github.com/docker/for-linux/issues/1015
56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/decidim/dev.rb', line 56 def self.uploaded_file(path, content_type, binary: false) original_filename = File.basename(path) extension = File.extname(original_filename) tempfile = Tempfile.open([File.basename(original_filename, extension), extension]) tempfile.binmode if binary tempfile.write(binary ? File.binread(path) : File.read(path)) tempfile.rewind Rack::Test::UploadedFile.new(tempfile, content_type, binary, original_filename:) ensure tempfile&.close! end |
.version ⇒ Object
6 7 8 |
# File 'lib/decidim/dev/version.rb', line 6 def self.version "0.32.0.rc3" end |