This commit is contained in:
Jonathan Abbett 2016-11-21 16:09:18 -05:00
parent 3849d72de9
commit 4da4659503
62 changed files with 152 additions and 85 deletions

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
source 'http://rubygems.org' source 'http://rubygems.org'
source 'http://rails-assets.org' source 'http://rails-assets.org'

View File

@ -49,6 +49,7 @@ GEM
minitest (~> 5.1) minitest (~> 5.1)
tzinfo (~> 1.1) tzinfo (~> 1.1)
arel (7.1.4) arel (7.1.4)
ast (2.3.0)
builder (3.2.2) builder (3.2.2)
concurrent-ruby (1.0.2) concurrent-ruby (1.0.2)
erubis (2.7.0) erubis (2.7.0)
@ -72,6 +73,9 @@ GEM
nio4r (1.2.1) nio4r (1.2.1)
nokogiri (1.6.8.1) nokogiri (1.6.8.1)
mini_portile2 (~> 2.1.0) mini_portile2 (~> 2.1.0)
parser (2.3.2.0)
ast (~> 2.2)
powerpack (0.1.1)
rack (2.0.1) rack (2.0.1)
rack-test (0.6.3) rack-test (0.6.3)
rack (>= 1.0) rack (>= 1.0)
@ -101,7 +105,15 @@ GEM
method_source method_source
rake (>= 0.8.7) rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0) thor (>= 0.18.1, < 2.0)
rainbow (2.1.0)
rake (11.3.0) rake (11.3.0)
rubocop (0.45.0)
parser (>= 2.3.1.1, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
ruby-progressbar (1.8.1)
sass (3.4.22) sass (3.4.22)
sass-rails (5.0.6) sass-rails (5.0.6)
railties (>= 4.0.0, < 6) railties (>= 4.0.0, < 6)
@ -122,6 +134,7 @@ GEM
tilt (2.0.5) tilt (2.0.5)
tzinfo (1.2.2) tzinfo (1.2.2)
thread_safe (~> 0.1) thread_safe (~> 0.1)
unicode-display_width (1.1.1)
websocket-driver (0.6.4) websocket-driver (0.6.4)
websocket-extensions (>= 0.1.0) websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2) websocket-extensions (0.1.2)
@ -131,6 +144,7 @@ PLATFORMS
DEPENDENCIES DEPENDENCIES
abraham! abraham!
rubocop
sqlite3 sqlite3
BUNDLED WITH BUNDLED WITH

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
begin begin
require 'bundler/setup' require 'bundler/setup'
rescue LoadError rescue LoadError
@ -14,14 +15,11 @@ RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_files.include('lib/**/*.rb') rdoc.rdoc_files.include('lib/**/*.rb')
end end
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__) APP_RAKEFILE = File.expand_path('../test/dummy/Rakefile', __FILE__)
load 'rails/tasks/engine.rake' load 'rails/tasks/engine.rake'
load 'rails/tasks/statistics.rake' load 'rails/tasks/statistics.rake'
require 'bundler/gem_tasks' require 'bundler/gem_tasks'
require 'rake/testtask' require 'rake/testtask'
@ -33,5 +31,4 @@ Rake::TestTask.new(:test) do |t|
t.verbose = false t.verbose = false
end end
task default: :test task default: :test

View File

@ -1,26 +1,28 @@
$:.push File.expand_path("../lib", __FILE__) # frozen_string_literal: true
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
# Maintain your gem's version: # Maintain your gem's version:
require "abraham/version" require 'abraham/version'
# Describe your gem and declare its dependencies: # Describe your gem and declare its dependencies:
Gem::Specification.new do |s| Gem::Specification.new do |s|
s.name = "abraham" s.name = 'abraham'
s.version = Abraham::VERSION s.version = Abraham::VERSION
s.authors = ["Jonathan Abbett"] s.authors = ['Jonathan Abbett']
s.email = ["jonathan@act.md"] s.email = ['jonathan@act.md']
s.homepage = "http://getabraham.com" s.homepage = 'http://getabraham.com'
s.summary = "Trackable application tours for Rails with i18n support." s.summary = 'Trackable application tours for Rails with i18n support.'
s.description = "Guide your users in the one true path." s.description = 'Guide your users in the one true path.'
s.license = "MIT" s.license = 'MIT'
s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"] s.files = Dir['{app,config,db,lib}/**/*', 'MIT-LICENSE', 'Rakefile', 'README.md']
s.add_dependency "rails", "~> 5.0.0", ">= 5.0.0.1" s.add_dependency 'rails', '~> 5.0.0', '>= 5.0.0.1'
s.add_dependency 'sass-rails', '~> 5.0' s.add_dependency 'sass-rails', '~> 5.0'
s.add_dependency "rails-assets-shepherd.js", "~> 1.8" s.add_dependency 'rails-assets-shepherd.js', '~> 1.8'
s.add_development_dependency "sqlite3" s.add_development_dependency 'sqlite3'
s.add_development_dependency 'rubocop'
s.add_runtime_dependency 'jquery-rails' s.add_runtime_dependency 'jquery-rails'
end end

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
class AbrahamHistoriesController < ApplicationController class AbrahamHistoriesController < ApplicationController
def create def create
@abraham_history = AbrahamHistory.new(abraham_history_params) @abraham_history = AbrahamHistory.new(abraham_history_params)

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module AbrahamHelper module AbrahamHelper
def abraham_tour def abraham_tour
# Do we have tours for this controller/action in the user's locale? # Do we have tours for this controller/action in the user's locale?
@ -10,15 +11,16 @@ module AbrahamHelper
if tours if tours
completed = AbrahamHistory.where( completed = AbrahamHistory.where(
creator_id: current_user, controller_name: controller_name, creator_id: current_user, controller_name: controller_name,
action_name: action_name) action_name: action_name
)
remaining = tours.keys - completed.map(&:tour_name) remaining = tours.keys - completed.map(&:tour_name)
if remaining.any? if remaining.any?
# Generate the javascript snippet for the next remaining tour # Generate the javascript snippet for the next remaining tour
render(:partial => 'application/abraham', render(partial: 'application/abraham',
:locals => {:tour_name => remaining.first, locals: { tour_name: remaining.first,
:steps => tours[remaining.first]['steps']}) steps: tours[remaining.first]['steps'] })
end end
end end
end end

View File

@ -1,2 +1,3 @@
# frozen_string_literal: true
class AbrahamHistory < ApplicationRecord class AbrahamHistory < ApplicationRecord
end end

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
class ApplicationRecord < ActiveRecord::Base class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true self.abstract_class = true
end end

View File

@ -1,4 +1,5 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
# frozen_string_literal: true
# This command will automatically be run when you run "rails" with Rails gems # This command will automatically be run when you run "rails" with Rails gems
# installed from the root of your application. # installed from the root of your application.

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
Rails.application.routes.draw do Rails.application.routes.draw do
resources :abraham_histories, only: :create resources :abraham_histories, only: :create
end end

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'abraham/engine' require 'abraham/engine'
module Abraham module Abraham

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'rubygems' require 'rubygems'
require 'rails-assets-shepherd.js' require 'rails-assets-shepherd.js'
require 'jquery-rails' require 'jquery-rails'

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module Abraham module Abraham
VERSION = '0.1.0' VERSION = '0.1.0'
end end

View File

@ -1,13 +1,14 @@
# frozen_string_literal: true
require 'rails/generators' require 'rails/generators'
require "rails/generators/active_record" require 'rails/generators/active_record'
module Abraham module Abraham
module Generators module Generators
class InstallGenerator < ActiveRecord::Generators::Base class InstallGenerator < ActiveRecord::Generators::Base
argument :name, type: :string, default: 'random_name' argument :name, type: :string, default: 'random_name'
class_option :'skip-migration', :type => :boolean, :desc => "Don't generate a migration for the histories table" class_option :'skip-migration', type: :boolean, desc: "Don't generate a migration for the histories table"
class_option :'skip-initializer', :type => :boolean, :desc => "Don't generate an initializer" class_option :'skip-initializer', type: :boolean, desc: "Don't generate an initializer"
source_root File.expand_path(File.join(File.dirname(__FILE__), 'templates')) source_root File.expand_path(File.join(File.dirname(__FILE__), 'templates'))

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
Rails.application.configure do Rails.application.configure do
tours = {} tours = {}

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
class CreateAbrahamHistories < ActiveRecord::Migration[5.0] class CreateAbrahamHistories < ActiveRecord::Migration[5.0]
def change def change
create_table :abraham_histories do |t| create_table :abraham_histories do |t|

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
# desc "Explaining what the task does" # desc "Explaining what the task does"
# task :abraham do # task :abraham do
# # Task goes here # # Task goes here

View File

@ -1,7 +1,8 @@
# frozen_string_literal: true
require 'test_helper' require 'test_helper'
class Abraham::Test < ActiveSupport::TestCase class Abraham::Test < ActiveSupport::TestCase
test "truth" do test 'truth' do
assert_kind_of Module, Abraham assert_kind_of Module, Abraham
end end
end end

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
# Add your own tasks in files placed in lib/tasks ending in .rake, # Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module ApplicationCable module ApplicationCable
class Channel < ActionCable::Channel::Base class Channel < ActionCable::Channel::Base
end end

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
module ApplicationCable module ApplicationCable
class Connection < ActionCable::Connection::Base class Connection < ActionCable::Connection::Base
end end

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
class ApplicationController < ActionController::Base class ApplicationController < ActionController::Base
protect_from_forgery with: :exception protect_from_forgery with: :exception
helper_method :current_user helper_method :current_user

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
class DashboardController < ApplicationController class DashboardController < ApplicationController
def home def home
end end

View File

@ -1,2 +1,3 @@
# frozen_string_literal: true
module ApplicationHelper module ApplicationHelper
end end

View File

@ -1,2 +1,3 @@
# frozen_string_literal: true
module DashboardHelper module DashboardHelper
end end

View File

@ -1,2 +1,3 @@
# frozen_string_literal: true
class ApplicationJob < ActiveJob::Base class ApplicationJob < ActiveJob::Base
end end

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
class ApplicationMailer < ActionMailer::Base class ApplicationMailer < ActionMailer::Base
default from: 'from@example.com' default from: 'from@example.com'
layout 'mailer' layout 'mailer'

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
class ApplicationRecord < ActiveRecord::Base class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true self.abstract_class = true
end end

View File

@ -1,3 +1,4 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
# frozen_string_literal: true
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
load Gem.bin_path('bundler', 'bundle') load Gem.bin_path('bundler', 'bundle')

View File

@ -1,4 +1,5 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
# frozen_string_literal: true
APP_PATH = File.expand_path('../config/application', __dir__) APP_PATH = File.expand_path('../config/application', __dir__)
require_relative '../config/boot' require_relative '../config/boot'
require 'rails/commands' require 'rails/commands'

View File

@ -1,4 +1,5 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
# frozen_string_literal: true
require_relative '../config/boot' require_relative '../config/boot'
require 'rake' require 'rake'
Rake.application.run Rake.application.run

View File

@ -1,4 +1,5 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
# frozen_string_literal: true
require 'pathname' require 'pathname'
require 'fileutils' require 'fileutils'
include FileUtils include FileUtils

View File

@ -1,4 +1,5 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
# frozen_string_literal: true
require 'pathname' require 'pathname'
require 'fileutils' require 'fileutils'
include FileUtils include FileUtils

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
# This file is used by Rack-based servers to start the application. # This file is used by Rack-based servers to start the application.
require_relative 'config/environment' require_relative 'config/environment'

View File

