arcadex 1.0.4 → 1.1.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8a2df497f9616e60ada9748c4d8b4f830b73f4bc
4
- data.tar.gz: bdc79db0a5ead6e7cb6792d58a99edfa60269ab3
3
+ metadata.gz: fde8998af5dc3ef8826484cbe4816ed4fafe18d5
4
+ data.tar.gz: 0c62bb5bdbc74436a0a12fc2a887a03faef3df90
5
5
  SHA512:
6
- metadata.gz: cc85b652cf9a5c4c5f1569d5f1ccc807d5d265ad40969f44b9e9425e7f91d56b03e3a964fbd7ff088fc3aa5c67c084f0b9fb30aa6577a7706eb8c3e36cc58e6e
7
- data.tar.gz: a8502e28f49ff40a92913acf12fe8fb11e46eed2d6f07f1d0ce1b41b0e03670989cfc107bfa08f8cd4f339a1c1c0074ff2d8808aa1d4651dab01609bb6ec3a86
6
+ metadata.gz: 14c9ff35b7efea9e0bb45e7b613f70e00f52828ec1c3332bef3a6823c2aff418d38daa80969d9a08dd91260b06904e89a2f2f6229ceac015a73b28676bf6f884
7
+ data.tar.gz: aee13593e96f145daa19114b8c975ece82d22bc32d8036dbe0857eb8de243834580f512d0379b78f5940d543fa8e43d59d3dbd640e1a652b27d4301acee60712
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,56 @@
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
+ }
@@ -29,7 +29,7 @@ module Arcadex
29
29
  if @token.save
30
30
  redirect_to @token, notice: 'Token was successfully created.'
31
31
  else
32
- render action: 'new'
32
+ render :new
33
33
  end
34
34
  end
35
35
 
@@ -38,7 +38,7 @@ module Arcadex
38
38
  if @token.update(token_params)
39
39
  redirect_to @token, notice: 'Token was successfully updated.'
40
40
  else
41
- render action: 'edit'
41
+ render :edit
42
42
  end
43
43
  end
44
44
 
@@ -56,7 +56,7 @@ module Arcadex
56
56
 
57
57
  # Only allow a trusted parameter "white list" through.
58
58
  def token_params
59
- params.require(:token).permit(:imageable_id, :imageable_type, :auth_token)
59
+ params.require(:token).permit(:imageable_id, :imageable_type, :auth_token, :first_ip_address, :current_ip_address, :times_used, :expiration_minutes)
60
60
  end
61
61
  end
62
62
  end
@@ -0,0 +1,4 @@
1
+ module Arcadex
2
+ module TokensHelper
3
+ end
4
+ end
@@ -11,7 +11,7 @@ module Arcadex
11
11
  validates :auth_token, uniqueness: true
12
12
 
13
13
  def generate_hash
14
- self.auth_token = ::Arcadex.generate_auth_token
14
+ self.auth_token = ::Arcadex::Create.generate_auth_token
15
15
  end
16
16
  end
17
17
  end
@@ -4,8 +4,8 @@
4
4
  <h2><%= pluralize(@token.errors.count, "error") %> prohibited this token from being saved:</h2>
5
5
 
6
6
  <ul>
7
- <% @token.errors.full_messages.each do |msg| %>
8
- <li><%= msg %></li>
7
+ <% @token.errors.full_messages.each do |message| %>
8
+ <li><%= message %></li>
9
9
  <% end %>
10
10
  </ul>
11
11
  </div>
@@ -13,7 +13,7 @@
13
13
 
14
14
  <div class="field">
15
15
  <%= f.label :imageable_id %><br>
16
- <%= f.text_field :imageable_id %>
16
+ <%= f.number_field :imageable_id %>
17
17
  </div>
18
18
  <div class="field">
19
19
  <%= f.label :imageable_type %><br>
@@ -23,6 +23,22 @@
23
23
  <%= f.label :auth_token %><br>
