decidim-dev/lib/decidim/dev/test/rspec_support/feature.rb in decidim-0.1.0 vs decidim-dev/lib/decidim/dev/test/rspec_support/feature.rb in decidim-0.2.0
- old
+ new
@@ -12,10 +12,18 @@
root to: proc { [200, {}, ["DUMMY ENGINE"]] }
resources :dummy_resources, controller: "decidim/dummy_resources"
end
end
+ class DummyAdminEngine < Rails::Engine
+ engine_name "dummy_admin"
+
+ routes do
+ root to: proc { [200, {}, ["DUMMY ADMIN ENGINE"]] }
+ end
+ end
+
class DummyResource < ActiveRecord::Base
include HasFeature
include Resourceable
include Reportable
include Authorable
@@ -43,12 +51,26 @@
}
end
end
end
+class DummySerializer
+ def initialize(id)
+ @id = id
+ end
+
+ def serialize
+ {
+ id: @id
+ }
+ end
+end
+
Decidim.register_feature(:dummy) do |feature|
feature.engine = Decidim::DummyEngine
+ feature.admin_engine = Decidim::DummyAdminEngine
+ feature.icon = "decidim/dummy.svg"
feature.actions = %w(foo bar)
feature.settings(:global) do |settings|
settings.attribute :comments_enabled, type: :boolean, default: true
@@ -64,9 +86,17 @@
feature.register_resource do |resource|
resource.name = :dummy
resource.model_class_name = "Decidim::DummyResource"
resource.template = "decidim/dummy_resource/linked_dummys"
+ end
+
+ feature.exports :dummies do |exports|
+ exports.collection do
+ [1, 2, 3]
+ end
+
+ exports.serializer DummySerializer
end
end
RSpec.configure do |config|
config.before(:suite) do