debian-mirror-gitlab/spec/models/lfs_file_lock_spec.rb

60 lines
1.6 KiB
Ruby
Raw Normal View History

2019-07-07 11:18:12 +05:30
# frozen_string_literal: true
2019-12-04 20:38:33 +05:30
require 'spec_helper'
2018-03-17 18:26:18 +05:30
describe LfsFileLock do
set(:lfs_file_lock) { create(:lfs_file_lock) }
subject { lfs_file_lock }
it { is_expected.to belong_to(:project) }
it { is_expected.to belong_to(:user) }
it { is_expected.to validate_presence_of(:project_id) }
it { is_expected.to validate_presence_of(:user_id) }
it { is_expected.to validate_presence_of(:path) }
describe '#can_be_unlocked_by?' do
let(:developer) { create(:user) }
2019-03-02 22:35:43 +05:30
let(:maintainer) { create(:user) }
2018-03-17 18:26:18 +05:30
before do
project = lfs_file_lock.project
project.add_developer(developer)
2018-11-18 11:00:15 +05:30
project.add_maintainer(maintainer)
2018-03-17 18:26:18 +05:30
end
context "when it's forced" do
it 'can be unlocked by the author' do
user = lfs_file_lock.user
expect(lfs_file_lock.can_be_unlocked_by?(user, true)).to eq(true)
end
2018-11-18 11:00:15 +05:30
it 'can be unlocked by a maintainer' do
expect(lfs_file_lock.can_be_unlocked_by?(maintainer, true)).to eq(true)
2018-03-17 18:26:18 +05:30
end
it "can't be unlocked by other user" do
expect(lfs_file_lock.can_be_unlocked_by?(developer, true)).to eq(false)
end
end
context "when it isn't forced" do
it 'can be unlocked by the author' do
user = lfs_file_lock.user
expect(lfs_file_lock.can_be_unlocked_by?(user)).to eq(true)
end
2018-11-18 11:00:15 +05:30
it "can't be unlocked by a maintainer" do
expect(lfs_file_lock.can_be_unlocked_by?(maintainer)).to eq(false)
2018-03-17 18:26:18 +05:30
end
it "can't be unlocked by other user" do
expect(lfs_file_lock.can_be_unlocked_by?(developer)).to eq(false)
end
end
end
end