24
24
  <%= f.text_field :auth_token %>
25
25
  </div>
26
+ <div class="field">
27
+ <%= f.label :first_ip_address %><br>
28
+ <%= f.text_field :first_ip_address %>
29
+ </div>
30
+ <div class="field">
31
+ <%= f.label :current_ip_address %><br>
32
+ <%= f.text_field :current_ip_address %>
33
+ </div>
34
+ <div class="field">
35
+ <%= f.label :times_used %><br>
36
+ <%= f.number_field :times_used %>
37
+ </div>
38
+ <div class="field">
39
+ <%= f.label :expiration_minutes %><br>
40
+ <%= f.number_field :expiration_minutes %>
41
+ </div>
26
42
  <div class="actions">
27
43
  <%= f.submit %>
28
44
  </div>
@@ -3,12 +3,14 @@
3
3
  <table>
4
4
  <thead>
5
5
  <tr>
6
- <th>Imageable_id</th>
7
- <th>Imageable_type</th>
8
- <th>Auth_token</th>
9
- <th></th>
10
- <th></th>
11
- <th></th>
6
+ <th>Imageable</th>
7
+ <th>Imageable type</th>
8
+ <th>Auth token</th>
9
+ <th>First ip address</th>
10
+ <th>Current ip address</th>
11
+ <th>Times used</th>
12
+ <th>Expiration minutes</th>
13
+ <th colspan="3"></th>
12
14
  </tr>
13
15
  </thead>
14
16
 
@@ -18,6 +20,10 @@
18
20
  <td><%= token.imageable_id %></td>
19
21
  <td><%= token.imageable_type %></td>
20
22
  <td><%= token.auth_token %></td>
23
+ <td><%= token.first_ip_address %></td>
24
+ <td><%= token.current_ip_address %></td>
25
+ <td><%= token.times_used %></td>
26
+ <td><%= token.expiration_minutes %></td>
21
27
  <td><%= link_to 'Show', token %></td>
22
28
  <td><%= link_to 'Edit', edit_token_path(token) %></td>
23
29
  <td><%= link_to 'Destroy', token, method: :delete, data: { confirm: 'Are you sure?' } %></td>
@@ -1,19 +1,39 @@
1
1
  <p id="notice"><%= notice %></p>
2
2
 
3
3
  <p>
4
- <strong>Imageable_id:</strong>
4
+ <strong>Imageable:</strong>
5
5
  <%= @token.imageable_id %>
6
6
  </p>
7
7
 
8
8
  <p>
9
- <strong>Imageable_type:</strong>
9
+ <strong>Imageable type:</strong>
10
10
  <%= @token.imageable_type %>
11
11
  </p>
12
12
 
13
13
  <p>
14
- <strong>Auth_token:</strong>
14
+ <strong>Auth token:</strong>
15
15
  <%= @token.auth_token %>
16
16
  </p>
17
17
 
18
+ <p>
19
+ <strong>First ip address:</strong>
20
+ <%= @token.first_ip_address %>
21
+ </p>
22
+
23
+ <p>
24
+ <strong>Current ip address:</strong>
25
+ <%= @token.current_ip_address %>
26
+ </p>
27
+
28
+ <p>
29
+ <strong>Times used:</strong>
30
+ <%= @token.times_used %>
31
+ </p>
32
+
33
+ <p>
34
+ <strong>Expiration minutes:</strong>
35
+ <%= @token.expiration_minutes %>
36
+ </p>
37
+
18
38
  <%= link_to 'Edit', edit_token_path(@token) %> |
19
39
  <%= link_to 'Back', tokens_path %>
data/config/routes.rb CHANGED
@@ -1,7 +1,5 @@
1
1
  Arcadex::Engine.routes.draw do
2
+
2
3
  root to: "tokens#index"
3
-
4
- scope 'admin' do
5
- resources :tokens
6
- end
4
+ resources :tokens
7
5
  end
