Skip to content

Commit

Permalink
Merge pull request #81 from KarinaKlevzhits/fix-specs-for-new-record-…
Browse files Browse the repository at this point in the history
…position

Fix specs for new record position
  • Loading branch information
johnnyshields authored Sep 13, 2023
2 parents 213e471 + fdcc0fb commit 7a0cc64
Showing 1 changed file with 48 additions and 36 deletions.
84 changes: 48 additions & 36 deletions spec/integration/multiple_fields_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,30 @@
describe 'inserting' do
let(:newbie) { MultipleFieldsOrderable.create! }

before { @position = newbie.position }
before do
@position = newbie.position
@record = MultipleFieldsOrderable.find(newbie.id)
end

it 'top' do
newbie.move_to! :top
@record.move_to! :top
expect(serial_nos).to eq([1, 2, 3, 4, 5, 6])
expect(newbie.serial_no).to eq(1)
expect(newbie.position).to eq(@position)
expect(@record.serial_no).to eq(1)
expect(@record.position).to eq(@position)
end

it 'bottom' do
newbie.move_to! :bottom
@record.move_to! :bottom
expect(serial_nos).to eq([1, 2, 3, 4, 5, 6])
expect(newbie.serial_no).to eq(6)
expect(newbie.position).to eq(@position)
expect(@record.serial_no).to eq(6)
expect(@record.position).to eq(@position)
end

it 'middle' do
newbie.move_to! 4
@record.move_to! 4
expect(serial_nos).to eq([1, 2, 3, 4, 5, 6])
expect(newbie.serial_no).to eq(4)
expect(newbie.position).to eq(@position)
expect(@record.serial_no).to eq(4)
expect(@record.position).to eq(@position)
end
end

Expand Down Expand Up @@ -163,27 +166,30 @@
describe 'inserting' do
let(:newbie) { MultipleFieldsOrderable.create! }

before { @position = newbie.position }
before do
@position = newbie.position
@record = MultipleFieldsOrderable.find(newbie.id)
end

it 'top' do
newbie.move_serial_no_to! :top
@record.move_serial_no_to! :top
expect(serial_nos).to eq([1, 2, 3, 4, 5, 6])
expect(newbie.serial_no).to eq(1)
expect(newbie.position).to eq(@position)
expect(@record.serial_no).to eq(1)
expect(@record.position).to eq(@position)
end

it 'bottom' do
newbie.move_serial_no_to! :bottom
@record.move_serial_no_to! :bottom
expect(serial_nos).to eq([1, 2, 3, 4, 5, 6])
expect(newbie.serial_no).to eq(6)
expect(newbie.position).to eq(@position)
expect(@record.serial_no).to eq(6)
expect(@record.position).to eq(@position)
end

it 'middle' do
newbie.move_serial_no_to! 4
@record.move_serial_no_to! 4
expect(serial_nos).to eq([1, 2, 3, 4, 5, 6])
expect(newbie.serial_no).to eq(4)
expect(newbie.position).to eq(@position)
expect(@record.serial_no).to eq(4)
expect(@record.position).to eq(@position)
end
end

Expand Down Expand Up @@ -316,27 +322,30 @@
describe 'inserting' do
let(:newbie) { MultipleFieldsOrderable.create! }

before { @serial_no = newbie.serial_no }
before do
@serial_no = newbie.serial_no
@record = MultipleFieldsOrderable.find(newbie.id)
end

it 'top' do
newbie.move_position_to! :top
@record.move_position_to! :top
expect(positions).to eq([0, 1, 2, 3, 4, 5])
expect(newbie.position).to eq(0)
expect(newbie.serial_no).to eq(@serial_no)
expect(@record.position).to eq(0)
expect(@record.serial_no).to eq(@serial_no)
end

it 'bottom' do
newbie.move_position_to! :bottom
@record.move_position_to! :bottom
expect(positions).to eq([0, 1, 2, 3, 4, 5])
expect(newbie.position).to eq(5)
expect(newbie.serial_no).to eq(@serial_no)
expect(@record.position).to eq(5)
expect(@record.serial_no).to eq(@serial_no)
end

it 'middle' do
newbie.move_position_to! 4
@record.move_position_to! 4
expect(positions).to eq([0, 1, 2, 3, 4, 5])
expect(newbie.position).to eq(4)
expect(newbie.serial_no).to eq(@serial_no)
expect(@record.position).to eq(4)
expect(@record.serial_no).to eq(@serial_no)
end
end

Expand Down Expand Up @@ -458,23 +467,26 @@
describe 'inserting' do
it 'top' do
newbie = MultipleFieldsOrderable.create! group_id: 1
newbie.move_groups_to! :top
record = MultipleFieldsOrderable.find(newbie.id)
record.move_groups_to! :top
expect(all_groups).to eq([1, 2, 3, 1, 2, 3])
expect(newbie.groups).to eq(1)
expect(record.groups).to eq(1)
end

it 'bottom' do
newbie = MultipleFieldsOrderable.create! group_id: 2
newbie.move_groups_to! :bottom
record = MultipleFieldsOrderable.find(newbie.id)
record.move_groups_to! :bottom
expect(all_groups).to eq([1, 2, 1, 2, 3, 4])
expect(newbie.groups).to eq(4)
expect(record.groups).to eq(4)
end

it 'middle' do
newbie = MultipleFieldsOrderable.create! group_id: 2
newbie.move_groups_to! 2
record = MultipleFieldsOrderable.find(newbie.id)
record.move_groups_to! 2
expect(all_groups).to eq([1, 2, 1, 2, 3, 4])
expect(newbie.groups).to eq(2)
expect(record.groups).to eq(2)
end
end

Expand Down

0 comments on commit 7a0cc64

Please sign in to comment.