token_for 0.0.1

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 (49) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/Rakefile +32 -0
  4. data/lib/tasks/token_for_tasks.rake +4 -0
  5. data/lib/token_for/version.rb +3 -0
  6. data/lib/token_for.rb +36 -0
  7. data/test/dummy/README.rdoc +28 -0
  8. data/test/dummy/Rakefile +6 -0
  9. data/test/dummy/app/assets/javascripts/application.js +13 -0
  10. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  11. data/test/dummy/app/controllers/application_controller.rb +5 -0
  12. data/test/dummy/app/helpers/application_helper.rb +2 -0
  13. data/test/dummy/app/models/example.rb +3 -0
  14. data/test/dummy/app/models/example_with_expired_token.rb +3 -0
  15. data/test/dummy/app/models/example_with_expires_in.rb +3 -0
  16. data/test/dummy/app/models/example_without_expires_in.rb +3 -0
  17. data/test/dummy/app/views/layouts/application.html.erb +13 -0
  18. data/test/dummy/bin/bundle +3 -0
  19. data/test/dummy/bin/rails +4 -0
  20. data/test/dummy/bin/rake +4 -0
  21. data/test/dummy/config/application.rb +29 -0
  22. data/test/dummy/config/boot.rb +5 -0
  23. data/test/dummy/config/database.yml +86 -0
  24. data/test/dummy/config/environment.rb +5 -0
  25. data/test/dummy/config/environments/development.rb +37 -0
  26. data/test/dummy/config/environments/production.rb +83 -0
  27. data/test/dummy/config/environments/test.rb +39 -0
  28. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  29. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  30. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  31. data/test/dummy/config/initializers/inflections.rb +16 -0
  32. data/test/dummy/config/initializers/mime_types.rb +4 -0
  33. data/test/dummy/config/initializers/session_store.rb +3 -0
  34. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  35. data/test/dummy/config/locales/en.yml +23 -0
  36. data/test/dummy/config/routes.rb +56 -0
  37. data/test/dummy/config/secrets.yml +22 -0
  38. data/test/dummy/config.ru +4 -0
  39. data/test/dummy/db/migrate/20140415105618_create_examples.rb +9 -0
  40. data/test/dummy/db/schema.rb +25 -0
  41. data/test/dummy/log/development.log +19 -0
  42. data/test/dummy/log/test.log +233 -0
  43. data/test/dummy/public/404.html +67 -0
  44. data/test/dummy/public/422.html +67 -0
  45. data/test/dummy/public/500.html +66 -0
  46. data/test/dummy/public/favicon.ico +0 -0
  47. data/test/test_helper.rb +16 -0
  48. data/test/token_for_test.rb +36 -0
  49. metadata +160 -0
