token_action 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +1 -1
  3. data/README.md +11 -18
  4. data/Rakefile +13 -4
  5. data/app/controllers/token_action/tokens_controller.rb +19 -11
  6. data/config/routes.rb +1 -1
  7. data/lib/generators/active_record/templates/migration.rb +1 -1
  8. data/lib/generators/templates/README +1 -1
  9. data/lib/token_action.rb +2 -2
  10. data/lib/token_action/{mixins → concerns}/model.rb +0 -0
  11. data/lib/token_action/{mixins → concerns}/token_generator.rb +0 -0
  12. data/lib/token_action/orm/mongoid.rb +6 -6
  13. data/lib/token_action/version.rb +1 -1
  14. data/spec/controllers/token_action/tokens_controller_spec.rb +159 -157
  15. data/spec/dummy/Rakefile +1 -2
  16. data/spec/dummy/app/assets/javascripts/application.js +4 -4
  17. data/spec/dummy/app/assets/stylesheets/application.css +6 -4
  18. data/spec/dummy/app/controllers/application_controller.rb +3 -1
  19. data/spec/dummy/app/controllers/hello_controller.rb +6 -6
  20. data/spec/dummy/app/mongoid/cat.rb +1 -1
  21. data/spec/dummy/app/views/layouts/application.html.erb +2 -2
  22. data/spec/dummy/bin/bundle +3 -0
  23. data/spec/dummy/bin/rails +4 -0
  24. data/spec/dummy/bin/rake +4 -0
  25. data/spec/dummy/bin/setup +29 -0
  26. data/spec/dummy/config.ru +2 -2
  27. data/spec/dummy/config/application.rb +11 -42
  28. data/spec/dummy/config/boot.rb +4 -9
  29. data/spec/dummy/config/database.yml +14 -7
  30. data/spec/dummy/config/environment.rb +3 -3
  31. data/spec/dummy/config/environments/development.rb +22 -18
  32. data/spec/dummy/config/environments/production.rb +46 -34
  33. data/spec/dummy/config/environments/test.rb +18 -17
  34. data/spec/dummy/config/initializers/assets.rb +11 -0
  35. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  36. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  37. data/spec/dummy/config/initializers/session_store.rb +1 -6
  38. data/spec/dummy/config/initializers/wrap_parameters.rb +6 -6
  39. data/spec/dummy/config/locales/en.yml +20 -2
  40. data/spec/dummy/config/mongoid.yml +4 -60
  41. data/spec/dummy/config/routes.rb +6 -6
  42. data/spec/dummy/config/secrets.yml +22 -0
  43. data/spec/dummy/db/migrate/20130104151630_create_token_action_tokens.rb +1 -1
  44. data/spec/dummy/db/schema.rb +32 -0
  45. data/spec/dummy/{db/development.sqlite3 → log/.keep} +0 -0
  46. data/spec/dummy/public/404.html +54 -13
  47. data/spec/dummy/public/422.html +54 -13
  48. data/spec/dummy/public/500.html +53 -12
  49. data/spec/factories.rb +1 -1
  50. data/spec/rails_helper.rb +102 -0
  51. data/spec/routing/token_action/tokens_routing_spec.rb +23 -23
  52. data/spec/spec_helper.rb +85 -87
  53. data/spec/token_action/concerns/model_spec.rb +14 -0
  54. data/spec/token_action/concerns/token_generator_spec.rb +13 -0
  55. data/spec/token_action/orm/active_record_spec.rb +4 -2
  56. data/spec/token_action/orm/mongoid_spec.rb +4 -2
  57. data/spec/token_action_spec.rb +9 -9
  58. metadata +109 -158
  59. data/spec/dummy/config/initializers/secret_token.rb +0 -7
  60. data/spec/dummy/log/development.log +0 -16
  61. data/spec/dummy/log/test.log +0 -4739
  62. data/spec/dummy/script/rails +0 -6
  63. data/spec/token_action/mixins/model_spec.rb +0 -13
  64. data/spec/token_action/mixins/token_generator_spec.rb +0 -11
@@ -1,5 +1,5 @@
1
- Dummy::Application.configure do
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
- # Configure static asset server for tests with Cache-Control for performance
11
- config.serve_static_assets = true
12
- config.static_cache_control = "public, max-age=3600"
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
- # Log error messages when you accidentally call methods on nil
15
- config.whiny_nils = true
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 = false
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
- # Raise exception on mass assignment protection for Active Record models
33
- # config.active_record.mass_assignment_sanitizer = :strict
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
- config.after_initialize do
39
- Rails.application.routes.default_url_options[:host] = 'test.host'
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 )
@@ -0,0 +1,3 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Rails.application.config.action_dispatch.cookies_serializer = :json
@@ -0,0 +1,4 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Configure sensitive parameters which will be filtered from the log file.
4
+ Rails.application.config.filter_parameters += [:password]
@@ -1,8 +1,3 @@
1
1
  # Be sure to restart your server when you modify this file.
2
2
 
3
- Dummy::Application.config.session_store :cookie_store, :key => '_dummy_session'
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 :format => [:json]
8
+ wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
9
9
  end
10
10
 
11
- # Disable root element in JSON by default.
12
- ActiveSupport.on_load(:active_record) do
13
- self.include_root_in_json = false
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
- # Sample localization file for English. Add more files in this directory for other locales.
2
- # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
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
- # Configure available database sessions. (required)
3
- sessions:
4
- # Defines the default session. (required)
2
+ clients:
5
3
  default:
6
- # Defines the name of the default database that Mongoid can connect to.
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
- sessions:
8
+ clients:
63
9
  default:
64
- database: token_action_test
10
+ database: dummy_test
65
11
  hosts:
66
12
  - localhost:27017
67
- options:
68
- consistency: :strong
@@ -1,9 +1,9 @@
1
1
  Rails.application.routes.draw do
2
2
  mount TokenAction::Engine => '/token_action'
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'
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"] %>
@@ -10,6 +10,6 @@ class CreateTokenActionTokens < ActiveRecord::Migration
10
10
  t.timestamps
11
11
  end
12
12
 
13
- add_index :token_action_tokens, :token, :unique => true
13
+ add_index :token_action_tokens, :token, unique: true
14
14
  end
15
15
  end
@@ -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
@@ -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
- <style type="text/css">
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
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
- <h1>The page you were looking for doesn't exist.</h1>
23
- <p>You may have mistyped the address or the page may have moved.</p>
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>
@@ -2,25 +2,66 @@
2
2
  <html>
3
3
  <head>
4
4
  <title>The change you wanted was rejected (422)</title>
5
- <style type="text/css">
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
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
- <h1>The change you wanted was rejected.</h1>
23
- <p>Maybe you tried to change something you didn't have access to.</p>
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>