diff options
author | Luke "Jared" Bennett <lbennett@gitlab.com> | 2016-07-20 02:05:57 +0100 |
---|---|---|
committer | Luke Bennett <lukeeeebennettplus@gmail.com> | 2016-08-20 17:07:50 +0100 |
commit | d871c8b9a020020b210050f534e95a6a666d4d79 (patch) | |
tree | 517206fd8e7facc419079baada1314c37fea5c67 | |
parent | a827acb281e67669f131ce95a45ceca56e0699ea (diff) | |
download | gitlab-ce-d871c8b9a020020b210050f534e95a6a666d4d79.tar.gz |
added feature test
-rw-r--r-- | spec/features/users_spec.rb | 27 | ||||
-rw-r--r-- | spec/javascripts/fixtures/username_validator.html.haml | 0 |
2 files changed, 26 insertions, 1 deletions
diff --git a/spec/features/users_spec.rb b/spec/features/users_spec.rb index b5a94fe0383..7630d299349 100644 --- a/spec/features/users_spec.rb +++ b/spec/features/users_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Users', feature: true do +feature 'Users', feature: true, js: true do let(:user) { create(:user, username: 'user1', name: 'User 1', email: 'user1@gitlab.com') } scenario 'GET /users/sign_in creates a new user account' do @@ -40,6 +40,31 @@ feature 'Users', feature: true do expect(number_of_errors_on_page(page)).to be(1), 'errors on page:\n #{errors_on_page page}' end + feature 'username validation' do + include WaitForAjax + let(:loading_icon) { '.fa.fa-spinner' } + let(:username_input) { 'new_user_username' } + + before(:each) do + visit new_user_session_path + @username_field = find '.username' + end + + scenario 'shows an error icon if the username already exists' do + fill_in username_input, with: user.username + expect(@username_field).to have_css loading_icon + wait_for_ajax + expect(@username_field).to have_css '.fa.error' + end + + scenario 'shows a success icon if the username is available' do + fill_in username_input, with: 'new-user' + expect(@username_field).to have_css loading_icon + wait_for_ajax + expect(@username_field).to have_css '.fa.success' + end + end + def errors_on_page(page) page.find('#error_explanation').find('ul').all('li').map{ |item| item.text }.join("\n") end diff --git a/spec/javascripts/fixtures/username_validator.html.haml b/spec/javascripts/fixtures/username_validator.html.haml new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/spec/javascripts/fixtures/username_validator.html.haml |