Currently waiting confirmation for: <%= resource.unconfirmed_email %>
+ <% end %>
+
+ <%= f.input :password, autocomplete: "off", hint: "leave it blank if you don't want to change it", required: false %>
+ <%= f.input :password_confirmation, required: false %>
+ <%= f.input :current_password, hint: "we need your current password to confirm your changes", required: true %>
+
+
+
+ <%= f.button :submit, "Update" %>
+
+<% end %>
+
+
Cancel my account
+
+
Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %>
+
+<% if resource.errors.any? %>
+
+<% end %>
diff --git a/config/initializers/carrierwave_backgrounder.rb b/config/initializers/carrierwave_backgrounder.rb
index 9da6264a..7244f05d 100644
--- a/config/initializers/carrierwave_backgrounder.rb
+++ b/config/initializers/carrierwave_backgrounder.rb
@@ -1,8 +1,3 @@
CarrierWave::Backgrounder.configure do |c|
- # c.backend :resque, queue: :carrierwave
c.backend :sidekiq, queue: :carrierwave
- # c.backend :girl_friday, queue: :carrierwave
- # c.backend :sucker_punch, queue: :carrierwave
- # c.backend :qu, queue: :carrierwave
- # c.backend :qc
end
diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb
new file mode 100644
index 00000000..95979ccd
--- /dev/null
+++ b/config/initializers/devise.rb
@@ -0,0 +1,272 @@
+Devise.setup do |config|
+ # The secret key used by Devise. Devise uses this key to generate
+ # random tokens. Changing this key will render invalid all existing
+ # confirmation, reset password and unlock tokens in the database.
+ # Devise will use the `secret_key_base` as its `secret_key`
+ # by default. You can change it below and use your own secret key.
+ # config.secret_key = 'bc2669e02c8d691af8d616988029515f9ece4ca647ea8831323466d13dc146368d6ea5cd60b9a5dc4116673c70bc0169406bf5c365125db76b7c813a33533aac'
+
+ # ==> Mailer Configuration
+ # Configure the e-mail address which will be shown in Devise::Mailer,
+ # note that it will be overwritten if you use your own mailer class
+ # with default "from" parameter.
+ config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com'
+
+ # Configure the class responsible to send e-mails.
+ # config.mailer = 'Devise::Mailer'
+
+ # Configure the parent class responsible to send e-mails.
+ # config.parent_mailer = 'ActionMailer::Base'
+
+ # ==> ORM configuration
+ # Load and configure the ORM. Supports :active_record (default) and
+ # :mongoid (bson_ext recommended) by default. Other ORMs may be
+ # available as additional gems.
+ require 'devise/orm/active_record'
+
+ # ==> Configuration for any authentication mechanism
+ # Configure which keys are used when authenticating a user. The default is
+ # just :email. You can configure it to use [:username, :subdomain], so for
+ # authenticating a user, both parameters are required. Remember that those
+ # parameters are used only when authenticating and not when retrieving from
+ # session. If you need permissions, you should implement that in a before filter.
+ # You can also supply a hash where the value is a boolean determining whether
+ # or not authentication should be aborted when the value is not present.
+ # config.authentication_keys = [:email]
+
+ # Configure parameters from the request object used for authentication. Each entry
+ # given should be a request method and it will automatically be passed to the
+ # find_for_authentication method and considered in your model lookup. For instance,
+ # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
+ # The same considerations mentioned for authentication_keys also apply to request_keys.
+ # config.request_keys = []
+
+ # Configure which authentication keys should be case-insensitive.
+ # These keys will be downcased upon creating or modifying a user and when used
+ # to authenticate or find a user. Default is :email.
+ config.case_insensitive_keys = [:email]
+
+ # Configure which authentication keys should have whitespace stripped.
+ # These keys will have whitespace before and after removed upon creating or
+ # modifying a user and when used to authenticate or find a user. Default is :email.
+ config.strip_whitespace_keys = [:email]
+
+ # Tell if authentication through request.params is enabled. True by default.
+ # It can be set to an array that will enable params authentication only for the
+ # given strategies, for example, `config.params_authenticatable = [:database]` will
+ # enable it only for database (email + password) authentication.
+ # config.params_authenticatable = true
+
+ # Tell if authentication through HTTP Auth is enabled. False by default.
+ # It can be set to an array that will enable http authentication only for the
+ # given strategies, for example, `config.http_authenticatable = [:database]` will
+ # enable it only for database authentication. The supported strategies are:
+ # :database = Support basic authentication with authentication key + password
+ # config.http_authenticatable = false
+
+ # If 401 status code should be returned for AJAX requests. True by default.
+ # config.http_authenticatable_on_xhr = true
+
+ # The realm used in Http Basic Authentication. 'Application' by default.
+ # config.http_authentication_realm = 'Application'
+
+ # It will change confirmation, password recovery and other workflows
+ # to behave the same regardless if the e-mail provided was right or wrong.
+ # Does not affect registerable.
+ # config.paranoid = true
+
+ # By default Devise will store the user in session. You can skip storage for
+ # particular strategies by setting this option.
+ # Notice that if you are skipping storage for all authentication paths, you
+ # may want to disable generating routes to Devise's sessions controller by
+ # passing skip: :sessions to `devise_for` in your config/routes.rb
+ config.skip_session_storage = [:http_auth]
+
+ # By default, Devise cleans up the CSRF token on authentication to
+ # avoid CSRF token fixation attacks. This means that, when using AJAX
+ # requests for sign in and sign up, you need to get a new CSRF token
+ # from the server. You can disable this option at your own risk.
+ # config.clean_up_csrf_token_on_authentication = true
+
+ # When false, Devise will not attempt to reload routes on eager load.
+ # This can reduce the time taken to boot the app but if your application
+ # requires the Devise mappings to be loaded during boot time the application
+ # won't boot properly.
+ # config.reload_routes = true
+
+ # ==> Configuration for :database_authenticatable
+ # For bcrypt, this is the cost for hashing the password and defaults to 11. If
+ # using other algorithms, it sets how many times you want the password to be hashed.
+ #
+ # Limiting the stretches to just one in testing will increase the performance of
+ # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
+ # a value less than 10 in other environments. Note that, for bcrypt (the default
+ # algorithm), the cost increases exponentially with the number of stretches (e.g.
+ # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
+ config.stretches = Rails.env.test? ? 1 : 20
+
+ # Set up a pepper to generate the hashed password.
+ # config.pepper = '93b2d1e623477421887577755a5603c40159c1451bf25ddecd14cb5f31a934ff2a841617dc828fb44e84247be3cc12969d6d2834103c20553b9e01446b7e4e0c'
+
+ # Send a notification email when the user's password is changed
+ # config.send_password_change_notification = false
+
+ # ==> Configuration for :confirmable
+ # A period that the user is allowed to access the website even without
+ # confirming their account. For instance, if set to 2.days, the user will be
+ # able to access the website for two days without confirming their account,
+ # access will be blocked just in the third day. Default is 0.days, meaning
+ # the user cannot access the website without confirming their account.
+ # config.allow_unconfirmed_access_for = 2.days
+
+ # A period that the user is allowed to confirm their account before their
+ # token becomes invalid. For example, if set to 3.days, the user can confirm
+ # their account within 3 days after the mail was sent, but on the fourth day
+ # their account can't be confirmed with the token any more.
+ # Default is nil, meaning there is no restriction on how long a user can take
+ # before confirming their account.
+ # config.confirm_within = 3.days
+
+ # If true, requires any email changes to be confirmed (exactly the same way as
+ # initial account confirmation) to be applied. Requires additional unconfirmed_email
+ # db field (see migrations). Until confirmed, new email is stored in
+ # unconfirmed_email column, and copied to email column on successful confirmation.
+ config.reconfirmable = true
+
+ # Defines which key will be used when confirming an account
+ # config.confirmation_keys = [:email]
+
+ # ==> Configuration for :rememberable
+ # The time the user will be remembered without asking for credentials again.
+ # config.remember_for = 2.weeks
+
+ # Invalidates all the remember me tokens when the user signs out.
+ config.expire_all_remember_me_on_sign_out = true
+
+ # If true, extends the user's remember period when remembered via cookie.
+ # config.extend_remember_period = false
+
+ # Options to be passed to the created cookie. For instance, you can set
+ # secure: true in order to force SSL only cookies.
+ # config.rememberable_options = {}
+
+ # ==> Configuration for :validatable
+ # Range for password length.
+ config.password_length = 6..128
+
+ # Email regex used to validate email formats. It simply asserts that
+ # one (and only one) @ exists in the given string. This is mainly
+ # to give user feedback and not to assert the e-mail validity.
+ config.email_regexp = /\A[^@\s]+@[^@\s]+\z/
+
+ # ==> Configuration for :timeoutable
+ # The time you want to timeout the user session without activity. After this
+ # time the user will be asked for credentials again. Default is 30 minutes.
+ # config.timeout_in = 30.minutes
+
+ # ==> Configuration for :lockable
+ # Defines which strategy will be used to lock an account.
+ # :failed_attempts = Locks an account after a number of failed attempts to sign in.
+ # :none = No lock strategy. You should handle locking by yourself.
+ # config.lock_strategy = :failed_attempts
+
+ # Defines which key will be used when locking and unlocking an account
+ # config.unlock_keys = [:email]
+
+ # Defines which strategy will be used to unlock an account.
+ # :email = Sends an unlock link to the user email
+ # :time = Re-enables login after a certain amount of time (see :unlock_in below)
+ # :both = Enables both strategies
+ # :none = No unlock strategy. You should handle unlocking by yourself.
+ # config.unlock_strategy = :both
+
+ # Number of authentication tries before locking an account if lock_strategy
+ # is failed attempts.
+ # config.maximum_attempts = 20
+
+ # Time interval to unlock the account if :time is enabled as unlock_strategy.
+ # config.unlock_in = 1.hour
+
+ # Warn on the last attempt before the account is locked.
+ # config.last_attempt_warning = true
+
+ # ==> Configuration for :recoverable
+ #
+ # Defines which key will be used when recovering the password for an account
+ # config.reset_password_keys = [:email]
+
+ # Time interval you can reset your password with a reset password key.
+ # Don't put a too small interval or your users won't have the time to
+ # change their passwords.
+ config.reset_password_within = 6.hours
+
+ # When set to false, does not sign a user in automatically after their password is
+ # reset. Defaults to true, so a user is signed in automatically after a reset.
+ # config.sign_in_after_reset_password = true
+
+ # ==> Configuration for :encryptable
+ # Allow you to use another hashing or encryption algorithm besides bcrypt (default).
+ # You can use :sha1, :sha512 or algorithms from others authentication tools as
+ # :clearance_sha1, :authlogic_sha512 (then you should set stretches above to 20
+ # for default behavior) and :restful_authentication_sha1 (then you should set
+ # stretches to 10, and copy REST_AUTH_SITE_KEY to pepper).
+ #
+ # Require the `devise-encryptable` gem when using anything other than bcrypt
+ config.encryptor = :authlogic_sha512
+
+ # ==> Scopes configuration
+ # Turn scoped views on. Before rendering "sessions/new", it will first check for
+ # "users/sessions/new". It's turned off by default because it's slower if you
+ # are using only default views.
+ config.scoped_views = true
+
+ # Configure the default scope given to Warden. By default it's the first
+ # devise role declared in your routes (usually :user).
+ # config.default_scope = :user
+
+ # Set this configuration to false if you want /users/sign_out to sign out
+ # only the current scope. By default, Devise signs out all scopes.
+ # config.sign_out_all_scopes = true
+
+ # ==> Navigation configuration
+ # Lists the formats that should be treated as navigational. Formats like
+ # :html, should redirect to the sign in page when the user does not have
+ # access, but formats like :xml or :json, should return 401.
+ #
+ # If you have any extra navigational formats, like :iphone or :mobile, you
+ # should add them to the navigational formats lists.
+ #
+ # The "*/*" below is required to match Internet Explorer requests.
+ # config.navigational_formats = ['*/*', :html]
+
+ # The default HTTP method used to sign out a resource. Default is :delete.
+ config.sign_out_via = :delete
+
+ # ==> OmniAuth
+ # Add a new OmniAuth provider. Check the wiki for more information on setting
+ # up on your models and hooks.
+ # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
+
+ # ==> Warden configuration
+ # If you want to use other strategies, that are not supported by Devise, or
+ # change the failure app, you can configure them inside the config.warden block.
+ #
+ # config.warden do |manager|
+ # manager.intercept_401 = false
+ # manager.default_strategies(scope: :user).unshift :some_external_strategy
+ # end
+
+ # ==> Mountable engine configurations
+ # When using Devise inside an engine, let's call it `MyEngine`, and this engine
+ # is mountable, there are some extra configurations to be taken into account.
+ # The following options are available, assuming the engine is mounted as:
+ #
+ # mount MyEngine, at: '/my_engine'
+ #
+ # The router that invoked `devise_for`, in the example above, would be:
+ # config.router_name = :my_engine
+ #
+ # When using OmniAuth, Devise cannot automatically set OmniAuth path,
+ # so you need to do it manually. For the users scope, it would be:
+ # config.omniauth_path_prefix = '/my_engine/users/auth'
+end
diff --git a/config/locales/devise.en.yml b/config/locales/devise.en.yml
new file mode 100644
index 00000000..bd4c3ebc
--- /dev/null
+++ b/config/locales/devise.en.yml
@@ -0,0 +1,62 @@
+# Additional translations at https://github.com/plataformatec/devise/wiki/I18n
+
+en:
+ devise:
+ confirmations:
+ confirmed: "Your email address has been successfully confirmed."
+ send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes."
+ send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes."
+ failure:
+ already_authenticated: "You are already signed in."
+ inactive: "Your account is not activated yet."
+ invalid: "Invalid %{authentication_keys} or password."
+ locked: "Your account is locked."
+ last_attempt: "You have one more attempt before your account is locked."
+ not_found_in_database: "Invalid %{authentication_keys} or password."
+ timeout: "Your session expired. Please sign in again to continue."
+ unauthenticated: "You need to sign in or sign up before continuing."
+ unconfirmed: "You have to confirm your email address before continuing."
+ mailer:
+ confirmation_instructions:
+ subject: "Confirmation instructions"
+ reset_password_instructions:
+ subject: "Reset password instructions"
+ unlock_instructions:
+ subject: "Unlock instructions"
+ password_change:
+ subject: "Password Changed"
+ omniauth_callbacks:
+ failure: "Could not authenticate you from %{kind} because \"%{reason}\"."
+ success: "Successfully authenticated from %{kind} account."
+ passwords:
+ no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided."
+ send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes."
+ send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
+ updated: "Your password has been changed successfully. You are now signed in."
+ updated_not_active: "Your password has been changed successfully."
+ registrations:
+ destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon."
+ signed_up: "Welcome! You have signed up successfully."
+ signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated."
+ signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked."
+ signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account."
+ update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirm link to confirm your new email address."
+ updated: "Your account has been updated successfully."
+ sessions:
+ signed_in: "Signed in successfully."
+ signed_out: "Signed out successfully."
+ already_signed_out: "Signed out successfully."
+ unlocks:
+ send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes."
+ send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes."
+ unlocked: "Your account has been unlocked successfully. Please sign in to continue."
+ errors:
+ messages:
+ already_confirmed: "was already confirmed, please try signing in"
+ confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one"
+ expired: "has expired, please request a new one"
+ not_found: "not found"
+ not_locked: "was not locked"
+ not_saved:
+ one: "1 error prohibited this %{resource} from being saved:"
+ other: "%{count} errors prohibited this %{resource} from being saved:"
diff --git a/config/routes/customer/customer_session.rb b/config/routes/customer/customer_session.rb
index 69d1e8c0..0a17a742 100644
--- a/config/routes/customer/customer_session.rb
+++ b/config/routes/customer/customer_session.rb
@@ -1,3 +1,6 @@
-resources :customer_sessions, only: [:new, :create] do
- delete :destroy, on: :collection
-end
+# resources :customer_sessions, only: [:new, :create] do
+# delete :destroy, on: :collection
+# end
+devise_for :customers, path: 'customers', controllers: {
+ sessions: 'customers/sessions' # poner todos los demas
+}
diff --git a/config/routes/user/user_session.rb b/config/routes/user/user_session.rb
index 010adbe8..97fd0982 100644
--- a/config/routes/user/user_session.rb
+++ b/config/routes/user/user_session.rb
@@ -1,3 +1,4 @@
-resources :user_sessions, only: [:new, :create] do
- delete :destroy, on: :collection
-end
+# resources :user_sessions, only: [:new, :create] do
+# delete :destroy, on: :collection
+# end
+devise_for :users, path: 'users', controllers: { sessions: 'users/sessions' }
diff --git a/db/migrate/20170304192533_authlogic_users_to_devise.rb b/db/migrate/20170304192533_authlogic_users_to_devise.rb
new file mode 100644
index 00000000..f9df841e
--- /dev/null
+++ b/db/migrate/20170304192533_authlogic_users_to_devise.rb
@@ -0,0 +1,49 @@
+class AuthlogicUsersToDevise < ActiveRecord::Migration[5.1]
+ def up
+ add_column :users, :confirmation_token, :string, limit: 255
+ add_column :users, :confirmed_at, :timestamp
+ add_column :users, :confirmation_sent_at, :timestamp
+ add_column :users, :unconfirmed_email, :string
+
+ execute "UPDATE users SET confirmed_at = created_at, confirmation_sent_at = created_at"
+
+ add_column :users, :reset_password_token, :string, limit: 255
+ add_column :users, :reset_password_sent_at, :timestamp
+ add_column :users, :remember_token, :string, limit: 255
+ add_column :users, :remember_created_at, :timestamp
+ add_column :users, :unlock_token, :string, limit: 255
+ add_column :users, :locked_at, :timestamp
+ add_column :users, :sign_in_count, :integer
+
+ rename_column :users, :crypted_password, :encrypted_password
+
+ remove_column :users, :persistence_token
+
+ add_index :users, :confirmation_token, unique: true
+ add_index :users, :reset_password_token, unique: true
+ add_index :users, :unlock_token, unique: true
+ end
+
+ def down
+ remove_column :users, :confirmation_token
+ remove_column :users, :confirmed_at
+ remove_column :users, :confirmation_sent_at
+ remove_column :users, :unconfirmed_email
+ remove_column :users, :reset_password_token
+ remove_column :users, :reset_password_sent_at
+ remove_column :users, :remember_token
+ remove_column :users, :remember_created_at
+ remove_column :users, :unlock_token
+ remove_column :users, :locked_at
+
+ rename_column :users, :encrypted_password, :crypted_password
+ rename_column :users, :sign_in_count, :login_count
+
+ add_column :users, :persistence_token, :string
+ add_column :users, :single_access_token, :string
+
+ remove_index :users, :confirmation_token
+ remove_index :users, :reset_password_token
+ remove_index :users, :unlock_token
+ end
+end
diff --git a/db/migrate/20170304195401_authlogic_customer_to_devise.rb b/db/migrate/20170304195401_authlogic_customer_to_devise.rb
new file mode 100644
index 00000000..0ede28e4
--- /dev/null
+++ b/db/migrate/20170304195401_authlogic_customer_to_devise.rb
@@ -0,0 +1,51 @@
+class AuthlogicCustomerToDevise < ActiveRecord::Migration[5.1]
+ def up
+ add_column :customers, :confirmation_token, :string, limit: 255
+ add_column :customers, :confirmed_at, :timestamp
+ add_column :customers, :confirmation_sent_at, :timestamp
+ add_column :customers, :unconfirmed_email, :string
+
+ execute "UPDATE customers SET confirmed_at = created_at, confirmation_sent_at = created_at"
+
+ add_column :customers, :reset_password_token, :string, limit: 255
+ add_column :customers, :reset_password_sent_at, :timestamp
+ add_column :customers, :remember_token, :string, limit: 255
+ add_column :customers, :remember_created_at, :timestamp
+ add_column :customers, :unlock_token, :string, limit: 255
+ add_column :customers, :locked_at, :timestamp
+ add_column :customers, :sign_in_count, :integer
+
+ rename_column :customers, :crypted_password, :encrypted_password
+
+ remove_column :customers, :persistence_token
+ remove_column :customers, :perishable_token
+
+ add_index :customers, :confirmation_token, unique: true
+ add_index :customers, :reset_password_token, unique: true
+ add_index :customers, :unlock_token, unique: true
+ end
+
+ def down
+ # remove_column :customers, :confirmation_token
+ remove_column :customers, :confirmed_at
+ remove_column :customers, :confirmation_sent_at
+ remove_column :customers, :unconfirmed_email
+ remove_column :customers, :reset_password_token
+ remove_column :customers, :reset_password_sent_at
+ remove_column :customers, :remember_token
+ remove_column :customers, :remember_created_at
+ remove_column :customers, :unlock_token
+ remove_column :customers, :locked_at
+
+ rename_column :customers, :encrypted_password, :crypted_password
+ rename_column :customers, :sign_in_count, :login_count
+
+ add_column :customers, :persistence_token, :string
+ add_column :customers, :perishable_token, :string
+ add_column :customers, :single_access_token, :string
+
+ # remove_index :customers, :confirmation_token
+ # remove_index :customers, :reset_password_token
+ # remove_index :customers, :unlock_token
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 7ab98d19..e21c332c 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -66,19 +66,30 @@
t.datetime "updated_at"
t.boolean "bonus_without_expiration", default: false, null: false
t.string "email"
- t.string "crypted_password"
+ t.string "encrypted_password"
t.string "password_salt"
- t.string "persistence_token"
- t.string "perishable_token"
t.boolean "enable", default: true
t.string "kind", limit: 1, default: "n", null: false
t.integer "group_id"
+ t.string "confirmation_token", limit: 255
+ t.datetime "confirmed_at"
+ t.datetime "confirmation_sent_at"
+ t.string "unconfirmed_email"
+ t.string "reset_password_token", limit: 255
+ t.datetime "reset_password_sent_at"
+ t.string "remember_token", limit: 255
+ t.datetime "remember_created_at"
+ t.string "unlock_token", limit: 255
+ t.datetime "locked_at"
+ t.integer "sign_in_count"
t.string "rfid"
t.index "to_tsvector('spanish'::regconfig, (((((COALESCE(identification, ''::character varying))::text || ' '::text) || (COALESCE(name, ''::character varying))::text) || ' '::text) || (COALESCE(lastname, ''::character varying))::text))", name: "index_customers_on_identification_name_and_lastname_ts", using: :gin
+ t.index ["confirmation_token"], name: "index_customers_on_confirmation_token", unique: true
t.index ["email"], name: "index_customers_on_email", unique: true
t.index ["enable"], name: "index_customers_on_enable"
t.index ["identification"], name: "index_customers_on_identification", unique: true
- t.index ["perishable_token"], name: "index_customers_on_perishable_token"
+ t.index ["reset_password_token"], name: "index_customers_on_reset_password_token", unique: true
+ t.index ["unlock_token"], name: "index_customers_on_unlock_token", unique: true
end
create_table "customers_groups", id: :serial, force: :cascade do |t|
@@ -314,9 +325,8 @@
t.string "language", null: false
t.string "email", null: false
t.string "username", null: false
- t.string "crypted_password", null: false
+ t.string "encrypted_password", null: false
t.string "password_salt", null: false
- t.string "persistence_token", null: false
t.boolean "admin", default: false, null: false
t.boolean "enable"
t.integer "lock_version", default: 0
@@ -329,7 +339,21 @@
t.datetime "avatar_updated_at"
t.integer "lines_per_page"
t.boolean "not_shifted", default: false
+ t.string "confirmation_token", limit: 255
+ t.datetime "confirmed_at"
+ t.datetime "confirmation_sent_at"
+ t.string "unconfirmed_email"
+ t.string "reset_password_token", limit: 255
+ t.datetime "reset_password_sent_at"
+ t.string "remember_token", limit: 255
+ t.datetime "remember_created_at"
+ t.string "unlock_token", limit: 255
+ t.datetime "locked_at"
+ t.integer "sign_in_count"
+ t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
t.index ["email"], name: "index_users_on_email", unique: true
+ t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
+ t.index ["unlock_token"], name: "index_users_on_unlock_token", unique: true
t.index ["username"], name: "index_users_on_username", unique: true
end
diff --git a/lib/admin_constraint.rb b/lib/admin_constraint.rb
index 61d25036..443e3fcd 100644
--- a/lib/admin_constraint.rb
+++ b/lib/admin_constraint.rb
@@ -3,7 +3,7 @@ def matches?(request)
credentials = request.cookie_jar['user_credentials']
Rails.logger.info("Someone wants to loggin #{credentials}")
return false if credentials.blank?
- user = User.find_by_persistence_token(credentials.split(':')[0])
- user && user.admin? && user.not_shifted
+ # user = User.find_by_persistence_token(credentials.split(':')[0])
+ # user && user.admin? && user.not_shifted
end
end
diff --git a/test/controllers/application_controller_test.rb b/test/controllers/application_controller_test.rb
index cc92d00b..ecc83c7d 100644
--- a/test/controllers/application_controller_test.rb
+++ b/test/controllers/application_controller_test.rb
@@ -28,7 +28,7 @@ def setup
test 'current user session' do
assert_nil @controller.send(:current_user_session)
- UserSession.create(@operator)
+ sign_in(@operator)
assert_not_nil @controller.send(:current_user_session)
end
@@ -36,7 +36,7 @@ def setup
test 'current user' do
assert_nil @controller.send(:current_user)
- UserSession.create(@operator)
+ sign_in(@operator)
assert_not_nil @controller.send(:current_user)
assert_equal @operator.id, @controller.send(:current_user).id
@@ -74,7 +74,7 @@ def setup
assert_equal I18n.t('messages.must_be_logged_in'),
@controller.send(:flash)[:notice]
- UserSession.create(@operator)
+ sign_in(@operator)
assert_not_equal false, @controller.send(:require_user)
end
@@ -82,7 +82,7 @@ def setup
test 'require no user' do
assert @controller.send(:require_no_user)
- UserSession.create(@operator)
+ sign_in(@operator)
assert !@controller.send(:require_no_user)
assert_redirected_to prints_url
@@ -96,7 +96,7 @@ def setup
assert_equal I18n.t('messages.must_be_logged_in'),
@controller.send(:flash)[:notice]
- UserSession.create(@operator)
+ sign_in(@operator)
assert_not_equal false, @controller.send(:require_customer_or_user)
end
@@ -107,7 +107,7 @@ def setup
assert_not_nil @controller.send(:check_logged_in)
assert_redirected_to root_url
- UserSession.create(@operator)
+ sign_in(@operator)
assert_nil @controller.send(:check_logged_in)
assert_not_nil @controller.send(:current_user)
@@ -145,7 +145,7 @@ def setup
assert_equal I18n.t('messages.must_be_logged_in'),
@controller.send(:flash)[:notice]
- UserSession.create(@operator)
+ sign_in(@operator)
assert_not_equal false, @controller.send(:require_no_customer_or_user)
end
@@ -163,14 +163,14 @@ def setup
test 'require no customer or admin with user' do
@operator.update(admin: false)
- UserSession.create(@operator)
+ sign_in(@operator)
assert @controller.send(:require_no_customer_or_user)
assert_response :success
end
test 'require admin user with admin user' do
- UserSession.create(@operator)
+ sign_in(@operator)
assert_not_equal false, @controller.send(:require_admin_user)
end
@@ -178,7 +178,7 @@ def setup
test 'require admin with a non admin user' do
@operator.update(admin: false)
- UserSession.create(@operator)
+ sign_in(@operator)
assert_equal false, @controller.send(:require_admin_user)
assert_redirected_to prints_url
@@ -209,7 +209,7 @@ def setup
@operator.update(admin: false, not_shifted: false)
@operator.close_pending_shifts!
- UserSession.create(@operator)
+ sign_in(@operator)
@controller.send(:session)[:has_an_open_shift] = true
@@ -230,7 +230,7 @@ def setup
@operator.update(not_shifted: true)
assert_no_difference 'Shift.count' do
- UserSession.create(@operator)
+ sign_in(@operator)
@controller.send(:session)[:has_an_open_shift] = true
assert_nil @controller.send(:run_shift_tasks)
diff --git a/test/controllers/articles_controller_test.rb b/test/controllers/articles_controller_test.rb
index 1f48b295..14b323b2 100644
--- a/test/controllers/articles_controller_test.rb
+++ b/test/controllers/articles_controller_test.rb
@@ -5,7 +5,7 @@ class ArticlesControllerTest < ActionController::TestCase
@article = articles(:binding)
@operator = users(:operator)
- UserSession.create(@operator)
+ sign_in(@operator)
end
test 'should get index' do
diff --git a/test/controllers/bonuses_controller_test.rb b/test/controllers/bonuses_controller_test.rb
index 4e330fe8..adacd567 100644
--- a/test/controllers/bonuses_controller_test.rb
+++ b/test/controllers/bonuses_controller_test.rb
@@ -2,7 +2,7 @@
class BonusesControllerTest < ActionController::TestCase
def setup
- UserSession.create(users(:operator))
+ sign_in(users(:operator))
end
test 'should get index' do
diff --git a/test/controllers/customers_controller_test.rb b/test/controllers/customers_controller_test.rb
index 6cf343f1..0d83bdfb 100644
--- a/test/controllers/customers_controller_test.rb
+++ b/test/controllers/customers_controller_test.rb
@@ -7,7 +7,7 @@ class CustomersControllerTest < ActionController::TestCase
end
test 'should get index' do
- UserSession.create(@operator)
+ sign_in(@operator)
get :index
assert_response :success
@@ -17,7 +17,7 @@ class CustomersControllerTest < ActionController::TestCase
end
test 'should get filtered index' do
- UserSession.create(@operator)
+ sign_in(@operator)
get :index, params: { q: 'Anakin|Darth' }
assert_response :success
@@ -30,7 +30,7 @@ class CustomersControllerTest < ActionController::TestCase
end
test 'should get index with debt customers' do
- UserSession.create(@operator)
+ sign_in(@operator)
get :index, params: { status: 'with_debt' }
assert_response :success
@@ -42,7 +42,7 @@ class CustomersControllerTest < ActionController::TestCase
end
test 'should get new' do
- UserSession.create(@operator)
+ sign_in(@operator)
get :new
assert_response :success
@@ -62,7 +62,7 @@ class CustomersControllerTest < ActionController::TestCase
end
test 'should create simple customer' do
- UserSession.create(@operator)
+ sign_in(@operator)
assert_difference ['Customer.unscoped.count'] do
assert_difference 'PaperTrail::Version.count' do
@@ -86,7 +86,7 @@ class CustomersControllerTest < ActionController::TestCase
test 'should create customer' do
User.where(id: @operator.id).update_all(not_shifted: true)
- UserSession.create(@operator)
+ sign_in(@operator)
assert_difference ['Customer.unscoped.count', 'Bonus.count'] do
assert_difference 'PaperTrail::Version.count', 2 do
@@ -169,7 +169,7 @@ class CustomersControllerTest < ActionController::TestCase
end
test 'should show customer' do
- UserSession.create(@operator)
+ sign_in(@operator)
get :show, params: { id: @customer.to_param }
assert_response :success
@@ -179,7 +179,7 @@ class CustomersControllerTest < ActionController::TestCase
end
test 'should get edit' do
- UserSession.create(@operator)
+ sign_in(@operator)
get :edit, params: { id: @customer.to_param }
assert_response :success
@@ -190,7 +190,7 @@ class CustomersControllerTest < ActionController::TestCase
test 'should update customer' do
User.where(id: @operator.id).update_all(not_shifted: true)
- UserSession.create(@operator)
+ sign_in(@operator)
assert_no_difference 'Customer.count' do
assert_difference 'Bonus.count' do
@@ -215,7 +215,7 @@ class CustomersControllerTest < ActionController::TestCase
end
test 'should update customer deposits' do
- UserSession.create(@operator)
+ sign_in(@operator)
assert_no_difference 'Customer.count' do
assert_difference 'Deposit.count' do
@@ -238,7 +238,7 @@ class CustomersControllerTest < ActionController::TestCase
end
test 'should destroy customer' do
- UserSession.create(@operator)
+ sign_in(@operator)
assert_difference('Customer.count', -1) do
delete :destroy, params: { id: Customer.find(customers(:teacher).id).to_param }
@@ -248,7 +248,7 @@ class CustomersControllerTest < ActionController::TestCase
end
test 'should get credit detail' do
- UserSession.create(@operator)
+ sign_in(@operator)
get :credit_detail, params: { id: @customer.to_param }, xhr: true
@@ -323,7 +323,7 @@ class CustomersControllerTest < ActionController::TestCase
end
test 'should pay off customer debt' do
- UserSession.create(@operator)
+ sign_in(@operator)
put :pay_off_debt, params: { id: @customer.to_param }, xhr: true
@@ -334,7 +334,7 @@ class CustomersControllerTest < ActionController::TestCase
end
test 'should pay off a customer month debt' do
- UserSession.create(@operator)
+ sign_in(@operator)
month = @customer.months_to_pay.last
@@ -347,7 +347,7 @@ class CustomersControllerTest < ActionController::TestCase
end
test 'should be able to use customer rfid' do
- UserSession.create(@operator)
+ sign_in(@operator)
@customer.update(rfid: '123123')
put :use_rfid, params: { id: @customer.to_param, rfid: '123123' }, xhr: true
@@ -359,7 +359,7 @@ class CustomersControllerTest < ActionController::TestCase
end
test 'should not be able to use customer rfid' do
- UserSession.create(@operator)
+ sign_in(@operator)
@customer.update(rfid: '123123')
put :use_rfid, params: { id: @customer.to_param, rfid: '111111' }, xhr: true
@@ -370,7 +370,7 @@ class CustomersControllerTest < ActionController::TestCase
end
test 'should assign customer rfid' do
- UserSession.create(@operator)
+ sign_in(@operator)
assert_nil @customer.rfid
post :assign_rfid, params: { id: @customer.to_param, rfid: '123123' }, xhr: true
diff --git a/test/controllers/customers_groups_controller_test.rb b/test/controllers/customers_groups_controller_test.rb
index e2b8fcf1..7971a156 100644
--- a/test/controllers/customers_groups_controller_test.rb
+++ b/test/controllers/customers_groups_controller_test.rb
@@ -3,7 +3,7 @@
class CustomersGroupsControllerTest < ActionController::TestCase
setup do
@customers_group = customers_groups(:graduate)
- UserSession.create users(:operator)
+ sign_in users(:operator)
end
test 'should get index' do
diff --git a/test/controllers/documents_controller_test.rb b/test/controllers/documents_controller_test.rb
index fac9340c..9a207b2c 100644
--- a/test/controllers/documents_controller_test.rb
+++ b/test/controllers/documents_controller_test.rb
@@ -5,7 +5,7 @@ class DocumentsControllerTest < ActionController::TestCase
@document = documents(:math_book)
@operator = users(:operator)
- UserSession.create(@operator)
+ sign_in(@operator)
prepare_document_files
end
diff --git a/test/controllers/files_controller_test.rb b/test/controllers/files_controller_test.rb
index 3290c4e7..19f9be39 100644
--- a/test/controllers/files_controller_test.rb
+++ b/test/controllers/files_controller_test.rb
@@ -10,7 +10,7 @@ class FilesControllerTest < ActionController::TestCase
end
test 'should download avatar' do
- UserSession.create(@operator)
+ sign_in(@operator)
get :download, params: { path: drop_private_dir(@operator.avatar.path) }
assert_response :success
@@ -21,7 +21,7 @@ class FilesControllerTest < ActionController::TestCase
end
test 'should download document' do
- UserSession.create(@operator)
+ sign_in(@operator)
get :download, params: { path: drop_private_dir(@document.file.path) }
assert_response :success
@@ -32,7 +32,7 @@ class FilesControllerTest < ActionController::TestCase
end
test 'should not download document' do
- UserSession.create(@operator)
+ sign_in(@operator)
file = @document.file.path
@@ -45,7 +45,7 @@ class FilesControllerTest < ActionController::TestCase
end
test 'should download barcode' do
- UserSession.create(@operator)
+ sign_in(@operator)
get :download_barcode, params: { code: @document.code }
assert_response :success
@@ -54,7 +54,7 @@ class FilesControllerTest < ActionController::TestCase
end
test 'should download barcode of new document' do
- UserSession.create(@operator)
+ sign_in(@operator)
get :download_barcode, params: { code: '159321' }
assert_response :success
@@ -84,7 +84,7 @@ class FilesControllerTest < ActionController::TestCase
end
test 'should not download avatar' do
- UserSession.create(@operator)
+ sign_in(@operator)
file = @operator.avatar.path
diff --git a/test/controllers/orders_controller_test.rb b/test/controllers/orders_controller_test.rb
index c46c2dd2..0915f759 100644
--- a/test/controllers/orders_controller_test.rb
+++ b/test/controllers/orders_controller_test.rb
@@ -10,7 +10,7 @@ class OrdersControllerTest < ActionController::TestCase
test 'should get user index' do
@request.host = 'localhost'
- UserSession.create(@operator)
+ sign_in(@operator)
get :index, params: { type: 'all' }
assert_response :success
@@ -25,7 +25,7 @@ class OrdersControllerTest < ActionController::TestCase
test 'should get user for print index' do
@request.host = 'localhost'
- UserSession.create(@operator)
+ sign_in(@operator)
get :index, params: { type: 'print' }
assert_response :success
@@ -38,7 +38,7 @@ class OrdersControllerTest < ActionController::TestCase
test 'should get user filtered index' do
@request.host = 'localhost'
- UserSession.create(@operator)
+ sign_in(@operator)
get :index, params: { type: 'all', q: 'darth' }
assert_response :success
@@ -114,7 +114,7 @@ class OrdersControllerTest < ActionController::TestCase
test 'should show user order' do
@request.host = 'localhost'
- UserSession.create(@operator)
+ sign_in(@operator)
get :show, params: { type: 'all', id: @order.to_param }
assert_response :success
@@ -168,7 +168,7 @@ class OrdersControllerTest < ActionController::TestCase
test 'should cancel order as user' do
@request.host = 'localhost'
- UserSession.create(@operator)
+ sign_in(@operator)
assert_no_difference 'Order.count' do
delete :destroy, params: { id: @order.to_param, type: 'all' }
diff --git a/test/controllers/payments_controller_test.rb b/test/controllers/payments_controller_test.rb
index ef711526..79bc3ede 100644
--- a/test/controllers/payments_controller_test.rb
+++ b/test/controllers/payments_controller_test.rb
@@ -2,7 +2,7 @@
class PaymentsControllerTest < ActionController::TestCase
def setup
- UserSession.create(users(:operator))
+ sign_in(users(:operator))
end
test 'should get index' do
diff --git a/test/controllers/print_job_types_controller_test.rb b/test/controllers/print_job_types_controller_test.rb
index 273cf744..ba3cca41 100644
--- a/test/controllers/print_job_types_controller_test.rb
+++ b/test/controllers/print_job_types_controller_test.rb
@@ -4,7 +4,7 @@ class PrintJobTypesControllerTest < ActionController::TestCase
setup do
@print_job_type = PrintJobType.find print_job_types(:a4).id
- UserSession.create(users(:operator))
+ sign_in(users(:operator))
end
test 'should get index' do
diff --git a/test/controllers/prints_controller_test.rb b/test/controllers/prints_controller_test.rb
index a4fab44e..9fb84d48 100644
--- a/test/controllers/prints_controller_test.rb
+++ b/test/controllers/prints_controller_test.rb
@@ -6,7 +6,7 @@ class PrintsControllerTest < ActionController::TestCase
@printer = ::CustomCups.pdf_printer
@operator = users(:operator)
- UserSession.create(@operator)
+ sign_in(@operator)
fail "Can't find a PDF printer to run tests with." unless @printer
diff --git a/test/controllers/shift_closures_controller_test.rb b/test/controllers/shift_closures_controller_test.rb
index d309f14f..c99615ad 100644
--- a/test/controllers/shift_closures_controller_test.rb
+++ b/test/controllers/shift_closures_controller_test.rb
@@ -5,7 +5,7 @@ class ShiftClosuresControllerTest < ActionController::TestCase
@shift_closure = shift_closures(:first)
@operator = users(:operator)
- UserSession.create(@operator)
+ sign_in(@operator)
end
test "should get index" do
diff --git a/test/controllers/shifts_controller_test.rb b/test/controllers/shifts_controller_test.rb
index 3a7841c5..319fc3ff 100644
--- a/test/controllers/shifts_controller_test.rb
+++ b/test/controllers/shifts_controller_test.rb
@@ -4,7 +4,7 @@ class ShiftsControllerTest < ActionController::TestCase
setup do
@shift = shifts(:current_shift)
- UserSession.create(users(:operator))
+ sign_in(users(:operator))
end
test 'should get index' do
diff --git a/test/controllers/stats_controller_test.rb b/test/controllers/stats_controller_test.rb
index 0bb95d68..d1ea8b7f 100644
--- a/test/controllers/stats_controller_test.rb
+++ b/test/controllers/stats_controller_test.rb
@@ -3,7 +3,7 @@
class StatsControllerTest < ActionController::TestCase
def setup
@controller = StatsController.new
- UserSession.create(users(:operator))
+ sign_in(users(:operator))
end
test 'should get printers stats' do
diff --git a/test/controllers/tags_controller_test.rb b/test/controllers/tags_controller_test.rb
index 5e5d2157..28d6f3a1 100644
--- a/test/controllers/tags_controller_test.rb
+++ b/test/controllers/tags_controller_test.rb
@@ -3,7 +3,7 @@
class TagsControllerTest < ActionController::TestCase
setup do
@tag = tags(:books)
- UserSession.create(users(:operator))
+ sign_in(users(:operator))
end
test 'should get index' do
diff --git a/test/controllers/user_sessions_controller_test.rb b/test/controllers/user_sessions_controller_test.rb
index 058e1c42..4ba98424 100644
--- a/test/controllers/user_sessions_controller_test.rb
+++ b/test/controllers/user_sessions_controller_test.rb
@@ -114,7 +114,7 @@ class UserSessionsControllerTest < ActionController::TestCase
@operator.close_pending_shifts!
assert_difference '@operator.shifts.count' do
- UserSession.create(@operator)
+ sign_in(@operator)
end
assert_not_nil UserSession.find
@@ -132,7 +132,7 @@ class UserSessionsControllerTest < ActionController::TestCase
@operator.close_pending_shifts!
assert_difference '@operator.shifts.count' do
- UserSession.create(@operator)
+ sign_in(@operator)
end
assert_not_nil UserSession.find
@@ -151,7 +151,7 @@ class UserSessionsControllerTest < ActionController::TestCase
test 'should exit whitout close the shift' do
@operator.close_pending_shifts!
- UserSession.create(@operator)
+ sign_in(@operator)
assert_equal 1, @operator.shifts.pending.size
diff --git a/test/controllers/users_controller_test.rb b/test/controllers/users_controller_test.rb
index 27cc4523..cfd0de5b 100644
--- a/test/controllers/users_controller_test.rb
+++ b/test/controllers/users_controller_test.rb
@@ -4,7 +4,7 @@ class UsersControllerTest < ActionController::TestCase
setup do
@operator = users(:operator)
- UserSession.create(@operator)
+ sign_in(@operator)
prepare_avatar_files
end
diff --git a/test/fixtures/customers.yml b/test/fixtures/customers.yml
index 91d8409d..ce532a42 100644
--- a/test/fixtures/customers.yml
+++ b/test/fixtures/customers.yml
@@ -4,10 +4,8 @@ student:
identification: 123
email: student@printhub.com
enable: true
- password_salt: <%= salt = Authlogic::Random.hex_token %>
- crypted_password: <%= Authlogic::CryptoProviders::Sha512.encrypt('student123' + salt) %>
- persistence_token: 6cde0674657a8a313ce952df979de2830309aa4c11ca65805dd00bfdc65dbcc2f5e36718660a1d2e68c1a08c276d996763985d2f06fd3d076eb7bc4d97b1e317
- perishable_token: <%= Authlogic::Random.friendly_token %>
+ password_salt: <%= salt = hex_token %>
+ encrypted_password: <%= encrypt('student123', salt) %>
free_monthly_bonus: 100.00
bonus_without_expiration: false
kind: <%= Customer::KINDS[:reliable] %>
@@ -18,10 +16,8 @@ teacher:
identification: 321
email: teacher@printhub.com
enable: true
- password_salt: <%= salt = Authlogic::Random.hex_token %>
- crypted_password: <%= Authlogic::CryptoProviders::Sha512.encrypt('teacher123' + salt) %>
- persistence_token: 6cde0674657a8a313ce952df979de2830309aa4c11ca65805dd00bfdc65dbcc2f5e36718660a1d2e68c1a08c276d996763985d2f06fd3d076eb7bc4d97b1e317
- perishable_token: <%= Authlogic::Random.friendly_token %>
+ password_salt: <%= salt = hex_token %>
+ encrypted_password: <%= encrypt('teacher123', salt) %>
free_monthly_bonus: 10.00
bonus_without_expiration: false
kind: <%= Customer::KINDS[:normal] %>
@@ -32,10 +28,8 @@ student_without_bonus:
identification: 666
email: student_without_bonus@printhub.com
enable: true
- password_salt: <%= salt = Authlogic::Random.hex_token %>
- crypted_password: <%= Authlogic::CryptoProviders::Sha512.encrypt('student_without_bonus123' + salt) %>
- persistence_token: 6cde0674657a8a313ce952df979de2830309aa4c11ca65805dd00bfdc65dbcc2f5e36718660a1d2e68c1a08c276d996763985d2f06fd3d076eb7bc4d97b1e317
- perishable_token: <%= Authlogic::Random.friendly_token %>
+ password_salt: <%= salt = hex_token %>
+ encrypted_password: <%= encrypt('student_without_bonus123', salt) %>
free_monthly_bonus: 0.00
bonus_without_expiration: false
kind: <%= Customer::KINDS[:normal] %>
diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml
index 7f40484a..31fc679e 100644
--- a/test/fixtures/users.yml
+++ b/test/fixtures/users.yml
@@ -6,9 +6,8 @@ operator:
default_printer: <%= Cups.show_destinations.select {|p| p =~ /pdf/i}.first %>
lines_per_page: 10
username: operator
- password_salt: <%= salt = Authlogic::Random.hex_token %>
- crypted_password: <%= Authlogic::CryptoProviders::Sha512.encrypt('operator123' + salt) %>
- persistence_token: 6cde0674657a8a313ce952df979de2830309aa4c11ca65805dd00bfdc65dbcc2f5e36718660a1d2e68c1a08c276d996763985d2f06fd3d076eb7bc4d97b1e317
+ password_salt: <%= salt = hex_token %>
+ encrypted_password: <%= encrypt('operator123', salt) %>
admin: true
enable: true
not_shifted: false
diff --git a/test/models/print_test.rb b/test/models/print_test.rb
index 457f6ba2..a791dd6a 100644
--- a/test/models/print_test.rb
+++ b/test/models/print_test.rb
@@ -2,6 +2,7 @@
# Clase para probar el modelo "Print"
class PrintTest < ActiveSupport::TestCase
+
# Función para inicializar las variables utilizadas en las pruebas
def setup
@print = prints(:math_print)
@@ -244,7 +245,7 @@ def teardown
end
test 'create with free credit and paying more in cash' do
- UserSession.create(users(:operator))
+ Current.user = users(:operator)
@customer = customers(:student)
Bonus.all.delete_all
Deposit.all.delete_all
@@ -314,7 +315,7 @@ def teardown
end
test 'create with free credit' do
- UserSession.create(users(:operator))
+ Current.user = users(:operator)
counts = ['Print.count', 'Payment.count',
'::CustomCups.last_job_id(@printer)', 'ArticleLine.count']
@@ -718,7 +719,7 @@ def teardown
end
test 'revoke' do
- UserSession.create(@operator)
+ Current.user = @operator
@article = articles(:binding)
assert_difference '@article.reload.stock', 2 do
@@ -733,7 +734,7 @@ def teardown
test 'can not revoke if is not admin' do
@operator.update(admin: false)
- UserSession.create(users(:operator))
+ Current.user = users(:operator)
assert_no_difference('Bonus.count') { assert_nil @print.revoke! }
@@ -741,7 +742,8 @@ def teardown
end
test 'revoke a print paid with credit returns the value to the customer' do
- UserSession.create(@operator)
+ Current.user = @operator
+
print = prints(:math_print_with_credit)
initial_bonus = print.customer.bonuses.to_a.sum(&:remaining)
payments_amount = print.payments.select(&:credit?).to_a.sum(&:paid)
diff --git a/test/models/user_test.rb b/test/models/user_test.rb
index ec4402ce..d2948216 100644
--- a/test/models/user_test.rb
+++ b/test/models/user_test.rb
@@ -2,6 +2,7 @@
# Clase para probar el modelo "User"
class UserTest < ActiveSupport::TestCase
+
# Función para inicializar las variables utilizadas en las pruebas
def setup
@operator = users(:operator)
@@ -17,7 +18,7 @@ def setup
assert_equal users(:operator).default_printer, @operator.default_printer
assert_equal users(:operator).lines_per_page, @operator.lines_per_page
assert_equal users(:operator).username, @operator.username
- assert_equal users(:operator).crypted_password, @operator.crypted_password
+ assert_equal users(:operator).encrypted_password, @operator.encrypted_password
assert_equal users(:operator).admin, @operator.admin
assert_equal users(:operator).enable, @operator.enable
end
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 5173eb45..7d550996 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -1,7 +1,7 @@
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
-require 'authlogic/test_case'
+# require 'authlogic/test_case'
require 'sidekiq/testing'
require 'database_cleaner'
# require 'minitest/reporters'
@@ -12,12 +12,32 @@
# Minitest::Reporters.use! Minitest::Reporters::ProgressReporter.new
+module FixturesExAuthlogicHelpers
+ def hex_token
+ SecureRandom.hex(64)
+ end
+
+ def friendly_token
+ SecureRandom.urlsafe_base64(15)
+ end
+
+ def encrypt(text, salt)
+ Devise::Encryptable::Encryptors::AuthlogicSha512.digest(
+ text, Devise.stretches, salt, nil
+ )
+ end
+end
+
+ActiveRecord::FixtureSet.context_class.send :include, FixturesExAuthlogicHelpers
+
class ActiveSupport::TestCase
ActiveRecord::Migration.maintain_test_schema!
set_fixture_class versions: PaperTrail::Version
# self.use_transactional_fixtures = true
# Minitest::Reporters.use! Minitest::Reporters::ProgressReporter.new
+ # Fixtures Ex-Authlogic generators
+
fixtures :all
# Add more helper methods to be used by all tests here...
@@ -95,13 +115,7 @@ def drop_all_prints
end
class ActionController::TestCase
- include Authlogic::TestCase
- setup :activate_authlogic
-end
-
-class ActiveSupport::TestCase
- include Authlogic::TestCase
- setup :activate_authlogic
+ include Devise::Test::ControllerHelpers
end
class JSException < Exception
@@ -150,6 +164,7 @@ def self._running_local
)
end
+ # (Capybara.page.driver.remove_cookie('user_credentials') rescue nil)
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(app, {
# debug: true,
@@ -238,7 +253,7 @@ def login(*args)
# options[:expected_path] ||= prints_path
# user = options[:user_id].present? ? User.find(options[:user_id]) : users(:operator)
- # # UserSession.create(user)
+ # # sign_in(user)
# page.driver.set_cookie(
# 'user_credentials',
# "#{user.persistence_token}::#{user.id}"