simple_token_authentication 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -1
  3. data/lib/simple_token_authentication/acts_as_token_authentication_handler.rb +4 -0
  4. data/lib/simple_token_authentication/version.rb +1 -1
  5. data/spec/dummy/app/models/user.rb +1 -3
  6. data/spec/dummy/config/application.rb +1 -0
  7. data/spec/dummy/config/initializers/devise.rb +3 -3
  8. data/spec/dummy/config/initializers/simple_token_authentication.rb +1 -23
  9. data/spec/dummy/db/migrate/{20140223182309_devise_create_users.rb → 20140426184323_devise_create_users.rb} +0 -0
  10. data/spec/dummy/db/migrate/{20140223182310_add_authentication_token_to_users.rb → 20140426184324_add_authentication_token_to_users.rb} +0 -0
  11. data/spec/dummy/log/test.log +0 -75
  12. metadata +96 -146
  13. data/spec/dummy/app/assets/javascripts/private_posts.js +0 -2
  14. data/spec/dummy/app/assets/stylesheets/private_posts.css +0 -4
  15. data/spec/dummy/app/assets/stylesheets/scaffold.css +0 -56
  16. data/spec/dummy/app/controllers/private_posts_controller.rb +0 -63
  17. data/spec/dummy/app/helpers/private_posts_helper.rb +0 -2
  18. data/spec/dummy/app/models/private_post.rb +0 -2
  19. data/spec/dummy/app/views/private_posts/_form.html.erb +0 -25
  20. data/spec/dummy/app/views/private_posts/edit.html.erb +0 -6
  21. data/spec/dummy/app/views/private_posts/index.html.erb +0 -29
  22. data/spec/dummy/app/views/private_posts/new.html.erb +0 -5
  23. data/spec/dummy/app/views/private_posts/show.html.erb +0 -14
  24. data/spec/dummy/db/migrate/20140223182312_create_private_posts.rb +0 -10
  25. data/spec/dummy/db/schema.rb +0 -43
  26. data/spec/dummy/db/test.sqlite3 +0 -0
  27. data/spec/dummy/spec/controllers/private_posts_controller_spec.rb +0 -22
  28. data/spec/dummy/spec/factories/users.rb +0 -11
  29. data/spec/dummy/spec/helpers/private_posts_helper_spec.rb +0 -15
  30. data/spec/dummy/spec/models/private_post_spec.rb +0 -5
  31. data/spec/dummy/spec/requests/private_posts_controller_spec.rb +0 -47
  32. data/spec/dummy/spec/routing/private_posts_routing_spec.rb +0 -35
  33. data/spec/dummy/spec/views/private_posts/edit.html.erb_spec.rb +0 -20
  34. data/spec/dummy/spec/views/private_posts/index.html.erb_spec.rb +0 -23
  35. data/spec/dummy/spec/views/private_posts/new.html.erb_spec.rb +0 -20
  36. data/spec/dummy/spec/views/private_posts/show.html.erb_spec.rb +0 -17
  37. data/spec/dummy/test/factories/private_posts.rb +0 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b82f0df25b0b1c4f975fac6ff17ec8baf7bb0d56
4
- data.tar.gz: 07648b40370631ec080940103c9e7632639f962b
3
+ metadata.gz: 2222a56f409c3bab94eb3524ee7d28737e264fb5
4
+ data.tar.gz: bbfc724250f735665f3e3bfe933a9fb96bb8784a
5
5
  SHA512:
6
- metadata.gz: abbb4abba13fbf7f9576462e4dc69f55ce516bb43c6c8e2760d009507c2bda35a4ca114172925c706a32aee4392be98104f765c399652048bbbd5755ae761d2d
7
- data.tar.gz: 016afaa432bcde97ca425cd23e574f03369ec45dbf12cefa4f72352bb6b1ce401b17395a7925d234cdcb958bb96f04ffbd1e9ae88b121258b5c32d69372b49da
6
+ metadata.gz: d891e6f73605d2d6f816ae2832f84f91c4fc5cc91fef1e9937f8c9d892a641af8b3e2a80d77f21b769cbaa42bcb4761088fb92f615577744a358f4c7d40c5117
7
+ data.tar.gz: 50421d5fcf18d6850be56676485eaa709b701a9d80125f65a1b43f4bb5b7b6c72482a81533ecbd8183fa4e73447551478e2c30933b4c90341851b64ba8009b85
data/README.md CHANGED
@@ -3,6 +3,8 @@ Simple Token Authentication
3
3
 
