Skip to content

Commit

Permalink
basic preview controller
Browse files Browse the repository at this point in the history
  • Loading branch information
evdevdev committed Aug 28, 2024
1 parent 1a04102 commit 6e990ad
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/controllers/action_prompt/previews_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class ActionPrompt::PreviewsController < ApplicationController
# Note: if we were to fully copy the mailer pattern, we would have
# a line like this:
# before_action :require_local!

def index
end

def show
end
end
1 change: 1 addition & 0 deletions app/views/action_prompt/previews/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>Action Prompt Previews</h1>
1 change: 1 addition & 0 deletions app/views/action_prompt/previews/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>Action Prompt Preview</h1>
1 change: 1 addition & 0 deletions lib/action_prompt.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require "action_prompt/version"
require "action_prompt/engine"
require "action_prompt/railtie"

module ActionPrompt
def self.render(template_name, locals: {})
Expand Down
1 change: 1 addition & 0 deletions lib/action_prompt/engine.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module ActionPrompt
class Engine < ::Rails::Engine
isolate_namespace ActionPrompt
end
end
14 changes: 14 additions & 0 deletions lib/action_prompt/railtie.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require "rails/application_controller"

module ActionPrompt
class Railtie < Rails::Railtie
config.after_initialize do |app|
if Rails.env.development? || Rails.env.test?
app.routes.prepend do
get "/action_prompt/previews", to: "action_prompt/previews#index", internal: true
get "/action_prompt/preview/:prompt_id", to: "action_prompt/previews#show", internal: true
end
end
end
end
end
8 changes: 8 additions & 0 deletions test/controllers/action_prompt/preview_controllers_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require "test_helper"

class ActionPrompt::PreviewControllerTest < ActionDispatch::IntegrationTest
test "should get index" do
get "/action_prompt/previews"
assert_response :success
end
end

0 comments on commit 6e990ad

Please sign in to comment.