Sha256: 70f0e4ba4575913686c2dd21900e40b18d3c5a1ebe0450476ed0badedfab90cf

Contents?: true

Size: 1.68 KB

Versions: 1

Compression:

Stored size: 1.68 KB

Contents

# static pages
generate "controller", "static_pages", "home", "status", "console"

inject_into_file "app/controllers/static_pages_controller.rb", after: "class StaticPagesController < ApplicationController\n" do
<<-EOF
  skip_before_action :authenticate_user!, only: [:home, :status]
  skip_before_action :authenticate_normal!, only: [:home, :status]
  before_action :authenticate_system!, only: [:console]
EOF
end

inject_into_file "app/controllers/static_pages_controller.rb", after: "def status\n" do
<<-EOF
    render json: {
      status: "ok",
      hostname: Socket.gethostname,
      service: "#{app_path}",
      commit: @@comment ||= `git log -1 --oneline`
    }
EOF
end

gsub_file "config/routes.rb", "get 'static_pages/home'", "root to: 'static_pages#home'"
gsub_file "config/routes.rb", "get 'static_pages/status'", "get '/status' => 'static_pages#status'"
gsub_file "config/routes.rb", "get 'static_pages/console'", "get '/console' => 'static_pages#console'"

inject_into_file "spec/controllers/static_pages_controller_spec.rb", after: "RSpec.describe StaticPagesController, type: :controller do\n" do
<<-EOF

  before { sign_in_user }
EOF
end

create_file "spec/routing/static_pages_spec.rb", <<-EOF
require "rails_helper"

describe StaticPagesController, :type => :routing do
  describe "routing" do

    it "routes to #home" do
      expect(:get => "/").to route_to("static_pages#home")
    end

    it "routes to #status" do
      expect(:get => "/status").to route_to("static_pages#status")
    end

    it "routes to #console" do
      expect(:get => "/console").to route_to("static_pages#console")
    end
  end
end
EOF

append_file "app/views/static_pages/console.html.slim", <<-EOF
= console
EOF

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
crosstie-0.0.7 lib/crosstie/templates/static_pages.rb