4
4
  [![Gem Version](https://badge.fury.io/rb/simple_token_authentication.png)](http://badge.fury.io/rb/simple_token_authentication)
5
5
  [![Build Status](https://travis-ci.org/gonzalo-bulnes/simple_token_authentication.png?branch=master)](https://travis-ci.org/gonzalo-bulnes/simple_token_authentication)
6
+ [![Code Climate](https://codeclimate.com/github/gonzalo-bulnes/simple_token_authentication.png)](https://codeclimate.com/github/gonzalo-bulnes/simple_token_authentication)
7
+ [![Dependency Status](https://gemnasium.com/gonzalo-bulnes/simple_token_authentication.svg)](https://gemnasium.com/gonzalo-bulnes/simple_token_authentication)
6
8
 
7
9
  Token authentication support has been removed from [Devise][devise] for security reasons. In [this gist][original-gist], Devise's [José Valim][josevalim] explains how token authentication should be performed in order to remain safe.
8
10
 
@@ -116,7 +118,7 @@ Usage
116
118
 
117
119
  ### Tokens Generation
118
120
 
119
- Assuming `user` is an instance of `User`, which is _token authenticatable_: each time `user` will be saved, and `user.authentication_token.is_blank?` it receives a new and unique authentication token (via `Devise.friendly_token`).
121
+ Assuming `user` is an instance of `User`, which is _token authenticatable_: each time `user` will be saved, and `user.authentication_token.blank?` it receives a new and unique authentication token (via `Devise.friendly_token`).
120
122
 
121
123
  ### Authentication Method 1: Query Params
122
124
 
@@ -54,6 +54,10 @@ module SimpleTokenAuthentication
54
54
  # in the database with the token given in the params, mitigating
55
55
  # timing attacks.
56
56
  if entity && Devise.secure_compare(entity.authentication_token, params[params_token_name])
57
+ # Sign in using token should not be tracked by Devise trackable
58
+ # See https://github.com/plataformatec/devise/issues/953
59
+ env["devise.skip_trackable"] = true
60
+
57
61
  # Notice we are passing store false, so the entity is not
58
62
  # actually stored in the session and a token is needed
59
63
  # for every request. If you want the token to work as a
@@ -1,3 +1,3 @@
1
1
  module SimpleTokenAuthentication
2
- VERSION = "1.2.0"
2
+ VERSION = "1.2.1"
3
3
  end
@@ -3,6 +3,4 @@ class User < ActiveRecord::Base
3
3
  # :confirmable, :lockable, :timeoutable and :omniauthable
4
4
  devise :database_authenticatable, :registerable,
5
5
  :recoverable, :rememberable, :trackable, :validatable
6
-
7
- acts_as_token_authenticatable
8
- end
6
+ end
@@ -1,3 +1,4 @@
1
+ require 'devise'
1
2
  require File.expand_path('../boot', __FILE__)
2
3
 
3
4
  require 'rails/all'
@@ -1,10 +1,10 @@
1
- require 'devise';# Use this hook to configure devise mailer, warden hooks and so forth.
1
+ # Use this hook to configure devise mailer, warden hooks and so forth.
2
2
  # Many of these configuration options can be set straight in your model.
3
3
  Devise.setup do |config|
4
4
  # The secret key used by Devise. Devise uses this key to generate
5
5
  # random tokens. Changing this key will render invalid all existing
6
6
  # confirmation, reset password and unlock tokens in the database.
7
- config.secret_key = 'f4566668fa384a9f77aa48c780d2889849f31fccda7ec17e009f0bdb29d236727aa710290892c43457946a068bb1974879409493b97c8c2a08dc5a1243d0fdf8'
7
+ config.secret_key = 'd23142eee0a6ef134290f7884471fd7333363b51de5446b94bb52df9bf85bd4d96a6ba6be28f7d64c206273cf20fabbd72781382ba2b02defdb7f843bd13dda6'
8
8
 
9
9
  # ==> Mailer Configuration
10
10
  # Configure the e-mail address which will be shown in Devise::Mailer,
@@ -95,7 +95,7 @@ Devise.setup do |config|
95
95
  config.stretches = Rails.env.test? ? 1 : 10
96
96
 
97
97
  # Setup a pepper to generate the encrypted password.
98
- # config.pepper = '4b8340c47cadf669bea0c43bb407c78d17fe599fc807427b00c08e55529022bfe33e8bfa3e1037de2d52a7f2b8d4f3b117564e6dbc200ea8ab9cb3f402516ba6'
98
+ # config.pepper = 'b7dea1457b7fef1924640a147249994df1ea2557aeddff63a6d5910f5e952b6c3d459663f121ff2c936e7da861da85d013f1e301a9be00d6af30378c505ac908'
99
99
 
100
100
  # ==> Configuration for :confirmable
101
101
  # A period that the user is allowed to access the website even without
@@ -1,23 +1 @@
1
- SimpleTokenAuthentication.configure do |config|
2
-
3
- # Configure the name of the HTTP headers watched for authentication.
4
- #
5
- # Default header names for a given token authenticatable entity follow the pattern:
6
- # { entity: { authentication_token: 'X-Entity-Token', email: 'X-Entity-Email'} }
7
- #
8
- # When several token authenticatable models are defined, custom header names
9
- # can be specified for none, any, or all of them.
10
- #
11
- # Examples
12
- #
13
- # Given User and SuperAdmin are token authenticatable,
14
- # When the following configuration is used:
15
- # `config.header_names = { super_admin: { authentication_token: 'X-Admin-Auth-Token' } }`
16
- # Then the token authentification handler for User watches the following headers:
17
- # `X-User-Token, X-User-Email`
18
- # And the token authentification handler for SuperAdmin watches the following headers:
19
- # `X-Admin-Auth-Token, X-SuperAdmin-Email`
20
- #
21
- config.header_names = { user: { authentication_token: 'X-User-Auth-Token', email: 'X-User-Email' } }
22
-
23
- end
1
+ require 'simple_token_authentication'
@@ -1,75 +0,0 @@
1
-  (123.9ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
2
-  (120.5ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
3
- ActiveRecord::SchemaMigration Load (0.5ms) SELECT "schema_migrations".* FROM "schema_migrations"
4
- Migrating to DeviseCreateUsers (20140223182309)
5
-  (0.1ms) begin transaction
6
-  (0.5ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "email" varchar(255) DEFAULT '' NOT NULL, "encrypted_password" varchar(255) DEFAULT '' NOT NULL, "reset_password_token" varchar(255), "reset_password_sent_at" datetime, "remember_created_at" datetime, "sign_in_count" integer DEFAULT 0 NOT NULL, "current_sign_in_at" datetime, "last_sign_in_at" datetime, "current_sign_in_ip" varchar(255), "last_sign_in_ip" varchar(255), "created_at" datetime, "updated_at" datetime) 
7
-  (0.2ms) CREATE UNIQUE INDEX "index_users_on_email" ON "users" ("email")
8
-  (0.1ms) CREATE UNIQUE INDEX "index_users_on_reset_password_token" ON "users" ("reset_password_token")
9
- SQL (0.4ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20140223182309"]]
10
-  (108.2ms) commit transaction
11
- Migrating to AddAuthenticationTokenToUsers (20140223182310)
12
-  (0.3ms) begin transaction
13
-  (0.6ms) ALTER TABLE "users" ADD "authentication_token" varchar(255)
14
-  (0.3ms) CREATE INDEX "index_users_on_authentication_token" ON "users" ("authentication_token")
15
- SQL (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20140223182310"]]
16
-  (127.5ms) commit transaction
17
- Migrating to CreatePrivatePosts (20140223182312)
18
-  (0.1ms) begin transaction
19
-  (0.6ms) CREATE TABLE "private_posts" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255), "body" text, "created_at" datetime, "updated_at" datetime)
20
- SQL (0.5ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20140223182312"]]
21
-  (84.8ms) commit transaction
22
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
23
- ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
24
-  (0.1ms) begin transaction
25
- Processing by PrivatePostsController#index as HTML
26
- Completed 500 Internal Server Error in 1ms
27
- Processing by PrivatePostsController#new as HTML
28
- Completed 500 Internal Server Error in 0ms
29
-  (0.1ms) rollback transaction
30
-  (0.1ms) begin transaction
31
- Rendered private_posts/_form.html.erb (39.6ms)
32
-  (0.1ms) rollback transaction
33
-  (0.1ms) begin transaction
34
-  (0.1ms) SAVEPOINT active_record_1
35
- User Exists (0.2ms) SELECT 1 AS one FROM "users" WHERE "users"."email" = 'alice@example.com' LIMIT 1
36
- Binary data inserted for `string` type on column `encrypted_password`
37
- SQL (3.1ms) INSERT INTO "users" ("authentication_token", "created_at", "email", "encrypted_password", "updated_at") VALUES (?, ?, ?, ?, ?) [["authentication_token", "ExaMpLeTokEn"], ["created_at", Sun, 23 Feb 2014 18:23:19 UTC +00:00], ["email", "alice@example.com"], ["encrypted_password", "$2a$04$tjMkNZ6xLjEZBvO8NFGVzOBCNhhW7xFEQYQmfoSuWnbF9aaibtdYW"], ["updated_at", Sun, 23 Feb 2014 18:23:19 UTC +00:00]]
38
-  (0.1ms) RELEASE SAVEPOINT active_record_1
39
- Started GET "/private_posts" for 127.0.0.1 at 2014-02-23 15:23:19 -0300
40
- Processing by PrivatePostsController#index as HTML
41
- User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."email" = 'alice@example.com' LIMIT 1
42
- Completed 500 Internal Server Error in 3ms
43
-  (0.2ms) rollback transaction
44
-  (0.1ms) begin transaction
45
-  (0.1ms) SAVEPOINT active_record_1
46
- User Exists (0.1ms) SELECT 1 AS one FROM "users" WHERE "users"."email" = 'alice@example.com' LIMIT 1
47
- Binary data inserted for `string` type on column `encrypted_password`
48
- SQL (1.1ms) INSERT INTO "users" ("authentication_token", "created_at", "email", "encrypted_password", "updated_at") VALUES (?, ?, ?, ?, ?) [["authentication_token", "ExaMpLeTokEn"], ["created_at", Sun, 23 Feb 2014 18:23:19 UTC +00:00], ["email", "alice@example.com"], ["encrypted_password", "$2a$04$AHYqxgr1.sE5iZF7dvLGLuDigz/DhW9DcHkCfE.Qhj.sae1kLsqWa"], ["updated_at", Sun, 23 Feb 2014 18:23:19 UTC +00:00]]
49
-  (0.1ms) RELEASE SAVEPOINT active_record_1
50
- Started GET "/private_posts" for 127.0.0.1 at 2014-02-23 15:23:19 -0300
51
- Processing by PrivatePostsController#index as HTML
52
- User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."email" = 'alice@example.com' LIMIT 1
53
- Completed 500 Internal Server Error in 2ms
54
-  (0.1ms) rollback transaction
55
-  (0.1ms) begin transaction
56
-  (0.1ms) rollback transaction
57
-  (0.1ms) begin transaction
58
-  (0.1ms) rollback transaction
59
-  (0.1ms) begin transaction
60
- Rendered private_posts/_form.html.erb (2.4ms)
61
-  (0.1ms) rollback transaction
62
-  (0.1ms) begin transaction
63
-  (0.1ms) rollback transaction
64
-  (0.1ms) begin transaction
65
-  (0.6ms) rollback transaction
66
-  (0.1ms) begin transaction
67
-  (0.1ms) rollback transaction
68
-  (0.0ms) begin transaction
69
-  (0.1ms) rollback transaction
70
-  (0.1ms) begin transaction
71
-  (0.1ms) rollback transaction
72
-  (0.0ms) begin transaction
73
-  (0.1ms) rollback transaction
74
-  (0.1ms) begin transaction
75
-  (0.1ms) rollback transaction
metadata CHANGED
@@ -1,151 +1,151 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_token_authentication
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gonzalo Bulnes Guilpain
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-24 00:00:00.000000000 Z
11
+ date: 2014-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 3.2.6
20
- - - <
20
+ - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: '5'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - '>='
27
+ - - ">="
28
28
  - !ruby/object:Gem::Version
29
29
  version: 3.2.6
30
- - - <
30
+ - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '5'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: actionmailer
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - '>='
37
+ - - ">="
38
38
  - !ruby/object:Gem::Version
39
39
  version: 3.2.6
40
- - - <
40
+ - - "<"
41
41
  - !ruby/object:Gem::Version
42
42
  version: '5'
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - '>='
47
+ - - ">="
48
48
  - !ruby/object:Gem::Version
49
49
  version: 3.2.6
50
- - - <
50
+ - - "<"
51
51
  - !ruby/object:Gem::Version
52
52
  version: '5'
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: devise
55
55
  requirement: !ruby/object:Gem::Requirement
56
56
  requirements:
57
- - - ~>
57
+ - - "~>"
58
58
  - !ruby/object:Gem::Version
59
59
  version: 3.2.0
60
60
  type: :runtime
61
61
  prerelease: false
62
62
  version_requirements: !ruby/object:Gem::Requirement
63
63
  requirements:
64
- - - ~>
64
+ - - "~>"
65
65
  - !ruby/object:Gem::Version
66
66
  version: 3.2.0
67
67
  - !ruby/object:Gem::Dependency
68
68
  name: sqlite3
69
69
  requirement: !ruby/object:Gem::Requirement
70
70
  requirements:
71
- - - '>='
71
+ - - ">="
72
72
  - !ruby/object:Gem::Version
73
73
  version: '0'
74
74
  type: :development
75
75
  prerelease: false
76
76
  version_requirements: !ruby/object:Gem::Requirement
77
77
  requirements:
78
- - - '>='
78
+ - - ">="
79
79
  - !ruby/object:Gem::Version
80
80
  version: '0'
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: rspec-rails
83
83
  requirement: !ruby/object:Gem::Requirement
84
84
  requirements:
85
- - - '>='
85
+ - - ">="
86
86
  - !ruby/object:Gem::Version
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
90
  version_requirements: !ruby/object:Gem::Requirement
91
91
  requirements:
92
- - - '>='
92
+ - - ">="
93
93
  - !ruby/object:Gem::Version
94
94
  version: '0'
95
95
  - !ruby/object:Gem::Dependency
96
96
  name: factory_girl_rails
97
97
  requirement: !ruby/object:Gem::Requirement
98
98
  requirements:
99
- - - '>='
99
+ - - ">="
100
100
  - !ruby/object:Gem::Version
101
101
  version: '0'
102
102
  type: :development
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
105
105
  requirements:
106
- - - '>='
106
+ - - ">="
107
107
  - !ruby/object:Gem::Version
108
108
  version: '0'
109
109
  - !ruby/object:Gem::Dependency
110
110
  name: cucumber-rails
111
111
  requirement: !ruby/object:Gem::Requirement
112
112
  requirements:
113
- - - '>='
113
+ - - ">="
114
114
  - !ruby/object:Gem::Version
115
115
  version: '0'
116
116
  type: :development
117
117
  prerelease: false
118
118
  version_requirements: !ruby/object:Gem::Requirement
119
119
  requirements:
120
- - - '>='
120
+ - - ">="
121
121
  - !ruby/object:Gem::Version
122
122
  version: '0'
123
123
  - !ruby/object:Gem::Dependency
124
124
  name: database_cleaner
125
125
  requirement: !ruby/object:Gem::Requirement
126
126
  requirements:
127
- - - '>='
127
+ - - ">="
128
128
  - !ruby/object:Gem::Version
129
129
  version: '0'
130
130
  type: :development
131
131
  prerelease: false
132
132
  version_requirements: !ruby/object:Gem::Requirement
133
133
  requirements:
134
- - - '>='
134
+ - - ">="
135
135
  - !ruby/object:Gem::Version
136
136
  version: '0'
137
137
  - !ruby/object:Gem::Dependency
138
138
  name: aruba
139
139
  requirement: !ruby/object:Gem::Requirement
140
140
  requirements:
141
- - - '>='
141
+ - - ">="
142
142
  - !ruby/object:Gem::Version
143
143
  version: '0'
144
144
  type: :development
145
145
  prerelease: false
146
146
  version_requirements: !ruby/object:Gem::Requirement
147
147
  requirements:
148
- - - '>='
148
+ - - ">="
149
149
  - !ruby/object:Gem::Version
150
150
  version: '0'
151
151
  description:
@@ -155,84 +155,59 @@ executables: []
155
155
  extensions: []
156
156
  extra_rdoc_files: []
157
157
  files:
158
- - lib/tasks/cucumber.rake
159
- - lib/tasks/simple_token_authentication_tasks.rake
160
- - lib/simple_token_authentication/configuration.rb
158
+ - LICENSE
159
+ - README.md
160
+ - Rakefile
161
+ - lib/simple_token_authentication.rb
161
162
  - lib/simple_token_authentication/acts_as_token_authenticatable.rb
162
163
  - lib/simple_token_authentication/acts_as_token_authentication_handler.rb
164
+ - lib/simple_token_authentication/configuration.rb
163
165
  - lib/simple_token_authentication/version.rb
164
- - lib/simple_token_authentication.rb
165
- - LICENSE
166
- - Rakefile
167
- - README.md
168
- - spec/dummy/config.ru
166
+ - lib/tasks/cucumber.rake
167
+ - lib/tasks/simple_token_authentication_tasks.rake
169
168
  - spec/dummy/Gemfile
169
+ - spec/dummy/README.rdoc
170
+ - spec/dummy/Rakefile
171
+ - spec/dummy/app/assets/javascripts/application.js
172
+ - spec/dummy/app/assets/stylesheets/application.css
173
+ - spec/dummy/app/controllers/application_controller.rb
174
+ - spec/dummy/app/helpers/application_helper.rb
175
+ - spec/dummy/app/models/user.rb
176
+ - spec/dummy/app/views/layouts/application.html.erb
170
177
  - spec/dummy/bin/bundle
171
178
  - spec/dummy/bin/rails
172
179
  - spec/dummy/bin/rake
173
- - spec/dummy/db/seeds.rb
174
- - spec/dummy/db/migrate/20140223182312_create_private_posts.rb
175
- - spec/dummy/db/migrate/20140223182309_devise_create_users.rb
176
- - spec/dummy/db/migrate/20140223182310_add_authentication_token_to_users.rb
177
- - spec/dummy/db/test.sqlite3
178
- - spec/dummy/db/schema.rb
179
- - spec/dummy/log/test.log
180
- - spec/dummy/README.rdoc
181
- - spec/dummy/config/initializers/wrap_parameters.rb
182
- - spec/dummy/config/initializers/inflections.rb
183
- - spec/dummy/config/initializers/secret_token.rb
184
- - spec/dummy/config/initializers/simple_token_authentication.rb
185
- - spec/dummy/config/initializers/devise.rb
186
- - spec/dummy/config/initializers/session_store.rb
187
- - spec/dummy/config/initializers/backtrace_silencers.rb
188
- - spec/dummy/config/initializers/filter_parameter_logging.rb
189
- - spec/dummy/config/initializers/mime_types.rb
190
- - spec/dummy/config/boot.rb
191
- - spec/dummy/config/routes.rb
180
+ - spec/dummy/config.ru
192
181
  - spec/dummy/config/application.rb
193
- - spec/dummy/config/environments/production.rb
194
- - spec/dummy/config/environments/development.rb
195
- - spec/dummy/config/environments/test.rb
182
+ - spec/dummy/config/boot.rb
196
183
  - spec/dummy/config/database.yml
197
184
  - spec/dummy/config/environment.rb
185
+ - spec/dummy/config/environments/development.rb
186
+ - spec/dummy/config/environments/production.rb
187
+ - spec/dummy/config/environments/test.rb
188
+ - spec/dummy/config/initializers/backtrace_silencers.rb
189
+ - spec/dummy/config/initializers/devise.rb
190
+ - spec/dummy/config/initializers/filter_parameter_logging.rb
191
+ - spec/dummy/config/initializers/inflections.rb
192
+ - spec/dummy/config/initializers/mime_types.rb
193
+ - spec/dummy/config/initializers/secret_token.rb
194
+ - spec/dummy/config/initializers/session_store.rb
195
+ - spec/dummy/config/initializers/simple_token_authentication.rb
196
+ - spec/dummy/config/initializers/wrap_parameters.rb
198
197
  - spec/dummy/config/locales/devise.en.yml
199
198
  - spec/dummy/config/locales/en.yml
200
- - spec/dummy/Rakefile
201
- - spec/dummy/spec/spec_helper.rb
202
- - spec/dummy/spec/views/private_posts/edit.html.erb_spec.rb
203
- - spec/dummy/spec/views/private_posts/new.html.erb_spec.rb
204
- - spec/dummy/spec/views/private_posts/index.html.erb_spec.rb
205
- - spec/dummy/spec/views/private_posts/show.html.erb_spec.rb
206
- - spec/dummy/spec/support/factory_girl.rb
207
- - spec/dummy/spec/factories/users.rb
208
- - spec/dummy/spec/routing/private_posts_routing_spec.rb
209
- - spec/dummy/spec/models/private_post_spec.rb
210
- - spec/dummy/spec/controllers/private_posts_controller_spec.rb
211
- - spec/dummy/spec/requests/private_posts_controller_spec.rb
212
- - spec/dummy/spec/helpers/private_posts_helper_spec.rb
213
- - spec/dummy/app/views/layouts/application.html.erb
214
- - spec/dummy/app/views/private_posts/new.html.erb
215
- - spec/dummy/app/views/private_posts/index.html.erb
216
- - spec/dummy/app/views/private_posts/edit.html.erb
217
- - spec/dummy/app/views/private_posts/_form.html.erb
218
- - spec/dummy/app/views/private_posts/show.html.erb
219
- - spec/dummy/app/assets/stylesheets/private_posts.css
220
- - spec/dummy/app/assets/stylesheets/application.css
221
- - spec/dummy/app/assets/stylesheets/scaffold.css
222
- - spec/dummy/app/assets/javascripts/private_posts.js
223
- - spec/dummy/app/assets/javascripts/application.js
224
- - spec/dummy/app/models/private_post.rb
225
- - spec/dummy/app/models/user.rb
226
- - spec/dummy/app/controllers/private_posts_controller.rb
227
- - spec/dummy/app/controllers/application_controller.rb
228
- - spec/dummy/app/helpers/application_helper.rb
229
- - spec/dummy/app/helpers/private_posts_helper.rb
230
- - spec/dummy/test/factories/private_posts.rb
231
- - spec/dummy/public/robots.txt
199
+ - spec/dummy/config/routes.rb
200
+ - spec/dummy/db/migrate/20140426184323_devise_create_users.rb
201
+ - spec/dummy/db/migrate/20140426184324_add_authentication_token_to_users.rb
202
+ - spec/dummy/db/seeds.rb
203
+ - spec/dummy/log/test.log
204
+ - spec/dummy/public/404.html
205
+ - spec/dummy/public/422.html
232
206
  - spec/dummy/public/500.html
233
207
  - spec/dummy/public/favicon.ico
234
- - spec/dummy/public/422.html
235
- - spec/dummy/public/404.html
208
+ - spec/dummy/public/robots.txt
209
+ - spec/dummy/spec/spec_helper.rb
210
+ - spec/dummy/spec/support/factory_girl.rb
236
211
  homepage: https://github.com/gonzalo-bulnes/simple_token_authentication
237
212
  licenses:
238
213
  - GPLv3
@@ -243,86 +218,61 @@ require_paths:
243
218
  - lib
244
219
  required_ruby_version: !ruby/object:Gem::Requirement
245
220
  requirements:
246
- - - '>='
221
+ - - ">="
247
222
  - !ruby/object:Gem::Version
248
223
  version: '0'
249
224
  required_rubygems_version: !ruby/object:Gem::Requirement
250
225
  requirements:
251
- - - '>='
226
+ - - ">="
252
227
  - !ruby/object:Gem::Version
253
228
  version: '0'
254
229
  requirements: []
255
230
  rubyforge_project:
256
- rubygems_version: 2.1.11
231
+ rubygems_version: 2.2.2
257
232
  signing_key:
258
233
  specification_version: 4
259
234
  summary: Simple (but safe) token authentication for Rails apps or API with Devise.
260
235
  test_files:
261
- - spec/dummy/config.ru
262
- - spec/dummy/Gemfile
236
+ - spec/dummy/spec/spec_helper.rb
237
+ - spec/dummy/spec/support/factory_girl.rb
238
+ - spec/dummy/log/test.log
239
+ - spec/dummy/public/robots.txt
240
+ - spec/dummy/public/favicon.ico
241
+ - spec/dummy/public/500.html
242
+ - spec/dummy/public/404.html
243
+ - spec/dummy/public/422.html
244
+ - spec/dummy/db/seeds.rb
245
+ - spec/dummy/db/migrate/20140426184324_add_authentication_token_to_users.rb
246
+ - spec/dummy/db/migrate/20140426184323_devise_create_users.rb
247
+ - spec/dummy/bin/rake
263
248
  - spec/dummy/bin/bundle
264
249
  - spec/dummy/bin/rails
265
- - spec/dummy/bin/rake
266
- - spec/dummy/db/seeds.rb
267
- - spec/dummy/db/migrate/20140223182312_create_private_posts.rb
268
- - spec/dummy/db/migrate/20140223182309_devise_create_users.rb
269
- - spec/dummy/db/migrate/20140223182310_add_authentication_token_to_users.rb
270
- - spec/dummy/db/test.sqlite3
271
- - spec/dummy/db/schema.rb
272
- - spec/dummy/log/test.log
273
- - spec/dummy/README.rdoc
274
- - spec/dummy/config/initializers/wrap_parameters.rb
250
+ - spec/dummy/Gemfile
251
+ - spec/dummy/config/application.rb
252
+ - spec/dummy/config/locales/en.yml
253
+ - spec/dummy/config/locales/devise.en.yml
254
+ - spec/dummy/config/initializers/backtrace_silencers.rb
255
+ - spec/dummy/config/initializers/session_store.rb
256
+ - spec/dummy/config/initializers/mime_types.rb
275
257
  - spec/dummy/config/initializers/inflections.rb
258
+ - spec/dummy/config/initializers/wrap_parameters.rb
276
259
  - spec/dummy/config/initializers/secret_token.rb
260
+ - spec/dummy/config/initializers/filter_parameter_logging.rb
277
261
  - spec/dummy/config/initializers/simple_token_authentication.rb
278
262
  - spec/dummy/config/initializers/devise.rb
279
- - spec/dummy/config/initializers/session_store.rb
280
- - spec/dummy/config/initializers/backtrace_silencers.rb
281
- - spec/dummy/config/initializers/filter_parameter_logging.rb
282
- - spec/dummy/config/initializers/mime_types.rb
283
- - spec/dummy/config/boot.rb
263
+ - spec/dummy/config/environment.rb
284
264
  - spec/dummy/config/routes.rb
285
- - spec/dummy/config/application.rb
286
- - spec/dummy/config/environments/production.rb
265
+ - spec/dummy/config/boot.rb
287
266
  - spec/dummy/config/environments/development.rb
288
267
  - spec/dummy/config/environments/test.rb
268
+ - spec/dummy/config/environments/production.rb
289
269
  - spec/dummy/config/database.yml
290
- - spec/dummy/config/environment.rb
291
- - spec/dummy/config/locales/devise.en.yml
292
- - spec/dummy/config/locales/en.yml
293
- - spec/dummy/Rakefile
294
- - spec/dummy/spec/spec_helper.rb
295
- - spec/dummy/spec/views/private_posts/edit.html.erb_spec.rb
296
- - spec/dummy/spec/views/private_posts/new.html.erb_spec.rb
297
- - spec/dummy/spec/views/private_posts/index.html.erb_spec.rb
298
- - spec/dummy/spec/views/private_posts/show.html.erb_spec.rb
299
- - spec/dummy/spec/support/factory_girl.rb
300
- - spec/dummy/spec/factories/users.rb
301
- - spec/dummy/spec/routing/private_posts_routing_spec.rb
302
- - spec/dummy/spec/models/private_post_spec.rb
303
- - spec/dummy/spec/controllers/private_posts_controller_spec.rb
304
- - spec/dummy/spec/requests/private_posts_controller_spec.rb
305
- - spec/dummy/spec/helpers/private_posts_helper_spec.rb
306
- - spec/dummy/app/views/layouts/application.html.erb
307
- - spec/dummy/app/views/private_posts/new.html.erb
308
- - spec/dummy/app/views/private_posts/index.html.erb
309
- - spec/dummy/app/views/private_posts/edit.html.erb
310
- - spec/dummy/app/views/private_posts/_form.html.erb
311
- - spec/dummy/app/views/private_posts/show.html.erb
312
- - spec/dummy/app/assets/stylesheets/private_posts.css
313
- - spec/dummy/app/assets/stylesheets/application.css
314
- - spec/dummy/app/assets/stylesheets/scaffold.css
315
- - spec/dummy/app/assets/javascripts/private_posts.js
316
270
  - spec/dummy/app/assets/javascripts/application.js
317
- - spec/dummy/app/models/private_post.rb
318
- - spec/dummy/app/models/user.rb
319
- - spec/dummy/app/controllers/private_posts_controller.rb
271
+ - spec/dummy/app/assets/stylesheets/application.css
320
272
  - spec/dummy/app/controllers/application_controller.rb
321
273
  - spec/dummy/app/helpers/application_helper.rb
322
- - spec/dummy/app/helpers/private_posts_helper.rb
323
- - spec/dummy/test/factories/private_posts.rb
324
- - spec/dummy/public/robots.txt
325
- - spec/dummy/public/500.html
326
- - spec/dummy/public/favicon.ico
327
- - spec/dummy/public/422.html
328
- - spec/dummy/public/404.html
274
+ - spec/dummy/app/views/layouts/application.html.erb
275
+ - spec/dummy/app/models/user.rb
276
+ - spec/dummy/README.rdoc
277
+ - spec/dummy/Rakefile
278
+ - spec/dummy/config.ru
@@ -1,2 +0,0 @@
1
- // Place all the behaviors and hooks related to the matching controller here.
2
- // All this logic will automatically be available in application.js.
@@ -1,4 +0,0 @@
1
- /*
2
- Place all the styles related to the matching controller here.
3
- They will automatically be included in application.css.
4
- */
@@ -1,56 +0,0 @@
1
- body { background-color: #fff; color: #333; }
2
-
3
- body, p, ol, ul, td {
4
- font-family: verdana, arial, helvetica, sans-serif;
5
- font-size: 13px;
6
- line-height: 18px;
7
- }
8
-
9
- pre {
10
- background-color: #eee;
11
- padding: 10px;
12
- font-size: 11px;
13
- }
14
-
15
- a { color: #000; }
16
- a:visited { color: #666; }
17
- a:hover { color: #fff; background-color:#000; }
18
-
19
- div.field, div.actions {
20
- margin-bottom: 10px;
21
- }
22
-
23
- #notice {
24
- color: green;
25
- }
26
-
27
- .field_with_errors {
28
- padding: 2px;
29
- background-color: red;
30
- display: table;
31
- }
32
-
33
- #error_explanation {
34
- width: 450px;
35
- border: 2px solid red;
36
- padding: 7px;
37
- padding-bottom: 0;
38
- margin-bottom: 20px;
39
- background-color: #f0f0f0;
40
- }
41
-
42
- #error_explanation h2 {
43
- text-align: left;
44
- font-weight: bold;
45
- padding: 5px 5px 5px 15px;
46
- font-size: 12px;
47
- margin: -7px;
48
- margin-bottom: 0px;
49
- background-color: #c00;
50
- color: #fff;
51
- }
52
-
53
- #error_explanation ul li {
54
- font-size: 12px;
55
- list-style: square;
56
- }
@@ -1,63 +0,0 @@
1
- class PrivatePostsController < ApplicationController
2
-
3
- # Please do notice that this controller DOES call `acts_as_authentication_handler`.
4
- # See test/dummy/spec/requests/posts_specs.rb
5
- acts_as_token_authentication_handler_for User
6
-
7
- before_action :set_private_post, only: [:show, :edit, :update, :destroy]
8
-
9
- # GET /private_posts
10
- def index
11
- @private_posts = PrivatePost.all
12
- end
13
-
14
- # GET /private_posts/1
15
- def show
16
- end
17
-
18
- # GET /private_posts/new
19
- def new
20
- @private_post = PrivatePost.new
21
- end
22
-
23
- # GET /private_posts/1/edit
24
- def edit
25
- end
26
-
27
- # POST /private_posts
28
- def create
29
- @private_post = PrivatePost.new(private_post_params)
30
-
31
- if @private_post.save
32
- redirect_to @private_post, notice: 'Private post was successfully created.'
33
- else
34
- render action: 'new'
35
- end
36
- end
37
-
38
- # PATCH/PUT /private_posts/1
39
- def update
40
- if @private_post.update(private_post_params)
41
- redirect_to @private_post, notice: 'Private post was successfully updated.'
42
- else
43
- render action: 'edit'
44
- end
45
- end
46
-
47
- # DELETE /private_posts/1
48
- def destroy
49
- @private_post.destroy
50
- redirect_to private_posts_url, notice: 'Private post was successfully destroyed.'
51
- end
52
-
53
- private
54
- # Use callbacks to share common setup or constraints between actions.
55
- def set_private_post
56
- @private_post = PrivatePost.find(params[:id])
57
- end
58
-
59
- # Only allow a trusted parameter "white list" through.
60
- def private_post_params
61
- params.require(:private_post).permit(:title, :body)
62
- end
63
- end
@@ -1,2 +0,0 @@
1
- module PrivatePostsHelper
2
- end
@@ -1,2 +0,0 @@
1
- class PrivatePost < ActiveRecord::Base
2
- end
@@ -1,25 +0,0 @@
1
- <%= form_for(@private_post) do |f| %>
2
- <% if @private_post.errors.any? %>
3
- <div id="error_explanation">
4
- <h2><%= pluralize(@private_post.errors.count, "error") %> prohibited this private_post from being saved:</h2>
5
-
6
- <ul>
7
- <% @private_post.errors.full_messages.each do |msg| %>
8
- <li><%= msg %></li>
9
- <% end %>
10
- </ul>
11
- </div>
12
- <% end %>
13
-
14
- <div class="field">
15
- <%= f.label :title %><br>
16
- <%= f.text_field :title %>
17
- </div>
18
- <div class="field">
19
- <%= f.label :body %><br>
20
- <%= f.text_area :body %>
21
- </div>
22
- <div class="actions">
23
- <%= f.submit %>
24
- </div>
25
- <% end %>
@@ -1,6 +0,0 @@
1
- <h1>Editing private_post</h1>
2
-
3
- <%= render 'form' %>
4
-
5
- <%= link_to 'Show', @private_post %> |
6
- <%= link_to 'Back', private_posts_path %>
@@ -1,29 +0,0 @@
1
- <h1>Listing private_posts</h1>
2
-
3
- <table>
4
- <thead>
5
- <tr>
6
- <th>Title</th>
7
- <th>Body</th>
8
- <th></th>
9
- <th></th>
10
- <th></th>
11
- </tr>
12
- </thead>
13
-
14
- <tbody>
15
- <% @private_posts.each do |private_post| %>
16
- <tr>
17
- <td><%= private_post.title %></td>
18
- <td><%= private_post.body %></td>
19
- <td><%= link_to 'Show', private_post %></td>
20
- <td><%= link_to 'Edit', edit_private_post_path(private_post) %></td>
21
- <td><%= link_to 'Destroy', private_post, method: :delete, data: { confirm: 'Are you sure?' } %></td>
22
- </tr>
23
- <% end %>
24
- </tbody>
25
- </table>
26
-
27
- <br>
28
-
29
- <%= link_to 'New Private post', new_private_post_path %>
@@ -1,5 +0,0 @@
1
- <h1>New private_post</h1>
2
-
3
- <%= render 'form' %>
4
-
5
- <%= link_to 'Back', private_posts_path %>
@@ -1,14 +0,0 @@
1
- <p id="notice"><%= notice %></p>
2
-
3
- <p>
4
- <strong>Title:</strong>
5
- <%= @private_post.title %>
6
- </p>
7
-
8
- <p>
9
- <strong>Body:</strong>
10
- <%= @private_post.body %>
11
- </p>
12
-
13
- <%= link_to 'Edit', edit_private_post_path(@private_post) %> |
14
- <%= link_to 'Back', private_posts_path %>
@@ -1,10 +0,0 @@
1
- class CreatePrivatePosts < ActiveRecord::Migration
2
- def change
3
- create_table :private_posts do |t|
4
- t.string :title
5
- t.text :body
6
-
7
- t.timestamps
8
- end
9
- end
10
- end
@@ -1,43 +0,0 @@
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: 20140223182312) do
15
-
16
- create_table "private_posts", force: true do |t|
17
- t.string "title"
18
- t.text "body"
19
- t.datetime "created_at"
20
- t.datetime "updated_at"
21
- end
22
-
23
- create_table "users", force: true do |t|
24
- t.string "email", default: "", null: false
25
- t.string "encrypted_password", default: "", null: false
26
- t.string "reset_password_token"
27
- t.datetime "reset_password_sent_at"
28
- t.datetime "remember_created_at"
29
- t.integer "sign_in_count", default: 0, null: false
30
- t.datetime "current_sign_in_at"
31
- t.datetime "last_sign_in_at"
32
- t.string "current_sign_in_ip"
33
- t.string "last_sign_in_ip"
34
- t.datetime "created_at"
35
- t.datetime "updated_at"
36
- t.string "authentication_token"
37
- end
38
-
39
- add_index "users", ["authentication_token"], name: "index_users_on_authentication_token"
40
- add_index "users", ["email"], name: "index_users_on_email", unique: true
41
- add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
42
-
43
- end
Binary file
@@ -1,22 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe PrivatePostsController do
4
-
5
- # This should return the minimal set of attributes required to create a valid
6
- # PrivatePost. As you add validations to PrivatePost, be sure to
7
- # adjust the attributes here as well.
8
- let(:valid_attributes) { { "title" => "MyString" } }
9
-
10
- # This should return the minimal set of values that should be in the session
11
- # in order to pass any filters (e.g. authentication) defined in
12
- # PrivatePostsController. Be sure to keep this updated too.
13
- let(:valid_session) { {} }
14
-
15
- describe "actions" do
16
- it "all require authentication" do
17
- # That's true for all actions, yet I think there's no need to repeat them all here.
18
- lambda { get :index, {}, valid_session }.should raise_exception(RuntimeError)
19
- lambda { get :new, {}, valid_session }.should raise_exception(RuntimeError)
20
- end
21
- end
22
- end
@@ -1,11 +0,0 @@
1
- FactoryGirl.define do
2
- sequence :email do |n|
3
- "user#{n}@factory.com"
4
- end
5
-
6
- factory :user do
7
- email
8
- password "password"
9
- password_confirmation "password"
10
- end
11
- end
@@ -1,15 +0,0 @@
1
- require 'spec_helper'
2
-
3
- # Specs in this file have access to a helper object that includes
4
- # the PrivatePostsHelper. For example:
5
- #
6
- # describe PrivatePostsHelper do
7
- # describe "string concat" do
8
- # it "concats two strings with spaces" do
9
- # expect(helper.concat_strings("this","that")).to eq("this that")
10
- # end
11
- # end
12
- # end
13
- describe PrivatePostsHelper do
14
- pending "add some examples to (or delete) #{__FILE__}"
15
- end
@@ -1,5 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe PrivatePost do
4
- pending "add some examples to (or delete) #{__FILE__}"
5
- end
@@ -1,47 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "PrivatePostsController" do
4
- describe "GET /private_posts" do
5
-
6
- context "when an initializer overrides the header_names default value" do
7
-
8
- # See config/initializers/simple_token_authentication.rb
9
-
10
- context "and the custom headers are set in the request" do
11
-
12
- it "performs token authentication" do
13
- user = FactoryGirl.create(:user \
14
- ,email: 'alice@example.com' \
15
- ,authentication_token: 'ExaMpLeTokEn' )
16
-
17
- # `sign_in` is configured to raise an exception when called,
18
- # see spec/dummy/app/controllers/application_controller.rb
19
- lambda do
20
- # see https://github.com/rspec/rspec-rails/issues/65
21
- # and http://guides.rubyonrails.org/testing.html#helpers-available-for-integration-tests
22
- request_via_redirect 'GET', private_posts_path, nil, { 'X-User-Email' => user.email, 'X-User-Auth-Token' => user.authentication_token }
23
- end.should raise_exception(RuntimeError, "`sign_in` was called.")
24
- end
25
- end
26
- context "and the custom headers are missing in the request (and no query params are used)" do
27
- context "even if the default headers are set in the request" do
28
-
29
- it "does not perform token authentication" do
30
- user = FactoryGirl.create(:user \
31
- ,email: 'alice@example.com' \
32
- ,authentication_token: 'ExaMpLeTokEn' )
33
-
34
- # `authenticate_user!` is configured to raise an exception when called,
35
- # see spec/dummy/app/controllers/application_controller.rb
36
- lambda do
37
- # see https://github.com/rspec/rspec-rails/issues/65
38
- # and http://guides.rubyonrails.org/testing.html#helpers-available-for-integration-tests
39
- request_via_redirect 'GET', private_posts_path, nil, { 'X-User-Email' => user.email, 'X-User-Token' => user.authentication_token }
40
- end.should raise_exception(RuntimeError, "`authenticate_user!` was called.")
41
- end
42
- end
43
- end
44
-
45
- end
46
- end
47
- end
@@ -1,35 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe PrivatePostsController do
4
- describe "routing" do
5
-
6
- it "routes to #index" do
7
- get("/private_posts").should route_to("private_posts#index")
8
- end
9
-
10
- it "routes to #new" do
11
- get("/private_posts/new").should route_to("private_posts#new")
12
- end
13
-
14
- it "routes to #show" do
15
- get("/private_posts/1").should route_to("private_posts#show", :id => "1")
16
- end
17
-
18
- it "routes to #edit" do
19
- get("/private_posts/1/edit").should route_to("private_posts#edit", :id => "1")
20
- end
21
-
22
- it "routes to #create" do
23
- post("/private_posts").should route_to("private_posts#create")
24
- end
25
-
26
- it "routes to #update" do
27
- put("/private_posts/1").should route_to("private_posts#update", :id => "1")
28
- end
29
-
30
- it "routes to #destroy" do
31
- delete("/private_posts/1").should route_to("private_posts#destroy", :id => "1")
32
- end
33
-
34
- end
35
- end
@@ -1,20 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "private_posts/edit" do
4
- before(:each) do
5
- @private_post = assign(:private_post, stub_model(PrivatePost,
6
- :title => "MyString",
7
- :body => "MyText"
8
- ))
9
- end
10
-
11
- it "renders the edit private_post form" do
12
- render
13
-
14
- # Run the generator again with the --webrat flag if you want to use webrat matchers
15
- assert_select "form[action=?][method=?]", private_post_path(@private_post), "post" do
16
- assert_select "input#private_post_title[name=?]", "private_post[title]"
17
- assert_select "textarea#private_post_body[name=?]", "private_post[body]"
18
- end
19
- end
20
- end
@@ -1,23 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "private_posts/index" do
4
- before(:each) do
5
- assign(:private_posts, [
6
- stub_model(PrivatePost,
7
- :title => "Title",
8
- :body => "MyText"
9
- ),
10
- stub_model(PrivatePost,
11
- :title => "Title",
12
- :body => "MyText"
13
- )
14
- ])
15
- end
16
-
17
- it "renders a list of private_posts" do
18
- render
19
- # Run the generator again with the --webrat flag if you want to use webrat matchers
20
- assert_select "tr>td", :text => "Title".to_s, :count => 2
21
- assert_select "tr>td", :text => "MyText".to_s, :count => 2
22
- end
23
- end
@@ -1,20 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "private_posts/new" do
4
- before(:each) do
5
- assign(:private_post, stub_model(PrivatePost,
6
- :title => "MyString",
7
- :body => "MyText"
8
- ).as_new_record)
9
- end
10
-
11
- it "renders new private_post form" do
12
- render
13
-
14
- # Run the generator again with the --webrat flag if you want to use webrat matchers
15
- assert_select "form[action=?][method=?]", private_posts_path, "post" do
16
- assert_select "input#private_post_title[name=?]", "private_post[title]"
17
- assert_select "textarea#private_post_body[name=?]", "private_post[body]"
18
- end
19
- end
20
- end
@@ -1,17 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "private_posts/show" do
4
- before(:each) do
5
- @private_post = assign(:private_post, stub_model(PrivatePost,
6
- :title => "Title",
7
- :body => "MyText"
8
- ))
9
- end
10
-
11
- it "renders attributes in <p>" do
12
- render
13
- # Run the generator again with the --webrat flag if you want to use webrat matchers
14
- rendered.should match(/Title/)
15
- rendered.should match(/MyText/)
16
- end
17
- end
@@ -1,8 +0,0 @@
1
- # Read about factories at https://github.com/thoughtbot/factory_girl
2
-
3
- FactoryGirl.define do
4
- factory :private_post do
5
- title "MyString"
6
- body "MyText"
7
- end
8
- end