sortability 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,7 +7,7 @@ module Sortability
7
7
  let(:container_1) { Container.new }
8
8
  let(:container_2) { Container.new }
9
9
 
10
- it 'can return the sort peers for a record' do
10
+ it 'can return the sort peers for a record (after saved)' do
11
11
  expect(container_1.sort_position_peers).to be_empty
12
12
  expect(container_2.sort_position_peers).to be_empty
13
13
 
@@ -86,30 +86,24 @@ module Sortability
86
86
  context 'scoped' do
87
87
  let(:container_1) { Container.create }
88
88
  let(:container_2) { Container.create }
89
- let(:item_1) { Item.new(container: container_1) }
90
- let(:item_2) { Item.new(container: container_1) }
91
- let(:item_3) { Item.new(container: container_2) }
89
+ let!(:item_1) { Item.new(container: container_1) }
90
+ let!(:item_2) { Item.new(container: container_1) }
91
+ let!(:item_3) { Item.new(container: container_2) }
92
92
 
93
- it 'can return the sort peers for a record' do
94
- expect(item_1.sort_position_peers).to be_empty
95
- expect(item_2.sort_position_peers).to be_empty
96
- expect(item_3.sort_position_peers).to be_empty
93
+ it 'can return the sort peers for a record (after initialized)' do
94
+ expect(item_1.sort_position_peers).to eq [ item_1, item_2 ]
95
+ expect(item_2.sort_position_peers).to eq [ item_1, item_2 ]
96
+ expect(item_3.sort_position_peers).to eq [ item_3 ]
97
97
 
98
98
  item_1.save!
99
- expect(item_1.sort_position_peers).to eq [ item_1 ]
100
- expect(item_2.sort_position_peers).to eq [ item_1 ]
101
- expect(item_3.sort_position_peers).to be_empty
102
-
103
- container_1.reload
104
- container_2.reload
99
+ expect(item_1.sort_position_peers).to eq [ item_1, item_2 ]
100
+ expect(item_2.sort_position_peers).to eq [ item_1, item_2 ]
101
+ expect(item_3.sort_position_peers).to eq [ item_3 ]
105
102
 
106
103
  item_2.save!
107
104
  expect(item_1.sort_position_peers).to eq [ item_1, item_2 ]
108
105
  expect(item_2.sort_position_peers).to eq [ item_1, item_2 ]
109
- expect(item_3.sort_position_peers).to be_empty
110
-
111
- container_1.reload
112
- container_2.reload
106
+ expect(item_3.sort_position_peers).to eq [ item_3 ]
113
107
 
114
108
  item_3.save!
115
109
  expect(item_1.sort_position_peers).to eq [ item_1, item_2 ]
@@ -13,7 +13,7 @@ module Sortability
13
13
  expect(table_definition).to(
14
14
  receive(:integer).with(:sort_position, options.merge(null: false))
15
15
  )
16
- table_definition.sortable options
16
+ table_definition.sortable(**options)
17
17
  end
18
18
  end
19
19
 
@@ -22,7 +22,7 @@ module Sortability
22
22
 
23
23
  it '#sortable calls the #integer method with the given options' do
24
24
  expect(table_definition).to receive(:integer).with(:pos, options.except(:on))
25
- table_definition.sortable options
25
+ table_definition.sortable(**options)
26
26
  end
27
27
  end
28
28
  end
@@ -14,7 +14,7 @@ module Sortability
14
14
  :add_column, table, :sort_position, :integer, options.merge(null: false)
15
15
  )
16
16
 
17
- migration.add_sortable_column table, options
17
+ migration.add_sortable_column table, **options
18
18
  end
19
19
 
20
20
  it '#add_sortable_index can add a sortable index, adding defaults' do
@@ -22,7 +22,7 @@ module Sortability
22
22
  :add_index, table, [ :sort_position ], options.merge(unique: true)
23
23
  )
24
24
 
25
- migration.add_sortable_index table, options
25
+ migration.add_sortable_index table, **options
26
26
  end
27
27
  end
28
28
 
@@ -36,7 +36,7 @@ module Sortability
36
36
  :add_column, table, :pos, :integer, options.except(:on)
37
37
  )
38
38
 
39
- migration.add_sortable_column table, options
39
+ migration.add_sortable_column table, **options
40
40
  end
41
41
 
42
42
  it '#add_sortable_index can add a sortable index with the given options' do
@@ -44,7 +44,7 @@ module Sortability
44
44
  :add_index, table, [ :container_id, :pos ], options.except(:on, :scope)
45
45
  )
46
46
 
47
- migration.add_sortable_index table, options
47
+ migration.add_sortable_index table, **options
48
48
  end
49
49
  end
50
50
  end
data/spec/rails_helper.rb CHANGED
@@ -3,7 +3,6 @@ ENV["RAILS_ENV"] ||= 'test'
3
3
  require 'spec_helper'
4
4
  require File.expand_path("../dummy/config/environment", __FILE__)
5
5
  require 'rspec/rails'
6
- require 'rspec/autorun'
7
6
  # Add additional requires below this line. Rails is not loaded until this point!
8
7
 
9
8
  # Requires supporting ruby files with custom matchers and macros, etc, in
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sortability
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dante Soares
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-08-14 00:00:00.000000000 Z
12
+ date: 2024-12-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -141,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
141
141
  - !ruby/object:Gem::Version
142
142
  version: '0'
143
143
  requirements: []
144
- rubygems_version: 3.5.17
144
+ rubygems_version: 3.5.21
145
145
  signing_key:
146
146
  specification_version: 4
147
147
  summary: Rails gem that provides easy to use ordered records