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
@@ -1,5 +1,5 @@
|
|
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
|
# The test environment is used exclusively to run your application's
|
5
5
|
# test suite. You never need to work with it otherwise. Remember that
|
@@ -7,35 +7,36 @@ Dummy::Application.configure do
|
|
7
7
|
# and recreated between test runs. Don't rely on the data there!
|
8
8
|
config.cache_classes = true
|
9
9
|
|
10
|
-
#
|
11
|
-
|
12
|
-
|
10
|
+
# Do not eager load code on boot. This avoids loading your whole application
|
11
|
+
# just for the purpose of running a single test. If you are using a tool that
|
12
|
+
# preloads Rails for running tests, you may have to set it to true.
|
13
|
+
config.eager_load = false
|
13
14
|
|
14
|
-
#
|
15
|
-
config.
|
15
|
+
# Configure static file server for tests with Cache-Control for performance.
|
16
|
+
config.serve_static_files = true
|
17
|
+
config.static_cache_control = 'public, max-age=3600'
|
16
18
|
|
17
|
-
# Show full error reports and disable caching
|
19
|
+
# Show full error reports and disable caching.
|
18
20
|
config.consider_all_requests_local = true
|
19
21
|
config.action_controller.perform_caching = false
|
20
22
|
|
21
|
-
# Raise exceptions instead of rendering exception templates
|
23
|
+
# Raise exceptions instead of rendering exception templates.
|
22
24
|
config.action_dispatch.show_exceptions = false
|
23
25
|
|
24
|
-
# Disable request forgery protection in test environment
|
25
|
-
config.action_controller.allow_forgery_protection
|
26
|
+
# Disable request forgery protection in test environment.
|
27
|
+
config.action_controller.allow_forgery_protection = false
|
26
28
|
|
27
29
|
# Tell Action Mailer not to deliver emails to the real world.
|
28
30
|
# The :test delivery method accumulates sent emails in the
|
29
31
|
# ActionMailer::Base.deliveries array.
|
30
32
|
config.action_mailer.delivery_method = :test
|
31
33
|
|
32
|
-
#
|
33
|
-
|
34
|
+
# Randomize the order test cases are executed.
|
35
|
+
config.active_support.test_order = :random
|
34
36
|
|
35
|
-
# Print deprecation notices to the stderr
|
37
|
+
# Print deprecation notices to the stderr.
|
36
38
|
config.active_support.deprecation = :stderr
|
37
39
|
|
38
|
-
|
39
|
-
|
40
|
-
end
|
40
|
+
# Raises error for missing translations
|
41
|
+
# config.action_view.raise_on_missing_translations = true
|
41
42
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Version of your assets, change this if you want to expire all your assets.
|
4
|
+
Rails.application.config.assets.version = '1.0'
|
5
|
+
|
6
|
+
# Add additional assets to the asset load path
|
7
|
+
# Rails.application.config.assets.paths << Emoji.images_path
|
8
|
+
|
9
|
+
# Precompile additional assets.
|
10
|
+
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
|
11
|
+
# Rails.application.config.assets.precompile += %w( search.js )
|
@@ -1,8 +1,3 @@
|
|
1
1
|
# Be sure to restart your server when you modify this file.
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
# Use the database for sessions instead of the cookie-based default,
|
6
|
-
# which shouldn't be used to store highly confidential information
|
7
|
-
# (create the session table with "rails generate session_migration")
|
8
|
-
# Dummy::Application.config.session_store :active_record_store
|
3
|
+
Rails.application.config.session_store :cookie_store, key: '_dummy_session'
|
@@ -1,14 +1,14 @@
|
|
1
1
|
# Be sure to restart your server when you modify this file.
|
2
|
-
|
2
|
+
|
3
3
|
# This file contains settings for ActionController::ParamsWrapper which
|
4
4
|
# is enabled by default.
|
5
5
|
|
6
6
|
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
7
7
|
ActiveSupport.on_load(:action_controller) do
|
8
|
-
wrap_parameters :
|
8
|
+
wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
|
9
9
|
end
|
10
10
|
|
11
|
-
#
|
12
|
-
ActiveSupport.on_load(:active_record) do
|
13
|
-
self.include_root_in_json =
|
14
|
-
end
|
11
|
+
# To enable root element in JSON for ActiveRecord objects.
|
12
|
+
# ActiveSupport.on_load(:active_record) do
|
13
|
+
# self.include_root_in_json = true
|
14
|
+
# end
|
@@ -1,5 +1,23 @@
|
|
1
|
-
#
|
2
|
-
#
|
1
|
+
# Files in the config/locales directory are used for internationalization
|
2
|
+
# and are automatically loaded by Rails. If you want to use locales other
|
3
|
+
# than English, add the necessary files in this directory.
|
4
|
+
#
|
5
|
+
# To use the locales, use `I18n.t`:
|
6
|
+
#
|
7
|
+
# I18n.t 'hello'
|
8
|
+
#
|
9
|
+
# In views, this is aliased to just `t`:
|
10
|
+
#
|
11
|
+
# <%= t('hello') %>
|
12
|
+
#
|
13
|
+
# To use a different locale, set it with `I18n.locale`:
|
14
|
+
#
|
15
|
+
# I18n.locale = :es
|
16
|
+
#
|
17
|
+
# This would use the information in config/locales/es.yml.
|
18
|
+
#
|
19
|
+
# To learn more, please read the Rails Internationalization guide
|
20
|
+
# available at http://guides.rubyonrails.org/i18n.html.
|
3
21
|
|
4
22
|
en:
|
5
23
|
hello: "Hello world"
|
@@ -1,68 +1,12 @@
|
|
1
1
|
development:
|
2
|
-
|
3
|
-
sessions:
|
4
|
-
# Defines the default session. (required)
|
2
|
+
clients:
|
5
3
|
default:
|
6
|
-
|
7
|
-
# (required).
|
8
|
-
database: token_action_development
|
9
|
-
# Provides the hosts the default session can connect to. Must be an array
|
10
|
-
# of host:port pairs. (required)
|
4
|
+
database: dummy_development
|
11
5
|
hosts:
|
12
6
|
- localhost:27017
|
13
|
-
options:
|
14
|
-
# Change whether the session persists in safe mode by default.
|
15
|
-
# (default: false)
|
16
|
-
# safe: false
|
17
|
-
|
18
|
-
# Change the default consistency model to :eventual or :strong.
|
19
|
-
# :eventual will send reads to secondaries, :strong sends everything
|
20
|
-
# to master. (default: :eventual)
|
21
|
-
consistency: :strong
|
22
|
-
# Configure Mongoid specific options. (optional)
|
23
|
-
options:
|
24
|
-
# Configuration for whether or not to allow access to fields that do
|
25
|
-
# not have a field definition on the model. (default: true)
|
26
|
-
# allow_dynamic_fields: true
|
27
|
-
|
28
|
-
# Enable the identity map, needed for eager loading. (default: false)
|
29
|
-
identity_map_enabled: true
|
30
|
-
|
31
|
-
# Includes the root model name in json serialization. (default: false)
|
32
|
-
# include_root_in_json: false
|
33
|
-
|
34
|
-
# Include the _type field in serializaion. (default: false)
|
35
|
-
# include_type_for_serialization: false
|
36
|
-
|
37
|
-
# Preload all models in development, needed when models use
|
38
|
-
# inheritance. (default: false)
|
39
|
-
# preload_models: false
|
40
|
-
|
41
|
-
# Protect id and type from mass assignment. (default: true)
|
42
|
-
# protect_sensitive_fields: true
|
43
|
-
|
44
|
-
# Raise an error when performing a #find and the document is not found.
|
45
|
-
# (default: true)
|
46
|
-
# raise_not_found_error: true
|
47
|
-
|
48
|
-
# Raise an error when defining a scope with the same name as an
|
49
|
-
# existing method. (default: false)
|
50
|
-
# scope_overwrite_exception: false
|
51
|
-
|
52
|
-
# Skip the database version check, used when connecting to a db without
|
53
|
-
# admin access. (default: false)
|
54
|
-
# skip_version_check: false
|
55
|
-
|
56
|
-
# User Active Support's time zone in conversions. (default: true)
|
57
|
-
# use_activesupport_time_zone: true
|
58
|
-
|
59
|
-
# Ensure all times are UTC in the app side. (default: false)
|
60
|
-
# use_utc: false
|
61
7
|
test:
|
62
|
-
|
8
|
+
clients:
|
63
9
|
default:
|
64
|
-
database:
|
10
|
+
database: dummy_test
|
65
11
|
hosts:
|
66
12
|
- localhost:27017
|
67
|
-
options:
|
68
|
-
consistency: :strong
|
data/spec/dummy/config/routes.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
Rails.application.routes.draw do
|
2
2
|
mount TokenAction::Engine => '/token_action'
|
3
|
-
get 'hello/token_success', :
|
4
|
-
get 'hello/token_failure', :
|
5
|
-
get 'hello/success', :
|
6
|
-
get 'hello/failure', :
|
7
|
-
get 'hello/not_found', :
|
8
|
-
root :
|
3
|
+
get 'hello/token_success', as: :token_success
|
4
|
+
get 'hello/token_failure', as: :token_failure
|
5
|
+
get 'hello/success', as: :success
|
6
|
+
get 'hello/failure', as: :failure
|
7
|
+
get 'hello/not_found', as: :not_found
|
8
|
+
root to: 'hello#hello'
|
9
9
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Your secret key is used for verifying the integrity of signed cookies.
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
5
|
+
|
6
|
+
# Make sure the secret is at least 30 characters and all random,
|
7
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
8
|
+
# You can use `rake secret` to generate a secure secret key.
|
9
|
+
|
10
|
+
# Make sure the secrets in this file are kept private
|
11
|
+
# if you're sharing your code publicly.
|
12
|
+
|
13
|
+
development:
|
14
|
+
secret_key_base: 3e089b85ddbfb93082a86f017ba20720b8ede09850aa31c5b45612263c6fac5ef752471deeb95e464170cbd290e0b683809085fbbbd934775590d1469d7e6af2
|
15
|
+
|
16
|
+
test:
|
17
|
+
secret_key_base: 8fd367e3386fe7b1515dbee7209e91936576170b0d42230cab302db85b6f2f5210ea21f0614bc8515ee09c119dbae20cba3e0e8c363a1b17a411f6710c09b379
|
18
|
+
|
19
|
+
# Do not keep production secrets in the repository,
|
20
|
+
# instead read values from the environment.
|
21
|
+
production:
|
22
|
+
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# This file is auto-generated from the current state of the database. Instead
|
3
|
+
# of editing this file, please use the migrations feature of Active Record to
|
4
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
5
|
+
#
|
6
|
+
# Note that this schema.rb definition is the authoritative source for your
|
7
|
+
# database schema. If you need to create the application database on another
|
8
|
+
# system, you should be using db:schema:load, not running all the migrations
|
9
|
+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
10
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
11
|
+
#
|
12
|
+
# It's strongly recommended that you check this file into your version control system.
|
13
|
+
|
14
|
+
ActiveRecord::Schema.define(version: 20130104201018) do
|
15
|
+
|
16
|
+
create_table "cats", force: :cascade do |t|
|
17
|
+
t.string "token"
|
18
|
+
end
|
19
|
+
|
20
|
+
create_table "token_action_tokens", force: :cascade do |t|
|
21
|
+
t.string "token"
|
22
|
+
t.string "kind"
|
23
|
+
t.text "args"
|
24
|
+
t.string "success_url"
|
25
|
+
t.string "failure_url"
|
26
|
+
t.datetime "created_at"
|
27
|
+
t.datetime "updated_at"
|
28
|
+
end
|
29
|
+
|
30
|
+
add_index "token_action_tokens", ["token"], name: "index_token_action_tokens_on_token", unique: true
|
31
|
+
|
32
|
+
end
|
File without changes
|
data/spec/dummy/public/404.html
CHANGED
@@ -2,25 +2,66 @@
|
|
2
2
|
<html>
|
3
3
|
<head>
|
4
4
|
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
-
<
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
16
54
|
</style>
|
17
55
|
</head>
|
18
56
|
|
19
57
|
<body>
|
20
58
|
<!-- This file lives in public/404.html -->
|
21
59
|
<div class="dialog">
|
22
|
-
<
|
23
|
-
|
60
|
+
<div>
|
61
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
62
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
63
|
+
</div>
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
24
65
|
</div>
|
25
66
|
</body>
|
26
67
|
</html>
|
data/spec/dummy/public/422.html
CHANGED
@@ -2,25 +2,66 @@
|
|
2
2
|
<html>
|
3
3
|
<head>
|
4
4
|
<title>The change you wanted was rejected (422)</title>
|
5
|
-
<
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<style>
|
7
|
+
body {
|
8
|
+
background-color: #EFEFEF;
|
9
|
+
color: #2E2F30;
|
10
|
+
text-align: center;
|
11
|
+
font-family: arial, sans-serif;
|
12
|
+
margin: 0;
|
13
|
+
}
|
14
|
+
|
15
|
+
div.dialog {
|
16
|
+
width: 95%;
|
17
|
+
max-width: 33em;
|
18
|
+
margin: 4em auto 0;
|
19
|
+
}
|
20
|
+
|
21
|
+
div.dialog > div {
|
22
|
+
border: 1px solid #CCC;
|
23
|
+
border-right-color: #999;
|
24
|
+
border-left-color: #999;
|
25
|
+
border-bottom-color: #BBB;
|
26
|
+
border-top: #B00100 solid 4px;
|
27
|
+
border-top-left-radius: 9px;
|
28
|
+
border-top-right-radius: 9px;
|
29
|
+
background-color: white;
|
30
|
+
padding: 7px 12% 0;
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
|
+
}
|
33
|
+
|
34
|
+
h1 {
|
35
|
+
font-size: 100%;
|
36
|
+
color: #730E15;
|
37
|
+
line-height: 1.5em;
|
38
|
+
}
|
39
|
+
|
40
|
+
div.dialog > p {
|
41
|
+
margin: 0 0 1em;
|
42
|
+
padding: 1em;
|
43
|
+
background-color: #F7F7F7;
|
44
|
+
border: 1px solid #CCC;
|
45
|
+
border-right-color: #999;
|
46
|
+
border-left-color: #999;
|
47
|
+
border-bottom-color: #999;
|
48
|
+
border-bottom-left-radius: 4px;
|
49
|
+
border-bottom-right-radius: 4px;
|
50
|
+
border-top-color: #DADADA;
|
51
|
+
color: #666;
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
53
|
+
}
|
16
54
|
</style>
|
17
55
|
</head>
|
18
56
|
|
19
57
|
<body>
|
20
58
|
<!-- This file lives in public/422.html -->
|
21
59
|
<div class="dialog">
|
22
|
-
<
|
23
|
-
|
60
|
+
<div>
|
61
|
+
<h1>The change you wanted was rejected.</h1>
|
62
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
63
|
+
</div>
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
24
65
|
</div>
|
25
66
|
</body>
|
26
67
|
</html>
|