diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 16:18:24 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-09-20 16:18:24 +0300 |
commit | 0653e08efd039a5905f3fa4f6e9cef9f5d2f799c (patch) | |
tree | 4dcc884cf6d81db44adae4aa99f8ec1233a41f55 /spec/services/boards/issues/list_service_spec.rb | |
parent | 744144d28e3e7fddc117924fef88de5d9674fe4c (diff) |
Add latest changes from gitlab-org/gitlab@14-3-stable-eev14.3.0-rc42
Diffstat (limited to 'spec/services/boards/issues/list_service_spec.rb')
-rw-r--r-- | spec/services/boards/issues/list_service_spec.rb | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/spec/services/boards/issues/list_service_spec.rb b/spec/services/boards/issues/list_service_spec.rb index bbdc178b234..d1f854f72bc 100644 --- a/spec/services/boards/issues/list_service_spec.rb +++ b/spec/services/boards/issues/list_service_spec.rb @@ -139,4 +139,51 @@ RSpec.describe Boards::Issues::ListService do end # rubocop: enable RSpec/MultipleMemoizedHelpers end + + describe '.initialize_relative_positions' do + let_it_be(:user) { create(:user) } + let_it_be(:project) { create(:project, :empty_repo) } + let_it_be(:board) { create(:board, project: project) } + let_it_be(:backlog) { create(:backlog_list, board: board) } + + let(:issue) { create(:issue, project: project, relative_position: nil) } + + context "when 'Gitlab::Database::read_write?' is true" do + before do + allow(Gitlab::Database).to receive(:read_write?).and_return(true) + end + + context 'user cannot move issues' do + it 'does not initialize the relative positions of issues' do + described_class.initialize_relative_positions(board, user, [issue]) + + expect(issue.relative_position).to eq nil + end + end + + context 'user can move issues' do + before do + project.add_developer(user) + end + + it 'initializes the relative positions of issues' do + described_class.initialize_relative_positions(board, user, [issue]) + + expect(issue.relative_position).not_to eq nil + end + end + end + + context "when 'Gitlab::Database::read_write?' is false" do + before do + allow(Gitlab::Database).to receive(:read_write?).and_return(false) + end + + it 'does not initialize the relative positions of issues' do + described_class.initialize_relative_positions(board, user, [issue]) + + expect(issue.relative_position).to eq nil + end + end + end end |