challah 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/lib/challah/encrypter.rb +1 -1
  3. data/lib/challah/engine.rb +1 -3
  4. data/lib/challah/routes.rb +1 -6
  5. data/lib/challah/test.rb +1 -1
  6. data/lib/challah/version.rb +2 -2
  7. data/test/{controller_test.rb → controllers/controller_test.rb} +2 -2
  8. data/test/{restrictions_controller_test.rb → controllers/restrictions_controller_test.rb} +2 -4
  9. data/test/{sessions_controller_test.rb → controllers/sessions_controller_test.rb} +2 -2
  10. data/test/dummy/README.rdoc +28 -0
  11. data/test/dummy/Rakefile +6 -0
  12. data/test/dummy/app/assets/javascripts/application.js +13 -0
  13. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  14. data/test/dummy/app/controllers/application_controller.rb +5 -0
  15. data/{app/controllers/challah/test → test/dummy/app/controllers}/restrictions_controller.rb +2 -2
  16. data/test/dummy/app/helpers/application_helper.rb +2 -0
  17. data/test/dummy/app/models/user.rb +15 -0
  18. data/test/dummy/app/models/widget.rb +3 -0
  19. data/test/dummy/app/views/bakery/templates/layouts/sample.erb +1 -0
  20. data/test/dummy/app/views/bakery/templates/partials/sample.html.haml +1 -0
  21. data/test/dummy/app/views/bakery/templates/themes/sample.haml +1 -0
  22. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  23. data/test/dummy/config.ru +4 -0
  24. data/test/dummy/config/application.rb +24 -0
  25. data/test/dummy/config/boot.rb +5 -0
  26. data/test/dummy/config/database.yml +30 -0
  27. data/test/dummy/config/environment.rb +5 -0
  28. data/test/dummy/config/environments/development.rb +29 -0
  29. data/test/dummy/config/environments/production.rb +80 -0
  30. data/test/dummy/config/environments/test.rb +36 -0
  31. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  32. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  33. data/test/dummy/config/initializers/i18n.rb +1 -0
  34. data/test/dummy/config/initializers/inflections.rb +16 -0
  35. data/test/dummy/config/initializers/mime_types.rb +5 -0
  36. data/test/dummy/config/initializers/secret_token.rb +12 -0
  37. data/test/dummy/config/initializers/session_store.rb +3 -0
  38. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  39. data/test/dummy/config/locales/en.yml +23 -0
  40. data/test/dummy/config/routes.rb +5 -0
  41. data/test/dummy/db/migrate/20140114212939_create_widgets.rb +32 -0
  42. data/test/dummy/db/migrate/20140307205735_create_users.challah_engine.rb +34 -0
  43. data/test/dummy/db/migrate/20140307205736_create_authorizations.challah_engine.rb +21 -0
  44. data/test/dummy/db/schema.rb +81 -0
  45. data/test/dummy/db/test.sqlite3 +0 -0
  46. data/test/dummy/log/test.log +11547 -0
  47. data/test/dummy/public/404.html +58 -0
  48. data/test/dummy/public/422.html +58 -0
  49. data/test/dummy/public/500.html +57 -0
  50. data/test/dummy/public/favicon.ico +0 -0
  51. data/test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  52. data/test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  53. data/test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  54. data/test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  55. data/test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  56. data/test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  57. data/test/{authorization_test.rb → models/authorization_test.rb} +2 -2
  58. data/test/{user_test.rb → models/user_test.rb} +2 -2
  59. data/test/{audit_test.rb → services/audit_test.rb} +2 -2
  60. data/test/{cookie_store_test.rb → services/cookie_store_test.rb} +2 -2
  61. data/test/{encrypter_test.rb → services/encrypter_test.rb} +27 -27
  62. data/test/{plugins_test.rb → services/plugins_test.rb} +2 -2
  63. data/test/{random_test.rb → services/random_test.rb} +9 -9
  64. data/test/{routes_test.rb → services/routes_test.rb} +2 -2
  65. data/test/{session_test.rb → services/session_test.rb} +2 -2
  66. data/test/{signup_test.rb → services/signup_test.rb} +2 -2
  67. data/test/{simple_cookie_store_test.rb → services/simple_cookie_store_test.rb} +2 -2
  68. data/test/support/stubs.rb +88 -0
  69. data/test/test_helper.rb +47 -0
  70. metadata +75 -29
  71. data/test/edge_helper.rb +0 -57
  72. data/test/helper.rb +0 -148