@@ -0,0 +1,5 @@
1
+ class AddFirstIpAddressToArcadexTokens < ActiveRecord::Migration
2
+ def change
3
+ add_column :arcadex_tokens, :first_ip_address, :string
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddCurrentIpAddressToArcadexTokens < ActiveRecord::Migration
2
+ def change
3
+ add_column :arcadex_tokens, :current_ip_address, :string
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddTimesUsedToArcadexTokens < ActiveRecord::Migration
2
+ def change
3
+ add_column :arcadex_tokens, :times_used, :integer
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddExpirationMinutesToArcadexTokens < ActiveRecord::Migration
2
+ def change
3
+ add_column :arcadex_tokens, :expiration_minutes, :integer
4
+ end
5
+ end
data/lib/arcadex.rb CHANGED
@@ -1,168 +1,10 @@
1
1
  require "arcadex/engine"
2
+ require "arcadex/authentication"
3
+ require "arcadex/header"
4
+ require "arcadex/find"
5
+ require "arcadex/destroy"
6
+ require "arcadex/create"
2
7
 
3
8
  module Arcadex
4
9
 
5
- ################Below are authentication methods###########################
6
- ############This should be called by the user##############################
7
- def self.full_authentication(params,request,should_use_email)
8
- auth_token = grab_token(params,request)
9
- email = grab_email(params,request)
10
- if should_use_email
11
- return authenticate_with_email_token(auth_token,email)
12
- else
13
- return authenticate_with_only_token(auth_token)
14
- end
15
- end
16
-
17
- ##########Below are authentication helper methods##########################
18
- #########These dont normally need to be called by the user#################
19
- #authenticate_with methods return nil if not authenticated and make a hash
20
- #if things go fine.
21
- #current_owner = @instance_hash["current_user"]
22
- #current_token = @instance_hash["current_token"]
23
-
24
- #Gets the auth_token from either the url or header
25
- def self.grab_token(params,request)
26
- #Header token has preference
27
- if !params["auth_token"].blank?
28
- auth_token = params["auth_token"]
29
- end
30
- if !request.headers["Auth-Token"].blank?
31
- auth_token = request.headers["Auth-Token"]
32
- end
33
- return auth_token
34
- end
35
- #Gets the email from either the url or header
36
- def self.grab_email(params,request)
37
- #Header email has preference
38
- if !params["email"].blank?
39
- email = params["email"]
40
- end
41
- if !request.headers["Email"].blank?
42
- email = request.headers["Email"]
43
- end
44
- return email
45
- end
46
- #This should be used in the application_controller before all actions
47
- def self.authenticate_with_email_token(auth_token,email)
48
- #Find token from auth_token and owner from token
49
- token = ::Arcadex.find_token_by_auth_token(auth_token)
50
- owner = ::Arcadex.find_owner_by_token(token)
51
- #This assumes that the owner of the token is indeed a user
52
- if !token.nil?
53
- user = Object.const_get(token.imageable_type).find_by(email: email)
54
- #user = ::People::User.find_by(email: email)
55
- end
56
- #This is to mitigate timing attacks
57
- ::Devise.secure_compare(auth_token,auth_token)
58
- if owner.nil? || user.nil? || user.id != owner.id
59
- return nil
60
- else
61
- #These are the variables available to every controller that inherits
62
- instance_hash = {"current_user" => owner, "current_token" => token}
63
- return instance_hash
64
- end
65
- end
66
- #This should be used in the application_controller before all actions
67
- def self.authenticate_with_only_token(auth_token)
68
- #Find token from auth_token and owner from token
69
- token = ::Arcadex.find_token_by_auth_token(auth_token)
70
- owner = ::Arcadex.find_owner_by_token(token)
71
- #This is to mitigate timing attacks
72
- ::Devise.secure_compare(auth_token,auth_token)
73
- if owner.nil?
74
- return nil
75
- else
76
- #These are the variables available to every controller that inherits
77
- instance_hash = {"current_user" => owner, "current_token" => token}
78
- return instance_hash
79
- end
80
- end
81
-
82
- ####################Below are helper methods###############################
83
- ############These dont need to be called by the user#######################
84
-
85
- #This is now called by the token when it's first saved
86
- #token = instance.tokens.new
87
- #token.auth_token = Arcadex.generate_auth_token
88
- #token.save
89
- def self.generate_auth_token
90
- token = ::Devise.friendly_token
91
- while Token.exists?(token)
92
- token = ::Devise.friendly_token
93
- end
94
- return token
95
- end
96
- #Arcadex.create_token(instance.id,instance.class.to_s)
97
- def self.create_token(id,type)
98
- token = Token.new
99
- token.imageable_id = id
100
- token.imageable_type = type
101
- #token.auth_token = generate_auth_token
102
- token.save
103
- return token
104
- end
105
-
106
-
107
- #Arcadex.find_token_by_auth_token(token.auth_token)
108
- def self.find_token_by_auth_token(auth_token_string)
109
- token = Token.find_by(auth_token: auth_token_string)
110
- if token.nil?
111
- return nil
112
- end
113
- if token_expired?(token)
114
- destroy_token(token)
115
- return nil
116
- else
117
- return token
118
- end
119
- end
120
-
121
-
122
- #Arcadex.destroy_token(token.auth_token)
123
- def self.destroy_auth_token(auth_token)
124
- token = find_token_by_auth_token(auth_token)
125
- destroy_token(token)
126
- end
127
- def self.destroy_token(token)
128
- if token.nil?
129
- return nil
130
- end
131
- token.destroy
132
- end
133
- #Arcadex.destroy_all_tokens(instance.id,instance.class.to_s)
134
- def self.destroy_all_tokens(id,type)
135
- if Object.const_get(type).exists?(id)
136
- instance = Object.const_get(type).find(id)
137
- instance.tokens.destroy_all
138
- end
139
- end
140
-
141
-
142
- #Arcadex.find_owner_by_auth_token(auth_token)
143
- def self.find_owner_by_auth_token(auth_token)
144
- token = Arcadex.find_token_by_auth_token(auth_token)
145
- return Arcadex.find_owner_by_token(token)
146
- end
147
- #Arcadex.find_owner_by_token(token)
148
- def self.find_owner_by_token(token)
149
- if token.nil?
150
- return nil
151
- end
152
- if token_expired?(token)
153
- destroy_token(token)
154
- return nil
155
- else
156
- instance = Object.const_get(token.imageable_type).find(token.imageable_id)
157
- return instance
158
- end
159
- end
160
-
161
-
162
- #Arcadex.token_expired?(token)
163
- #How long should tokens last? A day if not rememberable
164
- #And a month if you are?
165
- def self.token_expired?(token)
166
- return false
167
- end
168
10
  end
@@ -0,0 +1,70 @@
1
+ module Arcadex
2
+ module Authentication
3
+
4
+ ################Below are authentication methods###########################
5
+ ############This should be called by the user##############################
6
+ def self.full_authentication(params,request,should_use_email)
7
+ auth_token = ::Arcadex::Header.grab_token(params,request)
8
+ email = ::Arcadex::Header.grab_email(params,request)
9
+ instance_hash = nil;
10
+ if should_use_email
11
+ instance_hash = ::Arcadex::Authentication.authenticate_with_email_token(auth_token,email)
12
+ else
13
+ instance_hash = ::Arcadex::Authentication.authenticate_with_only_token(auth_token)
14
+ end
15
+ if instance_hash.nil?
16
+ return nil
17
+ else
18
+ token = instance_hash["current_token"]
19
+ if token.first_ip_address.nil?
20
+ token.first_ip_address = request.remote_ip
21
+ end
22
+ token.current_ip_address = request.remote_ip
23
+ if token.times_used.nil?
24
+ token.times_used = 0;
25
+ end
26
+ token.times_used = token.times_used + 1
27
+ token.save
28
+ return instance_hash
29
+ end
30
+ end
31
+
32
+ #This should be used in the application_controller before all actions
33
+ def self.authenticate_with_email_token(auth_token,email)
34
+ #Find token from auth_token and owner from token
35
+ token = ::Arcadex::Find.find_token_by_auth_token(auth_token)
36
+ owner = ::Arcadex::Find.find_owner_by_token(token)
37
+ #This assumes that the owner of the token is indeed a user
38
+ if !token.nil?
39
+ user = ::Object.const_get(token.imageable_type).find_by(email: email)
40
+ #user = ::People::User.find_by(email: email)
41
+ end
42
+ #This is to mitigate timing attacks
43
+ ::Devise.secure_compare(auth_token,auth_token)
44
+ if owner.nil? || user.nil? || user.id != owner.id
45
+ return nil
46
+ else
47
+ #These are the variables available to every controller that inherits
48
+ instance_hash = {"current_user" => owner, "current_token" => token}
49
+ return instance_hash
50
+ end
51
+ end
52
+
53
+ #This should be used in the application_controller before all actions
54
+ def self.authenticate_with_only_token(auth_token)
55
+ #Find token from auth_token and owner from token
56
+ token = ::Arcadex::Find.find_token_by_auth_token(auth_token)
57
+ owner = ::Arcadex::Find.find_owner_by_token(token)
58
+ #This is to mitigate timing attacks
59
+ ::Devise.secure_compare(auth_token,auth_token)
60
+ if owner.nil?
61
+ return nil
62
+ else
63
+ #These are the variables available to every controller that inherits
64
+ instance_hash = {"current_user" => owner, "current_token" => token}
65
+ return instance_hash
66
+ end
67
+ end
68
+
69
+ end
70
+ end
@@ -0,0 +1,24 @@
1
+ module Arcadex
2
+ module Create
3
+ #This is now called by the token when it's first saved
4
+ def self.generate_auth_token
5
+ token = ::Devise.friendly_token
6
+ while ::Arcadex::Token.exists?(token)
7
+ token = ::Devise.friendly_token
8
+ end
9
+ return token
10
+ end
11
+
12
+ #Arcadex.create_token(instance.tokens.new,exp_minutes,request)
13
+ #Put any token in here to set it's values. Usually when its first created
14
+ def self.set_token(token,exp_minutes,request)
15
+ token.first_ip_address = request.remote_ip
16
+ token.current_ip_address = request.remote_ip
17
+ token.times_used = 0
18
+ token.expiration_minutes = exp_minutes
19
+ token.save
20
+ return token
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,39 @@
1
+ module Arcadex
2
+ module Destroy
3
+
4
+ #Arcadex.destroy_token(token.auth_token)
5
+ def self.destroy_auth_token(auth_token)
6
+ token = ::Arcadex::Find.find_token_by_auth_token(auth_token)
7
+ ::Arcadex::Destroy.destroy_token(token)
8
+ end
9
+ def self.destroy_token(token)
10
+ if token.nil?
11
+ return nil
12
+ end
13
+ token.destroy
14
+ end
15
+ #Arcadex.destroy_all_tokens(instance.id,instance.class.to_s)
16
+ def self.destroy_all_tokens(id,type)
17
+ if ::Object.const_get(type).exists?(id)
18
+ instance = ::Object.const_get(type).find(id)
19
+ instance.tokens.destroy_all
20
+ end
21
+ end
22
+ #Arcadex.token_expired?(token)
23
+ #How long should tokens last? A day if not rememberable
24
+ #And a month if you are?
25
+ def self.token_expired?(token)
26
+ if !token.expiration_minutes.nil?
27
+ date = token.expiration_minutes.minutes + token.created_at
28
+ if date > DateTime.now
29
+ return true
30
+ else
31
+ return false
32
+ end
33
+ else
34
+ return false
35
+ end
36
+ end
37
+
38
+ end
39
+ end
@@ -0,0 +1,39 @@
1
+ module Arcadex
2
+ module Find
3
+
4
+ #Arcadex.find_owner_by_auth_token(auth_token)
5
+ def self.find_owner_by_auth_token(auth_token)
6
+ token = ::Arcadex::Find.find_token_by_auth_token(auth_token)
7
+ return ::Arcadex::Find.find_owner_by_token(token)
8
+ end
9
+
10
+ #Arcadex.find_owner_by_token(token)
11
+ def self.find_owner_by_token(token)
12
+ if token.nil?
13
+ return nil
14
+ end
15
+ if ::Arcadex::Destroy.token_expired?(token)
16
+ ::Arcadex::Destroy.destroy_token(token)
17
+ return nil
18
+ else
19
+ instance = ::Object.const_get(token.imageable_type).find(token.imageable_id)
20
+ return instance
21
+ end
22
+ end
23
+
24
+ #Arcadex.find_token_by_auth_token(token.auth_token)
25
+ def self.find_token_by_auth_token(auth_token_string)
26
+ token = ::Arcadex::Token.find_by(auth_token: auth_token_string)
27
+ if token.nil?
28
+ return nil
29
+ end
30
+ if ::Arcadex::Destroy.token_expired?(token)
31
+ ::Arcardex::Destroy.destroy_token(token)
32
+ return nil
33
+ else
34
+ return token
35
+ end
36
+ end
37
+
38
+ end
39
+ end
@@ -0,0 +1,29 @@
1
+ module Arcadex
2
+ module Header
3
+
4
+ #Gets the auth_token from either the url or header
5
+ def self.grab_token(params,request)
6
+ #Header token has preference
7
+ if !params["auth_token"].blank?
8
+ auth_token = params["auth_token"]
9
+ end
10
+ if !request.headers["Auth-Token"].blank?
11
+ auth_token = request.headers["Auth-Token"]
12
+ end
13
+ return auth_token
14
+ end
15
+
16
+ #Gets the email from either the url or header
17
+ def self.grab_email(params,request)
18
+ #Header email has preference
19
+ if !params["email"].blank?
20
+ email = params["email"]
21
+ end
22
+ if !request.headers["Email"].blank?
23
+ email = request.headers["Email"]
24
+ end
25
+ return email
26
+ end
27
+
28
+ end
29
+ end
@@ -1,3 +1,3 @@
1
1
  module Arcadex
2
- VERSION = "1.0.4"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -0,0 +1,51 @@
1
+ require 'test_helper'
2
+
3
+ module Arcadex
4
+ class TokensControllerTest < ActionController::TestCase
5
+ setup do
6
+ @token = tokens(:one)
7
+ end
8
+
9
+ test "should get index" do
10
+ get :index
11
+ assert_response :success
12
+ assert_not_nil assigns(:tokens)
13
+ end
14
+
15
+ test "should get new" do
16
+ get :new
17
+ assert_response :success
18
+ end
19
+
20
+ test "should create token" do
21
+ assert_difference('Token.count') do
22
+ post :create, token: { auth_token: @token.auth_token, current_ip_address: @token.current_ip_address, expiration_minutes: @token.expiration_minutes, first_ip_address: @token.first_ip_address, imageable_id: @token.imageable_id, imageable_type: @token.imageable_type, times_used: @token.times_used }
23
+ end
24
+
25
+ assert_redirected_to token_path(assigns(:token))
26
+ end
27
+
28
+ test "should show token" do
29
+ get :show, id: @token
30
+ assert_response :success
31
+ end
32
+
33
+ test "should get edit" do
34
+ get :edit, id: @token
35
+ assert_response :success
36
+ end
37
+
38
+ test "should update token" do
39
+ patch :update, id: @token, token: { auth_token: @token.auth_token, current_ip_address: @token.current_ip_address, expiration_minutes: @token.expiration_minutes, first_ip_address: @token.first_ip_address, imageable_id: @token.imageable_id, imageable_type: @token.imageable_type, times_used: @token.times_used }
40
+ assert_redirected_to token_path(assigns(:token))
41
+ end
42
+
43
+ test "should destroy token" do
44
+ assert_difference('Token.count', -1) do
45
+ delete :destroy, id: @token
46
+ end
47
+
48
+ assert_redirected_to tokens_path
49
+ end
50
+ end
51
+ end
Binary file
@@ -11,7 +11,7 @@
11
11
  #
