Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2017-05-05 17:01:08 +0300
committerRobert Speicher <robert@gitlab.com>2017-05-05 17:01:08 +0300
commitc89849af47dc3ce788adbc7ef06af8a39a5347fd (patch)
treea5e94d20dbf780c28ff5bbf7ab0f2e899391b6a8 /spec
parent10c1bf2d77fd0ab21309d0b136cbc0ac11f56c77 (diff)
parentf1ace97f8bdc69edc481b545b779721322cec95c (diff)
Merge branch 'backport-ee-4b464eaaee' into 'master'
Backport avatar-related spec changes from gitlab-org/gitlab-ee@4b464eaaee See merge request !11072
Diffstat (limited to 'spec')
-rw-r--r--spec/factories/groups.rb4
-rw-r--r--spec/factories/users.rb4
-rw-r--r--spec/models/group_spec.rb16
-rw-r--r--spec/models/project_spec.rb11
-rw-r--r--spec/models/user_spec.rb11
5 files changed, 38 insertions, 8 deletions
diff --git a/spec/factories/groups.rb b/spec/factories/groups.rb
index 86f51ffca99..52f76b094a3 100644
--- a/spec/factories/groups.rb
+++ b/spec/factories/groups.rb
@@ -17,6 +17,10 @@ FactoryGirl.define do
visibility_level Gitlab::VisibilityLevel::PRIVATE
end
+ trait :with_avatar do
+ avatar { File.open(Rails.root.join('spec/fixtures/dk.png')) }
+ end
+
trait :access_requestable do
request_access_enabled true
end
diff --git a/spec/factories/users.rb b/spec/factories/users.rb
index e1ae94a08e4..33fa80772ff 100644
--- a/spec/factories/users.rb
+++ b/spec/factories/users.rb
@@ -29,6 +29,10 @@ FactoryGirl.define do
after(:build) { |user, _| user.block! }
end
+ trait :with_avatar do
+ avatar { File.open(Rails.root.join('spec/fixtures/dk.png')) }
+ end
+
trait :two_factor_via_otp do
before(:create) do |user|
user.otp_required_for_login = true
diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb
index a11805926cc..3d60e52f23f 100644
--- a/spec/models/group_spec.rb
+++ b/spec/models/group_spec.rb
@@ -175,6 +175,22 @@ describe Group, models: true do
end
end
+ describe '#avatar_url' do
+ let!(:group) { create(:group, :access_requestable, :with_avatar) }
+ let(:user) { create(:user) }
+ subject { group.avatar_url }
+
+ context 'when avatar file is uploaded' do
+ before do
+ group.add_master(user)
+ end
+
+ let(:avatar_path) { "/uploads/group/avatar/#{group.id}/dk.png" }
+
+ it { should eq "http://#{Gitlab.config.gitlab.host}#{avatar_path}" }
+ end
+ end
+
describe '.search' do
it 'returns groups with a matching name' do
expect(described_class.search(group.name)).to eq([group])
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index 316ece87faa..2fc8ffed80a 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -811,12 +811,9 @@ describe Project, models: true do
context 'when avatar file is uploaded' do
let(:project) { create(:empty_project, :with_avatar) }
+ let(:avatar_path) { "/uploads/project/avatar/#{project.id}/dk.png" }
- it 'creates a correct avatar path' do
- avatar_path = "/uploads/project/avatar/#{project.id}/dk.png"
-
- expect(project.avatar_url).to eq("http://#{Gitlab.config.gitlab.host}#{avatar_path}")
- end
+ it { should eq "http://#{Gitlab.config.gitlab.host}#{avatar_path}" }
end
context 'When avatar file in git' do
@@ -824,9 +821,7 @@ describe Project, models: true do
allow(project).to receive(:avatar_in_git) { true }
end
- let(:avatar_path) do
- "/#{project.full_path}/avatar"
- end
+ let(:avatar_path) { "/#{project.full_path}/avatar" }
it { should eq "http://#{Gitlab.config.gitlab.host}#{avatar_path}" }
end
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 13179174956..401eaac07a1 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -874,6 +874,17 @@ describe User, models: true do
end
end
+ describe '#avatar_url' do
+ let(:user) { create(:user, :with_avatar) }
+ subject { user.avatar_url }
+
+ context 'when avatar file is uploaded' do
+ let(:avatar_path) { "/uploads/user/avatar/#{user.id}/dk.png" }
+
+ it { should eq "http://#{Gitlab.config.gitlab.host}#{avatar_path}" }
+ end
+ end
+
describe '#requires_ldap_check?' do
let(:user) { User.new }