@@ -0,0 +1,47 @@
1
+ # Coverage reporting, needs to be loaded first to capture all code coverage stats
2
+ require 'simplecov'
3
+
4
+ # Configure Rails Environment
5
+ ENV["RAILS_ENV"] ||= "test"
6
+
7
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
8
+
9
+ # Some other dependencies for testing w/ shoulda and factory girl
10
+ require 'shoulda'
11
+ require 'mocha/setup'
12
+ require 'factory_girl'
13
+ require 'factories'
14
+ require 'rails/test_help'
15
+
16
+ Rails.backtrace_cleaner.remove_silencers!
17
+
18
+ # Load the challah libraries
19
+ require 'challah'
20
+ require 'challah/test'
21
+
22
+ db_files = Dir["#{ Rails.root.join("db") }/**/*challah*.rb"]
23
+
24
+ # Allow repeat tests to run, dropping the db after each suite run
25
+ # (*not called on CI server)
26
+ if db_files.size > 0
27
+ `rake --rakefile #{ File.expand_path("../dummy/Rakefile", __FILE__) } db:test:purge`
28
+
29
+ FileUtils.rm_rf(db_files)
30
+ FileUtils.rm_rf(Rails.root.join("db", "schema.rb"))
31
+ end
32
+
33
+ `rake --rakefile #{ File.expand_path("../dummy/Rakefile", __FILE__) } challah_engine:install:migrations`
34
+ `rake --rakefile #{ File.expand_path("../dummy/Rakefile", __FILE__) } db:migrate`
35
+
36
+ Dir["#{ File.dirname(__FILE__) }/support/**/*.rb"].each { |f| require f }
37
+
38
+ class ActiveSupport::TestCase
39
+ ActiveRecord::Migration.check_pending!
40
+
41
+ fixtures :all
42
+
43
+ include FactoryGirl::Syntax::Methods
44
+
45
+ self.use_transactional_fixtures = true
46
+ end
47
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: challah
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Tornow
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-01 00:00:00.000000000 Z
11
+ date: 2014-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: highline
@@ -28,44 +28,44 @@ dependencies:
28
28
  name: rails
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: '4.0'
33
+ version: '4'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
- version: '4.0'
40
+ version: '4'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - '>='
46
46
  - !ruby/object:Gem::Version
47
- version: 0.9.2
47
+ version: '0.9'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '>='
53
53
  - !ruby/object:Gem::Version
54
- version: 0.9.2
54
+ version: '0.9'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bcrypt-ruby
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: '0'
61
+ version: '3.0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ~>
67
67
  - !ruby/object:Gem::Version
68
- version: '0'
68
+ version: '3.0'
69
69
  description: A simple gem for authorization and session management in Rails.
70
70
  email:
71
71
  - john@johntornow.com
@@ -73,7 +73,6 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
- - app/controllers/challah/test/restrictions_controller.rb
77
76
  - app/controllers/sessions_controller.rb
78
77
  - app/models/authorization.rb
79
78
  - app/models/user.rb
@@ -82,23 +81,70 @@ files:
82
81
  - config/locales/en.yml
83
82
  - db/migrate/20120127150433_create_users.rb
84
83
  - db/migrate/20121116210759_create_authorizations.rb