@ -1,9 +1,10 @@
# frozen_string_literal: true
require_relative 'boot' require_relative 'boot'
require 'rails/all' require 'rails/all'
Bundler.require(*Rails.groups) Bundler.require(*Rails.groups)
require "abraham" require 'abraham'
module Dummy module Dummy
class Application < Rails::Application class Application < Rails::Application
@ -12,4 +13,3 @@ module Dummy
# -- all .rb files in that directory are automatically loaded. # -- all .rb files in that directory are automatically loaded.
end end
end end

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
# Set up gems listed in the Gemfile. # Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__) ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
# Load the Rails application. # Load the Rails application.
require_relative 'application' require_relative 'application'

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
Rails.application.configure do Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb. # Settings specified here will take precedence over those in config/application.rb.

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
Rails.application.configure do Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb. # Settings specified here will take precedence over those in config/application.rb.
@ -47,7 +48,7 @@ Rails.application.configure do
config.log_level = :debug config.log_level = :debug
# Prepend all log lines with the following tags. # Prepend all log lines with the following tags.
config.log_tags = [ :request_id ] config.log_tags = [:request_id]
# Use a different cache store in production. # Use a different cache store in production.
# config.cache_store = :mem_cache_store # config.cache_store = :mem_cache_store
@ -75,7 +76,7 @@ Rails.application.configure do
# require 'syslog/logger' # require 'syslog/logger'
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
if ENV["RAILS_LOG_TO_STDOUT"].present? if ENV['RAILS_LOG_TO_STDOUT'].present?
logger = ActiveSupport::Logger.new(STDOUT) logger = ActiveSupport::Logger.new(STDOUT)
logger.formatter = config.log_formatter logger.formatter = config.log_formatter
config.logger = ActiveSupport::TaggedLogging.new(logger) config.logger = ActiveSupport::TaggedLogging.new(logger)

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
Rails.application.configure do Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb. # Settings specified here will take precedence over those in config/application.rb.

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
Rails.application.configure do Rails.application.configure do
tours = {} tours = {}

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# ApplicationController.renderer.defaults.merge!( # ApplicationController.renderer.defaults.merge!(

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets. # Version of your assets, change this if you want to expire all your assets.

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# Specify a serializer for the signed and encrypted cookie jars. # Specify a serializer for the signed and encrypted cookie jars.

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# Configure sensitive parameters which will be filtered from the log file. # Configure sensitive parameters which will be filtered from the log file.

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format. Inflections # Add new inflection rules using the following format. Inflections

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks: # Add new mime types for use in respond_to blocks:

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# #
# This file contains migration options to ease your Rails 5.0 upgrade. # This file contains migration options to ease your Rails 5.0 upgrade.

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
Rails.application.config.session_store :cookie_store, key: '_dummy_session' Rails.application.config.session_store :cookie_store, key: '_dummy_session'

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
# Be sure to restart your server when you modify this file. # Be sure to restart your server when you modify this file.
# This file contains settings for ActionController::ParamsWrapper which # This file contains settings for ActionController::ParamsWrapper which

View File

