challah 1.1.1 → 1.2.0.rc

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 (88) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +12 -1
  3. data/README.md +3 -3
  4. data/app/models/authorization.rb +2 -2
  5. data/app/models/user.rb +2 -2
  6. data/lib/challah.rb +60 -53
  7. data/lib/challah/active_record_extensions.rb +23 -0
  8. data/lib/challah/{authorization.rb → concerns/authorizeable.rb} +14 -19
  9. data/lib/challah/concerns/user/attributeable.rb +73 -0
  10. data/lib/challah/{user/authentication.rb → concerns/user/authenticateable.rb} +2 -2
  11. data/lib/challah/concerns/user/authorizable.rb +32 -0
  12. data/lib/challah/concerns/user/findable.rb +45 -0
  13. data/lib/challah/{user/password.rb → concerns/user/passwordable.rb} +2 -2
  14. data/lib/challah/{user/providers.rb → concerns/user/provideable.rb} +46 -6
  15. data/lib/challah/concerns/user/validateable.rb +21 -0
  16. data/lib/challah/concerns/userable.rb +20 -0
  17. data/lib/challah/engine.rb +1 -2
  18. data/lib/challah/test.rb +52 -32
  19. data/lib/challah/version.rb +1 -1
  20. metadata +14 -76
  21. data/lib/challah/user.rb +0 -128
  22. data/lib/challah/user/attributes.rb +0 -28
  23. data/lib/challah/user/finders.rb +0 -31
  24. data/lib/challah/user/reflector.rb +0 -15
  25. data/test/controllers/controller_test.rb +0 -34
  26. data/test/controllers/restrictions_controller_test.rb +0 -95
  27. data/test/controllers/sessions_controller_test.rb +0 -42
  28. data/test/dummy/README.rdoc +0 -28
  29. data/test/dummy/Rakefile +0 -6
  30. data/test/dummy/app/assets/javascripts/application.js +0 -13
  31. data/test/dummy/app/assets/stylesheets/application.css +0 -13
  32. data/test/dummy/app/controllers/application_controller.rb +0 -5
  33. data/test/dummy/app/controllers/restrictions_controller.rb +0 -25
  34. data/test/dummy/app/helpers/application_helper.rb +0 -2
  35. data/test/dummy/app/models/user.rb +0 -15
  36. data/test/dummy/app/models/widget.rb +0 -3
  37. data/test/dummy/app/views/bakery/templates/layouts/sample.erb +0 -1
  38. data/test/dummy/app/views/bakery/templates/partials/sample.html.haml +0 -1
  39. data/test/dummy/app/views/bakery/templates/themes/sample.haml +0 -1
  40. data/test/dummy/app/views/layouts/application.html.erb +0 -14
  41. data/test/dummy/config.ru +0 -4
  42. data/test/dummy/config/application.rb +0 -24
  43. data/test/dummy/config/boot.rb +0 -5
  44. data/test/dummy/config/database.yml +0 -30
  45. data/test/dummy/config/environment.rb +0 -5
  46. data/test/dummy/config/environments/development.rb +0 -29
  47. data/test/dummy/config/environments/production.rb +0 -80
  48. data/test/dummy/config/environments/test.rb +0 -36
  49. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  50. data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  51. data/test/dummy/config/initializers/i18n.rb +0 -1
  52. data/test/dummy/config/initializers/inflections.rb +0 -16
  53. data/test/dummy/config/initializers/mime_types.rb +0 -5
  54. data/test/dummy/config/initializers/secret_token.rb +0 -12
  55. data/test/dummy/config/initializers/session_store.rb +0 -3
  56. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  57. data/test/dummy/config/locales/en.yml +0 -23
  58. data/test/dummy/config/routes.rb +0 -5
  59. data/test/dummy/db/migrate/20140114212939_create_widgets.rb +0 -32
  60. data/test/dummy/db/migrate/20140307205735_create_users.challah_engine.rb +0 -34
  61. data/test/dummy/db/migrate/20140307205736_create_authorizations.challah_engine.rb +0 -21
  62. data/test/dummy/db/schema.rb +0 -81
  63. data/test/dummy/db/test.sqlite3 +0 -0
  64. data/test/dummy/log/test.log +0 -11547
  65. data/test/dummy/public/404.html +0 -58
  66. data/test/dummy/public/422.html +0 -58
  67. data/test/dummy/public/500.html +0 -57
  68. data/test/dummy/public/favicon.ico +0 -0
  69. data/test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  70. data/test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  71. data/test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  72. data/test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  73. data/test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  74. data/test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  75. data/test/factories.rb +0 -8
  76. data/test/models/authorization_test.rb +0 -20
  77. data/test/models/user_test.rb +0 -345
  78. data/test/services/audit_test.rb +0 -107
  79. data/test/services/cookie_store_test.rb +0 -97
  80. data/test/services/encrypter_test.rb +0 -73
  81. data/test/services/plugins_test.rb +0 -65
  82. data/test/services/random_test.rb +0 -22
  83. data/test/services/routes_test.rb +0 -11
  84. data/test/services/session_test.rb +0 -197
  85. data/test/services/signup_test.rb +0 -122
  86. data/test/services/simple_cookie_store_test.rb +0 -122
  87. data/test/support/stubs.rb +0 -88
  88. data/test/test_helper.rb +0 -47
