-
Notifications
You must be signed in to change notification settings - Fork 227
Add move to list option to Methodology cards #1580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
941aa68
abf51e4
d67902a
7b8fab7
e682e68
4b709e4
746bb51
c9e6ed0
92acb8e
14aebeb
fa11864
8c59b71
b4264cb
87511f2
1b2ed24
12944aa
ef8960f
17cc212
eb91548
458f24e
651c2c9
0c1187a
77992f9
42135fd
f782d5b
73e3e33
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| class Card < ApplicationRecord | ||
| include Commentable | ||
| include Eventable | ||
| include HasFields | ||
| include RevisionTracking | ||
| include Subscribable | ||
|
|
@@ -84,6 +85,16 @@ def to_xml(xml_builder, includes: [], version: 3) | |
| end | ||
| end | ||
|
|
||
| def local_event_payload | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're adding this for cards but are we actually using it? Either we keep this and use eventpublisher for cards, or leave this out for now.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed for now.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @aapomm please go ahead and add it. We probably need to include list information in the payload (and even a before/after in the particular Position one).
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why was this resolved @aapomm ? I think that someone paying attention to this event would like List / Board? |
||
| { | ||
| project: { | ||
| id: project.id, | ||
| name: project.name | ||
| }, | ||
| title: name | ||
| } | ||
| end | ||
|
|
||
| def local_fields | ||
| { | ||
| 'List' => list.name.parameterize(preserve_case: true, separator: '_'), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| require 'rails_helper' | ||
|
|
||
| describe 'cards#move_to_list' do | ||
| before { login_to_project_as_user } | ||
|
|
||
| let(:board) { create(:board, node: current_project.methodology_library, project: current_project) } | ||
| let(:source_list) { create(:list, board: board) } | ||
| let(:target_list) { create(:list, board: board, previous_id: source_list.id) } | ||
|
|
||
| let(:card_a) { create(:card, list: source_list) } | ||
| let(:card_b) { create(:card, list: source_list, previous_id: card_a.id) } | ||
| let(:card_c) { create(:card, list: source_list, previous_id: card_b.id) } | ||
|
|
||
| let(:last_card_in_target) { create(:card, list: target_list) } | ||
|
|
||
| let(:submit) do | ||
| post move_to_list_project_board_list_card_path(current_project, board, source_list, card_b), | ||
| params: { new_list_id: target_list.id } | ||
| end | ||
|
|
||
| before do | ||
| card_a | ||
| card_b | ||
| card_c | ||
| last_card_in_target | ||
| end | ||
|
|
||
| it 'moves the card to the target list' do | ||
| submit | ||
| expect(card_b.reload.list).to eq(target_list) | ||
| end | ||
|
|
||
| it 'appends the card to the end of the target list' do | ||
| submit | ||
| expect(card_b.reload.previous_id).to eq(last_card_in_target.id) | ||
| end | ||
|
|
||
| it 'repairs the source list chain' do | ||
| submit | ||
| expect(card_c.reload.previous_id).to eq(card_a.id) | ||
| end | ||
|
|
||
| it 'redirects to the card in its new list with a notice' do | ||
| submit | ||
| expect(response).to redirect_to(project_board_list_card_path(current_project, board, target_list, card_b)) | ||
| expect(flash[:notice]).to eq('Task moved.') | ||
| end | ||
|
|
||
| it 'creates an activity' do | ||
| expect { submit }.to have_enqueued_job(ActivityTrackingJob).with( | ||
| action: 'move_to_list', | ||
| project_id: current_project.id, | ||
| trackable_id: card_b.id, | ||
| trackable_type: 'Card', | ||
| user_id: @logged_in_as.id | ||
| ) | ||
| end | ||
|
|
||
| context 'when moving the first card in the source list' do | ||
| let(:submit) do | ||
| post move_to_list_project_board_list_card_path(current_project, board, source_list, card_a), | ||
| params: { new_list_id: target_list.id } | ||
| end | ||
|
|
||
| it 'promotes the next card to list head' do | ||
| submit | ||
| expect(card_b.reload.previous_id).to be_nil | ||
| end | ||
| end | ||
|
|
||
| context 'when moving the last card in the source list' do | ||
| let(:submit) do | ||
| post move_to_list_project_board_list_card_path(current_project, board, source_list, card_c), | ||
| params: { new_list_id: target_list.id } | ||
| end | ||
|
|
||
| it 'leaves the remaining chain intact' do | ||
| submit | ||
| expect(card_b.reload.previous_id).to eq(card_a.id) | ||
| end | ||
| end | ||
|
|
||
| context 'when the target list is the same as the source list' do | ||
| let(:submit) do | ||
| post move_to_list_project_board_list_card_path(current_project, board, source_list, card_c), | ||
| params: { new_list_id: source_list.id } | ||
| end | ||
|
|
||
| it 'does not change the card' do | ||
| original_previous_id = card_c.previous_id | ||
| submit | ||
| expect(card_c.reload.previous_id).to eq(original_previous_id) | ||
| end | ||
|
|
||
| it 'redirects with an alert' do | ||
| submit | ||
| expect(response).to redirect_to(project_board_list_card_path(current_project, board, source_list, card_c)) | ||
| expect(flash[:alert]).to eq('Task is already in that list.') | ||
| end | ||
| end | ||
|
|
||
| context 'when the target list is empty' do | ||
| let(:last_card_in_target) { nil } | ||
|
|
||
| before { target_list } | ||
|
|
||
| it 'makes the card the first item in the target list' do | ||
| submit | ||
| expect(card_b.reload.previous_id).to be_nil | ||
| end | ||
| end | ||
| end |
Uh oh!
There was an error while loading. Please reload this page.