Upgrade act as list gem, implement tests to check deal position behaviour and fix bug when change deal between stages from position 1#592
Conversation
| it 'move stage1_position1 to stage2 position 1 and create deal_stage_change event' do | ||
| expect do | ||
| Deal::CreateOrUpdate.new(stage1_position1, { stage: stage2, position: 1 }).call | ||
| end.to change(Event, :count).by(1) | ||
|
|
||
| expect(stage1_position2.reload.position).to eq 1 | ||
| expect(stage1_position3.reload.position).to eq 2 | ||
|
|
||
| expect(stage1_position1.reload.position).to eq 1 | ||
| expect(stage2_position1.reload.position).to eq 2 | ||
| expect(stage2_position2.reload.position).to eq 3 | ||
| expect(stage2_position3.reload.position).to eq 4 | ||
| expect(last_event.kind).to eq('deal_stage_change') | ||
| end |
There was a problem hiding this comment.
Criei esse pr, pois esse teste está falhando.
E se analisar, parece ser um bug da gem act_as_list.
Fiz o update da gem para a ultima versão, mas esse teste ainda está falhando.
There was a problem hiding this comment.
Abri uma issue no repostorio da gem act_as_list, e o rapaz que me respondeu falou que esse bug acontece pq as positions estão com default: 1. Removendo o default, esse bug é corrigido. Fiz isso nesse commit fdfaf83 e esse teste parou de falhar.
Segue o q o rapaz comentou:
So yes, you do have a default of 1 for that column. You'll need to remove this. It's best if this column doesn't have a default. What is happening is that acts_as_list can't see that the column value is being set explicitly so it's adding the record to the end of the table. Let me know how you get on
… deal position is 1
No description provided.