@ -1,19 +1,20 @@
# frozen_string_literal: true
# Puma can serve each request in a thread from an internal thread pool. # Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers a minimum and maximum. # The `threads` method setting takes two numbers a minimum and maximum.
# Any libraries that use thread pools should be configured to match # Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum # the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum, this matches the default thread size of Active Record. # and maximum, this matches the default thread size of Active Record.
# #
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i threads_count = ENV.fetch('RAILS_MAX_THREADS') { 5 }.to_i
threads threads_count, threads_count threads threads_count, threads_count
# Specifies the `port` that Puma will listen on to receive requests, default is 3000. # Specifies the `port` that Puma will listen on to receive requests, default is 3000.
# #
port ENV.fetch("PORT") { 3000 } port ENV.fetch('PORT') { 3000 }
# Specifies the `environment` that Puma will run in. # Specifies the `environment` that Puma will run in.
# #
environment ENV.fetch("RAILS_ENV") { "development" } environment ENV.fetch('RAILS_ENV') { 'development' }
# Specifies the number of `workers` to boot in clustered mode. # Specifies the number of `workers` to boot in clustered mode.
# Workers are forked webserver processes. If using threads and workers together # Workers are forked webserver processes. If using threads and workers together

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
Rails.application.routes.draw do Rails.application.routes.draw do
get 'dashboard/home' get 'dashboard/home'

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
%w( %w(
.ruby-version .ruby-version
.rbenv-vars .rbenv-vars

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
class CreateAbrahamHistories < ActiveRecord::Migration[5.0] class CreateAbrahamHistories < ActiveRecord::Migration[5.0]
def change def change
create_table :abraham_histories do |t| create_table :abraham_histories do |t|

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
# This file is auto-generated from the current state of the database. Instead # This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to # of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition. # incrementally modify your database, and then regenerate this schema definition.
@ -10,18 +11,16 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20161118143752) do ActiveRecord::Schema.define(version: 20_161_118_143_752) do
create_table 'abraham_histories', force: :cascade do |t|
create_table "abraham_histories", force: :cascade do |t| t.string 'controller_name'
t.string "controller_name" t.string 'action_name'
t.string "action_name" t.string 'tour_name'
t.string "tour_name" t.integer 'creator_id', null: false
t.integer "creator_id", null: false t.datetime 'created_at', null: false
t.datetime "created_at", null: false t.datetime 'updated_at', null: false
t.datetime "updated_at", null: false t.index ['created_at'], name: 'index_abraham_histories_on_created_at'
t.index ["created_at"], name: "index_abraham_histories_on_created_at" t.index ['creator_id'], name: 'index_abraham_histories_on_creator_id'
t.index ["creator_id"], name: "index_abraham_histories_on_creator_id" t.index ['updated_at'], name: 'index_abraham_histories_on_updated_at'
t.index ["updated_at"], name: "index_abraham_histories_on_updated_at"
end end
end end

View File

@ -1,9 +1,10 @@
# frozen_string_literal: true
require 'test_helper' require 'test_helper'
class AbrahamHistoriesControllerTest < ActionDispatch::IntegrationTest class AbrahamHistoriesControllerTest < ActionDispatch::IntegrationTest
test "should create AbrahamHistory" do test 'should create AbrahamHistory' do
assert_difference ['AbrahamHistory.count'] do assert_difference ['AbrahamHistory.count'] do
post abraham_histories_url, as: :json, params: { abraham_history: { action_name: "foo", controller_name: "bar", tour_name: "baz"} } post abraham_histories_url, as: :json, params: { abraham_history: { action_name: 'foo', controller_name: 'bar', tour_name: 'baz' } }
end end
end end
end end

View File

@ -1,35 +1,36 @@
# frozen_string_literal: true
require 'test_helper' require 'test_helper'
class DashboardControllerTest < ActionDispatch::IntegrationTest class DashboardControllerTest < ActionDispatch::IntegrationTest
test "uses configured shepherd theme" do test 'uses configured shepherd theme' do
# default # default
get dashboard_home_url get dashboard_home_url
assert_response :success assert_response :success
assert_select "body script" do |element| assert_select 'body script' do |element|
# it's the home tour # it's the home tour
assert element.text.include? "classes: 'shepherd-theme-default'" assert element.text.include? "classes: 'shepherd-theme-default'"
end end
# custom # custom
Rails.configuration.abraham.default_theme = "my-custom-theme" Rails.configuration.abraham.default_theme = 'my-custom-theme'
get dashboard_home_url get dashboard_home_url
assert_select "body script" do |element| assert_select 'body script' do |element|
# it's the home tour # it's the home tour
assert element.text.include? "classes: 'my-custom-theme'" assert element.text.include? "classes: 'my-custom-theme'"
end end
end end
test "home should have home tour code" do test 'home should have home tour code' do
get dashboard_home_url get dashboard_home_url
assert_response :success assert_response :success
assert_select "body script" do |element| assert_select 'body script' do |element|
# it's the home tour # it's the home tour
assert element.text.include? "ENGLISH This first HOME step is centered text-only" assert element.text.include? 'ENGLISH This first HOME step is centered text-only'
# it has three steps # it has three steps
assert element.text.include? "step-1" assert element.text.include? 'step-1'
assert element.text.include? "step-2" assert element.text.include? 'step-2'
assert element.text.include? "step-3" assert element.text.include? 'step-3'
# it will post the right completion information # it will post the right completion information
assert element.text.include? "controller_name: 'dashboard'" assert element.text.include? "controller_name: 'dashboard'"
assert element.text.include? "action_name: 'home'" assert element.text.include? "action_name: 'home'"
@ -37,15 +38,15 @@ class DashboardControllerTest < ActionDispatch::IntegrationTest
end end
end end
test "other should have other tour code" do test 'other should have other tour code' do
get dashboard_other_url get dashboard_other_url
assert_response :success assert_response :success
assert_select "body script" do |element| assert_select 'body script' do |element|
# it's the home tour # it's the home tour
assert element.text.include? "TOUR ONE step one ENGLISH" assert element.text.include? 'TOUR ONE step one ENGLISH'
# it has only one steps # it has only one steps
assert element.text.include? "step-1" assert element.text.include? 'step-1'
# it will post the right completion information # it will post the right completion information
assert element.text.include? "controller_name: 'dashboard'" assert element.text.include? "controller_name: 'dashboard'"
assert element.text.include? "action_name: 'other'" assert element.text.include? "action_name: 'other'"

View File

@ -1,48 +1,47 @@
# frozen_string_literal: true
require 'test_helper' require 'test_helper'
require "rails/generators" require 'rails/generators'
require "generators/abraham/install_generator" require 'generators/abraham/install_generator'
class InstallGeneratorTest < Rails::Generators::TestCase class InstallGeneratorTest < Rails::Generators::TestCase
tests Abraham::Generators::InstallGenerator tests Abraham::Generators::InstallGenerator
destination File.expand_path("../../tmp", __FILE__) destination File.expand_path('../../tmp', __FILE__)
setup :prepare_destination setup :prepare_destination
test "should generate a migration" do test 'should generate a migration' do
begin begin
run_generator run_generator
assert_migration "db/migrate/create_abraham_histories" assert_migration 'db/migrate/create_abraham_histories'
ensure ensure
FileUtils.rm_rf self.destination_root FileUtils.rm_rf destination_root
end end
end end
test "should skip the migration when told to do so" do test 'should skip the migration when told to do so' do
begin begin
run_generator ['--skip-migration'] run_generator ['--skip-migration']
assert_no_migration "db/migrate/create_abraham_histories" assert_no_migration 'db/migrate/create_abraham_histories'
ensure ensure
FileUtils.rm_rf self.destination_root FileUtils.rm_rf destination_root
end end
end end
test "should generate an initializer" do test 'should generate an initializer' do
begin begin
run_generator run_generator
assert_file "config/initializers/abraham.rb" assert_file 'config/initializers/abraham.rb'
ensure ensure
FileUtils.rm_rf self.destination_root FileUtils.rm_rf destination_root
end end
end end
test "should skip the initializer when told to do so" do test 'should skip the initializer when told to do so' do
begin begin
run_generator ['--skip-initializer'] run_generator ['--skip-initializer']
assert_no_file "config/initializers/abraham.rb" assert_no_file 'config/initializers/abraham.rb'
ensure ensure
FileUtils.rm_rf self.destination_root FileUtils.rm_rf destination_root
end end
end end
end end

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'test_helper' require 'test_helper'
class NavigationTest < ActionDispatch::IntegrationTest class NavigationTest < ActionDispatch::IntegrationTest
@ -5,4 +6,3 @@ class NavigationTest < ActionDispatch::IntegrationTest
# assert true # assert true
# end # end
end end

View File

@ -1,3 +1,4 @@
# frozen_string_literal: true
require 'test_helper' require 'test_helper'
class AbrahamHistoryTest < ActiveSupport::TestCase class AbrahamHistoryTest < ActiveSupport::TestCase

View File

@ -1,9 +1,10 @@
# frozen_string_literal: true
# Configure Rails Environment # Configure Rails Environment
ENV["RAILS_ENV"] = "test" ENV['RAILS_ENV'] = 'test'
require File.expand_path("../../test/dummy/config/environment.rb", __FILE__) require File.expand_path('../../test/dummy/config/environment.rb', __FILE__)
ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../test/dummy/db/migrate", __FILE__)] ActiveRecord::Migrator.migrations_paths = [File.expand_path('../../test/dummy/db/migrate', __FILE__)]
require "rails/test_help" require 'rails/test_help'
# Filter out Minitest backtrace while allowing backtrace from other libraries # Filter out Minitest backtrace while allowing backtrace from other libraries
# to be shown. # to be shown.