Commit c89849af authored by Robert Speicher's avatar Robert Speicher

Merge branch 'backport-ee-4b464eaaee' into 'master'

Backport avatar-related spec changes from gitlab-org/gitlab-ee@4b464eaaee

See merge request !11072
parents 10c1bf2d f1ace97f
...@@ -17,6 +17,10 @@ FactoryGirl.define do ...@@ -17,6 +17,10 @@ FactoryGirl.define do
visibility_level Gitlab::VisibilityLevel::PRIVATE visibility_level Gitlab::VisibilityLevel::PRIVATE
end end
trait :with_avatar do
avatar { File.open(Rails.root.join('spec/fixtures/dk.png')) }
end
trait :access_requestable do trait :access_requestable do
request_access_enabled true request_access_enabled true
end end
......
...@@ -29,6 +29,10 @@ FactoryGirl.define do ...@@ -29,6 +29,10 @@ FactoryGirl.define do
after(:build) { |user, _| user.block! } after(:build) { |user, _| user.block! }
end end
trait :with_avatar do
avatar { File.open(Rails.root.join('spec/fixtures/dk.png')) }
end
trait :two_factor_via_otp do trait :two_factor_via_otp do
before(:create) do |user| before(:create) do |user|
user.otp_required_for_login = true user.otp_required_for_login = true
......
...@@ -175,6 +175,22 @@ describe Group, models: true do ...@@ -175,6 +175,22 @@ describe Group, models: true do
end end
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 describe '.search' do
it 'returns groups with a matching name' do it 'returns groups with a matching name' do
expect(described_class.search(group.name)).to eq([group]) expect(described_class.search(group.name)).to eq([group])
......
...@@ -811,12 +811,9 @@ describe Project, models: true do ...@@ -811,12 +811,9 @@ describe Project, models: true do
context 'when avatar file is uploaded' do context 'when avatar file is uploaded' do
let(:project) { create(:empty_project, :with_avatar) } let(:project) { create(:empty_project, :with_avatar) }
let(:avatar_path) { "/uploads/project/avatar/#{project.id}/dk.png" }
it 'creates a correct avatar path' do it { should eq "http://#{Gitlab.config.gitlab.host}#{avatar_path}" }
avatar_path = "/uploads/project/avatar/#{project.id}/dk.png"
expect(project.avatar_url).to eq("http://#{Gitlab.config.gitlab.host}#{avatar_path}")
end
end end
context 'When avatar file in git' do context 'When avatar file in git' do
...@@ -824,9 +821,7 @@ describe Project, models: true do ...@@ -824,9 +821,7 @@ describe Project, models: true do
allow(project).to receive(:avatar_in_git) { true } allow(project).to receive(:avatar_in_git) { true }
end end
let(:avatar_path) do let(:avatar_path) { "/#{project.full_path}/avatar" }
"/#{project.full_path}/avatar"
end
it { should eq "http://#{Gitlab.config.gitlab.host}#{avatar_path}" } it { should eq "http://#{Gitlab.config.gitlab.host}#{avatar_path}" }
end end
......
...@@ -874,6 +874,17 @@ describe User, models: true do ...@@ -874,6 +874,17 @@ describe User, models: true do
end end
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 describe '#requires_ldap_check?' do
let(:user) { User.new } let(:user) { User.new }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment