Commit 67a76fa3 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge branch 'id-lfs-move-ee-tests-to-ee-dir' into 'master'

Move lfs ee tests under ee directory

Closes #6518

See merge request gitlab-org/gitlab-ee!9970
parents d55945aa a0ad96b6
# frozen_string_literal: true
require 'spec_helper'
describe Lfs::LockFileService do
let(:project) { create(:project) }
let(:current_user) { create(:user) }
let(:params) { { path: 'README.md' } }
subject { described_class.new(project, current_user, params) }
describe '#execute' do
context 'when authorized' do
before do
project.add_developer(current_user)
end
context 'when File Locking is available' do
before do
stub_licensed_features(file_locks: true)
end
it 'creates the Path Lock' do
expect { subject.execute }.to change { PathLock.count }.to(1)
end
end
context 'when File Locking is not available' do
before do
stub_licensed_features(file_locks: false)
end
it 'does not create the Path Lock' do
expect { subject.execute }.not_to change { PathLock.count }
end
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
describe Lfs::UnlockFileService do
let(:project) { create(:project) }
let(:lock_author) { create(:user) }
let!(:lock) { create(:lfs_file_lock, user: lock_author, project: project) }
subject { described_class.new(project, current_user, params) }
describe '#execute' do
context 'when authorized' do
before do
project.add_developer(current_user)
end
describe 'File Locking integraction' do
let(:params) { { id: lock.id } }
let(:current_user) { lock_author }
before do
project.add_developer(lock_author)
project.path_locks.create(path: lock.path, user: lock_author)
end
context 'when File Locking is available' do
it 'deletes the Path Lock' do
expect { subject.execute }.to change { PathLock.count }.to(0)
end
end
context 'when File Locking is not available' do
before do
allow(project).to receive(:feature_available?).with(:file_locks).and_return(false)
end
it 'does not delete the Path Lock' do
expect { subject.execute }.not_to change { PathLock.count }
end
end
end
end
end
end
......@@ -57,26 +57,6 @@ describe Lfs::LockFileService do
expect(subject.execute[:status]).to eq(:error)
end
end
context 'when File Locking is available' do
before do
stub_licensed_features(file_locks: true)
end
it 'creates the Path Lock' do
expect { subject.execute }.to change { PathLock.count }.to(1)
end
end
context 'when File Locking is not available' do
before do
stub_licensed_features(file_locks: false)
end
it 'creates the Path Lock' do
expect { subject.execute }.not_to change { PathLock.count }
end
end
end
end
end
......@@ -100,34 +100,6 @@ describe Lfs::UnlockFileService do
end
end
end
describe 'File Locking integraction' do
let(:params) { { id: lock.id } }
let(:current_user) { lock_author }
before do
project.add_developer(lock_author)
project.path_locks.create(path: lock.path, user: lock_author)
end
context 'when File Locking is available' do
it 'deletes the Path Lock' do
expect { subject.execute }.to change { PathLock.count }.to(0)
end
end
context 'when File Locking is not available' do
before do
stub_licensed_features(file_locks: false)
end
# For some reason RSpec is reseting the mock and
# License.feature_available?(:file_locks) returns true when the spec runs.
xit 'does not delete the Path Lock' do
expect { subject.execute }.not_to change { PathLock.count }
end
end
end
end
end
end
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