mirror of
https://github.com/ENSL/ensl.org.git
synced 2024-12-26 04:21:36 +00:00
Fixed tests, all tests pass
This commit is contained in:
parent
e73278088b
commit
d44c04534b
10 changed files with 42 additions and 31 deletions
|
@ -136,8 +136,8 @@ header .banner {
|
|||
}
|
||||
|
||||
.register {
|
||||
@include span-columns(5 of 12);
|
||||
@include shift(-1);
|
||||
@include span-columns(4 of 12);
|
||||
@include shift(0.1);
|
||||
|
||||
.password-reset {
|
||||
float: right;
|
||||
|
|
|
@ -134,7 +134,7 @@ class User < ActiveRecord::Base
|
|||
|
||||
before_validation :update_password
|
||||
|
||||
validates_uniqueness_of :username, :email, :steamid
|
||||
validates_uniqueness_of :username, :email, :steamid, :case_sensitive => false
|
||||
validates_length_of :firstname, :in => 1..15, :allow_blank => true
|
||||
validates_length_of :lastname, :in => 1..25, :allow_blank => true
|
||||
validates_length_of :username, :in => 1..30
|
||||
|
@ -454,7 +454,7 @@ class User < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def self.authenticate(login)
|
||||
user = where('username = ?', login[:username]).first
|
||||
user = where('lower(username) = ?', login[:username].downcase).first
|
||||
return nil unless user
|
||||
|
||||
begin
|
||||
|
|
|
@ -34,4 +34,6 @@ Rails.application.configure do
|
|||
config.active_support.deprecation = :stderr
|
||||
|
||||
config.eager_load = true
|
||||
|
||||
config.assets.compile = true
|
||||
end
|
||||
|
|
|
@ -10,10 +10,6 @@ FactoryBot.define do
|
|||
raw_password "PasswordABC123"
|
||||
# lastvisit "Sun, 15 Mar 2020 13:31:06 +0000"
|
||||
|
||||
after(:create) do |user|
|
||||
create(:profile, user: user)
|
||||
end
|
||||
|
||||
trait :admin do
|
||||
after(:create) do |user|
|
||||
group = create(:group, :admin)
|
||||
|
|
|
@ -12,7 +12,7 @@ feature "Case insensitive login", js: :true do
|
|||
feature "when a user with mixed-case username signs in" do
|
||||
scenario "with a matching case allows the user to sign in" do
|
||||
fill_login_form(username)
|
||||
find('.login input').trigger('click')
|
||||
find('#authentication input[name="commit"]').trigger('click')
|
||||
|
||||
expect(page).to have_content(I18n.t("login_successful"))
|
||||
|
||||
|
@ -23,7 +23,7 @@ feature "Case insensitive login", js: :true do
|
|||
|
||||
scenario "with a non-matching case allows the user to sign in" do
|
||||
fill_login_form("CASE_INSENSITIVE")
|
||||
find('.login input').trigger('click')
|
||||
find('#authentication input[name="commit"]').trigger('click')
|
||||
|
||||
expect(page).to have_content(I18n.t("login_successful"))
|
||||
|
||||
|
|
|
@ -8,13 +8,18 @@ feature "User Stream Information" do
|
|||
scenario "user updates their stream" do
|
||||
visit user_path(user)
|
||||
expect(page.html).to_not include("<dt>Stream</dt>")
|
||||
|
||||
sign_in_as(user)
|
||||
|
||||
visit edit_user_path(user)
|
||||
stream_url = "twitch.tv/gold_n"
|
||||
expect(page).to have_content("Stream")
|
||||
|
||||
fill_in "user_profile_attributes_stream", with: stream_url
|
||||
click_button "Update Profile"
|
||||
|
||||
expect(page).to have_content(I18n.t(:users_update))
|
||||
|
||||
visit user_path(user)
|
||||
expect(page.html).to include("<dt>Stream</dt>")
|
||||
expect(page).to have_content(stream_url)
|
||||
|
|
|
@ -46,6 +46,7 @@ RSpec.configure do |config|
|
|||
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
||||
# examples within a transaction, remove the following line or assign false
|
||||
# instead of true.
|
||||
# DEBUG: set to false
|
||||
config.use_transactional_fixtures = true
|
||||
|
||||
# RSpec Rails can automatically mix in different behaviours to your tests
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
ENV["RAILS_ENV"] ||= "test"
|
||||
|
||||
# DEBUG use this
|
||||
# require 'pry-byebug'
|
||||
|
||||
require 'dotenv'
|
||||
Dotenv.load('.env.' + ENV['RAILS_ENV'] + '.local', '.env.local', '.env.' + ENV['RAILS_ENV'], '.env')
|
||||
|
||||
|
@ -26,22 +29,22 @@ end
|
|||
|
||||
Capybara.javascript_driver = :poltergeist
|
||||
|
||||
SELENIUM_HOST = ENV['SELENIUM_HOST']
|
||||
TEST_APP_HOST = ENV['TEST_APP_HOST']
|
||||
TEST_APP_PORT = ENV['TEST_APP_PORT']
|
||||
# SELENIUM_HOST = ENV['SELENIUM_HOST']
|
||||
# TEST_APP_HOST = ENV['TEST_APP_HOST']
|
||||
# TEST_APP_PORT = ENV['TEST_APP_PORT']
|
||||
|
||||
Capybara.server_port = TEST_APP_PORT
|
||||
Capybara.server_host = '0.0.0.0'
|
||||
Capybara.app_host = "http://#{TEST_APP_HOST}:#{TEST_APP_PORT}"
|
||||
Capybara.register_driver :selenium_remote do |app|
|
||||
Capybara::Selenium::Driver.new(
|
||||
app,
|
||||
browser: :remote,
|
||||
url: "http://#{SELENIUM_HOST}:4444/wd/hub",
|
||||
desired_capabilities: Selenium::WebDriver::Remote::Capabilities.chrome
|
||||
)
|
||||
end
|
||||
Capybara.default_max_wait_time = 8
|
||||
# Capybara.server_port = TEST_APP_PORT
|
||||
# Capybara.server_host = '0.0.0.0'
|
||||
# Capybara.app_host = "http://#{TEST_APP_HOST}:#{TEST_APP_PORT}"
|
||||
# Capybara.register_driver :selenium_remote do |app|
|
||||
# Capybara::Selenium::Driver.new(
|
||||
# app,
|
||||
# browser: :remote,
|
||||
# url: "http://#{SELENIUM_HOST}:4444/wd/hub",
|
||||
# desired_capabilities: Selenium::WebDriver::Remote::Capabilities.chrome
|
||||
# )
|
||||
# end
|
||||
# Capybara.default_max_wait_time = 8
|
||||
|
||||
# Capybara.javascript_driver = :selenium
|
||||
# Capybara.javascript_driver = :selenium_remote
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
RSpec.configure do |config|
|
||||
config.before(:suite) do
|
||||
DatabaseCleaner.clean_with(:truncation)
|
||||
DatabaseCleaner.clean_with(
|
||||
:truncation,
|
||||
except: %w(ar_internal_metadata)
|
||||
)
|
||||
end
|
||||
|
||||
config.before(:each) do
|
||||
|
|
|
@ -3,18 +3,19 @@ module Features
|
|||
def sign_in_as(user)
|
||||
visit root_path
|
||||
|
||||
fill_in "login_username", with: user.username
|
||||
find_field("login_username").set(user.username)
|
||||
fill_in "login_password", with: user.raw_password
|
||||
|
||||
# Apparently poltergeist does not suppor this
|
||||
find('#authentication input[name="commit"]').click()
|
||||
# click_button I18n.t("helpers.submit.user.login")
|
||||
find('#authentication .login input').trigger('click')
|
||||
|
||||
expect(page).to have_content(I18n.t('login_successful'))
|
||||
end
|
||||
|
||||
def sign_out
|
||||
visit root_path
|
||||
|
||||
# click_button I18n.t("helpers.submit.user.login")
|
||||
|
||||
find('a#logout').trigger('click')
|
||||
expect(page).to have_content(I18n.t('login_out'))
|
||||
end
|
||||
|
@ -24,7 +25,7 @@ module Features
|
|||
|
||||
click_link I18n.t("profile.locals")
|
||||
find("option[value='#{timezone}']").select_option
|
||||
|
||||
|
||||
click_button I18n.t("helpers.submit.user.update")
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue