diff --git a/lib/discourse_patrons/engine.rb b/lib/discourse_patrons/engine.rb new file mode 100644 index 0000000..22d53fb --- /dev/null +++ b/lib/discourse_patrons/engine.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +module ::DiscoursePatrons + class Engine < ::Rails::Engine + engine_name 'discourse-patrons' + isolate_namespace DiscoursePatrons + end +end diff --git a/plugin.rb b/plugin.rb index 0c6dce3..aa6f2a8 100644 --- a/plugin.rb +++ b/plugin.rb @@ -4,6 +4,11 @@ enabled_site_setting :discourse_patrons_enabled after_initialize do + load File.expand_path('../lib/discourse_patrons/engine.rb', __FILE__) load File.expand_path('../config/routes.rb', __FILE__) load File.expand_path('../app/controllers/patrons_controller.rb', __FILE__) + + Discourse::Application.routes.append do + mount ::DiscoursePatrons::Engine, at: 'patrons' + end end diff --git a/spec/controllers/discourse_patrons/patrons_controller_spec.rb b/spec/controllers/discourse_patrons/patrons_controller_spec.rb index e9bcc52..ade147e 100644 --- a/spec/controllers/discourse_patrons/patrons_controller_spec.rb +++ b/spec/controllers/discourse_patrons/patrons_controller_spec.rb @@ -5,5 +5,13 @@ require 'rails_helper' module DiscoursePatrons RSpec.describe PatronsController, type: :controller do routes { DiscoursePatrons::Engine.routes } + + it 'responds ok for anonymous users' do + post :create, params: {}, format: :json + + aggregate_failures do + expect(response).to have_http_status(200) + end + end end end