mirror of
https://github.com/ENSL/ensl.org.git
synced 2025-06-02 01:31:01 +00:00
Purged git history and removed sensitive information.
This commit is contained in:
commit
6bcc8dc76b
862 changed files with 25312 additions and 0 deletions
19
spec/factories/user.rb
Normal file
19
spec/factories/user.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
FactoryGirl.define do
|
||||
sequence :username do |n|
|
||||
"Player#{n}"
|
||||
end
|
||||
|
||||
sequence :email do |n|
|
||||
"player#{n}@ensl.org"
|
||||
end
|
||||
|
||||
factory :user do
|
||||
username
|
||||
email
|
||||
firstname "ENSL"
|
||||
lastname "Player"
|
||||
steamid "0:1:23456789"
|
||||
country "EU"
|
||||
raw_password "PasswordABC123"
|
||||
end
|
||||
end
|
45
spec/features/users/user_signs_up_spec.rb
Normal file
45
spec/features/users/user_signs_up_spec.rb
Normal file
|
@ -0,0 +1,45 @@
|
|||
require 'spec_helper'
|
||||
|
||||
feature 'Visitor signs up' do
|
||||
let(:user) { attributes_for(:user) }
|
||||
|
||||
before do
|
||||
visit new_user_path
|
||||
end
|
||||
|
||||
scenario 'with valid Username, Email, Password and Steam ID' do
|
||||
fill_form(:user, user.slice(*sign_up_attributes))
|
||||
click_button submit(:user, :create)
|
||||
|
||||
expect(page).to have_content("Logged in as: #{user[:username]}")
|
||||
end
|
||||
|
||||
scenario 'with invalid Email' do
|
||||
fill_form(:user, user.slice(*sign_up_attributes).merge({ email: "invalid" }))
|
||||
click_button submit(:user, :create)
|
||||
|
||||
expect(page).to have_content(error_message('email.invalid'))
|
||||
end
|
||||
|
||||
scenario 'with blank Password' do
|
||||
fill_form(:user, user.slice(*sign_up_attributes).merge({ raw_password: "" }))
|
||||
click_button submit(:user, :create)
|
||||
|
||||
expect(page).to have_content(error_message('raw_password.blank'))
|
||||
end
|
||||
|
||||
scenario 'with invalid Steam ID' do
|
||||
fill_form(:user, user.slice(*sign_up_attributes).merge({ steamid: "invalid" }))
|
||||
click_button submit(:user, :create)
|
||||
|
||||
expect(page).to have_content(error_message('steamid.invalid'))
|
||||
end
|
||||
|
||||
def sign_up_attributes
|
||||
[:username, :email, :raw_password, :steamid]
|
||||
end
|
||||
|
||||
def error_message(translation)
|
||||
I18n.t("activerecord.errors.models.user.attributes.#{translation}")
|
||||
end
|
||||
end
|
21
spec/spec_helper.rb
Normal file
21
spec/spec_helper.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
ENV["RAILS_ENV"] ||= 'test'
|
||||
|
||||
require 'simplecov'
|
||||
SimpleCov.start 'rails'
|
||||
|
||||
require File.expand_path("../../config/environment", __FILE__)
|
||||
require 'rspec/rails'
|
||||
require 'capybara/rspec'
|
||||
require 'capybara/poltergeist'
|
||||
|
||||
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
|
||||
|
||||
Capybara.javascript_driver = :poltergeist
|
||||
|
||||
RSpec.configure do |config|
|
||||
config.include FactoryGirl::Syntax::Methods
|
||||
|
||||
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
||||
config.use_transactional_fixtures = true
|
||||
config.order = "random"
|
||||
end
|
4
spec/support/features.rb
Normal file
4
spec/support/features.rb
Normal file
|
@ -0,0 +1,4 @@
|
|||
RSpec.configure do |config|
|
||||
config.include Features::FormHelpers, type: :feature
|
||||
config.include Features::SessionHelpers, type: :feature
|
||||
end
|
23
spec/support/features/form_helpers.rb
Normal file
23
spec/support/features/form_helpers.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
module Features
|
||||
module FormHelpers
|
||||
def fill_form(model, hash)
|
||||
hash.each do |attribute, value|
|
||||
fill_in attribute_translation(model, attribute), :with => value
|
||||
end
|
||||
end
|
||||
|
||||
def submit(model, action)
|
||||
helper_translation(model, action)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def attribute_translation(model, attribute)
|
||||
I18n.t("activerecord.attributes.#{model}.#{attribute}")
|
||||
end
|
||||
|
||||
def helper_translation(model, action)
|
||||
I18n.t("helpers.submit.#{model}.#{action}")
|
||||
end
|
||||
end
|
||||
end
|
10
spec/support/features/session_helpers.rb
Normal file
10
spec/support/features/session_helpers.rb
Normal file
|
@ -0,0 +1,10 @@
|
|||
module Features
|
||||
module SessionHelpers
|
||||
def sign_in
|
||||
visit root_path
|
||||
user = create(:user)
|
||||
fill_form(:user, { email: user.email, password: user.raw_password })
|
||||
click_button '»'
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue