rework tests

This commit is contained in:
Josh
2018-06-15 14:41:07 -04:00
parent 8cffc4872c
commit 086a39ca3d
35 changed files with 96 additions and 594 deletions

View File

@ -48,20 +48,22 @@ class UsersController < ApplicationController
errors = {}
# Verify that the provided password is correct.
if user_params[:password] && @user.authenticate(user_params[:password])
# Verify that the new passwords match.
if user_params[:new_password] == user_params[:password_confirmation]
@user.password = user_params[:new_password]
if user_params[:password]
if @user.authenticate(user_params[:password])
# Verify that the new passwords match.
if user_params[:new_password] == user_params[:password_confirmation]
@user.password = user_params[:new_password]
else
# New passwords don't match.
errors[:password_confirmation] = "'s don't match"
end
else
# New passwords don't match.
errors[:password_confirmation] = "'s don't match"
# Original password is incorrect, can't update.
errors[:password] = "is incorrect"
end
else
# Original password is incorrect, can't update.
errors[:password] = "is incorrect"
end
if @user.save
if @user.save!
# Notify the use that their account has been updated.
redirect_to edit_user_path(@user), notice: "Information successfully updated."
else

View File

@ -5,7 +5,6 @@ class Room < ApplicationRecord
validates :name, presence: true
belongs_to :owner, class_name: 'User', foreign_key: :user_id
has_one :meeting
RETURNCODE_SUCCESS = "SUCCESS"

View File

@ -13,7 +13,7 @@ class User < ApplicationRecord
uniqueness: { case_sensitive: false },
format: {with: /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i }
validates :password, length: { minimum: 6 }, presence: true, confirmation: true, if: :greenlight_account?
validates :password, length: { minimum: 6 }, presence: true, confirmation: true, allow_blank: true, if: :greenlight_account?
# We don't want to require password validations on all accounts.
has_secure_password(validations: false)
@ -97,7 +97,7 @@ class User < ApplicationRecord
# Initializes a room for the user and assign a BigBlueButton user id.
def initialize_main_room
self.uid = "gl-#{(0...12).map { (65 + rand(26)).chr }.join.downcase}"
self.uid = "gl-#{(0...12).map { (65 + rand(26)).chr }.join.downcase}"
self.main_room = Room.create!(owner: self, name: firstname + "'s Room")
self.save
end

View File

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>Greenlight20</title>
<title>Greenlight</title>
<%= csrf_meta_tags %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>