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: 5d450654560793ee8c97eecee62988c0a3fdecf5
4
- data.tar.gz: f3b7532e3634887b6d8ce3cab5c61707cac32e69
3
+ metadata.gz: db76dcc9dd75596012bba9f3d3dd4c0afbe11ebb
4
+ data.tar.gz: f612c2f0f9cc036be4f156c1430f8e0919dbf0cf
5
5
  SHA512:
6
- metadata.gz: f240ff897add0bb33a8bb3820b9dbb635cc43a88ae6ed87ea07ae72586368fdb1c1a00b737c760d16ec3344039d6220bed25cf68297ca43af3e5fcae1244ab5a
7
- data.tar.gz: f47e149a85990db0991c1be32dbafad1a5b1e46a7bdb46cab62d40476e32cc5d2a7a064b23b63cc7a13fe3f38d64a062f52e38847c43aaa590f7b46275c98250
6
+ metadata.gz: 1d70c381dff1c8743e3c8a7dc68a96fb53a926ae742c6850044a3b1902c299569c63a66018166ccadd78429bfd87bd255a31913fbbc5e555d1a4c90f4e456118
7
+ data.tar.gz: fc98d2bec5e1f01e3546f0e209d13b65f8bb292487603bee332058820c98dd703b555bdfce86b6775edf8a5644d72277dca177e904fe451ec1cbfa604185feac
@@ -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", "~>3.2"
22
+ gem.add_development_dependency "actionpack", "~>4.0"
23
23
  gem.add_development_dependency "guard-rspec", "~>3.0.1"
24
24
  end
@@ -1,3 +1,3 @@
1
1
  module BasicTableSorter
2
- VERSION = "0.0.2.beta"
2
+ VERSION = "0.0.3.beta"
3
3
  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
- expected_link_params = {table_sort: :title, table_sort_direction: 'desc'}
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({:table_sort => :name, :table_sort_direction => "desc"}, {:class => "selected-column"})
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
- helper.should_receive(:link_to).with({:table_sort => :name, :table_sort_direction => "asc"}, {:class => "selected-column"})
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', {table_sort: :last_name, table_sort_direction: 'asc'})
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
- helper.should_receive(:link_to).with('Name', {table_sort: :last_name, table_sort_direction: 'asc', extra_param: 'extra_param'})
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.2.beta
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-06-11 00:00:00.000000000 Z
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: '3.2'
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: '3.2'
40
+ version: '4.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: guard-rspec
43
43
  requirement: !ruby/object:Gem::Requirement