Files
nairobi/spec/features/registration_form_spec.rb
Javi Martín db97f9d08c Add and apply rubocop rules for empty lines
We were very inconsistent regarding these rules.

Personally I prefer no empty lines around blocks, clases, etc... as
recommended by the Ruby style guide [1], and they're the default values
in rubocop, so those are the settings I'm applying.

The exception is the `private` access modifier, since we were leaving
empty lines around it most of the time. That's the default rubocop rule
as well. Personally I don't have a strong preference about this one.


[1] https://rubystyle.guide/#empty-lines-around-bodies
2019-10-24 17:11:47 +02:00

80 lines
2.8 KiB
Ruby

require "rails_helper"
describe "Registration form" do
scenario "username is not available", :js do
user = create(:user)
visit new_user_registration_path
expect(page).not_to have_content I18n.t("devise_views.users.registrations.new.username_is_not_available")
fill_in "user_username", with: user.username
check "user_terms_of_service"
expect(page).to have_content I18n.t("devise_views.users.registrations.new.username_is_not_available")
end
scenario "username is available", :js do
visit new_user_registration_path
expect(page).not_to have_content I18n.t("devise_views.users.registrations.new.username_is_available")
fill_in "user_username", with: "available username"
check "user_terms_of_service"
expect(page).to have_content I18n.t("devise_views.users.registrations.new.username_is_available")
end
scenario "do not save blank redeemable codes" do
visit new_user_registration_path(use_redeemable_code: "true")
fill_in "user_username", with: "NewUserWithCode77"
fill_in "user_email", with: "new@consul.dev"
fill_in "user_password", with: "password"
fill_in "user_password_confirmation", with: "password"
fill_in "user_redeemable_code", with: " "
check "user_terms_of_service"
click_button "Register"
expect(page).to have_content "Thank you for registering"
new_user = User.last
expect(new_user.username).to eq("NewUserWithCode77")
expect(new_user.redeemable_code).to be_nil
end
scenario "Create with invisible_captcha honeypot field" do
visit new_user_registration_path
fill_in "user_username", with: "robot"
fill_in "user_address", with: "This is the honeypot field"
fill_in "user_email", with: "robot@robot.com"
fill_in "user_password", with: "destroyallhumans"
fill_in "user_password_confirmation", with: "destroyallhumans"
check "user_terms_of_service"
click_button "Register"
expect(page.status_code).to eq(200)
expect(page.html).to be_empty
expect(page).to have_current_path(user_registration_path)
end
scenario "Create organization too fast" do
allow(InvisibleCaptcha).to receive(:timestamp_threshold).and_return(Float::INFINITY)
visit new_user_registration_path
fill_in "user_username", with: "robot"
fill_in "user_address", with: "This is the honeypot field"
fill_in "user_email", with: "robot@robot.com"
fill_in "user_password", with: "destroyallhumans"
fill_in "user_password_confirmation", with: "destroyallhumans"
check "user_terms_of_service"
click_button "Register"
expect(page).to have_content "Sorry, that was too quick! Please resubmit"
expect(page).to have_current_path(new_user_registration_path)
end
end