12
12
  # It's strongly recommended that you check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(version: 20140806202340) do
14
+ ActiveRecord::Schema.define(version: 20140910215147) do
15
15
 
16
16
  create_table "arcadex_tokens", force: true do |t|
17
17
  t.integer "imageable_id"
@@ -19,6 +19,10 @@ ActiveRecord::Schema.define(version: 20140806202340) do
19
19
  t.string "auth_token"
20
20
  t.datetime "created_at"
21
21
  t.datetime "updated_at"
22
+ t.string "first_ip_address"
23
+ t.string "current_ip_address"
24
+ t.integer "times_used"
25
+ t.integer "expiration_minutes"
22
26
  end
23
27
 
24
28
  add_index "arcadex_tokens", ["auth_token"], name: "index_arcadex_tokens_on_auth_token", unique: true
@@ -14,3 +14,33 @@ Migrating to AddIndexToToken (20140806202340)
14
14
  SQL (0.6ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20140806202340"]]
15
15
   (100.2ms) commit transaction
16
16
  ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
17
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
18
+ Migrating to AddFirstIpAddressToArcadexTokens (20140910215044)
19
+  (0.1ms) begin transaction
20
+  (0.6ms) ALTER TABLE "arcadex_tokens" ADD "first_ip_address" varchar(255)
21
+ SQL (0.5ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20140910215044"]]
22
+  (226.8ms) commit transaction
23
+ Migrating to AddCurrentIpAddressToArcadexTokens (20140910215118)
24
+  (0.1ms) begin transaction
25
+  (1.7ms) ALTER TABLE "arcadex_tokens" ADD "current_ip_address" varchar(255)
26
+ SQL (1.1ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20140910215118"]]
27
+  (146.8ms) commit transaction
28
+ Migrating to AddTimesUsedToArcadexTokens (20140910215136)
29
+  (0.1ms) begin transaction
30
+  (0.6ms) ALTER TABLE "arcadex_tokens" ADD "times_used" integer
31
+ SQL (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20140910215136"]]
32
+  (141.6ms) commit transaction
33
+ Migrating to AddExpirationMinutesToArcadexTokens (20140910215147)
34
+  (0.2ms) begin transaction
35
+  (1.5ms) ALTER TABLE "arcadex_tokens" ADD "expiration_minutes" integer
36
+ SQL (1.1ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20140910215147"]]
37
+  (169.5ms) commit transaction
38
+ ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
39
+  (0.1ms)  SELECT sql
40
+ FROM sqlite_master
41
+ WHERE name='index_arcadex_tokens_on_auth_token' AND type='index'
42
+ UNION ALL
43
+ SELECT sql
44
+ FROM sqlite_temp_master
45
+ WHERE name='index_arcadex_tokens_on_auth_token' AND type='index'
46
+ 
@@ -4,8 +4,16 @@ one:
4
4
  imageable_id: 1
5
5
  imageable_type: MyString
6
6
  auth_token: MyString
7
+ first_ip_address: MyString
8
+ current_ip_address: MyString
9
+ times_used: 1
10
+ expiration_minutes: 1
7
11
 
8
12
  two:
9
13
  imageable_id: 1
10
14
  imageable_type: MyString
11
15
  auth_token: MyString
16
+ first_ip_address: MyString
17
+ current_ip_address: MyString
18
+ times_used: 1
19
+ expiration_minutes: 1
@@ -0,0 +1,6 @@
1
+ require 'test_helper'
2
+
3
+ module Arcadex
4
+ class TokensHelperTest < ActionView::TestCase
5
+ end
6
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arcadex
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cleophus Robinson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-13 00:00:00.000000000 Z
11
+ date: 2014-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -65,10 +65,14 @@ files:
65
65
  - MIT-LICENSE
66
66
  - Rakefile
67
67
  - app/assets/javascripts/arcadex/application.js
68
+ - app/assets/javascripts/arcadex/tokens.js
68
69
  - app/assets/stylesheets/arcadex/application.css
70
+ - app/assets/stylesheets/arcadex/tokens.css
71
+ - app/assets/stylesheets/scaffold.css
69
72
  - app/controllers/arcadex/application_controller.rb
70
73
  - app/controllers/arcadex/tokens_controller.rb
71
74
  - app/helpers/arcadex/application_helper.rb
75
+ - app/helpers/arcadex/tokens_helper.rb
72
76
  - app/models/arcadex/token.rb
73
77
  - app/views/arcadex/tokens/_form.html.erb
74
78
  - app/views/arcadex/tokens/edit.html.erb
@@ -79,11 +83,21 @@ files:
79
83
  - config/routes.rb
80
84
  - db/migrate/20140806194834_create_arcadex_tokens.rb
81
85
  - db/migrate/20140806202340_add_index_to_token.rb
86
+ - db/migrate/20140910215044_add_first_ip_address_to_arcadex_tokens.rb
87
+ - db/migrate/20140910215118_add_current_ip_address_to_arcadex_tokens.rb
88
+ - db/migrate/20140910215136_add_times_used_to_arcadex_tokens.rb
89
+ - db/migrate/20140910215147_add_expiration_minutes_to_arcadex_tokens.rb
82
90
  - lib/arcadex.rb
91
+ - lib/arcadex/authentication.rb
92
+ - lib/arcadex/create.rb
93
+ - lib/arcadex/destroy.rb
83
94
  - lib/arcadex/engine.rb
95
+ - lib/arcadex/find.rb
96
+ - lib/arcadex/header.rb
84
97
  - lib/arcadex/version.rb
85
98
  - lib/tasks/arcadex_tasks.rake
86
99
  - test/arcadex_test.rb
100
+ - test/controllers/arcadex/tokens_controller_test.rb
87
101
  - test/dummy/README.rdoc
88
102
  - test/dummy/Rakefile
89
103
  - test/dummy/app/assets/javascripts/application.js
@@ -121,6 +135,7 @@ files:
121
135
  - test/dummy/public/500.html
122
136
  - test/dummy/public/favicon.ico
123
137
  - test/fixtures/arcadex/tokens.yml
138
+ - test/helpers/arcadex/tokens_helper_test.rb
124
139
  - test/integration/navigation_test.rb
125
140
  - test/models/arcadex/token_test.rb
126
141
  - test/test_helper.rb
@@ -151,6 +166,7 @@ test_files:
151
166
  - test/fixtures/arcadex/tokens.yml
152
167
  - test/integration/navigation_test.rb
153
168
  - test/models/arcadex/token_test.rb
169
+ - test/controllers/arcadex/tokens_controller_test.rb
154
170
  - test/dummy/bin/rake
155
171
  - test/dummy/bin/rails
156
172
  - test/dummy/bin/bundle
@@ -188,4 +204,5 @@ test_files:
188
204
  - test/dummy/log/development.log
189
205
  - test/dummy/log/test.log
190
206
  - test/test_helper.rb
207
+ - test/helpers/arcadex/tokens_helper_test.rb
191
208
  - test/arcadex_test.rb