85
- - test/audit_test.rb
86
- - test/authorization_test.rb
87
- - test/controller_test.rb
88
- - test/cookie_store_test.rb
89
- - test/edge_helper.rb
90
- - test/encrypter_test.rb
84
+ - test/controllers/controller_test.rb
85
+ - test/controllers/restrictions_controller_test.rb
86
+ - test/controllers/sessions_controller_test.rb
87
+ - test/dummy/app/assets/javascripts/application.js
88
+ - test/dummy/app/assets/stylesheets/application.css
89
+ - test/dummy/app/controllers/application_controller.rb
90
+ - test/dummy/app/controllers/restrictions_controller.rb
91
+ - test/dummy/app/helpers/application_helper.rb
92
+ - test/dummy/app/models/user.rb
93
+ - test/dummy/app/models/widget.rb
94
+ - test/dummy/app/views/bakery/templates/layouts/sample.erb
95
+ - test/dummy/app/views/bakery/templates/partials/sample.html.haml
96
+ - test/dummy/app/views/bakery/templates/themes/sample.haml
97
+ - test/dummy/app/views/layouts/application.html.erb
98
+ - test/dummy/config/application.rb
99
+ - test/dummy/config/boot.rb
100
+ - test/dummy/config/database.yml
101
+ - test/dummy/config/environment.rb
102
+ - test/dummy/config/environments/development.rb
103
+ - test/dummy/config/environments/production.rb
104
+ - test/dummy/config/environments/test.rb
105
+ - test/dummy/config/initializers/backtrace_silencers.rb
106
+ - test/dummy/config/initializers/filter_parameter_logging.rb
107
+ - test/dummy/config/initializers/i18n.rb
108
+ - test/dummy/config/initializers/inflections.rb
109
+ - test/dummy/config/initializers/mime_types.rb
110
+ - test/dummy/config/initializers/secret_token.rb
111
+ - test/dummy/config/initializers/session_store.rb
112
+ - test/dummy/config/initializers/wrap_parameters.rb
113
+ - test/dummy/config/locales/en.yml
114
+ - test/dummy/config/routes.rb
115
+ - test/dummy/config.ru
116
+ - test/dummy/db/migrate/20140114212939_create_widgets.rb
117
+ - test/dummy/db/migrate/20140307205735_create_users.challah_engine.rb
118
+ - test/dummy/db/migrate/20140307205736_create_authorizations.challah_engine.rb
119
+ - test/dummy/db/schema.rb
120
+ - test/dummy/db/test.sqlite3
121
+ - test/dummy/log/test.log
122
+ - test/dummy/public/404.html
123
+ - test/dummy/public/422.html
124
+ - test/dummy/public/500.html
125
+ - test/dummy/public/favicon.ico
126
+ - test/dummy/Rakefile
127
+ - test/dummy/README.rdoc
128
+ - test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705
129
+ - test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af
130
+ - test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953
131
+ - test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994
132
+ - test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6
133
+ - test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655
91
134
  - test/factories.rb
92
- - test/helper.rb
93
- - test/plugins_test.rb
94
- - test/random_test.rb
95
- - test/restrictions_controller_test.rb
96
- - test/routes_test.rb
97
- - test/session_test.rb
98
- - test/sessions_controller_test.rb
99
- - test/signup_test.rb
100
- - test/simple_cookie_store_test.rb
101
- - test/user_test.rb
135
+ - test/models/authorization_test.rb
136
+ - test/models/user_test.rb
137
+ - test/services/audit_test.rb
138
+ - test/services/cookie_store_test.rb
139
+ - test/services/encrypter_test.rb
140
+ - test/services/plugins_test.rb
141
+ - test/services/random_test.rb
142
+ - test/services/routes_test.rb
143
+ - test/services/session_test.rb
144
+ - test/services/signup_test.rb
145
+ - test/services/simple_cookie_store_test.rb
146
+ - test/support/stubs.rb
147
+ - test/test_helper.rb
102
148
  - lib/challah/audit.rb
103
149
  - lib/challah/authenticators/api_key.rb
104
150
  - lib/challah/authenticators/password.rb
