Commit f684346b authored by Rubén Dávila's avatar Rubén Dávila

Fix some broken specs

parent 4b898dbc
......@@ -36,15 +36,13 @@ class Projects::LfsLocksApiController < Projects::GitHttpClientController
end
def build_payload(data, process)
serialized_data = process ? LfsFileLockSerializer.new.represent(data) : data
data = LfsFileLockSerializer.new.represent(data) if process
if @result[:status] == :success
serialized_data
else
# When the locking failed due to an existent Lock the existent record
return data if @result[:status] == :success
# When the locking failed due to an existent Lock, the existent record
# is returned in `@result[:lock]`
error_payload(@result[:message], @result[:lock] ? serialized_data : {})
end
error_payload(@result[:message], @result[:lock] ? data : {})
end
def error_payload(message, custom_attrs = {})
......
......@@ -22,7 +22,7 @@ module Lfs
elsif forced
error('You must have master access to force delete a lock', 403)
else
error("#{@lock.path} is locked by GitLab User #{current_user.id}", 403)
error("#{@lock.path} is locked by GitLab User #{@lock.user_id}", 403)
end
end
end
......
......@@ -13,8 +13,6 @@ module EE
push_rule_committer_not_allowed: "You cannot push commits for '%{committer_email}'. You can only push commits that were committed with one of your own verified emails."
}.freeze
attr_reader :push_rule
override :exec
def exec
return true if skip_authorization
......@@ -31,11 +29,13 @@ module EE
private
def push_rule
project.push_rule
end
def push_rule_check
return unless newrev && oldrev && project.feature_available?(:push_rules)
@push_rule = project.push_rule
if tag_name
push_rule_tag_check
else
......
......@@ -225,7 +225,6 @@ describe Gitlab::Checks::ChangeAccess do
subject.exec
end
end
context 'with LFS enabled' do
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe Lfs::LocksFinderService do
let(:project) { create(:project) }
let(:user) { create(:user) }
let(:params) { Hash.new }
let(:params) { {} }
subject { described_class.new(project, user, params) }
......
......@@ -2,10 +2,12 @@ require 'spec_helper'
describe Lfs::UnlockFileService do
let(:project) { create(:project) }
let(:user) { create(:user) }
let!(:lock) { create(:lfs_file_lock, user: user, project: project) }
let(:current_user) { create(:user) }
let(:lock_author) { create(:user) }
let!(:lock) { create(:lfs_file_lock, user: lock_author, project: project) }
let(:params) { {} }
subject { described_class.new(project, user, params) }
subject { described_class.new(project, current_user, params) }
describe '#execute' do
context 'when lock does not exists' do
......@@ -19,6 +21,7 @@ describe Lfs::UnlockFileService do
end
context 'when unlocked by the author' do
let(:current_user) { lock_author }
let(:params) { { id: lock.id } }
it "succeeds" do
......@@ -30,13 +33,14 @@ describe Lfs::UnlockFileService do
end
context 'when unlocked by a different user' do
let(:user) { create(:user) }
let(:current_user) { create(:user) }
let(:params) { { id: lock.id } }
it "doesn't succeed" do
result = subject.execute
expect(result[:status]).to eq(:error)
expect(result[:message]).to match(/is locked by GitLab User #{user.id}/)
expect(result[:message]).to match(/is locked by GitLab User #{lock_author.id}/)
expect(result[:http_status]).to eq(403)
end
end
......@@ -51,7 +55,7 @@ describe Lfs::UnlockFileService do
end
context 'by a regular user' do
let(:user) { developer }
let(:current_user) { developer }
let(:params) do
{ id: lock.id,
force: true }
......@@ -67,7 +71,7 @@ describe Lfs::UnlockFileService do
end
context 'by a master user' do
let(:user) { developer }
let(:current_user) { master }
let(:params) do
{ id: lock.id,
force: true }
......
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