Commit 4b464eaa authored by Rémy Coutable's avatar Rémy Coutable

Fix avatar-related failures

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent a0f8bcc2
...@@ -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
factory :group_with_members do factory :group_with_members do
after(:create) do |group, evaluator| after(:create) do |group, evaluator|
group.add_developer(create :user) group.add_developer(create :user)
......
...@@ -33,6 +33,10 @@ FactoryGirl.define do ...@@ -33,6 +33,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
......
...@@ -176,19 +176,16 @@ describe Group, models: true do ...@@ -176,19 +176,16 @@ describe Group, models: true do
end end
describe '#avatar_url' do describe '#avatar_url' do
let!(:group) { create(:group, :access_requestable, :with_avatar) }
let(:user) { create(:user) } let(:user) { create(:user) }
subject { group.avatar_url } subject { group.avatar_url }
context 'when avatar file is uploaded' do context 'when avatar file is uploaded' do
before do before do
group.add_user(user, GroupMember::MASTER) group.add_master(user)
group.update_columns(avatar: 'avatar.png')
allow(group.avatar).to receive(:present?) { true }
end end
let(:avatar_path) do let(:avatar_path) { "/uploads/group/avatar/#{group.id}/dk.png" }
"/uploads/group/avatar/#{group.id}/avatar.png"
end
it { should eq "http://#{Gitlab.config.gitlab.host}#{avatar_path}" } it { should eq "http://#{Gitlab.config.gitlab.host}#{avatar_path}" }
......
...@@ -963,23 +963,6 @@ describe Project, models: true do ...@@ -963,23 +963,6 @@ describe Project, models: true do
end end
end end
describe '#execute_hooks' do
it "triggers project and group hooks" do
group = create :group, name: 'gitlab'
project = create(:project, name: 'gitlabhq', namespace: group)
project_hook = create(:project_hook, push_events: true, project: project)
group_hook = create(:group_hook, push_events: true, group: group)
stub_request(:post, project_hook.url)
stub_request(:post, group_hook.url)
expect_any_instance_of(GroupHook).to receive(:async_execute).and_return(true)
expect_any_instance_of(ProjectHook).to receive(:async_execute).and_return(true)
project.execute_hooks({}, :push_hooks)
end
end
describe '#avatar_url' do describe '#avatar_url' do
subject { project.avatar_url } subject { project.avatar_url }
...@@ -987,12 +970,9 @@ describe Project, models: true do ...@@ -987,12 +970,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
context 'When in a geo secondary node' do context 'When in a geo secondary node' do
let(:geo_url) { 'http://geo.example.com' } let(:geo_url) { 'http://geo.example.com' }
...@@ -1011,9 +991,7 @@ describe Project, models: true do ...@@ -1011,9 +991,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
...@@ -1025,6 +1003,23 @@ describe Project, models: true do ...@@ -1025,6 +1003,23 @@ describe Project, models: true do
end end
end end
describe '#execute_hooks' do
it "triggers project and group hooks" do
group = create :group, name: 'gitlab'
project = create(:project, name: 'gitlabhq', namespace: group)
project_hook = create(:project_hook, push_events: true, project: project)
group_hook = create(:group_hook, push_events: true, group: group)
stub_request(:post, project_hook.url)
stub_request(:post, group_hook.url)
expect_any_instance_of(GroupHook).to receive(:async_execute).and_return(true)
expect_any_instance_of(ProjectHook).to receive(:async_execute).and_return(true)
project.execute_hooks({}, :push_hooks)
end
end
describe '#allowed_to_share_with_group?' do describe '#allowed_to_share_with_group?' do
let(:project) { create(:project) } let(:project) { create(:project) }
......
...@@ -899,18 +899,11 @@ describe User, models: true do ...@@ -899,18 +899,11 @@ describe User, models: true do
end end
describe '#avatar_url' do describe '#avatar_url' do
let(:user) { create(:user) } let(:user) { create(:user, :with_avatar) }
subject { user.avatar_url } subject { user.avatar_url }
context 'when avatar file is uploaded' do context 'when avatar file is uploaded' do
before do let(:avatar_path) { "/uploads/user/avatar/#{user.id}/dk.png" }
user.update_columns(avatar: 'uploads/avatar.png')
allow(user.avatar).to receive(:present?) { true }
end
let(:avatar_path) do
"/uploads/user/avatar/#{user.id}/uploads/avatar.png"
end
it { should eq "http://#{Gitlab.config.gitlab.host}#{avatar_path}" } it { should eq "http://#{Gitlab.config.gitlab.host}#{avatar_path}" }
......
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