lperichon-devise_invitable 0.3.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.
Files changed (50) hide show
  1. data/.document +5 -0
  2. data/.gitignore +22 -0
  3. data/LICENSE +20 -0
  4. data/README.rdoc +92 -0
  5. data/Rakefile +54 -0
  6. data/VERSION +1 -0
  7. data/app/controllers/devise/invitations_controller.rb +52 -0
  8. data/app/views/devise/invitations/edit.html.erb +14 -0
  9. data/app/views/devise/invitations/new.html.erb +12 -0
  10. data/app/views/devise/mailer/invitation.html.erb +8 -0
  11. data/devise_invitable.gemspec +123 -0
  12. data/init.rb +1 -0
  13. data/lib/devise_invitable.rb +21 -0
  14. data/lib/devise_invitable/controllers/helpers.rb +6 -0
  15. data/lib/devise_invitable/controllers/url_helpers.rb +24 -0
  16. data/lib/devise_invitable/locales/en.yml +5 -0
  17. data/lib/devise_invitable/mailer.rb +8 -0
  18. data/lib/devise_invitable/model.rb +139 -0
  19. data/lib/devise_invitable/rails.rb +15 -0
  20. data/lib/devise_invitable/routes.rb +11 -0
  21. data/lib/devise_invitable/schema.rb +11 -0
  22. data/test/integration/invitable_test.rb +122 -0
  23. data/test/integration_tests_helper.rb +39 -0
  24. data/test/mailers/invitation_test.rb +62 -0
  25. data/test/model_tests_helper.rb +41 -0
  26. data/test/models/invitable_test.rb +172 -0
  27. data/test/models_test.rb +35 -0
  28. data/test/rails_app/app/controllers/admins_controller.rb +6 -0
  29. data/test/rails_app/app/controllers/application_controller.rb +10 -0
  30. data/test/rails_app/app/controllers/home_controller.rb +4 -0
  31. data/test/rails_app/app/controllers/users_controller.rb +12 -0
  32. data/test/rails_app/app/helpers/application_helper.rb +3 -0
  33. data/test/rails_app/app/models/user.rb +4 -0
  34. data/test/rails_app/app/views/home/index.html.erb +0 -0
  35. data/test/rails_app/config/boot.rb +110 -0
  36. data/test/rails_app/config/database.yml +22 -0
  37. data/test/rails_app/config/environment.rb +44 -0
  38. data/test/rails_app/config/environments/development.rb +17 -0
  39. data/test/rails_app/config/environments/production.rb +28 -0
  40. data/test/rails_app/config/environments/test.rb +28 -0
  41. data/test/rails_app/config/initializers/backtrace_silencers.rb +7 -0
  42. data/test/rails_app/config/initializers/devise.rb +105 -0
  43. data/test/rails_app/config/initializers/inflections.rb +2 -0
  44. data/test/rails_app/config/initializers/new_rails_defaults.rb +21 -0
  45. data/test/rails_app/config/initializers/session_store.rb +15 -0
  46. data/test/rails_app/config/routes.rb +3 -0
  47. data/test/rails_app/vendor/plugins/devise_invitable/init.rb +1 -0
  48. data/test/routes_test.rb +20 -0
  49. data/test/test_helper.rb +58 -0
  50. metadata +173 -0
