diff options
-rw-r--r-- | Gemfile | 4 | ||||
-rw-r--r-- | Gemfile.lock | 64 | ||||
-rw-r--r-- | app/assets/stylesheets/generic/zen.scss | 27 | ||||
-rw-r--r-- | app/controllers/profiles/two_factor_auths_controller.rb | 6 | ||||
-rw-r--r-- | app/models/user.rb | 4 | ||||
-rw-r--r-- | app/views/projects/_zen.html.haml | 2 | ||||
-rw-r--r-- | doc/release/monthly.md | 6 | ||||
-rw-r--r-- | doc/workflow/importing/README.md | 3 | ||||
-rw-r--r-- | lib/gitlab/o_auth/user.rb | 9 | ||||
-rw-r--r-- | spec/features/users_spec.rb | 21 | ||||
-rw-r--r-- | spec/lib/gitlab/o_auth/user_spec.rb | 102 |
11 files changed, 136 insertions, 112 deletions
@@ -1,6 +1,6 @@ source "https://rubygems.org" -gem "rails", "~> 4.1.0" +gem 'rails', '4.1.11' # Default values for AR models gem "default_value_for", "~> 3.0.0" @@ -193,7 +193,7 @@ gem 'font-awesome-rails', '~> 4.2' gem 'gitlab_emoji', '~> 0.1' gem 'gon', '~> 5.0.0' gem 'jquery-atwho-rails', '~> 1.0.0' -gem 'jquery-rails', '3.1.2' +gem 'jquery-rails', '3.1.3' gem 'jquery-scrollto-rails' gem 'jquery-ui-rails' gem 'nprogress-rails' diff --git a/Gemfile.lock b/Gemfile.lock index fd7cbd508e5..0640c14d343 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -4,31 +4,31 @@ GEM CFPropertyList (2.3.1) RedCloth (4.2.9) ace-rails-ap (2.0.1) - actionmailer (4.1.9) - actionpack (= 4.1.9) - actionview (= 4.1.9) + actionmailer (4.1.11) + actionpack (= 4.1.11) + actionview (= 4.1.11) mail (~> 2.5, >= 2.5.4) - actionpack (4.1.9) - actionview (= 4.1.9) - activesupport (= 4.1.9) + actionpack (4.1.11) + actionview (= 4.1.11) + activesupport (= 4.1.11) rack (~> 1.5.2) rack-test (~> 0.6.2) - actionview (4.1.9) - activesupport (= 4.1.9) + actionview (4.1.11) + activesupport (= 4.1.11) builder (~> 3.1) erubis (~> 2.7.0) - activemodel (4.1.9) - activesupport (= 4.1.9) + activemodel (4.1.11) + activesupport (= 4.1.11) builder (~> 3.1) - activerecord (4.1.9) - activemodel (= 4.1.9) - activesupport (= 4.1.9) + activerecord (4.1.11) + activemodel (= 4.1.11) + activesupport (= 4.1.11) arel (~> 5.0.0) activeresource (4.0.0) activemodel (~> 4.0) activesupport (~> 4.0) rails-observers (~> 0.1.1) - activesupport (4.1.9) + activesupport (4.1.11) i18n (~> 0.6, >= 0.6.9) json (~> 1.7, >= 1.7.7) minitest (~> 5.1) @@ -331,7 +331,7 @@ GEM inflecto (0.0.2) ipaddress (0.8.0) jquery-atwho-rails (1.0.1) - jquery-rails (3.1.2) + jquery-rails (3.1.3) railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) jquery-scrollto-rails (1.4.3) @@ -341,7 +341,7 @@ GEM turbolinks jquery-ui-rails (4.2.1) railties (>= 3.2.16) - json (1.8.2) + json (1.8.3) jwt (0.1.13) multi_json (>= 1.5) kaminari (0.15.1) @@ -366,7 +366,7 @@ GEM mini_portile (0.6.2) minitest (5.3.5) mousetrap-rails (1.4.6) - multi_json (1.10.1) + multi_json (1.11.1) multi_xml (0.5.5) multipart-post (1.2.0) mysql2 (0.3.16) @@ -449,7 +449,7 @@ GEM quiet_assets (1.0.2) railties (>= 3.1, < 5.0) racc (1.4.10) - rack (1.5.3) + rack (1.5.4) rack-accept (0.4.5) rack (>= 0.4) rack-attack (4.3.0) @@ -469,21 +469,21 @@ GEM rack rack-test (0.6.3) rack (>= 1.0) - rails (4.1.9) - actionmailer (= 4.1.9) - actionpack (= 4.1.9) - actionview (= 4.1.9) - activemodel (= 4.1.9) - activerecord (= 4.1.9) - activesupport (= 4.1.9) + rails (4.1.11) + actionmailer (= 4.1.11) + actionpack (= 4.1.11) + actionview (= 4.1.11) + activemodel (= 4.1.11) + activerecord (= 4.1.11) + activesupport (= 4.1.11) bundler (>= 1.3.0, < 2.0) - railties (= 4.1.9) + railties (= 4.1.11) sprockets-rails (~> 2.0) rails-observers (0.1.2) activemodel (~> 4.0) - railties (4.1.9) - actionpack (= 4.1.9) - activesupport (= 4.1.9) + railties (4.1.11) + actionpack (= 4.1.11) + activesupport (= 4.1.11) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rainbow (2.0.0) @@ -633,7 +633,7 @@ GEM multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - sprockets-rails (2.2.4) + sprockets-rails (2.3.1) actionpack (>= 3.0) activesupport (>= 3.0) sprockets (>= 2.8, < 4.0) @@ -777,7 +777,7 @@ DEPENDENCIES html-pipeline (~> 1.11.0) httparty jquery-atwho-rails (~> 1.0.0) - jquery-rails (= 3.1.2) + jquery-rails (= 3.1.3) jquery-scrollto-rails jquery-turbolinks jquery-ui-rails @@ -807,7 +807,7 @@ DEPENDENCIES rack-cors rack-mini-profiler rack-oauth2 (~> 1.0.5) - rails (~> 4.1.0) + rails (= 4.1.11) raphael-rails (~> 2.1.2) rdoc (~> 3.6) redcarpet (~> 3.3.0) diff --git a/app/assets/stylesheets/generic/zen.scss b/app/assets/stylesheets/generic/zen.scss index 7ab01187a02..7e86a0fe4b9 100644 --- a/app/assets/stylesheets/generic/zen.scss +++ b/app/assets/stylesheets/generic/zen.scss @@ -63,43 +63,24 @@ } } - // Make the placeholder text in the standard textarea the same color as the - // background, effectively hiding it - - .zen-backdrop textarea::-webkit-input-placeholder { - color: white; - } - - .zen-backdrop textarea:-moz-placeholder { - color: white; - } - - .zen-backdrop textarea::-moz-placeholder { - color: white; - } - - .zen-backdrop textarea:-ms-input-placeholder { - color: white; - } - // Make the color of the placeholder text in the Zenned-out textarea darker, // so it becomes visible input:checked ~ .zen-backdrop textarea::-webkit-input-placeholder { - color: #999; + color: #A8A8A8; } input:checked ~ .zen-backdrop textarea:-moz-placeholder { - color: #999; + color: #A8A8A8; opacity: 1; } input:checked ~ .zen-backdrop textarea::-moz-placeholder { - color: #999; + color: #A8A8A8; opacity: 1; } input:checked ~ .zen-backdrop textarea:-ms-input-placeholder { - color: #999; + color: #A8A8A8; } } diff --git a/app/controllers/profiles/two_factor_auths_controller.rb b/app/controllers/profiles/two_factor_auths_controller.rb index 42579b3eb44..e7579c652fb 100644 --- a/app/controllers/profiles/two_factor_auths_controller.rb +++ b/app/controllers/profiles/two_factor_auths_controller.rb @@ -43,8 +43,12 @@ class Profiles::TwoFactorAuthsController < Profiles::ApplicationController private def build_qr_code - issuer = "GitLab | #{current_user.email}" + issuer = "#{issuer_host} | #{current_user.email}" uri = current_user.otp_provisioning_uri(current_user.email, issuer: issuer) RQRCode::render_qrcode(uri, :svg, level: :m, unit: 3) end + + def issuer_host + Gitlab.config.gitlab.host + end end diff --git a/app/models/user.rb b/app/models/user.rb index 6ac287203b1..982c05212ce 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -137,7 +137,9 @@ class User < ActiveRecord::Base # Validations # validates :name, presence: true - validates :email, presence: true, email: { strict_mode: true }, uniqueness: true + # Note that a 'uniqueness' and presence check is provided by devise :validatable for email. We do not need to + # duplicate that here as the validation framework will have duplicate errors in the event of a failure. + validates :email, presence: true, email: { strict_mode: true } validates :notification_email, presence: true, email: { strict_mode: true } validates :public_email, presence: true, email: { strict_mode: true }, allow_blank: true, uniqueness: true validates :bio, length: { maximum: 255 }, allow_blank: true diff --git a/app/views/projects/_zen.html.haml b/app/views/projects/_zen.html.haml index cf1c55ecca6..e27394ab30b 100644 --- a/app/views/projects/_zen.html.haml +++ b/app/views/projects/_zen.html.haml @@ -2,7 +2,7 @@ %input#zen-toggle-comment.zen-toggle-comment{ tabindex: '-1', type: 'checkbox' } .zen-backdrop - classes << ' js-gfm-input markdown-area' - = f.text_area attr, class: classes, placeholder: 'Leave a comment' + = f.text_area attr, class: classes, placeholder: 'You can tag other participants like this: @michael do you think this is a good idea? Also @deborah, what do you think?' = link_to nil, class: 'zen-enter-link', tabindex: '-1' do %i.fa.fa-expand Edit in fullscreen diff --git a/doc/release/monthly.md b/doc/release/monthly.md index d50258f2796..7cb0e3d84cf 100644 --- a/doc/release/monthly.md +++ b/doc/release/monthly.md @@ -51,7 +51,9 @@ Xth: (4 working days before the 22nd) - [ ] Update GitLab.com with rc1 (#LINK) (https://dev.gitlab.org/cookbooks/chef-repo/blob/master/doc/administration.md#deploy-the-package) - [ ] Update ci.gitLab.com with rc1 (#LINK) (https://dev.gitlab.org/cookbooks/chef-repo/blob/master/doc/administration.md#deploy-the-package) - [ ] Create regression issues (CE, CI) (#LINK) -- [ ] Tweet about rc1 (#LINK) +- [ ] Tweet about rc1 (#LINK), proposed text: + +> GitLab x.x.0.rc1 is available https://packages.gitlab.com/gitlab/unstable Use at your own risk. Please link regressions issues from LINK_TO_REGRESSION_ISSUE Xth: (3 working days before the 22nd) @@ -212,4 +214,4 @@ Consider creating a post on Hacker News. ## Create a WIP blogpost for the next release -Create a WIP blogpost using [release blog template](https://gitlab.com/gitlab-com/www-gitlab-com/blob/master/doc/release_blog_template.md).
\ No newline at end of file +Create a WIP blogpost using [release blog template](https://gitlab.com/gitlab-com/www-gitlab-com/blob/master/doc/release_blog_template.md). diff --git a/doc/workflow/importing/README.md b/doc/workflow/importing/README.md index 2b2e9037425..19395657719 100644 --- a/doc/workflow/importing/README.md +++ b/doc/workflow/importing/README.md @@ -4,3 +4,6 @@ 2. [GitHub](import_projects_from_github.md)
3. [GitLab.com](import_projects_from_gitlab_com.md)
4. [SVN](migrating_from_svn.md)
+
+### Note
+* If you'd like to migrate from a self-hosted GitLab instance to GitLab.com, you can copy your repos by changing the remote and pushing to the new server; but issues and merge requests can't be imported.
\ No newline at end of file diff --git a/lib/gitlab/o_auth/user.rb b/lib/gitlab/o_auth/user.rb index c4971b5bcc6..17ce4d4b174 100644 --- a/lib/gitlab/o_auth/user.rb +++ b/lib/gitlab/o_auth/user.rb @@ -87,12 +87,13 @@ module Gitlab def ldap_person return @ldap_person if defined?(@ldap_person) - # looks for a corresponding person with same uid in any of the configured LDAP providers - @ldap_person = Gitlab::LDAP::Config.providers.find do |provider| + # Look for a corresponding person with same uid in any of the configured LDAP providers + Gitlab::LDAP::Config.providers.each do |provider| adapter = Gitlab::LDAP::Adapter.new(provider) - - Gitlab::LDAP::Person.find_by_uid(auth_hash.uid, adapter) + @ldap_person = Gitlab::LDAP::Person.find_by_uid(auth_hash.uid, adapter) + break if @ldap_person end + @ldap_person end def ldap_config diff --git a/spec/features/users_spec.rb b/spec/features/users_spec.rb index 93d2b18b5fc..a4c3dfe9205 100644 --- a/spec/features/users_spec.rb +++ b/spec/features/users_spec.rb @@ -27,4 +27,25 @@ feature 'Users' do user.reload expect(user.reset_password_token).to be_nil end + + let!(:user) { create(:user, username: 'user1', name: 'User 1', email: 'user1@gitlab.com') } + scenario 'Should show one error if email is already taken' do + visit new_user_session_path + fill_in 'user_name', with: 'Another user name' + fill_in 'user_username', with: 'anotheruser' + fill_in 'user_email', with: user.email + fill_in 'user_password_sign_up', with: '12341234' + expect { click_button 'Sign up' }.to change { User.count }.by(0) + expect(page).to have_text('Email has already been taken') + expect(number_of_errors_on_page(page)).to be(1), 'errors on page:\n #{errors_on_page page}' + end + + def errors_on_page(page) + page.find('#error_explanation').find('ul').all('li').map{ |item| item.text }.join("\n") + end + + def number_of_errors_on_page(page) + page.find('#error_explanation').find('ul').all('li').count + end + end diff --git a/spec/lib/gitlab/o_auth/user_spec.rb b/spec/lib/gitlab/o_auth/user_spec.rb index 2a982e8b107..d383ea2d051 100644 --- a/spec/lib/gitlab/o_auth/user_spec.rb +++ b/spec/lib/gitlab/o_auth/user_spec.rb @@ -62,55 +62,65 @@ describe Gitlab::OAuth::User do context "with auto_link_ldap_user enabled" do before { Gitlab.config.omniauth.stub auto_link_ldap_user: true } - - context "and a corresponding LDAP person" do - before do - ldap_user.stub(:uid) { uid } - ldap_user.stub(:username) { uid } - ldap_user.stub(:email) { ['johndoe@example.com','john2@example.com'] } - ldap_user.stub(:dn) { 'uid=user1,ou=People,dc=example' } - allow(oauth_user).to receive(:ldap_person).and_return(ldap_user) - end - - context "and no account for the LDAP user" do - - it "creates a user with dual LDAP and omniauth identities" do - oauth_user.save - - expect(gl_user).to be_valid - expect(gl_user.username).to eql uid - expect(gl_user.email).to eql 'johndoe@example.com' - expect(gl_user.identities.length).to eql 2 - identities_as_hash = gl_user.identities.map { |id| { provider: id.provider, extern_uid: id.extern_uid } } - expect(identities_as_hash).to match_array( - [ { provider: 'ldapmain', extern_uid: 'uid=user1,ou=People,dc=example' }, - { provider: 'twitter', extern_uid: uid } - ]) + + context "and no LDAP provider defined" do + before { allow(Gitlab::LDAP::Config).to receive(:providers).and_return([]) } + + include_examples "to verify compliance with allow_single_sign_on" + end + + context "and at least one LDAP provider is defined" do + before { allow(Gitlab::LDAP::Config).to receive(:providers).and_return(['ldapmain']) } + + context "and a corresponding LDAP person" do + before do + ldap_user.stub(:uid) { uid } + ldap_user.stub(:username) { uid } + ldap_user.stub(:email) { ['johndoe@example.com','john2@example.com'] } + ldap_user.stub(:dn) { 'uid=user1,ou=People,dc=example' } + allow(Gitlab::LDAP::Person).to receive(:find_by_uid).and_return(ldap_user) end - end - - context "and LDAP user has an account already" do - let!(:existing_user) { create(:omniauth_user, email: 'john@example.com', extern_uid: 'uid=user1,ou=People,dc=example', provider: 'ldapmain', username: 'john') } - it "adds the omniauth identity to the LDAP account" do - oauth_user.save - - expect(gl_user).to be_valid - expect(gl_user.username).to eql 'john' - expect(gl_user.email).to eql 'john@example.com' - expect(gl_user.identities.length).to eql 2 - identities_as_hash = gl_user.identities.map { |id| { provider: id.provider, extern_uid: id.extern_uid } } - expect(identities_as_hash).to match_array( - [ { provider: 'ldapmain', extern_uid: 'uid=user1,ou=People,dc=example' }, - { provider: 'twitter', extern_uid: uid } - ]) + + context "and no account for the LDAP user" do + + it "creates a user with dual LDAP and omniauth identities" do + oauth_user.save + + expect(gl_user).to be_valid + expect(gl_user.username).to eql uid + expect(gl_user.email).to eql 'johndoe@example.com' + expect(gl_user.identities.length).to eql 2 + identities_as_hash = gl_user.identities.map { |id| { provider: id.provider, extern_uid: id.extern_uid } } + expect(identities_as_hash).to match_array( + [ { provider: 'ldapmain', extern_uid: 'uid=user1,ou=People,dc=example' }, + { provider: 'twitter', extern_uid: uid } + ]) + end + end + + context "and LDAP user has an account already" do + let!(:existing_user) { create(:omniauth_user, email: 'john@example.com', extern_uid: 'uid=user1,ou=People,dc=example', provider: 'ldapmain', username: 'john') } + it "adds the omniauth identity to the LDAP account" do + oauth_user.save + + expect(gl_user).to be_valid + expect(gl_user.username).to eql 'john' + expect(gl_user.email).to eql 'john@example.com' + expect(gl_user.identities.length).to eql 2 + identities_as_hash = gl_user.identities.map { |id| { provider: id.provider, extern_uid: id.extern_uid } } + expect(identities_as_hash).to match_array( + [ { provider: 'ldapmain', extern_uid: 'uid=user1,ou=People,dc=example' }, + { provider: 'twitter', extern_uid: uid } + ]) + end end end - end - - context "and no corresponding LDAP person" do - before { allow(oauth_user).to receive(:ldap_person).and_return(nil) } - - include_examples "to verify compliance with allow_single_sign_on" + + context "and no corresponding LDAP person" do + before { allow(Gitlab::LDAP::Person).to receive(:find_by_uid).and_return(nil) } + + include_examples "to verify compliance with allow_single_sign_on" + end end end |