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