2015-09-24 09:19:00 +00:00
|
|
|
require "spec_helper"
|
2014-03-23 00:22:25 +00:00
|
|
|
|
2015-09-24 09:19:00 +00:00
|
|
|
feature "Visitor signs up", js: :true do
|
2014-03-23 00:22:25 +00:00
|
|
|
let(:user) { attributes_for(:user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
visit new_user_path
|
|
|
|
end
|
|
|
|
|
2015-09-24 09:19:00 +00:00
|
|
|
scenario "with valid Username, Email, Password and Steam ID" do
|
2014-04-17 07:55:19 +00:00
|
|
|
within registration_form do
|
|
|
|
fill_form(:user, user.slice(*sign_up_attributes))
|
|
|
|
click_button submit(:user, :create)
|
|
|
|
end
|
2015-11-08 09:41:11 +00:00
|
|
|
|
2015-09-24 09:19:00 +00:00
|
|
|
expect(user_status).to have_content("ACCOUNT")
|
2014-03-23 00:22:25 +00:00
|
|
|
end
|
|
|
|
|
2015-09-24 09:19:00 +00:00
|
|
|
scenario "with invalid Email" do
|
2014-04-17 07:55:19 +00:00
|
|
|
within registration_form do
|
2015-09-24 09:19:00 +00:00
|
|
|
fill_form(:user, user.slice(*sign_up_attributes).merge(email: "invalid"))
|
2014-04-17 07:55:19 +00:00
|
|
|
click_button submit(:user, :create)
|
|
|
|
end
|
2014-03-23 00:22:25 +00:00
|
|
|
|
2015-09-24 09:19:00 +00:00
|
|
|
expect(page).to have_content(error_message("email.invalid"))
|
2014-03-23 00:22:25 +00:00
|
|
|
end
|
|
|
|
|
2015-09-24 09:19:00 +00:00
|
|
|
scenario "with blank Password" do
|
2014-04-17 07:55:19 +00:00
|
|
|
within registration_form do
|
2015-09-24 09:19:00 +00:00
|
|
|
fill_form(:user, user.slice(*sign_up_attributes).merge(raw_password: ""))
|
2014-04-17 07:55:19 +00:00
|
|
|
click_button submit(:user, :create)
|
|
|
|
end
|
2014-03-23 00:22:25 +00:00
|
|
|
|
2015-09-24 09:19:00 +00:00
|
|
|
expect(page).to have_content(error_message("raw_password.blank"))
|
2014-03-23 00:22:25 +00:00
|
|
|
end
|
|
|
|
|
2015-09-24 09:19:00 +00:00
|
|
|
scenario "with invalid Steam ID" do
|
2014-04-17 07:55:19 +00:00
|
|
|
within registration_form do
|
2015-09-24 09:19:00 +00:00
|
|
|
fill_form(:user, user.slice(*sign_up_attributes).merge(steamid: "invalid"))
|
2014-04-17 07:55:19 +00:00
|
|
|
click_button submit(:user, :create)
|
|
|
|
end
|
2014-03-23 00:22:25 +00:00
|
|
|
|
2015-09-24 09:19:00 +00:00
|
|
|
expect(page).to have_content(error_message("steamid.invalid"))
|
2014-03-23 00:22:25 +00:00
|
|
|
end
|
|
|
|
|
2015-09-24 09:19:00 +00:00
|
|
|
scenario "with out of range Steam ID" do
|
2015-09-24 05:58:21 +00:00
|
|
|
within registration_form do
|
2015-09-24 09:19:00 +00:00
|
|
|
fill_form(:user, user.slice(*sign_up_attributes).merge(steamid: "0:0:2147483648"))
|
2015-09-24 05:58:21 +00:00
|
|
|
click_button submit(:user, :create)
|
|
|
|
end
|
|
|
|
|
2015-09-24 09:19:00 +00:00
|
|
|
expect(page).to have_content(error_message("steamid.invalid"))
|
2015-09-24 05:58:21 +00:00
|
|
|
end
|
|
|
|
|
2015-09-24 09:19:00 +00:00
|
|
|
scenario "with nil Steam ID" do
|
2015-09-24 06:15:49 +00:00
|
|
|
within registration_form do
|
2015-09-24 09:19:00 +00:00
|
|
|
fill_form(:user, user.slice(*sign_up_attributes).merge(steamid: nil))
|
2015-09-24 06:15:49 +00:00
|
|
|
click_button submit(:user, :create)
|
|
|
|
end
|
|
|
|
|
2015-09-24 09:19:00 +00:00
|
|
|
expect(page).to have_content(error_message("steamid.invalid"))
|
2015-09-24 06:15:49 +00:00
|
|
|
end
|
|
|
|
|
2014-03-23 00:22:25 +00:00
|
|
|
def sign_up_attributes
|
|
|
|
[:username, :email, :raw_password, :steamid]
|
|
|
|
end
|
|
|
|
|
|
|
|
def error_message(translation)
|
|
|
|
I18n.t("activerecord.errors.models.user.attributes.#{translation}")
|
|
|
|
end
|
|
|
|
end
|