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
visibility_level Gitlab::VisibilityLevel::PRIVATE
end
trait :with_avatar do
avatar { File.open(Rails.root.join('spec/fixtures/dk.png')) }
end
factory :group_with_members do
after(:create) do |group, evaluator|
group.add_developer(create :user)
......
......@@ -33,6 +33,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
......
......@@ -176,19 +176,16 @@ describe Group, models: true do
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_user(user, GroupMember::MASTER)
group.update_columns(avatar: 'avatar.png')
allow(group.avatar).to receive(:present?) { true }
group.add_master(user)
end
let(:avatar_path) do
"/uploads/group/avatar/#{group.id}/avatar.png"
end
let(:avatar_path) { "/uploads/group/avatar/#{group.id}/dk.png" }
it { should eq "http://#{Gitlab.config.gitlab.host}#{avatar_path}" }
......
......@@ -963,23 +963,6 @@ describe Project, models: true do
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
subject { project.avatar_url }
......@@ -987,12 +970,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}" }
context 'When in a geo secondary node' do
let(:geo_url) { 'http://geo.example.com' }
......@@ -1011,9 +991,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
......@@ -1025,6 +1003,23 @@ describe Project, models: true do
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
let(:project) { create(:project) }
......
......@@ -899,18 +899,11 @@ describe User, models: true do
end
describe '#avatar_url' do
let(:user) { create(:user) }
let(:user) { create(:user, :with_avatar) }
subject { user.avatar_url }
context 'when avatar file is uploaded' do
before do
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
let(:avatar_path) { "/uploads/user/avatar/#{user.id}/dk.png" }
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