@@ -0,0 +1,17 @@
1
+ # Settings specified here will take precedence over those in config/environment.rb
2
+
3
+ # In the development environment your application's code is reloaded on
4
+ # every request. This slows down response time but is perfect for development
5
+ # since you don't have to restart the webserver when you make code changes.
6
+ config.cache_classes = false
7
+
8
+ # Log error messages when you accidentally call methods on nil.
9
+ config.whiny_nils = true
10
+
11
+ # Show full error reports and disable caching
12
+ config.action_controller.consider_all_requests_local = true
13
+ config.action_view.debug_rjs = 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
@@ -0,0 +1,28 @@
1
+ # Settings specified here will take precedence over those in config/environment.rb
2
+
3
+ # The production environment is meant for finished, "live" apps.
4
+ # Code is not reloaded between requests
5
+ config.cache_classes = true
6
+
7
+ # Full error reports are disabled and caching is turned on
8
+ config.action_controller.consider_all_requests_local = false
9
+ config.action_controller.perform_caching = true
10
+ config.action_view.cache_template_loading = true
11
+
12
+ # See everything in the log (default is :info)
13
+ # config.log_level = :debug
14
+
15
+ # Use a different logger for distributed setups
16
+ # config.logger = SyslogLogger.new
17
+
18
+ # Use a different cache store in production
19
+ # config.cache_store = :mem_cache_store
20
+
21
+ # Enable serving of images, stylesheets, and javascripts from an asset server
22
+ # config.action_controller.asset_host = "http://assets.example.com"
23
+
24
+ # Disable delivery errors, bad email addresses will be ignored
25
+ # config.action_mailer.raise_delivery_errors = false
26
+
27
+ # Enable threaded mode
28
+ # config.threadsafe!
@@ -0,0 +1,28 @@
1
+ # Settings specified here will take precedence over those in config/environment.rb
2
+
3
+ # The test environment is used exclusively to run your application's
4
+ # test suite. You never need to work with it otherwise. Remember that
5
+ # your test database is "scratch space" for the test suite and is wiped
6
+ # and recreated between test runs. Don't rely on the data there!
7
+ config.cache_classes = true
8
+
9
+ # Log error messages when you accidentally call methods on nil.
10
+ config.whiny_nils = true
11
+
12
+ # Show full error reports and disable caching
13
+ config.action_controller.consider_all_requests_local = true
14
+ config.action_controller.perform_caching = false
15
+ config.action_view.cache_template_loading = true
16
+
17
+ # Disable request forgery protection in test environment
18
+ config.action_controller.allow_forgery_protection = false
19
+
20
+ # Tell Action Mailer not to deliver emails to the real world.
21
+ # The :test delivery method accumulates sent emails in the
22
+ # ActionMailer::Base.deliveries array.
23
+ config.action_mailer.delivery_method = :test
24
+
25
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
26
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
27
+ # like if you have constraints or database-specific column types
28
+ # config.active_record.schema_format = :sql
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
+
6
+ # You can also remove all the silencers if you're trying do debug a problem that might steem from framework code.
7
+ Rails.backtrace_cleaner.remove_silencers!
@@ -0,0 +1,105 @@
1
+ # Use this hook to configure devise mailer, warden hooks and so forth. The first
2
+ # four configuration values can also be set straight in your models.
3
+ Devise.setup do |config|
4
+ # Configure the e-mail address which will be shown in DeviseMailer.
5
+ config.mailer_sender = "please-change-me@config-initializers-devise.com"
6
+
7
+ # Configure the content type of DeviseMailer mails (defaults to text/html")
8
+ # config.mailer_content_type = "text/plain"
9
+
10
+ # ==> Configuration for :authenticatable
11
+ # Invoke `rake secret` and use the printed value to setup a pepper to generate
12
+ # the encrypted password. By default no pepper is used.
13
+ # config.pepper = "rake secret output"
14
+
15
+ # Configure how many times you want the password is reencrypted. Default is 10.
16
+ # config.stretches = 10
17
+
18
+ # Define which will be the encryption algorithm. Supported algorithms are :sha1
19
+ # (default), :sha512 and :bcrypt. Devise also supports encryptors from others
20
+ # authentication tools as :clearance_sha1, :authlogic_sha512 (then you should set
21
+ # stretches above to 20 for default behavior) and :restful_authentication_sha1
22
+ # (then you should set stretches to 10, and copy REST_AUTH_SITE_KEY to pepper)
23
+ # config.encryptor = :sha1
24
+
25
+ # Configure which keys are used when authenticating an user. By default is
26
+ # just :email. You can configure it to use [:username, :subdomain], so for
27
+ # authenticating an user, both parameters are required. Remember that those
28
+ # parameters are used only when authenticating and not when retrieving from
29
+ # session. If you need permissions, you should implement that in a before filter.
30
+ # config.authentication_keys = [ :email ]
31
+
32
+ # The realm used in Http Basic Authentication
33
+ # config.http_authentication_realm = "Application"
34
+
35
+ # ==> Configuration for :confirmable
36
+ # The time you want give to your user to confirm his account. During this time
37
+ # he will be able to access your application without confirming. Default is nil.
38
+ # config.confirm_within = 2.days
39
+
40
+ # ==> Configuration for :rememberable
41
+ # The time the user will be remembered without asking for credentials again.
42
+ # config.remember_for = 2.weeks
43
+
44
+ # ==> Configuration for :timeoutable
45
+ # The time you want to timeout the user session without activity. After this
46
+ # time the user will be asked for credentials again.
47
+ # config.timeout_in = 10.minutes
48
+
49
+ # ==> Configuration for :lockable
50
+ # Number of authentication tries before locking an account.
51
+ # config.maximum_attempts = 20
52
+
53
+ # Defines which strategy will be used to unlock an account.
54
+ # :email = Sends an unlock link to the user email
55
+ # :time = Reanables login after a certain ammount of time (see :unlock_in below)
56
+ # :both = enables both strategies
57
+ # config.unlock_strategy = :both
58
+
59
+ # Time interval to unlock the account if :time is enabled as unlock_strategy.
60
+ # config.unlock_in = 1.hour
61
+
62
+ # ==> Configuration for :token_authenticatable
63
+ # Defines name of the authentication token params key
64
+ # config.token_authentication_key = :auth_token
65
+
66
+ # ==> General configuration
67
+ # Load and configure the ORM. Supports :active_record (default), :mongo_mapper
68
+ # (requires mongo_ext installed) and :data_mapper (experimental).
69
+ # require 'devise/orm/mongo_mapper'
70
+ # config.orm = :mongo_mapper
71
+
72
+ # Turn scoped views on. Before rendering "sessions/new", it will first check for
73
+ # "sessions/users/new". It's turned off by default because it's slower if you
74
+ # are using only default views.
75
+ # config.scoped_views = true
76
+
77
+ # By default, devise detects the role accessed based on the url. So whenever
78
+ # accessing "/users/sign_in", it knows you are accessing an User. This makes
79
+ # routes as "/sign_in" not possible, unless you tell Devise to use the default
80
+ # scope, setting true below.
81
+ # config.use_default_scope = true
82
+
83
+ # Configure the default scope used by Devise. By default it's the first devise
84
+ # role declared in your routes.
85
+ # config.default_scope = :user
86
+
87
+ # If you want to use other strategies, that are not (yet) supported by Devise,
88
+ # you can configure them inside the config.warden block. The example below
89
+ # allows you to setup OAuth, using http://github.com/roman/warden_oauth
90
+ #
91
+ # config.warden do |manager|
92
+ # manager.oauth(:twitter) do |twitter|
93
+ # twitter.consumer_secret = <YOUR CONSUMER SECRET>
94
+ # twitter.consumer_key = <YOUR CONSUMER KEY>
95
+ # twitter.options :site => 'http://twitter.com'
96
+ # end
97
+ # manager.default_strategies.unshift :twitter_oauth
98
+ # end
99
+
100
+ # Configure default_url_options if you are using dynamic segments in :path_prefix
101
+ # for devise_for.
102
+ # config.default_url_options do
103
+ # { :locale => I18n.locale }
104
+ # end
105
+ end
@@ -0,0 +1,2 @@
1
+ ActiveSupport::Inflector.inflections do |inflect|
2
+ end
@@ -0,0 +1,21 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # These settings change the behavior of Rails 2 apps and will be defaults
4
+ # for Rails 3. You can remove this initializer when Rails 3 is released.
5
+
6
+ if defined?(ActiveRecord)
7
+ # Include Active Record class name as root for JSON serialized output.
8
+ ActiveRecord::Base.include_root_in_json = true
9
+
10
+ # Store the full class name (including module namespace) in STI type column.
11
+ ActiveRecord::Base.store_full_sti_class = true
12
+ end
13
+
14
+ ActionController::Routing.generate_best_match = false
15
+
16
+ # Use ISO 8601 format for JSON serialized times and dates.
17
+ ActiveSupport.use_standard_json_time_format = true
18
+
19
+ # Don't escape HTML entities in JSON, leave that for the #json_escape helper.
20
+ # if you're including raw json in an HTML page.
21
+ ActiveSupport.escape_html_entities_in_json = false
@@ -0,0 +1,15 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key for verifying cookie session data integrity.
4
+ # If you change this key, all old sessions will become invalid!
5
+ # Make sure the secret is at least 30 characters and all random,
6
+ # no regular words or you'll be exposed to dictionary attacks.
7
+ ActionController::Base.session = {
8
+ :key => '_rails_app_session',
9
+ :secret => '89e8147901a0d7c221ac130e0ded3eeab6dab4a97127255909f08fedaae371918b41dec9d4d75c5b27a55c3772d43c2b6a3cbac232c5cc2ce4b8ec22242f5e60'
10
+ }
11
+
12
+ # Use the database for sessions instead of the cookie-based default,
13
+ # which shouldn't be used to store highly confidential information
14
+ # (create the session table with "rake db:sessions:create")
15
+ # ActionController::Base.session_store = :active_record_store
@@ -0,0 +1,3 @@
1
+ ActionController::Routing::Routes.draw do |map|
2
+ map.root :controller => :home
3
+ end
@@ -0,0 +1 @@
1
+ require File.join(File.dirname(__FILE__), '../../../../../init')
@@ -0,0 +1,20 @@
1
+ require 'test/test_helper'
2
+
3
+ class MapRoutingTest < ActionController::TestCase
4
+
5
+ test 'map new user invitation' do
6
+ assert_recognizes({:controller => 'invitations', :action => 'new'}, {:path => 'users/invitation/new', :method => :get})
7
+ end
8
+
9
+ test 'map create user invitation' do
10
+ assert_recognizes({:controller => 'invitations', :action => 'create'}, {:path => 'users/invitation', :method => :post})
11
+ end
12
+
13
+ test 'map accept user invitation' do
14
+ assert_recognizes({:controller => 'invitations', :action => 'edit'}, 'users/invitation/accept')
15
+ end
16
+
17
+ test 'map update user invitation' do
18
+ assert_recognizes({:controller => 'invitations', :action => 'update'}, {:path => 'users/invitation', :method => :put})
19
+ end
20
+ end
@@ -0,0 +1,58 @@
1
+ ENV["RAILS_ENV"] = "test"
2
+ require File.join(File.dirname(__FILE__), 'rails_app', 'config', 'environment')
3
+
4
+ require 'test_help'
5
+ require 'mocha'
6
+ require 'webrat'
7
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'devise', 'controllers', 'url_helpers')
8
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'devise', 'controllers', 'helpers')
9
+ ActionView::Base.send :include, Devise::Controllers::UrlHelpers
10
+
11
+ path = File.join(File.dirname(__FILE__), '..', 'app', 'views')
12
+ ActionController::Base.view_paths << path
13
+ Devise::Mailer.view_paths << path
14
+
15
+ ActionMailer::Base.delivery_method = :test
16
+ ActionMailer::Base.perform_deliveries = true
17
+ ActionMailer::Base.default_url_options[:host] = 'test.com'
18
+
19
+ ActiveRecord::Migration.verbose = false
20
+ ActiveRecord::Base.logger = Logger.new(nil)
21
+
22
+ ActiveRecord::Schema.define(:version => 1) do
23
+ create_table :users do |t|
24
+ t.database_authenticatable :null => true
25
+ t.string :username
26
+ t.confirmable
27
+ t.invitable
28
+
29
+ t.timestamps
30
+ end
31
+ end
32
+ class User
33
+ devise :database_authenticatable, :invitable
34
+ end
35
+ ActionController::Routing::Routes.draw do |map|
36
+ map.devise_for :users
37
+ end
38
+ require File.join(File.dirname(__FILE__), '..', 'app', 'controllers', 'invitations_controller')
39
+ InvitationsController.send :include, Devise::Controllers::Helpers
40
+
41
+ Webrat.configure do |config|
42
+ config.mode = :rails
43
+ config.open_error_files = false
44
+ end
45
+
46
+ class ActiveSupport::TestCase
47
+ self.use_transactional_fixtures = true
48
+ self.use_instantiated_fixtures = false
49
+
50
+ def assert_not(assertion, message = nil)
51
+ assert !assertion, message
52
+ end
53
+
54
+ def assert_not_blank(assertion)
55
+ assert !assertion.blank?
56
+ end
57
+ alias :assert_present :assert_not_blank
58
+ end
metadata ADDED
@@ -0,0 +1,173 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lperichon-devise_invitable
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 3
8
+ - 0
9
+ version: 0.3.0
10
+ platform: ruby
11
+ authors:
12
+ - Sergio Cambra
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-07-02 00:00:00 -03:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: mocha
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ type: :development
31
+ version_requirements: *id001
32
+ - !ruby/object:Gem::Dependency
33
+ name: webrat
34
+ prerelease: false
35
+ requirement: &id002 !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ segments:
40
+ - 0
41
+ version: "0"
42
+ type: :development
43
+ version_requirements: *id002
44
+ - !ruby/object:Gem::Dependency
45
+ name: devise
46
+ prerelease: false
47
+ requirement: &id003 !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ~>
50
+ - !ruby/object:Gem::Version
51
+ segments:
52
+ - 1
53
+ - 1
54
+ - 0
55
+ version: 1.1.0
56
+ type: :runtime
57
+ version_requirements: *id003
58
+ description: It adds support for send invitations by email (it requires to be authenticated) and accept the invitation setting the password
59
+ email: sergio@entrecables.com
60
+ executables: []
61
+
62
+ extensions: []
63
+
64
+ extra_rdoc_files:
65
+ - LICENSE
66
+ - README.rdoc
67
+ files:
68
+ - .document
69
+ - .gitignore
70
+ - LICENSE
71
+ - README.rdoc
72
+ - Rakefile
73
+ - VERSION
74
+ - app/controllers/devise/invitations_controller.rb
75
+ - app/views/devise/invitations/edit.html.erb
76
+ - app/views/devise/invitations/new.html.erb
77
+ - app/views/devise/mailer/invitation.html.erb
78
+ - devise_invitable.gemspec
79
+ - init.rb
80
+ - lib/devise_invitable.rb
81
+ - lib/devise_invitable/controllers/helpers.rb
82
+ - lib/devise_invitable/controllers/url_helpers.rb
83
+ - lib/devise_invitable/locales/en.yml
84
+ - lib/devise_invitable/mailer.rb
85
+ - lib/devise_invitable/model.rb
86
+ - lib/devise_invitable/rails.rb
87
+ - lib/devise_invitable/routes.rb
88
+ - lib/devise_invitable/schema.rb
89
+ - test/integration/invitable_test.rb
90
+ - test/integration_tests_helper.rb
91
+ - test/mailers/invitation_test.rb
92
+ - test/model_tests_helper.rb
93
+ - test/models/invitable_test.rb
94
+ - test/models_test.rb
95
+ - test/rails_app/app/controllers/admins_controller.rb
96
+ - test/rails_app/app/controllers/application_controller.rb
97
+ - test/rails_app/app/controllers/home_controller.rb
98
+ - test/rails_app/app/controllers/users_controller.rb
99
+ - test/rails_app/app/helpers/application_helper.rb
100
+ - test/rails_app/app/models/user.rb
101
+ - test/rails_app/app/views/home/index.html.erb
102
+ - test/rails_app/config/boot.rb
103
+ - test/rails_app/config/database.yml
104
+ - test/rails_app/config/environment.rb
105
+ - test/rails_app/config/environments/development.rb
106
+ - test/rails_app/config/environments/production.rb
107
+ - test/rails_app/config/environments/test.rb
108
+ - test/rails_app/config/initializers/backtrace_silencers.rb
109
+ - test/rails_app/config/initializers/devise.rb
110
+ - test/rails_app/config/initializers/inflections.rb
111
+ - test/rails_app/config/initializers/new_rails_defaults.rb
112
+ - test/rails_app/config/initializers/session_store.rb
113
+ - test/rails_app/config/routes.rb
114
+ - test/rails_app/vendor/plugins/devise_invitable/init.rb
115
+ - test/routes_test.rb
116
+ - test/test_helper.rb
117
+ has_rdoc: true
118
+ homepage: http://github.com/scambra/devise_invitable
119
+ licenses: []
120
+
121
+ post_install_message:
122
+ rdoc_options:
123
+ - --charset=UTF-8
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ segments:
131
+ - 0
132
+ version: "0"
133
+ required_rubygems_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ segments:
138
+ - 0
139
+ version: "0"
140
+ requirements: []
141
+
142
+ rubyforge_project:
143
+ rubygems_version: 1.3.6
144
+ signing_key:
145
+ specification_version: 3
146
+ summary: An invitation strategy for devise
147
+ test_files:
148
+ - test/mailers/invitation_test.rb
149
+ - test/test_helper.rb
150
+ - test/routes_test.rb
151
+ - test/model_tests_helper.rb
152
+ - test/integration_tests_helper.rb
153
+ - test/models_test.rb
154
+ - test/rails_app/app/controllers/home_controller.rb
155
+ - test/rails_app/app/controllers/users_controller.rb
156
+ - test/rails_app/app/controllers/application_controller.rb
157
+ - test/rails_app/app/controllers/admins_controller.rb
158
+ - test/rails_app/app/helpers/application_helper.rb
159
+ - test/rails_app/app/models/user.rb
160
+ - test/rails_app/config/boot.rb
161
+ - test/rails_app/config/initializers/devise.rb
162
+ - test/rails_app/config/initializers/new_rails_defaults.rb
163
+ - test/rails_app/config/initializers/inflections.rb
164
+ - test/rails_app/config/initializers/session_store.rb
165
+ - test/rails_app/config/initializers/backtrace_silencers.rb
166
+ - test/rails_app/config/environments/production.rb
167
+ - test/rails_app/config/environments/development.rb
168
+ - test/rails_app/config/environments/test.rb
169
+ - test/rails_app/config/routes.rb
170
+ - test/rails_app/config/environment.rb
171
+ - test/rails_app/vendor/plugins/devise_invitable/init.rb
172
+ - test/integration/invitable_test.rb
173
+ - test/models/invitable_test.rb