basic_table_sorter 0.0.2.beta → 0.0.3.beta
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db76dcc9dd75596012bba9f3d3dd4c0afbe11ebb
|
4
|
+
data.tar.gz: f612c2f0f9cc036be4f156c1430f8e0919dbf0cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d70c381dff1c8743e3c8a7dc68a96fb53a926ae742c6850044a3b1902c299569c63a66018166ccadd78429bfd87bd255a31913fbbc5e555d1a4c90f4e456118
|
7
|
+
data.tar.gz: fc98d2bec5e1f01e3546f0e209d13b65f8bb292487603bee332058820c98dd703b555bdfce86b6775edf8a5644d72277dca177e904fe451ec1cbfa604185feac
|
data/basic_table_sorter.gemspec
CHANGED
@@ -19,6 +19,6 @@ Gem::Specification.new do |gem|
|
|
19
19
|
gem.require_paths = ["lib"]
|
20
20
|
|
21
21
|
gem.add_development_dependency "rspec", "~>2.13.0"
|
22
|
-
gem.add_development_dependency "actionpack", "~>
|
22
|
+
gem.add_development_dependency "actionpack", "~>4.0"
|
23
23
|
gem.add_development_dependency "guard-rspec", "~>3.0.1"
|
24
24
|
end
|
@@ -12,11 +12,11 @@ module BasicTableSorter
|
|
12
12
|
|
13
13
|
if column_selected
|
14
14
|
#link_to takes automatically current controller and action from params if missing in arguments
|
15
|
-
link_to link_params, class: 'selected-column' do
|
15
|
+
link_to url_for(link_params), class: 'selected-column' do
|
16
16
|
content_tag(:span, title) + tag(:i, class: icon_class)
|
17
17
|
end
|
18
18
|
else
|
19
|
-
link_to title, link_params
|
19
|
+
link_to title, url_for(link_params)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -6,6 +6,8 @@ describe BasicTableSorter::ViewHelpers do
|
|
6
6
|
helper_class = Class.new
|
7
7
|
helper_class.send(:include, BasicTableSorter::ViewHelpers)
|
8
8
|
helper_class.send(:include, ActionView::Helpers::TagHelper)
|
9
|
+
helper_class.any_instance.stub(:url_for).and_return('url_returned_by_url_for')
|
10
|
+
helper_class.any_instance.stub(:link_to)
|
9
11
|
helper_class.new
|
10
12
|
end
|
11
13
|
|
@@ -17,13 +19,21 @@ describe BasicTableSorter::ViewHelpers do
|
|
17
19
|
helper.stub(:params).and_return({table_sort: 'title'})
|
18
20
|
helper.stub(:table_sort_direction).and_return('asc')
|
19
21
|
|
20
|
-
|
21
|
-
helper.should_receive(:link_to).with(expected_link_params, class: 'selected-column') do |&block|
|
22
|
+
helper.should_receive(:link_to).with('url_returned_by_url_for', class: 'selected-column') do |&block|
|
22
23
|
block.call.should match /<span>Title<\/span><i class="icon-.*" \/>/
|
23
24
|
end
|
24
25
|
helper.sortable(:title, 'Title')
|
25
26
|
end
|
26
27
|
|
28
|
+
|
29
|
+
it 'should call url_for with correct params' do
|
30
|
+
helper.stub(:params).and_return({table_sort: 'title'})
|
31
|
+
helper.stub(:table_sort_direction).and_return('asc')
|
32
|
+
expected_link_params = {table_sort: :title, table_sort_direction: 'desc'}
|
33
|
+
helper.should_receive(:url_for).with(expected_link_params)
|
34
|
+
helper.sortable(:title, 'Title')
|
35
|
+
end
|
36
|
+
|
27
37
|
context 'column sorted asc' do
|
28
38
|
|
29
39
|
before :each do
|
@@ -32,7 +42,7 @@ describe BasicTableSorter::ViewHelpers do
|
|
32
42
|
end
|
33
43
|
|
34
44
|
it 'should have link to sort desc' do
|
35
|
-
helper.should_receive(:link_to).with(
|
45
|
+
helper.should_receive(:link_to).with('url_returned_by_url_for', {:class => "selected-column"})
|
36
46
|
helper.sortable(:name, 'Name')
|
37
47
|
end
|
38
48
|
|
@@ -54,7 +64,8 @@ describe BasicTableSorter::ViewHelpers do
|
|
54
64
|
end
|
55
65
|
|
56
66
|
it 'should have link to sort asc' do
|
57
|
-
|
67
|
+
expected_link_params = {:table_sort => :name, :table_sort_direction => "asc"}
|
68
|
+
helper.should_receive(:link_to).with('url_returned_by_url_for', {:class => "selected-column"})
|
58
69
|
helper.sortable(:name, 'Name')
|
59
70
|
end
|
60
71
|
|
@@ -72,14 +83,22 @@ describe BasicTableSorter::ViewHelpers do
|
|
72
83
|
|
73
84
|
it 'should return link with title' do
|
74
85
|
helper.stub(:params).and_return({table_sort: 'first_name'})
|
75
|
-
helper.should_receive(:link_to).with('Name',
|
86
|
+
helper.should_receive(:link_to).with('Name', 'url_returned_by_url_for')
|
87
|
+
helper.sortable(:last_name, 'Name')
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'should call url_for with correct params' do
|
91
|
+
helper.stub(:params).and_return({table_sort: 'first_name'})
|
92
|
+
expected_params = {table_sort: :last_name, table_sort_direction: 'asc'}
|
93
|
+
helper.should_receive(:url_for).with(expected_params)
|
76
94
|
helper.sortable(:last_name, 'Name')
|
77
95
|
end
|
78
96
|
end
|
79
97
|
|
80
|
-
it 'should merge additional arguments' do
|
98
|
+
it 'should merge additional arguments before calling url for' do
|
81
99
|
helper.stub(:params).and_return({table_sort: 'title'})
|
82
|
-
|
100
|
+
epected_params = {table_sort: :last_name, table_sort_direction: 'asc', extra_param: 'extra_param'}
|
101
|
+
helper.should_receive(:url_for).with(epected_params)
|
83
102
|
helper.sortable(:last_name, 'Name', extra_param: 'extra_param')
|
84
103
|
end
|
85
104
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: basic_table_sorter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3.beta
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Grawunder, Christian Mierich
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '4.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '4.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: guard-rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|