paginated_table 0.0.3 → 0.0.4
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.
- data/lib/paginated_table/controller_helpers.rb +4 -5
- data/lib/paginated_table/page.rb +2 -1
- data/lib/paginated_table/version.rb +1 -1
- data/lib/paginated_table/view_helpers.rb +1 -2
- data/test/dummy/app/controllers/data_controller.rb +3 -3
- data/test/dummy/log/test.log +5883 -0
- data/test/units/controller_helpers_test.rb +7 -8
- data/test/units/page_test.rb +13 -2
- data/test/units/view_helpers_test.rb +2 -3
- metadata +3 -3
@@ -10,33 +10,32 @@ module PaginatedTable
|
|
10
10
|
}
|
11
11
|
|
12
12
|
describe "#paginated_table" do
|
13
|
+
let(:name) { "collection_name" }
|
13
14
|
let(:collection) { stub("collection") }
|
14
|
-
let(:tables) { { "collection_name" => collection } }
|
15
15
|
let(:page) { stub("page") }
|
16
16
|
let(:data) { stub("data") }
|
17
17
|
let(:data_page) { stub("data_page", :data => data, :page => page) }
|
18
18
|
|
19
19
|
before do
|
20
|
-
PageParams.stubs(:
|
20
|
+
PageParams.stubs(:create_page).with(params, {}).returns(page)
|
21
21
|
DataPage.stubs(:new).with(collection, page).returns(data_page)
|
22
22
|
end
|
23
23
|
|
24
24
|
it "sets an instance variable on the controller with the data page" do
|
25
|
-
controller.paginated_table(
|
26
|
-
controller.instance_variable_get("
|
25
|
+
controller.paginated_table(name, collection)
|
26
|
+
controller.instance_variable_get("@#{name}").must_equal data_page
|
27
27
|
end
|
28
28
|
|
29
29
|
it "renders the named partial without layout if request is xhr?" do
|
30
30
|
request.stubs(:xhr? => true)
|
31
|
-
controller.expects(:render).
|
32
|
-
|
33
|
-
controller.paginated_table(tables)
|
31
|
+
controller.expects(:render).with(:partial => name, :layout => false)
|
32
|
+
controller.paginated_table(name, collection)
|
34
33
|
end
|
35
34
|
|
36
35
|
it "does not render if request is not xhr?" do
|
37
36
|
request.stubs(:xhr? => false)
|
38
37
|
controller.expects(:render).never
|
39
|
-
controller.paginated_table(
|
38
|
+
controller.paginated_table(name, collection)
|
40
39
|
end
|
41
40
|
end
|
42
41
|
end
|
data/test/units/page_test.rb
CHANGED
@@ -123,9 +123,9 @@ module PaginatedTable
|
|
123
123
|
end
|
124
124
|
|
125
125
|
describe PageParams do
|
126
|
-
describe ".
|
126
|
+
describe ".create_page" do
|
127
127
|
it "returns a new page created from the request params" do
|
128
|
-
page = PageParams.
|
128
|
+
page = PageParams.create_page(
|
129
129
|
:page => '2',
|
130
130
|
:per_page => '5',
|
131
131
|
:sort_column => 'name',
|
@@ -136,6 +136,17 @@ module PaginatedTable
|
|
136
136
|
page.sort_column.must_equal 'name'
|
137
137
|
page.sort_direction.must_equal 'desc'
|
138
138
|
end
|
139
|
+
|
140
|
+
it "returns a new page created from the request params and the defaults" do
|
141
|
+
page = PageParams.create_page(
|
142
|
+
{ :page => '2', :per_page => '5' },
|
143
|
+
{ :sort_column => 'name', :sort_direction => 'desc' }
|
144
|
+
)
|
145
|
+
page.number.must_equal 2
|
146
|
+
page.rows.must_equal 5
|
147
|
+
page.sort_column.must_equal 'name'
|
148
|
+
page.sort_direction.must_equal 'desc'
|
149
|
+
end
|
139
150
|
end
|
140
151
|
|
141
152
|
describe ".to_params" do
|
@@ -9,15 +9,14 @@ module PaginatedTable
|
|
9
9
|
view.stubs("params" => params)
|
10
10
|
view
|
11
11
|
}
|
12
|
-
let(:
|
12
|
+
let(:page) { stub("page") }
|
13
|
+
let(:data_page) { stub("data_page", :page => page) }
|
13
14
|
let(:description_block) { lambda {} }
|
14
15
|
|
15
16
|
describe "#paginated_table" do
|
16
17
|
it "renders a table" do
|
17
18
|
table_description = stub("table_description")
|
18
19
|
TableDescription.stubs("new").with(description_block).returns(table_description)
|
19
|
-
page = stub("page")
|
20
|
-
PageParams.stubs("create_page_from_params").with(params).returns(page)
|
21
20
|
link_renderer = stub("link_renderer")
|
22
21
|
LinkRenderer.stubs("new").with(page).returns(link_renderer)
|
23
22
|
table_renderer = stub("table_renderer")
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paginated_table
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Donald Ball
|