Module: Bbq::Devise
- Defined in:
- lib/bbq/devise.rb
Instance Attribute Summary collapse
-
#devise_authentication_key ⇒ Object
Returns the value of attribute devise_authentication_key.
-
#email ⇒ Object
Returns the value of attribute email.
-
#password ⇒ Object
Returns the value of attribute password.
-
#scope ⇒ Object
Returns the value of attribute scope.
Class Method Summary collapse
Instance Method Summary collapse
- #initialize_devise ⇒ Object
- #login ⇒ Object
- #logout ⇒ Object
- #register ⇒ Object
- #register_and_login ⇒ Object
Instance Attribute Details
#devise_authentication_key ⇒ Object
Returns the value of attribute devise_authentication_key.
6 7 8 |
# File 'lib/bbq/devise.rb', line 6 def devise_authentication_key @devise_authentication_key end |
#email ⇒ Object
Returns the value of attribute email.
6 7 8 |
# File 'lib/bbq/devise.rb', line 6 def email @email end |
#password ⇒ Object
Returns the value of attribute password.
6 7 8 |
# File 'lib/bbq/devise.rb', line 6 def password @password end |
#scope ⇒ Object
Returns the value of attribute scope.
6 7 8 |
# File 'lib/bbq/devise.rb', line 6 def scope @scope end |
Class Method Details
.included(klass) ⇒ Object
8 9 10 11 |
# File 'lib/bbq/devise.rb', line 8 def self.included(klass) require 'bbq/rails/routes' klass.send(:include, Bbq::Rails::Routes) end |
.next_email ⇒ Object
48 49 50 |
# File 'lib/bbq/devise.rb', line 48 def self.next_email "#{SecureRandom.hex(3)}@example.com" end |
.next_password ⇒ Object
52 53 54 |
# File 'lib/bbq/devise.rb', line 52 def self.next_password SecureRandom.hex(8) end |
Instance Method Details
#initialize_devise ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/bbq/devise.rb', line 13 def initialize_devise @devise_initialized ||= begin self.devise_authentication_key = ::Devise.authentication_keys.first self.email = [devise_authentication_key.to_sym] || Bbq::Devise.next_email self.password = [:password] || Bbq::Devise.next_password self.scope = ::Devise.mappings.first.second.singular.to_s true end end |
#login ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/bbq/devise.rb', line 32 def login initialize_devise visit send("new_#{scope}_session_path") fill_in "#{scope}_#{devise_authentication_key}", :with => @email fill_in "#{scope}_password", :with => @password find(:xpath, "//input[@name='commit']").click end |
#logout ⇒ Object
40 41 42 |
# File 'lib/bbq/devise.rb', line 40 def logout visit send("destroy_#{scope}_session_path") end |
#register ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/bbq/devise.rb', line 23 def register initialize_devise visit send("new_#{scope}_registration_path") fill_in "#{scope}_#{devise_authentication_key}", :with => @email fill_in "#{scope}_password", :with => @password fill_in "#{scope}_password_confirmation", :with => @password find(:xpath, "//input[@name='commit']").click end |
#register_and_login ⇒ Object
44 45 46 |
# File 'lib/bbq/devise.rb', line 44 def register_and_login register end |