@@ -1,15 +0,0 @@
1
- module Challah::User
2
-
3
- module Reflector
4
-
5
- def authorizations_table_name
6
- @authorizations_table_name ||= authorization_model.table_name
7
- end
8
-
9
- def authorization_model
10
- @authorization_model ||= ::Authorization
11
- end
12
-
13
- end
14
-
15
- end
@@ -1,34 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ControllerTest < ActiveSupport::TestCase
4
- include Challah
5
-
6
- context "A controller" do
7
- setup do
8
- @user = create(:user)
9
- @controller = MockController.new
10
- end
11
-
12
- should "be signed out by default" do
13
- assert_equal false, @controller.send(:current_user?)
14
- end
15
-
16
- should "have signed_in? and current_user methods" do
17
- session = Session.create(@user)
18
- session.save
19
-
20
- assert_equal true, @controller.send(:current_user?)
21
- assert_equal true, @controller.send(:signed_in?)
22
- assert_equal @user, @controller.send(:current_user)
23
- end
24
-
25
- should "redirect to login page if user is not logged in" do
26
- @controller.request.url = 'http://example.com/protected-page'
27
- @controller.stubs(:signed_in?).returns(false)
28
- @controller.expects(:redirect_to)
29
- @controller.send(:signin_required)
30
-
31
- assert_equal @controller.session[:return_to], 'http://example.com/protected-page'
32
- end
33
- end
34
- end
@@ -1,95 +0,0 @@
1
- require 'test_helper'
2
-
3
- class RestrictionsControllerTest < ActionController::TestCase
4
- context "The restrictions controller" do
5
- context "With no user" do
6
- setup do
7
- signout
8
- end
9
-
10
- should "be able to get to the index page" do
11
- get :index
12
- assert_response :success
13
- assert_equal nil, assigns(:current_user)
14
- end
15
-
16
- should "not be able to get to the edit page" do
17
- get :edit
18
- assert_redirected_to '/sign-in'
19
- end
20
- end
21
-
22
- context "with a regular user" do
23
- setup do
24
- @user = create(:user)
25
- signin_as(@user)
26
- end
27
-
28
- should "get to the index page" do
29
- get :index
30
- assert_response :success
31
- assert_equal @user, assigns(:current_user)
32
- end
33
-
34
- should "get to the edit page" do
35
- get :edit
36
- assert_response :success
37
- end
38
-
39
- should "get to the show page" do
40
- get :show
41
- assert_response :success
42
- end
43
- end
44
-
45
- context "With an api key" do
46
- setup do
47
- @user = create(:user)
48
- end
49
-
50
- context "and api_key functionality enabled" do
51
- setup do
52
- Challah.options[:api_key_enabled] = true
53
- end
54
-
55
- should "get to the index page" do
56
- get :index, :key => @user.api_key
57
- assert_response :success
58
- assert_equal @user, assigns(:current_user)
59
- end
60
-
61
- should "get to the edit page" do
62
- get :edit, :key => @user.api_key
63
- assert_response :success
64
- end
65
-
66
- should "get to the show page" do
67
- get :show, :key => @user.api_key
68
- assert_response :success
69
- end
70
- end
71
-
72
- context "and api_key functionality disabled" do
73
- setup do
74
- Challah.options[:api_key_enabled] = false
75
- end
76
-
77
- should "get to the index page" do
78
- get :index, :key => @user.api_key
79
- assert_response :success
80
- assert_equal nil, assigns(:current_user)
81
- end
82
-
83
- should "not get to the edit page" do
84
- get :edit, :key => @user.api_key
85
- assert_redirected_to '/sign-in'
86
- end
87
-
88
- should "not get to the show page" do
89
- get :show, :key => @user.api_key
90
- assert_redirected_to '/sign-in'
91
- end
92
- end
93
- end
94
- end
95
- end
@@ -1,42 +0,0 @@
1
- require 'test_helper'
2
-
3
- class SessionsControllerTest < ActionController::TestCase
4
- tests SessionsController
5
-
6
- context "The sessions controller" do
7
- setup do
8
- @user = build(:user, :username => 'sessions-user-test')
9
- @user.password! 'abc123'
10
- @user.save
11
- end
12
-
13
- should "have a sign-in page" do
14
- get :new
15
- assert_response :success
16
- end
17
-
18
- should "be able to sign in" do
19
- Challah::Session.any_instance.stubs(:save).returns(true)
20
-
21
- post :create, :username => 'sessions-user-test', :password => 'abc123'
22
- assert_redirected_to '/'
23
-
24
- Challah::Session.any_instance.unstub(:save)
25
- end
26
-
27
- should "send you back to the sign in page if you can't sign in" do
28
- Challah::Session.any_instance.stubs(:save).returns(false)
29
-
30
- post :create, :username => 'sessions-user-test', :password => 'abc123'
31
- assert_redirected_to '/sign-in'
32
-
33
- Challah::Session.any_instance.unstub(:save)
34
- end
35
-
36
- should "be able to sign out" do
37
- get :destroy
38
-
39
- assert_redirected_to '/sign-in'
40
- end
41
- end
42
- end
@@ -1,28 +0,0 @@
1
- == README
2
-
3
- This README would normally document whatever steps are necessary to get the
4
- application up and running.
5
-
6
- Things you may want to cover:
7
-
8
- * Ruby version
9
-
10
- * System dependencies
11
-
12
- * Configuration
13
-
14
- * Database creation
15
-
16
- * Database initialization
17
-
18
- * How to run the test suite
19
-
20
- * Services (job queues, cache servers, search engines, etc.)
21
-
22
- * Deployment instructions
23
-
24
- * ...
25
-
26
-
27
- Please feel free to use a different markup language if you do not plan to run
28
- <tt>rake doc:app</tt>.
data/test/dummy/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- # Add your own tasks in files placed in lib/tasks ending in .rake,
2
- # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
-
4
- require File.expand_path('../config/application', __FILE__)
5
-
6
- Dummy::Application.load_tasks
@@ -1,13 +0,0 @@
1
- // This is a manifest file that'll be compiled into application.js, which will include all the files
2
- // listed below.
3
- //
4
- // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
- // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
- //
7
- // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
- // compiled file.
9
- //
10
- // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
- // about supported directives.
12
- //
13
- //= require_tree .
@@ -1,13 +0,0 @@
1
- /*
2
- * This is a manifest file that'll be compiled into application.css, which will include all the files
3
- * listed below.
4
- *
5
- * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
- * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
- *
8
- * You're free to add application-wide styles to this file and they'll appear at the top of the
9
- * compiled file, but it's generally better to create a new file per style scope.
10
- *
11
- *= require_self
12
- *= require_tree .
13
- */
@@ -1,5 +0,0 @@
1
- class ApplicationController < ActionController::Base
2
- # Prevent CSRF attacks by raising an exception.
3
- # For APIs, you may want to use :null_session instead.
4
- protect_from_forgery with: :exception
5
- end
@@ -1,25 +0,0 @@
1
- # @private
2
- # This controller is only used for testing purposes, it does not actually get used outside of test.
3
- class RestrictionsController < ApplicationController
4
- signin_required only: [ :blah ]
5
- before_filter :signin_required, only: [ :edit ]
6
- restrict_to_authenticated only: [ :show ]
7
-
8
- def index
9
- current_user
10
-
11
- head :ok
12
- end
13
-
14
- def show
15
- head :ok
16
- end
17
-
18
- def edit
19
- head :ok
20
- end
21
-
22
- def blah
23
- head :ok
24
- end
25
- end
@@ -1,2 +0,0 @@
1
- module ApplicationHelper
2
- end
@@ -1,15 +0,0 @@
1
- class User < ActiveRecord::Base
2
- # Uncomment this line if you are not using Rails 4. If you'd like to continue using
3
- # attr_accessible you can always install the strong_parameters gem from:
4
- # https://github.com/rails/strong_parameters
5
- #
6
- # attr_accessible :email, :first_name, :last_name, :password_confirmation, :password, :username
7
-
8
- # Set up Challah's User methods. Keep this as the first line of your model to include
9
- # all methods by default. You can override methods after this line as necessary.
10
- #
11
- # For a list of all methods included into User, see:
12
- #
13
- # http://rubydoc.info/gems/challah
14
- challah_user
15
- end
@@ -1,3 +0,0 @@
1
- # Just a fake content model for testing
2
- class Widget < ActiveRecord::Base
3
- end
@@ -1 +0,0 @@
1
- Just a sample template.
@@ -1 +0,0 @@
1
- Just a sample template.
@@ -1 +0,0 @@
1
- Just a sample template.
@@ -1,14 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Dummy</title>
5
- <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
6
- <%= javascript_include_tag "application", "data-turbolinks-track" => true %>
7
- <%= csrf_meta_tags %>
8
- </head>
9
- <body>
10
-
11
- <%= yield %>
12
-
13
- </body>
14
- </html>
data/test/dummy/config.ru DELETED
@@ -1,4 +0,0 @@
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
@@ -1,24 +0,0 @@
1
- require File.expand_path('../boot', __FILE__)
2
-
3
- require 'rails/all'
4
-
5
- Bundler.require(*Rails.groups)
6
-
7
- require "challah"
8
-
9
- module Dummy
10
- class Application < Rails::Application
11
- # Settings in config/environments/* take precedence over those specified here.
12
- # Application configuration should go into files in config/initializers
13
- # -- all .rb files in that directory are automatically loaded.
14
-
15
- # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
16
- # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
17
- # config.time_zone = 'Central Time (US & Canada)'
18
-
19
- # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
20
- # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
21
- # config.i18n.default_locale = :de
22
- end
23
- end
24
-
@@ -1,5 +0,0 @@
1
- # Set up gems listed in the Gemfile.
2
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
3
-
4
- require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
5
- $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
@@ -1,30 +0,0 @@
1
- # SQLite version 3.x
2
- # gem install sqlite3
3
- #
4
- # Ensure the SQLite 3 gem is defined in your Gemfile
5
- # gem 'sqlite3'
6
- #
7
- default: &default
8
- adapter: sqlite3
9
- pool: 5
10
- timeout: 5000
11
-
12
- development:
13
- <<: *default
14
- database: db/development.sqlite3
15
-
16
- # Warning: The database defined as "test" will be erased and
17
- # re-generated from your development database when you run "rake".
18
- # Do not set this db to the same as development or production.
19
- test:
20
- <<: *default
21
- database: db/test.sqlite3
22
-
23
- # Do not keep production credentials in the repository,
24
- # instead read the configuration from the environment.
25
- #
26
- # Example:
27
- # sqlite3://myuser:mypass@localhost/full/path/to/somedatabase
28
- #
29
- production:
30
- url: <%= ENV["DATABASE_URL"] %>
@@ -1,5 +0,0 @@
1
- # Load the Rails application.
2
- require File.expand_path('../application', __FILE__)
3
-
4
- # Initialize the Rails application.
5
- Dummy::Application.initialize!
@@ -1,29 +0,0 @@
1
- Dummy::Application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb.
3
-
4
- # In the development environment your application's code is reloaded on
5
- # every request. This slows down response time but is perfect for development
6
- # since you don't have to restart the web server when you make code changes.
7
- config.cache_classes = false
8
-
9
- # Do not eager load code on boot.
10
- config.eager_load = false
11
-
12
- # Show full error reports and disable caching.
13
- config.consider_all_requests_local = true
14
- config.action_controller.perform_caching = false
15
-
16
- # Don't care if the mailer can't send.
17
- config.action_mailer.raise_delivery_errors = false
18
-
19
- # Print deprecation notices to the Rails logger.
20
- config.active_support.deprecation = :log
21
-
22
- # Raise an error on page load if there are pending migrations
23
- config.active_record.migration_error = :page_load
24
-
25
- # Debug mode disables concatenation and preprocessing of assets.
26
- # This option may cause significant delays in view rendering with a large
27
- # number of complex assets.
28
- config.assets.debug = true
29
- end