data/test/edge_helper.rb DELETED
@@ -1,57 +0,0 @@
1
- class ActiveSupport::TestCase
2
- ActiveRecord::Migration.check_pending!
3
-
4
- fixtures :all
5
-
6
- include FactoryGirl::Syntax::Methods
7
-
8
- # Get shoulda-context working in Rails 4
9
- include Shoulda::Context::Assertions
10
- include Shoulda::Context::InstanceMethods
11
- extend Shoulda::Context::ClassMethods
12
-
13
- # Get shoulda-matchers (for AR) working in Rails 4
14
- include Shoulda::Matchers::ActiveRecord
15
- extend Shoulda::Matchers::ActiveRecord
16
- include Shoulda::Matchers::ActiveModel
17
- extend Shoulda::Matchers::ActiveModel
18
-
19
- # Override shoulda-context
20
- #
21
- # Should be fixed by time Rails 4 actually comes out
22
- def assert_accepts(matcher, target, options = {})
23
- if matcher.respond_to?(:in_context)
24
- matcher.in_context(self)
25
- end
26
-
27
- if matcher.matches?(target)
28
- assert true
29
- if options[:message]
30
- assert_match options[:message], matcher.negative_failure_message
31
- end
32
- else
33
- assert false, matcher.failure_message
34
- end
35
- end
36
-
37
- # Override shoulda-context
38
- #
39
- # Should be fixed by time Rails 4 actually comes out
40
- def assert_rejects(matcher, target, options = {})
41
- if matcher.respond_to?(:in_context)
42
- matcher.in_context(self)
43
- end
44
-
45
- not_match = matcher.respond_to?(:does_not_match?) ? matcher.does_not_match?(target) : !matcher.matches?(target)
46
-
47
- if not_match
48
- assert true
49
-
50
- if options[:message]
51
- assert_match options[:message], matcher.failure_message
52
- end
53
- else
54
- assert false, matcher.failure_message
55
- end
56
- end
57
- end
data/test/helper.rb DELETED
@@ -1,148 +0,0 @@
1
- # Coverage reporting, needs to be loaded first to capture all code coverage stats
2
- require 'simplecov'
3
-
4
- # Setup a sample rails app for testing rails modules
5
- sample_root = File.expand_path(File.join(File.dirname(__FILE__), '..', 'tmp', 'sampleapp'))
6
- FileUtils.rm_rf(sample_root) if File.exists?(sample_root)
7
- `./bin/rails new #{sample_root} --skip-bundle --skip-sprockets`
8
-
9
- # Setup environment variables for the Rails instance
10
- ENV['RAILS_ENV'] = 'test'
11
- ENV['BUNDLE_GEMFILE'] ||= File.join(sample_root, 'Gemfile')
12
-
13
- # Load the newly created rails instance environment
14
- require "#{sample_root}/config/environment"
15
-
16
- # Some other dependencies for testing w/ shoulda and factory girl
17
- require 'shoulda'
18
- require 'mocha/setup'
19
- require 'factory_girl'
20
- require 'factories'
21
- require 'rails/test_help'
22
-
23
- # Load the challah libraries
24
- require 'challah'
25
- require 'challah/test'
26
-
27
- # Setup the challah app, including running migrations within the rails app
28
- # TODO - this causes some annoying output in 1.9.3, still works, but would like to suppress
29
- `rake --rakefile #{File.join(sample_root, 'Rakefile')} challah:setup:migrations`
30
-
31
- # Run migrations for the sample app, hiding output
32
- ActiveRecord::Migration.verbose = false
33
- ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate")
34
-
35
- # Use ActiveSupport::TestCase for any tests using factories and database saving,
36
- # so we can have a transactional rollback after each test.
37
- class ActiveSupport::TestCase
38
- include FactoryGirl::Syntax::Methods
39
-
40
- self.use_transactional_fixtures = true
41
- end
42
-
43
- if Rails::VERSION::MAJOR >= 4
44
- require 'edge_helper'
45
- end
46
-
47
- class MockController
48
- include Challah::Controller
49
-
50
- attr_accessor :request, :session, :params
51
-
52
- def initialize()
53
- @request = MockRequest.new
54
- @session ||= {}
55
- @params ||= {}
56
- end
57
-
58
- def redirect_to(*args)
59
- # do nothing
60
- end
61
-
62
- def login_path
63
- "/login"
64
- end
65
-
66
- def logout_path
67
- "/logout"
68
- end
69
-
70
- def signin_path
71
- "/sign-in"
72
- end
73
-
74
- def signout_path
75
- "/sign-out"
76
- end
77
- end
78
-
79
- class MockRequest
80
- attr_accessor :cookie_jar, :session_options, :url
81
-
82
- class MockCookieJar < Hash
83
- def delete(key, options = {})
84
- super(key)
85
- end
86
- end
87
-
88
- def initialize
89
- @cookie_jar = MockCookieJar.new
90
- @session_options = { :domain => 'test.dev' }
91
- @url = "http://example.com/"
92
- end
93
-
94
- def cookies
95
- @cookie_jar
96
- end
97
-
98
- def cookies=(value)
99
- @cookie_jar = value
100
- end
101
-
102
- def remote_ip
103
- "8.8.8.8"
104
- end
105
-
106
- def user_agent
107
- "Some Cool Browser"
108
- end
109
- end
110
-
111
- class FakeProvider
112
- def self.save(record)
113
- set(record.fake_provider.merge(user_id: record.id))
114
- end
115
-
116
- def self.set(options = {})
117
- user_id = options.fetch(:user_id)
118
- uid = options.fetch(:uid, '')
119
- token = options.fetch(:token, '')
120
-
121
- Authorization.set({
122
- provider: :fake,
123
- user_id: user_id,
124
- uid: uid,
125
- token: token
126
- })
127
- end
128
-
129
- def self.valid?(record)
130
- record.fake_provider? and record.fake_provider.fetch(:token) == 'me'
131
- end
132
- end
133
-
134
- Challah.register_provider :fake, FakeProvider
135
-
136
- # Monkey patch fix for shoulda and Rails 3.1+.
137
- module Shoulda
138
- module ActiveRecord
139
- module Matchers
140
- class AssociationMatcher
141
- protected
142
- def foreign_key
143
- reflection.foreign_key
144
- end
145
- end
146
- end
147
- end
148
- end