Update: Upgrade to Rails 5.1 to fix security vulnerabilities
Update: Added system tests Update: More specific cookie names to avoid inter-app collisions
This commit is contained in:
parent
03f7d71c32
commit
feb71e47a7
2
.gitignore
vendored
2
.gitignore
vendored
@ -2,6 +2,7 @@
|
||||
capybara-*.html
|
||||
.rspec
|
||||
/log
|
||||
/node_modules
|
||||
/tmp
|
||||
/test/dummy/log
|
||||
/test/dummy/tmp
|
||||
@ -15,6 +16,7 @@ capybara-*.html
|
||||
**.orig
|
||||
rerun.txt
|
||||
pickle-email-*.html
|
||||
yarn-error.log
|
||||
|
||||
# TODO Comment out these rules if you are OK with secrets being uploaded to the repo
|
||||
config/initializers/secret_token.rb
|
||||
|
@ -1 +1 @@
|
||||
2.3.3
|
||||
2.5.3
|
||||
|
21
Gemfile
21
Gemfile
@ -1,20 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
source "http://rubygems.org"
|
||||
source "http://rails-assets.org"
|
||||
source 'http://rubygems.org'
|
||||
|
||||
# Declare your gem's dependencies in abraham.gemspec.
|
||||
# Bundler will treat runtime dependencies like base dependencies, and
|
||||
# development dependencies will be added by default to the :development group.
|
||||
gemspec
|
||||
|
||||
# These rails-assets dependencies need to be added to the developer's Gemfile
|
||||
# since there's no way to specify a source in the gemspec.
|
||||
source "http://rails-assets.org" do
|
||||
gem "rails-assets-js-cookie", "~> 2.1"
|
||||
gem "rails-assets-shepherd.js", "~> 1.8"
|
||||
end
|
||||
|
||||
# Declare any dependencies that are still in development here instead of in
|
||||
# your gemspec. These might include edge Rails or gems from your path or
|
||||
# Git. Remember to move these dependencies to your gemspec before releasing
|
||||
@ -23,5 +14,11 @@ end
|
||||
# To use a debugger
|
||||
# gem 'byebug', group: [:development, :test]
|
||||
|
||||
# Avoid the 'multiple sources' confusion
|
||||
gem "rails-assets-tether", source: "http://rails-assets.org/"
|
||||
group :test do
|
||||
# Adds support for Capybara system testing and selenium driver
|
||||
gem 'capybara', '>= 2.15'
|
||||
gem 'selenium-webdriver'
|
||||
# Easy installation and use of web drivers to run system tests with browsers
|
||||
gem 'webdrivers'
|
||||
gem 'mocha'
|
||||
end
|
||||
|
188
Gemfile.lock
188
Gemfile.lock
@ -2,73 +2,80 @@ PATH
|
||||
remote: .
|
||||
specs:
|
||||
abraham (1.3)
|
||||
jquery-rails
|
||||
rails (~> 5.0, >= 5.0.0.1)
|
||||
rails-assets-js-cookie (~> 2.1)
|
||||
rails-assets-shepherd.js (~> 1.8)
|
||||
sass-rails (~> 5.0)
|
||||
rails (~> 5.1)
|
||||
|
||||
GEM
|
||||
remote: http://rubygems.org/
|
||||
remote: http://rails-assets.org/
|
||||
specs:
|
||||
actioncable (5.2.1)
|
||||
actionpack (= 5.2.1)
|
||||
actioncable (5.2.2.1)
|
||||
actionpack (= 5.2.2.1)
|
||||
nio4r (~> 2.0)
|
||||
websocket-driver (>= 0.6.1)
|
||||
actionmailer (5.2.1)
|
||||
actionpack (= 5.2.1)
|
||||
actionview (= 5.2.1)
|
||||
activejob (= 5.2.1)
|
||||
actionmailer (5.2.2.1)
|
||||
actionpack (= 5.2.2.1)
|
||||
actionview (= 5.2.2.1)
|
||||
activejob (= 5.2.2.1)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
actionpack (5.2.1)
|
||||
actionview (= 5.2.1)
|
||||
activesupport (= 5.2.1)
|
||||
actionpack (5.2.2.1)
|
||||
actionview (= 5.2.2.1)
|
||||
activesupport (= 5.2.2.1)
|
||||
rack (~> 2.0)
|
||||
rack-test (>= 0.6.3)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||
actionview (5.2.1)
|
||||
activesupport (= 5.2.1)
|
||||
actionview (5.2.2.1)
|
||||
activesupport (= 5.2.2.1)
|
||||
builder (~> 3.1)
|
||||
erubi (~> 1.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
||||
activejob (5.2.1)
|
||||
activesupport (= 5.2.1)
|
||||
activejob (5.2.2.1)
|
||||
activesupport (= 5.2.2.1)
|
||||
globalid (>= 0.3.6)
|
||||
activemodel (5.2.1)
|
||||
activesupport (= 5.2.1)
|
||||
activerecord (5.2.1)
|
||||
activemodel (= 5.2.1)
|
||||
activesupport (= 5.2.1)
|
||||
activemodel (5.2.2.1)
|
||||
activesupport (= 5.2.2.1)
|
||||
activerecord (5.2.2.1)
|
||||
activemodel (= 5.2.2.1)
|
||||
activesupport (= 5.2.2.1)
|
||||
arel (>= 9.0)
|
||||
activestorage (5.2.1)
|
||||
actionpack (= 5.2.1)
|
||||
activerecord (= 5.2.1)
|
||||
activestorage (5.2.2.1)
|
||||
actionpack (= 5.2.2.1)
|
||||
activerecord (= 5.2.2.1)
|
||||
marcel (~> 0.3.1)
|
||||
activesupport (5.2.1)
|
||||
activesupport (5.2.2.1)
|
||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||
i18n (>= 0.7, < 2)
|
||||
minitest (~> 5.1)
|
||||
tzinfo (~> 1.1)
|
||||
addressable (2.6.0)
|
||||
public_suffix (>= 2.0.2, < 4.0)
|
||||
arel (9.0.0)
|
||||
ast (2.4.0)
|
||||
builder (3.2.3)
|
||||
concurrent-ruby (1.1.2)
|
||||
capybara (3.15.0)
|
||||
addressable
|
||||
mini_mime (>= 0.1.3)
|
||||
nokogiri (~> 1.8)
|
||||
rack (>= 1.6.0)
|
||||
rack-test (>= 0.6.3)
|
||||
regexp_parser (~> 1.2)
|
||||
xpath (~> 3.2)
|
||||
childprocess (0.9.0)
|
||||
ffi (~> 1.0, >= 1.0.11)
|
||||
concurrent-ruby (1.1.5)
|
||||
crass (1.0.4)
|
||||
erubi (1.7.1)
|
||||
ffi (1.9.25)
|
||||
globalid (0.4.1)
|
||||
erubi (1.8.0)
|
||||
ffi (1.10.0)
|
||||
globalid (0.4.2)
|
||||
activesupport (>= 4.2.0)
|
||||
i18n (1.1.1)
|
||||
i18n (1.6.0)
|
||||
concurrent-ruby (~> 1.0)
|
||||
jaro_winkler (1.5.1)
|
||||
jquery-rails (4.3.3)
|
||||
rails-dom-testing (>= 1, < 3)
|
||||
railties (>= 4.2.0)
|
||||
thor (>= 0.14, < 2.0)
|
||||
listen (3.1.5)
|
||||
rb-fsevent (~> 0.9, >= 0.9.4)
|
||||
rb-inotify (~> 0.9, >= 0.9.7)
|
||||
ruby_dep (~> 1.2)
|
||||
loofah (2.2.3)
|
||||
crass (~> 1.0.2)
|
||||
nokogiri (>= 1.5.9)
|
||||
@ -76,74 +83,79 @@ GEM
|
||||
mini_mime (>= 0.1.1)
|
||||
marcel (0.3.3)
|
||||
mimemagic (~> 0.3.2)
|
||||
method_source (0.9.1)
|
||||
mimemagic (0.3.2)
|
||||
metaclass (0.0.4)
|
||||
method_source (0.9.2)
|
||||
mimemagic (0.3.3)
|
||||
mini_mime (1.0.1)
|
||||
mini_portile2 (2.3.0)
|
||||
mini_portile2 (2.4.0)
|
||||
minitest (5.11.3)
|
||||
mocha (1.8.0)
|
||||
metaclass (~> 0.0.1)
|
||||
net_http_ssl_fix (0.0.10)
|
||||
nio4r (2.3.1)
|
||||
nokogiri (1.8.5)
|
||||
mini_portile2 (~> 2.3.0)
|
||||
nokogiri (1.10.2)
|
||||
mini_portile2 (~> 2.4.0)
|
||||
parallel (1.12.1)
|
||||
parser (2.5.3.0)
|
||||
parser (2.5.1.2)
|
||||
ast (~> 2.4.0)
|
||||
powerpack (0.1.2)
|
||||
public_suffix (3.0.3)
|
||||
rack (2.0.6)
|
||||
rack-test (1.1.0)
|
||||
rack (>= 1.0, < 3)
|
||||
rails (5.2.1)
|
||||
actioncable (= 5.2.1)
|
||||
actionmailer (= 5.2.1)
|
||||
actionpack (= 5.2.1)
|
||||
actionview (= 5.2.1)
|
||||
activejob (= 5.2.1)
|
||||
activemodel (= 5.2.1)
|
||||
activerecord (= 5.2.1)
|
||||
activestorage (= 5.2.1)
|
||||
activesupport (= 5.2.1)
|
||||
rails (5.2.2.1)
|
||||
actioncable (= 5.2.2.1)
|
||||
actionmailer (= 5.2.2.1)
|
||||
actionpack (= 5.2.2.1)
|
||||
actionview (= 5.2.2.1)
|
||||
activejob (= 5.2.2.1)
|
||||
activemodel (= 5.2.2.1)
|
||||
activerecord (= 5.2.2.1)
|
||||
activestorage (= 5.2.2.1)
|
||||
activesupport (= 5.2.2.1)
|
||||
bundler (>= 1.3.0)
|
||||
railties (= 5.2.1)
|
||||
railties (= 5.2.2.1)
|
||||
sprockets-rails (>= 2.0.0)
|
||||
rails-assets-js-cookie (2.2.0)
|
||||
rails-assets-shepherd.js (1.8.1)
|
||||
rails-assets-tether (>= 1.0.1, < 2)
|
||||
rails-assets-tether (1.4.3)
|
||||
rails-dom-testing (2.0.3)
|
||||
activesupport (>= 4.2.0)
|
||||
nokogiri (>= 1.6)
|
||||
rails-html-sanitizer (1.0.4)
|
||||
loofah (~> 2.2, >= 2.2.2)
|
||||
railties (5.2.1)
|
||||
actionpack (= 5.2.1)
|
||||
activesupport (= 5.2.1)
|
||||
railties (5.2.2.1)
|
||||
actionpack (= 5.2.2.1)
|
||||
activesupport (= 5.2.2.1)
|
||||
method_source
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.19.0, < 2.0)
|
||||
rainbow (3.0.0)
|
||||
rake (12.3.1)
|
||||
rake (12.3.2)
|
||||
rb-fsevent (0.10.3)
|
||||
rb-inotify (0.9.10)
|
||||
ffi (>= 0.5.0, < 2)
|
||||
rubocop (0.60.0)
|
||||
rb-inotify (0.10.0)
|
||||
ffi (~> 1.0)
|
||||
regexp_parser (1.3.0)
|
||||
rubocop (0.59.2)
|
||||
jaro_winkler (~> 1.5.1)
|
||||
parallel (~> 1.10)
|
||||
parser (>= 2.5, != 2.5.1.1)
|
||||
powerpack (~> 0.1)
|
||||
rainbow (>= 2.2.2, < 4.0)
|
||||
ruby-progressbar (~> 1.7)
|
||||
unicode-display_width (~> 1.4.0)
|
||||
unicode-display_width (~> 1.0, >= 1.0.1)
|
||||
ruby-progressbar (1.10.0)
|
||||
sass (3.6.0)
|
||||
sass-listen (~> 4.0.0)
|
||||
sass-listen (4.0.0)
|
||||
rb-fsevent (~> 0.9, >= 0.9.4)
|
||||
rb-inotify (~> 0.9, >= 0.9.7)
|
||||
sass-rails (5.0.7)
|
||||
railties (>= 4.0.0, < 6)
|
||||
sass (~> 3.1)
|
||||
sprockets (>= 2.8, < 4.0)
|
||||
sprockets-rails (>= 2.0, < 4.0)
|
||||
tilt (>= 1.1, < 3)
|
||||
ruby_dep (1.5.0)
|
||||
rubyzip (1.2.2)
|
||||
sassc (2.0.1)
|
||||
ffi (~> 1.9)
|
||||
rake
|
||||
sassc-rails (2.1.0)
|
||||
railties (>= 4.0.0)
|
||||
sassc (>= 2.0)
|
||||
sprockets (> 3.0)
|
||||
sprockets-rails
|
||||
tilt
|
||||
selenium-webdriver (3.141.0)
|
||||
childprocess (~> 0.5)
|
||||
rubyzip (~> 1.2, >= 1.2.2)
|
||||
sprockets (3.7.2)
|
||||
concurrent-ruby (~> 1.0)
|
||||
rack (> 1, < 3)
|
||||
@ -152,26 +164,36 @@ GEM
|
||||
activesupport (>= 4.0)
|
||||
sprockets (>= 3.0.0)
|
||||
sqlite3 (1.3.13)
|
||||
thor (0.20.0)
|
||||
thor (0.20.3)
|
||||
thread_safe (0.3.6)
|
||||
tilt (2.0.8)
|
||||
tilt (2.0.9)
|
||||
tzinfo (1.2.5)
|
||||
thread_safe (~> 0.1)
|
||||
unicode-display_width (1.4.0)
|
||||
webdrivers (3.7.1)
|
||||
net_http_ssl_fix
|
||||
nokogiri (~> 1.6)
|
||||
rubyzip (~> 1.0)
|
||||
selenium-webdriver (~> 3.0)
|
||||
websocket-driver (0.7.0)
|
||||
websocket-extensions (>= 0.1.0)
|
||||
websocket-extensions (0.1.3)
|
||||
xpath (3.2.0)
|
||||
nokogiri (~> 1.8)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
abraham!
|
||||
rails-assets-js-cookie (~> 2.1)!
|
||||
rails-assets-shepherd.js (~> 1.8)!
|
||||
rails-assets-tether!
|
||||
capybara (>= 2.15)
|
||||
listen
|
||||
mocha
|
||||
rubocop
|
||||
sassc-rails
|
||||
selenium-webdriver
|
||||
sqlite3
|
||||
webdrivers
|
||||
|
||||
BUNDLED WITH
|
||||
1.17.1
|
||||
1.17.3
|
||||
|
15
README.md
15
README.md
@ -16,22 +16,25 @@ Abraham needs to know the current user to track tour views, e.g. `current_user`
|
||||
|
||||
## Installation
|
||||
|
||||
Add `abraham` and its JavaScript dependencies to your Gemfile:
|
||||
Add `abraham` to your Gemfile:
|
||||
|
||||
```
|
||||
gem 'abraham'
|
||||
|
||||
source 'https://rails-assets.org' do
|
||||
gem 'rails-assets-shepherd.js', '~> 1.8'
|
||||
gem 'rails-assets-js-cookie', '~> 2.1'
|
||||
end
|
||||
```
|
||||
|
||||
Then run:
|
||||
Install the gem and run the installer:
|
||||
|
||||
```
|
||||
$ bundle install
|
||||
$ rails generate abraham:install
|
||||
$ rails db:migrate
|
||||
```
|
||||
|
||||
Install the JavaScript dependencies:
|
||||
|
||||
```
|
||||
$ yarn add jquery js-cookie shepherd.js
|
||||
```
|
||||
|
||||
Require `abraham` in `app/assets/javascripts/application.js`
|
||||
|
@ -18,12 +18,10 @@ Gem::Specification.new do |s|
|
||||
|
||||
s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"]
|
||||
|
||||
s.add_dependency "jquery-rails"
|
||||
s.add_dependency "rails", "~> 5.0", ">= 5.0.0.1"
|
||||
s.add_dependency "rails-assets-js-cookie", "~> 2.1"
|
||||
s.add_dependency "rails-assets-shepherd.js", "~> 1.8"
|
||||
s.add_dependency "sass-rails", "~> 5.0"
|
||||
s.add_dependency 'rails', '~> 5.1'
|
||||
|
||||
s.add_development_dependency "rubocop"
|
||||
s.add_development_dependency "sqlite3"
|
||||
s.add_development_dependency 'sassc-rails'
|
||||
s.add_development_dependency 'sqlite3'
|
||||
s.add_development_dependency 'rubocop'
|
||||
s.add_development_dependency 'listen'
|
||||
end
|
||||
|
@ -1,8 +1,6 @@
|
||||
//= require jquery
|
||||
//= require jquery_ujs
|
||||
//= require js-cookie
|
||||
//= require tether
|
||||
//= require shepherd.js.js
|
||||
//= require js-cookie/src/js.cookie
|
||||
//= require shepherd.js/dist/js/shepherd
|
||||
|
||||
$(document).on('turbolinks:before-cache', function() {
|
||||
// Remove visible product tours
|
||||
|
@ -23,4 +23,12 @@ module AbrahamHelper
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def abraham_cookie_prefix
|
||||
"abraham-#{Rails.application.class.parent.to_s.underscore}-#{current_user.id}-#{controller_name}-#{action_name}"
|
||||
end
|
||||
|
||||
def abraham_domain
|
||||
request.host
|
||||
end
|
||||
end
|
||||
|
@ -13,6 +13,7 @@
|
||||
dataType: "json",
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify({
|
||||
authenticity_token: '<%= form_authenticity_token %>',
|
||||
controller_name: '<%= controller_name %>',
|
||||
action_name: '<%= action_name %>',
|
||||
tour_name: '<%= tour_name %>'
|
||||
@ -21,7 +22,7 @@
|
||||
});
|
||||
|
||||
tour.on("cancel", function() {
|
||||
Cookies.set('abraham-<%= controller_name %>-<%= action_name %>-<%= tour_name %>', 'later');
|
||||
Cookies.set('<%= abraham_cookie_prefix %>-<%= tour_name %>', 'later', { domain: '<%= abraham_domain %>' });
|
||||
});
|
||||
|
||||
<% steps.each_with_index do |(key, step), index| %>
|
||||
@ -54,7 +55,7 @@
|
||||
<% end %>
|
||||
|
||||
// Don't start the tour if the user dismissed it once this session
|
||||
if (!Cookies.get('abraham-<%= controller_name %>-<%= action_name %>-<%= tour_name %>')) {
|
||||
if (!Cookies.get('<%= abraham_cookie_prefix %>-<%= tour_name %>', { domain: '<%= abraham_domain %>' })) {
|
||||
tour.start();
|
||||
}
|
||||
</script>
|
||||
|
@ -4,8 +4,5 @@ require "rubygems"
|
||||
|
||||
module Abraham
|
||||
class Engine < ::Rails::Engine
|
||||
require "rails-assets-shepherd.js"
|
||||
require "jquery-rails"
|
||||
require "rails-assets-js-cookie"
|
||||
end
|
||||
end
|
||||
|
9
package.json
Normal file
9
package.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"name": "abraham",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"jquery": "^3.3.1",
|
||||
"js-cookie": "^2.2.0",
|
||||
"shepherd.js": "^2.5.0"
|
||||
}
|
||||
}
|
20
test/application_system_test_case.rb
Normal file
20
test/application_system_test_case.rb
Normal file
@ -0,0 +1,20 @@
|
||||
require "test_helper"
|
||||
require "webdrivers"
|
||||
|
||||
Capybara.server = :webrick
|
||||
|
||||
Capybara.register_driver(:headless_chrome) do |app|
|
||||
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
|
||||
chromeOptions: { args: %w[headless disable-gpu] }
|
||||
)
|
||||
|
||||
Capybara::Selenium::Driver.new(
|
||||
app,
|
||||
browser: :chrome,
|
||||
desired_capabilities: capabilities
|
||||
)
|
||||
end
|
||||
|
||||
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
|
||||
driven_by :selenium, using: :chrome, screen_size: [1400, 1400]
|
||||
end
|
@ -12,4 +12,4 @@
|
||||
*
|
||||
*= require "shepherd.js/dist/css/shepherd-theme-default"
|
||||
*= require_tree .
|
||||
*/
|
||||
*/
|
@ -12,5 +12,7 @@ module Dummy
|
||||
# Settings in config/environments/* take precedence over those specified here.
|
||||
# Application configuration should go into files in config/initializers
|
||||
# -- all .rb files in that directory are automatically loaded.
|
||||
|
||||
config.active_record.sqlite3.represent_boolean_as_integer = true
|
||||
end
|
||||
end
|
||||
|
@ -6,4 +6,5 @@ test:
|
||||
|
||||
production:
|
||||
adapter: redis
|
||||
url: redis://localhost:6379/1
|
||||
url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
|
||||
channel_prefix: dummy_production
|
@ -52,5 +52,5 @@ Rails.application.configure do
|
||||
|
||||
# Use an evented file watcher to asynchronously detect changes in source code,
|
||||
# routes, locales, etc. This feature depends on the listen gem.
|
||||
# config.file_watcher = ActiveSupport::EventedFileUpdateChecker
|
||||
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
|
||||
end
|
||||
|
@ -8,6 +8,9 @@ Rails.application.config.assets.version = "1.0"
|
||||
# Add additional assets to the asset load path
|
||||
# Rails.application.config.assets.paths << Emoji.images_path
|
||||
|
||||
# Add Yarn node_modules folder to the asset load path.
|
||||
Rails.application.config.assets.paths << Rails.root.join('../../node_modules')
|
||||
|
||||
# Precompile additional assets.
|
||||
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
|
||||
# Rails.application.config.assets.precompile += %w( search.js )
|
||||
|
@ -4,4 +4,4 @@
|
||||
|
||||
# Specify a serializer for the signed and encrypted cookie jars.
|
||||
# Valid options are :json, :marshal, and :hybrid.
|
||||
Rails.application.config.action_dispatch.cookies_serializer = :json
|
||||
Rails.application.config.action_dispatch.cookies_serializer = :marshal
|
@ -19,8 +19,5 @@ ActiveSupport.to_time_preserves_timezone = true
|
||||
# Require `belongs_to` associations by default. Previous versions had false.
|
||||
Rails.application.config.active_record.belongs_to_required_by_default = true
|
||||
|
||||
# Do not halt callback chains when a callback returns false. Previous versions had true.
|
||||
ActiveSupport.halt_callback_chains_on_return_false = false
|
||||
|
||||
# Configure SSL options to enable HSTS with subdomains. Previous versions had false.
|
||||
Rails.application.config.ssl_options = { hsts: { subdomains: true } }
|
||||
|
@ -16,6 +16,16 @@
|
||||
#
|
||||
# This would use the information in config/locales/es.yml.
|
||||
#
|
||||
# The following keys must be escaped otherwise they will not be retrieved by
|
||||
# the default I18n backend:
|
||||
#
|
||||
# true, false, on, off, yes, no
|
||||
#
|
||||
# Instead, surround them with single quotes.
|
||||
#
|
||||
# en:
|
||||
# 'true': 'foo'
|
||||
#
|
||||
# To learn more, please read the Rails Internationalization guide
|
||||
# available at http://guides.rubyonrails.org/i18n.html.
|
||||
|
||||
|
@ -12,16 +12,18 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20_161_118_143_752) do
|
||||
ActiveRecord::Schema.define(version: 2016_11_18_143752) do
|
||||
|
||||
create_table "abraham_histories", force: :cascade do |t|
|
||||
t.string "controller_name"
|
||||
t.string "action_name"
|
||||
t.string "tour_name"
|
||||
t.integer "creator_id", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.string "controller_name"
|
||||
t.string "action_name"
|
||||
t.string "tour_name"
|
||||
t.integer "creator_id", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["created_at"], name: "index_abraham_histories_on_created_at"
|
||||
t.index ["creator_id"], name: "index_abraham_histories_on_creator_id"
|
||||
t.index ["updated_at"], name: "index_abraham_histories_on_updated_at"
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -3,6 +3,14 @@
|
||||
require "test_helper"
|
||||
|
||||
class DashboardControllerTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
I18n.locale = :en
|
||||
end
|
||||
|
||||
teardown do
|
||||
I18n.locale = :en
|
||||
end
|
||||
|
||||
test "uses configured shepherd theme" do
|
||||
# default
|
||||
get dashboard_home_url
|
||||
@ -42,6 +50,17 @@ class DashboardControllerTest < ActionDispatch::IntegrationTest
|
||||
end
|
||||
end
|
||||
|
||||
test "should show tour for locale" do
|
||||
I18n.locale = :es
|
||||
get dashboard_home_url
|
||||
assert_response :success
|
||||
|
||||
assert_select 'body script' do |element|
|
||||
# it's the spanish home tour
|
||||
assert element.text.include? 'SPANISH This first HOME step is centered text-only'
|
||||
end
|
||||
end
|
||||
|
||||
test "other should have other tour code" do
|
||||
get dashboard_other_url
|
||||
assert_response :success
|
||||
|
66
test/dummy/test/system/tours_test.rb
Normal file
66
test/dummy/test/system/tours_test.rb
Normal file
@ -0,0 +1,66 @@
|
||||
require "application_system_test_case"
|
||||
|
||||
class ToursTest < ApplicationSystemTestCase
|
||||
setup do
|
||||
@user_id = Random.rand(1..99999)
|
||||
@cookie_name = "abraham-dummy-#{@user_id}-dashboard-home-intro"
|
||||
ApplicationController.any_instance.stubs(:current_user).returns(OpenStruct.new(id: @user_id))
|
||||
end
|
||||
|
||||
test "see and complete a tour" do
|
||||
visit dashboard_home_url
|
||||
|
||||
# Tour Step 1
|
||||
assert_selector ".shepherd-element", visible: true
|
||||
assert_selector ".shepherd-text", text: "ENGLISH This first HOME step is centered text-only"
|
||||
assert_selector ".shepherd-button", text: "LATER"
|
||||
assert_selector ".shepherd-button", text: "CONTINUE"
|
||||
find(".shepherd-button", text: "CONTINUE").click
|
||||
|
||||
# Tour Step 2
|
||||
assert_selector ".shepherd-header", text: "ENGLISH This step has a title"
|
||||
assert_selector ".shepherd-text", text: "ENGLISH This intermediate step has some text"
|
||||
assert_selector ".shepherd-button", text: "EXIT"
|
||||
assert_selector ".shepherd-button", text: "NEXT"
|
||||
find(".shepherd-button", text: "NEXT").click
|
||||
|
||||
# Tour Step 3 (should be skipped)
|
||||
refute_selector ".shepherd-header", text: "ENGLISH A missing step"
|
||||
|
||||
# Tour Step 4
|
||||
assert_selector ".shepherd-header", text: "ENGLISH The final step"
|
||||
assert_selector ".shepherd-text", text: "ENGLISH Some text here too, and it's attached to the right"
|
||||
assert_selector ".tippy-arrow", visible: true
|
||||
assert_selector ".shepherd-button", text: "DONE"
|
||||
find(".shepherd-button", text: "DONE").click
|
||||
|
||||
# Tour should no longer be visible
|
||||
refute_selector ".shepherd-element"
|
||||
|
||||
# Tour should not reappear on reload
|
||||
visit dashboard_home_url
|
||||
refute_selector ".shepherd-element"
|
||||
end
|
||||
|
||||
test "mark a tour for later and it will not come back in this session" do
|
||||
visit dashboard_home_url
|
||||
assert_selector ".shepherd-element", visible: true
|
||||
|
||||
# Dismiss tour
|
||||
find(".shepherd-button", text: "LATER").click
|
||||
|
||||
# Tour should no longer be visible
|
||||
refute_selector ".shepherd-element"
|
||||
|
||||
# Tour should not reappear on reload
|
||||
visit dashboard_home_url
|
||||
refute_selector ".shepherd-element"
|
||||
|
||||
# Clear the cookie (simulate browser restart)
|
||||
execute_script("Cookies.remove('#{@cookie_name}', { domain: '127.0.0.1' });")
|
||||
|
||||
# Tour should reappear
|
||||
visit dashboard_home_url
|
||||
assert_selector ".shepherd-element", visible: true
|
||||
end
|
||||
end
|
@ -1,9 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "test_helper"
|
||||
|
||||
class NavigationTest < ActionDispatch::IntegrationTest
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
@ -3,9 +3,10 @@
|
||||
# Configure Rails Environment
|
||||
ENV["RAILS_ENV"] = "test"
|
||||
|
||||
require File.expand_path("../test/dummy/config/environment.rb", __dir__)
|
||||
ActiveRecord::Migrator.migrations_paths = [File.expand_path("../test/dummy/db/migrate", __dir__)]
|
||||
require "rails/test_help"
|
||||
require File.expand_path('../dummy/config/environment.rb', __FILE__)
|
||||
ActiveRecord::Migrator.migrations_paths = [File.expand_path('../dummy/db/migrate', __FILE__)]
|
||||
require 'rails/test_help'
|
||||
require 'mocha/minitest'
|
||||
|
||||
# Filter out Minitest backtrace while allowing backtrace from other libraries
|
||||
# to be shown.
|
||||
|
45
yarn.lock
Normal file
45
yarn.lock
Normal file
@ -0,0 +1,45 @@
|
||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
element-matches@^0.1.2:
|
||||
version "0.1.2"
|
||||
resolved "https://registry.yarnpkg.com/element-matches/-/element-matches-0.1.2.tgz#7345cb71e965bd2b12f725e524591c102198361a"
|
||||
integrity sha512-yWh1otcs3OKUWDvu/IxyI36ZI3WNaRZlI0uG/DK6fu0pap0VYZ0J5pEGTk1zakme+hT0OKHwhlHc0N5TJhY6yQ==
|
||||
|
||||
jquery@^3.3.1:
|
||||
version "3.3.1"
|
||||
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.3.1.tgz#958ce29e81c9790f31be7792df5d4d95fc57fbca"
|
||||
integrity sha512-Ubldcmxp5np52/ENotGxlLe6aGMvmF4R8S6tZjsP6Knsaxd/xp3Zrh50cG93lR6nPXyUFwzN3ZSOQI0wRJNdGg==
|
||||
|
||||
js-cookie@^2.2.0:
|
||||
version "2.2.0"
|
||||
resolved "https://registry.yarnpkg.com/js-cookie/-/js-cookie-2.2.0.tgz#1b2c279a6eece380a12168b92485265b35b1effb"
|
||||
integrity sha1-Gywnmm7s44ChIWi5JIUmWzWx7/s=
|
||||
|
||||
lodash-es@^4.17.11:
|
||||
version "4.17.11"
|
||||
resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.11.tgz#145ab4a7ac5c5e52a3531fb4f310255a152b4be0"
|
||||
integrity sha512-DHb1ub+rMjjrxqlB3H56/6MXtm1lSksDp2rA2cNWjG8mlDUYFhUj3Di2Zn5IwSU87xLv8tNIQ7sSwE/YOX/D/Q==
|
||||
|
||||
popper.js@^1.14.7:
|
||||
version "1.14.7"
|
||||
resolved "https://registry.yarnpkg.com/popper.js/-/popper.js-1.14.7.tgz#e31ec06cfac6a97a53280c3e55e4e0c860e7738e"
|
||||
integrity sha512-4q1hNvoUre/8srWsH7hnoSJ5xVmIL4qgz+s4qf2TnJIMyZFUFMGH+9vE7mXynAlHSZ/NdTmmow86muD0myUkVQ==
|
||||
|
||||
shepherd.js@^2.5.0:
|
||||
version "2.5.0"
|
||||
resolved "https://registry.yarnpkg.com/shepherd.js/-/shepherd.js-2.5.0.tgz#c8fdc1fbaff55f1e021c930178d0e2b1cea7a7e3"
|
||||
integrity sha512-DesuIO0wqlCWP6tWU/g5Qt//OfapVEamnvLBWwCBUB/AbrPtWomngi7MJmmkulTJGQz8F6FGnc3TSXK6bM9cOA==
|
||||
dependencies:
|
||||
element-matches "^0.1.2"
|
||||
lodash-es "^4.17.11"
|
||||
popper.js "^1.14.7"
|
||||
tippy.js "^4.0.1"
|
||||
|
||||
tippy.js@^4.0.1:
|
||||
version "4.2.0"
|
||||
resolved "https://registry.yarnpkg.com/tippy.js/-/tippy.js-4.2.0.tgz#68387485cbc5d30ad5416bb01a20e63548898145"
|
||||
integrity sha512-+WZRGtpIusZeJdZB2W5/rmOsT+6t3ASiQP0gln/OW1c+Goc6lx4vf+3i3KAJO875y7Vc1hGmFgyAMHor/eISBQ==
|
||||
dependencies:
|
||||
popper.js "^1.14.7"
|
Loading…
x
Reference in New Issue
Block a user