token_action 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +1 -1
- data/README.md +11 -18
- data/Rakefile +13 -4
- data/app/controllers/token_action/tokens_controller.rb +19 -11
- data/config/routes.rb +1 -1
- data/lib/generators/active_record/templates/migration.rb +1 -1
- data/lib/generators/templates/README +1 -1
- data/lib/token_action.rb +2 -2
- data/lib/token_action/{mixins → concerns}/model.rb +0 -0
- data/lib/token_action/{mixins → concerns}/token_generator.rb +0 -0
- data/lib/token_action/orm/mongoid.rb +6 -6
- data/lib/token_action/version.rb +1 -1
- data/spec/controllers/token_action/tokens_controller_spec.rb +159 -157
- data/spec/dummy/Rakefile +1 -2
- data/spec/dummy/app/assets/javascripts/application.js +4 -4
- data/spec/dummy/app/assets/stylesheets/application.css +6 -4
- data/spec/dummy/app/controllers/application_controller.rb +3 -1
- data/spec/dummy/app/controllers/hello_controller.rb +6 -6
- data/spec/dummy/app/mongoid/cat.rb +1 -1
- data/spec/dummy/app/views/layouts/application.html.erb +2 -2
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +29 -0
- data/spec/dummy/config.ru +2 -2
- data/spec/dummy/config/application.rb +11 -42
- data/spec/dummy/config/boot.rb +4 -9
- data/spec/dummy/config/database.yml +14 -7
- data/spec/dummy/config/environment.rb +3 -3
- data/spec/dummy/config/environments/development.rb +22 -18
- data/spec/dummy/config/environments/production.rb +46 -34
- data/spec/dummy/config/environments/test.rb +18 -17
- data/spec/dummy/config/initializers/assets.rb +11 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/session_store.rb +1 -6
- data/spec/dummy/config/initializers/wrap_parameters.rb +6 -6
- data/spec/dummy/config/locales/en.yml +20 -2
- data/spec/dummy/config/mongoid.yml +4 -60
- data/spec/dummy/config/routes.rb +6 -6
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/db/migrate/20130104151630_create_token_action_tokens.rb +1 -1
- data/spec/dummy/db/schema.rb +32 -0
- data/spec/dummy/{db/development.sqlite3 → log/.keep} +0 -0
- data/spec/dummy/public/404.html +54 -13
- data/spec/dummy/public/422.html +54 -13
- data/spec/dummy/public/500.html +53 -12
- data/spec/factories.rb +1 -1
- data/spec/rails_helper.rb +102 -0
- data/spec/routing/token_action/tokens_routing_spec.rb +23 -23
- data/spec/spec_helper.rb +85 -87
- data/spec/token_action/concerns/model_spec.rb +14 -0
- data/spec/token_action/concerns/token_generator_spec.rb +13 -0
- data/spec/token_action/orm/active_record_spec.rb +4 -2
- data/spec/token_action/orm/mongoid_spec.rb +4 -2
- data/spec/token_action_spec.rb +9 -9
- metadata +109 -158
- data/spec/dummy/config/initializers/secret_token.rb +0 -7
- data/spec/dummy/log/development.log +0 -16
- data/spec/dummy/log/test.log +0 -4739
- data/spec/dummy/script/rails +0 -6
- data/spec/token_action/mixins/model_spec.rb +0 -13
- data/spec/token_action/mixins/token_generator_spec.rb +0 -11
data/spec/dummy/Rakefile
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
#!/usr/bin/env rake
|
2
1
|
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
3
2
|
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
4
3
|
|
5
4
|
require File.expand_path('../config/application', __FILE__)
|
6
5
|
|
7
|
-
|
6
|
+
Rails.application.load_tasks
|
@@ -2,12 +2,12 @@
|
|
2
2
|
// listed below.
|
3
3
|
//
|
4
4
|
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
-
// or vendor/assets/javascripts
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
6
|
//
|
7
7
|
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
-
//
|
8
|
+
// compiled file.
|
9
9
|
//
|
10
|
-
//
|
11
|
-
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
12
|
//
|
13
13
|
//= require_tree .
|
@@ -3,11 +3,13 @@
|
|
3
3
|
* listed below.
|
4
4
|
*
|
5
5
|
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
-
* or vendor/assets/stylesheets
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
7
|
*
|
8
|
-
* You're free to add application-wide styles to this file and they'll appear at the
|
9
|
-
* compiled file
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
+
* file per style scope.
|
10
12
|
*
|
11
|
-
*= require_self
|
12
13
|
*= require_tree .
|
14
|
+
*= require_self
|
13
15
|
*/
|
@@ -1,25 +1,25 @@
|
|
1
1
|
class HelloController < ApplicationController
|
2
2
|
def hello
|
3
|
-
render :
|
3
|
+
render text: 'Hello, world'
|
4
4
|
end
|
5
5
|
|
6
6
|
def token_success
|
7
|
-
render :
|
7
|
+
render nothing: true
|
8
8
|
end
|
9
9
|
|
10
10
|
def token_failure
|
11
|
-
render :
|
11
|
+
render nothing: true
|
12
12
|
end
|
13
13
|
|
14
14
|
def success
|
15
|
-
render :
|
15
|
+
render nothing: true
|
16
16
|
end
|
17
17
|
|
18
18
|
def failure
|
19
|
-
render :
|
19
|
+
render nothing: true
|
20
20
|
end
|
21
21
|
|
22
22
|
def not_found
|
23
|
-
render :
|
23
|
+
render nothing: true
|
24
24
|
end
|
25
25
|
end
|
@@ -2,8 +2,8 @@
|
|
2
2
|
<html>
|
3
3
|
<head>
|
4
4
|
<title>Dummy</title>
|
5
|
-
<%= stylesheet_link_tag
|
6
|
-
<%= javascript_include_tag
|
5
|
+
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
|
6
|
+
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
|
7
7
|
<%= csrf_meta_tags %>
|
8
8
|
</head>
|
9
9
|
<body>
|
data/spec/dummy/bin/rake
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
# path to your application root.
|
5
|
+
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
6
|
+
|
7
|
+
Dir.chdir APP_ROOT do
|
8
|
+
# This script is a starting point to setup your application.
|
9
|
+
# Add necessary setup steps to this file:
|
10
|
+
|
11
|
+
puts "== Installing dependencies =="
|
12
|
+
system "gem install bundler --conservative"
|
13
|
+
system "bundle check || bundle install"
|
14
|
+
|
15
|
+
# puts "\n== Copying sample files =="
|
16
|
+
# unless File.exist?("config/database.yml")
|
17
|
+
# system "cp config/database.yml.sample config/database.yml"
|
18
|
+
# end
|
19
|
+
|
20
|
+
puts "\n== Preparing database =="
|
21
|
+
system "bin/rake db:setup"
|
22
|
+
|
23
|
+
puts "\n== Removing old logs and tempfiles =="
|
24
|
+
system "rm -f log/*"
|
25
|
+
system "rm -rf tmp/cache"
|
26
|
+
|
27
|
+
puts "\n== Restarting application server =="
|
28
|
+
system "touch tmp/restart.txt"
|
29
|
+
end
|
data/spec/dummy/config.ru
CHANGED
@@ -2,17 +2,16 @@ require File.expand_path('../boot', __FILE__)
|
|
2
2
|
|
3
3
|
require "action_controller/railtie"
|
4
4
|
require "action_mailer/railtie"
|
5
|
-
require "active_resource/railtie"
|
6
5
|
require "sprockets/railtie"
|
7
6
|
|
8
|
-
Bundler.require
|
7
|
+
Bundler.require(*Rails.groups)
|
9
8
|
require "token_action"
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
require "
|
14
|
-
|
15
|
-
|
10
|
+
case TOKEN_ACTION_ORM
|
11
|
+
when :active_record
|
12
|
+
require "active_record/railtie"
|
13
|
+
when :mongoid
|
14
|
+
require "mongoid"
|
16
15
|
end
|
17
16
|
|
18
17
|
module Dummy
|
@@ -24,16 +23,6 @@ module Dummy
|
|
24
23
|
# Application configuration should go into files in config/initializers
|
25
24
|
# -- all .rb files in that directory are automatically loaded.
|
26
25
|
|
27
|
-
# Custom directories with classes and modules you want to be autoloadable.
|
28
|
-
# config.autoload_paths += %W(#{config.root}/extras)
|
29
|
-
|
30
|
-
# Only load the plugins named here, in the order given (default is alphabetical).
|
31
|
-
# :all can be used as a placeholder for all plugins not explicitly named.
|
32
|
-
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
33
|
-
|
34
|
-
# Activate observers that should always be running.
|
35
|
-
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
36
|
-
|
37
26
|
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
38
27
|
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
39
28
|
# config.time_zone = 'Central Time (US & Canada)'
|
@@ -42,30 +31,10 @@ module Dummy
|
|
42
31
|
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
43
32
|
# config.i18n.default_locale = :de
|
44
33
|
|
45
|
-
#
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
config.filter_parameters += [:password]
|
50
|
-
|
51
|
-
# Enable escaping HTML in JSON.
|
52
|
-
config.active_support.escape_html_entities_in_json = true
|
53
|
-
|
54
|
-
# Use SQL instead of Active Record's schema dumper when creating the database.
|
55
|
-
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
56
|
-
# like if you have constraints or database-specific column types
|
57
|
-
# config.active_record.schema_format = :sql
|
58
|
-
|
59
|
-
# Enforce whitelist mode for mass assignment.
|
60
|
-
# This will create an empty whitelist of attributes available for mass-assignment for all models
|
61
|
-
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
|
62
|
-
# parameters by using an attr_accessible or attr_protected declaration.
|
63
|
-
# config.active_record.whitelist_attributes = true
|
64
|
-
|
65
|
-
# Enable the asset pipeline
|
66
|
-
config.assets.enabled = true
|
67
|
-
|
68
|
-
# Version of your assets, change this if you want to expire all your assets
|
69
|
-
config.assets.version = '1.0'
|
34
|
+
# Do not swallow errors in after_commit/after_rollback callbacks.
|
35
|
+
if TOKEN_ACTION_ORM == :active_record
|
36
|
+
config.active_record.raise_in_transactional_callbacks = true
|
37
|
+
end
|
70
38
|
end
|
71
39
|
end
|
40
|
+
|
data/spec/dummy/config/boot.rb
CHANGED
@@ -3,13 +3,8 @@ unless defined?(TOKEN_ACTION_ORM)
|
|
3
3
|
TOKEN_ACTION_ORM = (ENV['TOKEN_ACTION_ORM'] || :active_record).to_sym
|
4
4
|
end
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
# Set up gems listed in the Gemfile.
|
7
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
|
8
8
|
|
9
|
-
if File.exist?(
|
10
|
-
|
11
|
-
require 'bundler'
|
12
|
-
Bundler.setup
|
13
|
-
end
|
14
|
-
|
15
|
-
$:.unshift File.expand_path('../../../../lib', __FILE__)
|
9
|
+
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
10
|
+
$LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
|
@@ -1,18 +1,25 @@
|
|
1
1
|
# SQLite version 3.x
|
2
|
-
# gem install sqlite3
|
3
|
-
|
2
|
+
# gem install sqlite3
|
3
|
+
#
|
4
|
+
# Ensure the SQLite 3 gem is defined in your Gemfile
|
5
|
+
# gem 'sqlite3'
|
6
|
+
#
|
7
|
+
default: &default
|
4
8
|
adapter: sqlite3
|
5
|
-
database: db/development.sqlite3
|
6
9
|
pool: 5
|
7
10
|
timeout: 5000
|
8
11
|
|
12
|
+
development:
|
13
|
+
<<: *default
|
14
|
+
database: db/development.sqlite3
|
15
|
+
|
9
16
|
# Warning: The database defined as "test" will be erased and
|
10
17
|
# re-generated from your development database when you run "rake".
|
11
18
|
# Do not set this db to the same as development or production.
|
12
19
|
test:
|
13
|
-
|
14
|
-
database:
|
20
|
+
<<: *default
|
21
|
+
database: db/test.sqlite3
|
15
22
|
|
16
23
|
production:
|
17
|
-
|
18
|
-
database:
|
24
|
+
<<: *default
|
25
|
+
database: db/production.sqlite3
|
@@ -1,37 +1,41 @@
|
|
1
|
-
|
2
|
-
# Settings specified here will take precedence over those in config/application.rb
|
1
|
+
Rails.application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
3
3
|
|
4
4
|
# In the development environment your application's code is reloaded on
|
5
5
|
# every request. This slows down response time but is perfect for development
|
6
6
|
# since you don't have to restart the web server when you make code changes.
|
7
7
|
config.cache_classes = false
|
8
8
|
|
9
|
-
#
|
10
|
-
config.
|
9
|
+
# Do not eager load code on boot.
|
10
|
+
config.eager_load = false
|
11
11
|
|
12
|
-
# Show full error reports and disable caching
|
12
|
+
# Show full error reports and disable caching.
|
13
13
|
config.consider_all_requests_local = true
|
14
14
|
config.action_controller.perform_caching = false
|
15
15
|
|
16
|
-
# Don't care if the mailer can't send
|
16
|
+
# Don't care if the mailer can't send.
|
17
17
|
config.action_mailer.raise_delivery_errors = false
|
18
18
|
|
19
|
-
# Print deprecation notices to the Rails logger
|
19
|
+
# Print deprecation notices to the Rails logger.
|
20
20
|
config.active_support.deprecation = :log
|
21
21
|
|
22
|
-
#
|
23
|
-
config.
|
22
|
+
# Raise an error on page load if there are pending migrations.
|
23
|
+
config.active_record.migration_error = :page_load
|
24
24
|
|
25
|
-
#
|
26
|
-
#
|
25
|
+
# Debug mode disables concatenation and preprocessing of assets.
|
26
|
+
# This option may cause significant delays in view rendering with a large
|
27
|
+
# number of complex assets.
|
28
|
+
config.assets.debug = true
|
27
29
|
|
28
|
-
#
|
29
|
-
#
|
30
|
-
|
30
|
+
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
|
31
|
+
# yet still be able to expire them through the digest params.
|
32
|
+
config.assets.digest = true
|
31
33
|
|
32
|
-
#
|
33
|
-
|
34
|
+
# Adds additional error checking when serving assets at runtime.
|
35
|
+
# Checks for improperly declared sprockets dependencies.
|
36
|
+
# Raises helpful error messages.
|
37
|
+
config.assets.raise_runtime_errors = true
|
34
38
|
|
35
|
-
#
|
36
|
-
config.
|
39
|
+
# Raises error for missing translations
|
40
|
+
# config.action_view.raise_on_missing_translations = true
|
37
41
|
end
|
@@ -1,67 +1,79 @@
|
|
1
|
-
|
2
|
-
# Settings specified here will take precedence over those in config/application.rb
|
1
|
+
Rails.application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
3
3
|
|
4
|
-
# Code is not reloaded between requests
|
4
|
+
# Code is not reloaded between requests.
|
5
5
|
config.cache_classes = true
|
6
6
|
|
7
|
-
#
|
7
|
+
# Eager load code on boot. This eager loads most of Rails and
|
8
|
+
# your application in memory, allowing both threaded web servers
|
9
|
+
# and those relying on copy on write to perform better.
|
10
|
+
# Rake tasks automatically ignore this option for performance.
|
11
|
+
config.eager_load = true
|
12
|
+
|
13
|
+
# Full error reports are disabled and caching is turned on.
|
8
14
|
config.consider_all_requests_local = false
|
9
15
|
config.action_controller.perform_caching = true
|
10
16
|
|
11
|
-
#
|
12
|
-
|
17
|
+
# Enable Rack::Cache to put a simple HTTP cache in front of your application
|
18
|
+
# Add `rack-cache` to your Gemfile before enabling this.
|
19
|
+
# For large-scale production use, consider using a caching reverse proxy like
|
20
|
+
# NGINX, varnish or squid.
|
21
|
+
# config.action_dispatch.rack_cache = true
|
22
|
+
|
23
|
+
# Disable serving static files from the `/public` folder by default since
|
24
|
+
# Apache or NGINX already handles this.
|
25
|
+
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
|
13
26
|
|
14
|
-
# Compress JavaScripts and CSS
|
15
|
-
config.assets.
|
27
|
+
# Compress JavaScripts and CSS.
|
28
|
+
config.assets.js_compressor = :uglifier
|
29
|
+
# config.assets.css_compressor = :sass
|
16
30
|
|
17
|
-
#
|
31
|
+
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
18
32
|
config.assets.compile = false
|
19
33
|
|
20
|
-
#
|
34
|
+
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
|
35
|
+
# yet still be able to expire them through the digest params.
|
21
36
|
config.assets.digest = true
|
22
37
|
|
23
|
-
#
|
24
|
-
# config.assets.manifest = YOUR_PATH
|
38
|
+
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
|
25
39
|
|
26
|
-
# Specifies the header that your server uses for sending files
|
27
|
-
# config.action_dispatch.x_sendfile_header =
|
28
|
-
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for
|
40
|
+
# Specifies the header that your server uses for sending files.
|
41
|
+
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
|
42
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
|
29
43
|
|
30
44
|
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
31
45
|
# config.force_ssl = true
|
32
46
|
|
33
|
-
#
|
34
|
-
#
|
47
|
+
# Use the lowest log level to ensure availability of diagnostic information
|
48
|
+
# when problems arise.
|
49
|
+
config.log_level = :debug
|
35
50
|
|
36
|
-
# Prepend all log lines with the following tags
|
51
|
+
# Prepend all log lines with the following tags.
|
37
52
|
# config.log_tags = [ :subdomain, :uuid ]
|
38
53
|
|
39
|
-
# Use a different logger for distributed setups
|
54
|
+
# Use a different logger for distributed setups.
|
40
55
|
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
|
41
56
|
|
42
|
-
# Use a different cache store in production
|
57
|
+
# Use a different cache store in production.
|
43
58
|
# config.cache_store = :mem_cache_store
|
44
59
|
|
45
|
-
# Enable serving of images, stylesheets, and JavaScripts from an asset server
|
46
|
-
# config.action_controller.asset_host =
|
47
|
-
|
48
|
-
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
|
49
|
-
# config.assets.precompile += %w( search.js )
|
60
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
61
|
+
# config.action_controller.asset_host = 'http://assets.example.com'
|
50
62
|
|
51
|
-
#
|
63
|
+
# Ignore bad email addresses and do not raise email delivery errors.
|
64
|
+
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
52
65
|
# config.action_mailer.raise_delivery_errors = false
|
53
66
|
|
54
|
-
# Enable threaded mode
|
55
|
-
# config.threadsafe!
|
56
|
-
|
57
67
|
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
58
|
-
# the I18n.default_locale when a translation
|
68
|
+
# the I18n.default_locale when a translation cannot be found).
|
59
69
|
config.i18n.fallbacks = true
|
60
70
|
|
61
|
-
# Send deprecation notices to registered listeners
|
71
|
+
# Send deprecation notices to registered listeners.
|
62
72
|
config.active_support.deprecation = :notify
|
63
73
|
|
64
|
-
#
|
65
|
-
|
66
|
-
|
74
|
+
# Use default logging formatter so that PID and timestamp are not suppressed.
|
75
|
+
config.log_formatter = ::Logger::Formatter.new
|
76
|
+
|
77
|
+
# Do not dump schema after migrations.
|
78
|
+
config.active_record.dump_schema_after_migration = false
|
67
79
|
end
|