@@ -0,0 +1,56 @@
1
+ Rails.application.routes.draw do
2
+ # The priority is based upon order of creation: first created -> highest priority.
3
+ # See how all your routes lay out with "rake routes".
4
+
5
+ # You can have the root of your site routed with "root"
6
+ # root 'welcome#index'
7
+
8
+ # Example of regular route:
9
+ # get 'products/:id' => 'catalog#view'
10
+
11
+ # Example of named route that can be invoked with purchase_url(id: product.id)
12
+ # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
13
+
14
+ # Example resource route (maps HTTP verbs to controller actions automatically):
15
+ # resources :products
16
+
17
+ # Example resource route with options:
18
+ # resources :products do
19
+ # member do
20
+ # get 'short'
21
+ # post 'toggle'
22
+ # end
23
+ #
24
+ # collection do
25
+ # get 'sold'
26
+ # end
27
+ # end
28
+
29
+ # Example resource route with sub-resources:
30
+ # resources :products do
31
+ # resources :comments, :sales
32
+ # resource :seller
33
+ # end
34
+
35
+ # Example resource route with more complex sub-resources:
36
+ # resources :products do
37
+ # resources :comments
38
+ # resources :sales do
39
+ # get 'recent', on: :collection
40
+ # end
41
+ # end
42
+
43
+ # Example resource route with concerns:
44
+ # concern :toggleable do
45
+ # post 'toggle'
46
+ # end
47
+ # resources :posts, concerns: :toggleable
48
+ # resources :photos, concerns: :toggleable
49
+
50
+ # Example resource route within a namespace:
51
+ # namespace :admin do
52
+ # # Directs /admin/products/* to Admin::ProductsController
53
+ # # (app/controllers/admin/products_controller.rb)
54
+ # resources :products
55
+ # end
56
+ 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: 3a5e6934a669d23a2a1ac9074457c24d60a84cc74dd9ad5220c96a216e5998eeef863b2560750bffa4d83a1aea16be219f10d5771eda1fa4a6a5243d13f44b4d
15
+
16
+ test:
17
+ secret_key_base: 64099b6f1b19800bd6b72342acc4c9b87546842dfffea6ea495783764d1d8c2c2d004e44b7709d06e23d8513a82784c3923fa3653059e2efeaea7326b0bab305
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,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Rails.application
@@ -0,0 +1,9 @@
1
+ class CreateExamples < ActiveRecord::Migration
2
+ def change
3
+ create_table :examples do |t|
4
+ t.string :test_attribute
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,25 @@
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: 20140415105618) do
15
+
16
+ # These are extensions that must be enabled in order to support this database
17
+ enable_extension "plpgsql"
18
+
19
+ create_table "examples", force: true do |t|
20
+ t.string "test_attribute"
21
+ t.datetime "created_at"
22
+ t.datetime "updated_at"
23
+ end
24
+
25
+ end
@@ -0,0 +1,19 @@
1
+  (15.5ms) CREATE TABLE "schema_migrations" ("version" character varying(255) NOT NULL) 
2
+  (7.3ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
3
+ ActiveRecord::SchemaMigration Load (0.9ms) SELECT "schema_migrations".* FROM "schema_migrations"
4
+ Migrating to CreateExamples (20140415105618)
5
+  (0.2ms) BEGIN
6
+  (6.0ms) CREATE TABLE "examples" ("id" serial primary key, "test_attribute" character varying(255), "created_at" timestamp, "updated_at" timestamp) 
7
+ SQL (0.8ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20140415105618"]]
8
+  (5.6ms) COMMIT
9
+ ActiveRecord::SchemaMigration Load (0.9ms) SELECT "schema_migrations".* FROM "schema_migrations"
10
+  (3.7ms) SELECT version FROM schema_migrations
11
+  (10.6ms) CREATE TABLE "schema_migrations" ("version" character varying(255) NOT NULL) 
12
+  (20.5ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
13
+ ActiveRecord::SchemaMigration Load (0.9ms) SELECT "schema_migrations".* FROM "schema_migrations"
14
+ Migrating to CreateExamples (20140415105618)
15
+  (0.2ms) BEGIN
16
+  (209.0ms) CREATE TABLE "examples" ("id" serial primary key, "test_attribute" character varying(255), "created_at" timestamp, "updated_at" timestamp) 
17
+ SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20140415105618"]]
18
+  (2.4ms) COMMIT
19
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
@@ -0,0 +1,233 @@
1
+ PG::UndefinedTable: ERROR: relation "examples" does not exist
2
+ LINE 5: WHERE a.attrelid = '"examples"'::regclass
3
+ ^
4
+ : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
5
+ pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
6
+ FROM pg_attribute a LEFT JOIN pg_attrdef d
7
+ ON a.attrelid = d.adrelid AND a.attnum = d.adnum
8
+ WHERE a.attrelid = '"examples"'::regclass
9
+ AND a.attnum > 0 AND NOT a.attisdropped
10
+ ORDER BY a.attnum
11
+
12
+ PG::UndefinedTable: ERROR: relation "examples" does not exist
13
+ LINE 5: WHERE a.attrelid = '"examples"'::regclass
14
+ ^
15
+ : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
16
+ pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
17
+ FROM pg_attribute a LEFT JOIN pg_attrdef d
18
+ ON a.attrelid = d.adrelid AND a.attnum = d.adnum
19
+ WHERE a.attrelid = '"examples"'::regclass
20
+ AND a.attnum > 0 AND NOT a.attisdropped
21
+ ORDER BY a.attnum
22
+
23
+ PG::UndefinedTable: ERROR: relation "examples" does not exist
24
+ LINE 5: WHERE a.attrelid = '"examples"'::regclass
25
+ ^
26
+ : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
27
+ pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
28
+ FROM pg_attribute a LEFT JOIN pg_attrdef d
29
+ ON a.attrelid = d.adrelid AND a.attnum = d.adnum
30
+ WHERE a.attrelid = '"examples"'::regclass
31
+ AND a.attnum > 0 AND NOT a.attisdropped
32
+ ORDER BY a.attnum
33
+
34
+ PG::UndefinedTable: ERROR: relation "examples" does not exist
35
+ LINE 5: WHERE a.attrelid = '"examples"'::regclass
36
+ ^
37
+ : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
38
+ pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
39
+ FROM pg_attribute a LEFT JOIN pg_attrdef d
40
+ ON a.attrelid = d.adrelid AND a.attnum = d.adnum
41
+ WHERE a.attrelid = '"examples"'::regclass
42
+ AND a.attnum > 0 AND NOT a.attisdropped
43
+ ORDER BY a.attnum
44
+
45
+ PG::UndefinedTable: ERROR: relation "examples" does not exist
46
+ LINE 5: WHERE a.attrelid = '"examples"'::regclass
47
+ ^
48
+ : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
49
+ pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
50
+ FROM pg_attribute a LEFT JOIN pg_attrdef d
51
+ ON a.attrelid = d.adrelid AND a.attnum = d.adnum
52
+ WHERE a.attrelid = '"examples"'::regclass
53
+ AND a.attnum > 0 AND NOT a.attisdropped
54
+ ORDER BY a.attnum
55
+
56
+ PG::UndefinedTable: ERROR: relation "examples" does not exist
57
+ LINE 5: WHERE a.attrelid = '"examples"'::regclass
58
+ ^
59
+ : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
60
+ pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
61
+ FROM pg_attribute a LEFT JOIN pg_attrdef d
62
+ ON a.attrelid = d.adrelid AND a.attnum = d.adnum
63
+ WHERE a.attrelid = '"examples"'::regclass
64
+ AND a.attnum > 0 AND NOT a.attisdropped
65
+ ORDER BY a.attnum
66
+
67
+ PG::UndefinedTable: ERROR: relation "examples" does not exist
68
+ LINE 5: WHERE a.attrelid = '"examples"'::regclass
69
+ ^
70
+ : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
71
+ pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
72
+ FROM pg_attribute a LEFT JOIN pg_attrdef d
73
+ ON a.attrelid = d.adrelid AND a.attnum = d.adnum
74
+ WHERE a.attrelid = '"examples"'::regclass
75
+ AND a.attnum > 0 AND NOT a.attisdropped
76
+ ORDER BY a.attnum
77
+
78
+ PG::UndefinedTable: ERROR: relation "examples" does not exist
79
+ LINE 5: WHERE a.attrelid = '"examples"'::regclass
80
+ ^
81
+ : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
82
+ pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
83
+ FROM pg_attribute a LEFT JOIN pg_attrdef d
84
+ ON a.attrelid = d.adrelid AND a.attnum = d.adnum
85
+ WHERE a.attrelid = '"examples"'::regclass
86
+ AND a.attnum > 0 AND NOT a.attisdropped
87
+ ORDER BY a.attnum
88
+
89
+ PG::UndefinedTable: ERROR: relation "examples" does not exist
90
+ LINE 5: WHERE a.attrelid = '"examples"'::regclass
91
+ ^
92
+ : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
93
+ pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
94
+ FROM pg_attribute a LEFT JOIN pg_attrdef d
95
+ ON a.attrelid = d.adrelid AND a.attnum = d.adnum
96
+ WHERE a.attrelid = '"examples"'::regclass
97
+ AND a.attnum > 0 AND NOT a.attisdropped
98
+ ORDER BY a.attnum
99
+
100
+ PG::UndefinedTable: ERROR: relation "examples" does not exist
101
+ LINE 5: WHERE a.attrelid = '"examples"'::regclass
102
+ ^
103
+ : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
104
+ pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
105
+ FROM pg_attribute a LEFT JOIN pg_attrdef d
106
+ ON a.attrelid = d.adrelid AND a.attnum = d.adnum
107
+ WHERE a.attrelid = '"examples"'::regclass
108
+ AND a.attnum > 0 AND NOT a.attisdropped
109
+ ORDER BY a.attnum
110
+
111
+ PG::UndefinedTable: ERROR: relation "examples" does not exist
112
+ LINE 5: WHERE a.attrelid = '"examples"'::regclass
113
+ ^
114
+ : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
115
+ pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
116
+ FROM pg_attribute a LEFT JOIN pg_attrdef d
117
+ ON a.attrelid = d.adrelid AND a.attnum = d.adnum
118
+ WHERE a.attrelid = '"examples"'::regclass
119
+ AND a.attnum > 0 AND NOT a.attisdropped
120
+ ORDER BY a.attnum
121
+
122
+ PG::UndefinedTable: ERROR: relation "examples" does not exist
123
+ LINE 5: WHERE a.attrelid = '"examples"'::regclass
124
+ ^
125
+ : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
126
+ pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
127
+ FROM pg_attribute a LEFT JOIN pg_attrdef d
128
+ ON a.attrelid = d.adrelid AND a.attnum = d.adnum
129
+ WHERE a.attrelid = '"examples"'::regclass
130
+ AND a.attnum > 0 AND NOT a.attisdropped
131
+ ORDER BY a.attnum
132
+
133
+ PG::UndefinedTable: ERROR: relation "examples" does not exist
134
+ LINE 5: WHERE a.attrelid = '"examples"'::regclass
135
+ ^
136
+ : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
137
+ pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
138
+ FROM pg_attribute a LEFT JOIN pg_attrdef d
139
+ ON a.attrelid = d.adrelid AND a.attnum = d.adnum
140
+ WHERE a.attrelid = '"examples"'::regclass
141
+ AND a.attnum > 0 AND NOT a.attisdropped
142
+ ORDER BY a.attnum
143
+
144
+ PG::UndefinedTable: ERROR: relation "examples" does not exist
145
+ LINE 5: WHERE a.attrelid = '"examples"'::regclass
146
+ ^
147
+ : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
148
+ pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
149
+ FROM pg_attribute a LEFT JOIN pg_attrdef d
150
+ ON a.attrelid = d.adrelid AND a.attnum = d.adnum
151
+ WHERE a.attrelid = '"examples"'::regclass
152
+ AND a.attnum > 0 AND NOT a.attisdropped
153
+ ORDER BY a.attnum
154
+
155
+ PG::UndefinedTable: ERROR: relation "examples" does not exist
156
+ LINE 5: WHERE a.attrelid = '"examples"'::regclass
157
+ ^
158
+ : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
159
+ pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
160
+ FROM pg_attribute a LEFT JOIN pg_attrdef d
161
+ ON a.attrelid = d.adrelid AND a.attnum = d.adnum
162
+ WHERE a.attrelid = '"examples"'::regclass
163
+ AND a.attnum > 0 AND NOT a.attisdropped
164
+ ORDER BY a.attnum
165
+
166
+ PG::UndefinedTable: ERROR: relation "examples" does not exist
167
+ LINE 5: WHERE a.attrelid = '"examples"'::regclass
168
+ ^
169
+ : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
170
+ pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
171
+ FROM pg_attribute a LEFT JOIN pg_attrdef d
172
+ ON a.attrelid = d.adrelid AND a.attnum = d.adnum
173
+ WHERE a.attrelid = '"examples"'::regclass
174
+ AND a.attnum > 0 AND NOT a.attisdropped
175
+ ORDER BY a.attnum
176
+
177
+ PG::UndefinedTable: ERROR: relation "examples" does not exist
178
+ LINE 5: WHERE a.attrelid = '"examples"'::regclass
179
+ ^
180
+ : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
181
+ pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
182
+ FROM pg_attribute a LEFT JOIN pg_attrdef d
183
+ ON a.attrelid = d.adrelid AND a.attnum = d.adnum
184
+ WHERE a.attrelid = '"examples"'::regclass
185
+ AND a.attnum > 0 AND NOT a.attisdropped
186
+ ORDER BY a.attnum
187
+
188
+ PG::UndefinedTable: ERROR: relation "examples" does not exist
189
+ LINE 5: WHERE a.attrelid = '"examples"'::regclass
190
+ ^
191
+ : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
192
+ pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
193
+ FROM pg_attribute a LEFT JOIN pg_attrdef d
194
+ ON a.attrelid = d.adrelid AND a.attnum = d.adnum
195
+ WHERE a.attrelid = '"examples"'::regclass
196
+ AND a.attnum > 0 AND NOT a.attisdropped
197
+ ORDER BY a.attnum
198
+
199
+ PG::UndefinedTable: ERROR: relation "examples" does not exist
200
+ LINE 5: WHERE a.attrelid = '"examples"'::regclass
201
+ ^
202
+ : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
203
+ pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
204
+ FROM pg_attribute a LEFT JOIN pg_attrdef d
205
+ ON a.attrelid = d.adrelid AND a.attnum = d.adnum
206
+ WHERE a.attrelid = '"examples"'::regclass
207
+ AND a.attnum > 0 AND NOT a.attisdropped
208
+ ORDER BY a.attnum
209
+
210
+  (80.5ms) CREATE TABLE "schema_migrations" ("version" character varying(255) NOT NULL) 
211
+  (11.8ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
212
+ ActiveRecord::SchemaMigration Load (0.4ms) SELECT "schema_migrations".* FROM "schema_migrations"
213
+ Migrating to CreateExamples (20140415105618)
214
+  (0.2ms) BEGIN
215
+  (6.3ms) CREATE TABLE "examples" ("id" serial primary key, "test_attribute" character varying(255), "created_at" timestamp, "updated_at" timestamp) 
216
+ SQL (0.4ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20140415105618"]]
217
+  (2.5ms) COMMIT
218
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
219
+ ActiveRecord::SchemaMigration Load (1.0ms) SELECT "schema_migrations".* FROM "schema_migrations"
220
+ ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
221
+ ExampleWithExpiresIn Load (1.3ms) SELECT "examples".* FROM "examples" WHERE "examples"."test_attribute" = 'user@example.com' AND "examples"."expires_on" = '2014-04-20 04:44:29.795806' LIMIT 1
222
+ PG::UndefinedColumn: ERROR: column examples.expires_on does not exist
223
+ LINE 1: ...amples"."test_attribute" = 'user@example.com' AND "examples"...
224
+ ^
225
+ : SELECT "examples".* FROM "examples" WHERE "examples"."test_attribute" = 'user@example.com' AND "examples"."expires_on" = '2014-04-20 04:44:29.795806' LIMIT 1
226
+ ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
227
+ ExampleWithExpiresIn Load (0.8ms) SELECT "examples".* FROM "examples" WHERE "examples"."test_attribute" = 'user@example.com' LIMIT 1
228
+ ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
229
+ ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
230
+ ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
231
+ ActiveRecord::SchemaMigration Load (2.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
232
+ ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
233
+ ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
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
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/404.html -->
59
+ <div class="dialog">
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>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
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
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/422.html -->
59
+ <div class="dialog">
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>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,66 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
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
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/500.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>We're sorry, but something went wrong.</h1>
62
+ </div>
63
+ <p>If you are the application owner check the logs for more information.</p>
64
+ </div>
65
+ </body>
66
+ </html>
File without changes
@@ -0,0 +1,16 @@
1
+ # Configure Rails Environment
2
+ ENV["RAILS_ENV"] = "test"
3
+ require 'minitest/autorun'
4
+
5
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
6
+ require "rails/test_help"
7
+
8
+ Rails.backtrace_cleaner.remove_silencers!
9
+
10
+ # Load support files
11
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
12
+
13
+ # Load fixtures from the engine
14
+ if ActiveSupport::TestCase.method_defined?(:fixture_path=)
15
+ ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
16
+ end
@@ -0,0 +1,36 @@
1
+ require 'test_helper'
2
+
3
+ describe TokenFor do
4
+
5
+ # TODO Actually test the find_by_whatever_token! method
6
+ describe 'with expires_in' do
7
+ let(:example_class) { ExampleWithoutExpiresIn }
8
+ let(:example_class_with_expired_token) { ExampleWithExpiredToken }
9
+ let(:token) { example_class.new(test_attribute: 'user@example.com').test_token }
10
+ let(:expired_token) { example_class_with_expired_token.new(test_attribute: 'user@example.com').test_token }
11
+
12
+ it('generates token') { token.wont_be_nil }
13
+
14
+ it 'properly verifies the token if active' do
15
+ example_class.verifier_for(:test).verify(token).values.must_include 'user@example.com'
16
+ end
17
+
18
+ it 'raises TokenExpired if the token has expired' do
19
+ # The expires_on key must be in the token
20
+ example_class_with_expired_token.verifier_for(:test).verify(expired_token).keys.must_include :expires_on
21
+ # must_raise needs such syntax
22
+ ->{example_class_with_expired_token.find_by_test_token!(expired_token)}.must_raise TokenFor::TokenExpired
23
+ end
24
+ end
25
+
26
+ describe 'without expires_in' do
27
+ let(:example_class) { ExampleWithoutExpiresIn }
28
+ let(:token) { example_class.new(test_attribute: 'user@example.com').test_token }
29
+
30
+ it('generates token') { token.wont_be_nil }
31
+
32
+ it 'properly verifies the token' do
33
+ example_class.verifier_for(:test).verify(token).must_equal test_attribute: 'user@example.com'
34
+ end
35
+ end
36
+ end