sorting_table_for 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.mdown +6 -0
- data/MIT-LICENSE +1 -1
- data/README.mdown +7 -7
- data/Rakefile +32 -8
- data/lib/sorting_table_for/format_cell.rb +1 -5
- data/lib/sorting_table_for/tools.rb +0 -8
- data/lib/sorting_table_for/version.rb +3 -0
- data/spec/dummy/README.rdoc +261 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +59 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +67 -0
- data/spec/dummy/config/environments/test.rb +37 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +58 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/fixtures/sorting_table_for_user.rb +4 -10
- data/spec/helpers/builder_spec.rb +13 -13
- data/spec/helpers/caption_spec.rb +19 -19
- data/spec/helpers/cell_value_spec.rb +23 -23
- data/spec/helpers/column_spec.rb +81 -79
- data/spec/helpers/footer_spec.rb +46 -46
- data/spec/helpers/header_spec.rb +74 -84
- data/spec/locales/{test_rails3.yml → test_rails.yml} +0 -0
- data/spec/spec_helper.rb +10 -45
- metadata +120 -12
- data/spec/locales/test.yml +0 -104
data/spec/helpers/footer_spec.rb
CHANGED
@@ -8,7 +8,7 @@ include SortingTableForSpecHelper
|
|
8
8
|
describe SortingTableFor, :type => :helper do
|
9
9
|
|
10
10
|
before :all do
|
11
|
-
|
11
|
+
routes_rails
|
12
12
|
end
|
13
13
|
|
14
14
|
before :each do
|
@@ -22,7 +22,7 @@ describe SortingTableFor, :type => :helper do
|
|
22
22
|
it "should set nothing" do
|
23
23
|
helper.sorting_table_for(@users) do |table|
|
24
24
|
html = table.footers
|
25
|
-
html.should_not
|
25
|
+
html.should_not have_selector("tfoot")
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -33,50 +33,50 @@ describe SortingTableFor, :type => :helper do
|
|
33
33
|
it "should set a footer with argument" do
|
34
34
|
helper.sorting_table_for(@users) do |table|
|
35
35
|
html = table.footers 'hello'
|
36
|
-
html.should
|
37
|
-
html.should
|
38
|
-
html.should
|
36
|
+
html.should have_selector("tfoot", :count => 1)
|
37
|
+
html.should have_selector("tr", :count => 1)
|
38
|
+
html.should have_selector("td", :count => 1)
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
42
|
it "should set a footer with multiple arguments" do
|
43
43
|
helper.sorting_table_for(@users) do |table|
|
44
44
|
html = table.footers 'hello', 'hi', 'footer'
|
45
|
-
html.should
|
46
|
-
html.should
|
47
|
-
html.should
|
45
|
+
html.should have_selector("tfoot", :count => 1)
|
46
|
+
html.should have_selector("tr", :count => 1)
|
47
|
+
html.should have_selector("td", :count => 3)
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
51
|
it "should set i18n" do
|
52
52
|
helper.sorting_table_for(@users) do |table|
|
53
53
|
html = table.footers :username
|
54
|
-
html.should
|
54
|
+
html.should have_selector('td', :content => 'UserFoot')
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
58
|
it "should set i18n for multiple arguments" do
|
59
59
|
helper.sorting_table_for(@users) do |table|
|
60
60
|
html = table.footers :username, :price
|
61
|
-
html.should
|
62
|
-
html.should
|
61
|
+
html.should have_selector('td:nth-child(1)', :content => 'UserFoot')
|
62
|
+
html.should have_selector('td:nth-child(2)', :content => 'PriceFoot')
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
66
|
it "should works with colspan" do
|
67
67
|
helper.sorting_table_for(@users) do |table|
|
68
68
|
html = table.footers :username, :colspan => 5
|
69
|
-
html.should
|
69
|
+
html.should have_selector('td[colspan="5"]')
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
73
|
it "should be customize with html" do
|
74
74
|
table_html = helper.sorting_table_for(@users, :html => { :class => 'table_class', :id => 'table_id' }) do |table|
|
75
75
|
html = table.footers :username, :html => { :class => 'header_class', :id => 'header_id' }
|
76
|
-
html.should
|
76
|
+
html.should have_selector("tr[class=header_class][id=header_id]")
|
77
77
|
end
|
78
78
|
helper.output_buffer.concat(table_html)
|
79
|
-
helper.output_buffer.should
|
79
|
+
helper.output_buffer.should have_selector("table[class='table_class sorting_table_for'][id=table_id]")
|
80
80
|
end
|
81
81
|
|
82
82
|
end
|
@@ -88,9 +88,9 @@ describe SortingTableFor, :type => :helper do
|
|
88
88
|
html = table.footers do
|
89
89
|
table.footer 'hello'
|
90
90
|
end
|
91
|
-
html.should
|
92
|
-
html.should
|
93
|
-
html.should
|
91
|
+
html.should have_selector("tfoot", :count => 1)
|
92
|
+
html.should have_selector("tr", :count => 1)
|
93
|
+
html.should have_selector("td", :count => 1)
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
@@ -101,9 +101,9 @@ describe SortingTableFor, :type => :helper do
|
|
101
101
|
table.footer 'hi'
|
102
102
|
table.footer 'footer'
|
103
103
|
end
|
104
|
-
html.should
|
105
|
-
html.should
|
106
|
-
html.should
|
104
|
+
html.should have_selector("tfoot", :count => 1)
|
105
|
+
html.should have_selector("tr", :count => 1)
|
106
|
+
html.should have_selector("td", :count => 3)
|
107
107
|
end
|
108
108
|
end
|
109
109
|
|
@@ -112,7 +112,7 @@ describe SortingTableFor, :type => :helper do
|
|
112
112
|
html = table.footers do
|
113
113
|
table.footer :username
|
114
114
|
end
|
115
|
-
html.should
|
115
|
+
html.should have_selector('td', :content => 'UserFoot')
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
@@ -122,8 +122,8 @@ describe SortingTableFor, :type => :helper do
|
|
122
122
|
table.footer :username
|
123
123
|
table.footer :price
|
124
124
|
end
|
125
|
-
html.should
|
126
|
-
html.should
|
125
|
+
html.should have_selector('td:nth-child(1)', :content => 'UserFoot')
|
126
|
+
html.should have_selector('td:nth-child(2)', :content => 'PriceFoot')
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
@@ -132,7 +132,7 @@ describe SortingTableFor, :type => :helper do
|
|
132
132
|
html = table.footers do
|
133
133
|
table.footer :username, :colspan => 5
|
134
134
|
end
|
135
|
-
html.should
|
135
|
+
html.should have_selector('td[colspan="5"]')
|
136
136
|
end
|
137
137
|
end
|
138
138
|
|
@@ -143,13 +143,13 @@ describe SortingTableFor, :type => :helper do
|
|
143
143
|
table.footer :firstname, :html => { :class => 'cell_2_class', :id => 'cell_2_id', :title => 'hello_2' }
|
144
144
|
table.footer 'hello', :html => { :class => 'cell_3_class', :id => 'cell_3_id', :title => 'hello_3' }
|
145
145
|
end
|
146
|
-
html.should
|
147
|
-
html.should
|
148
|
-
html.should
|
149
|
-
html.should
|
146
|
+
html.should have_selector("tr[class=header_class][id=header_id]")
|
147
|
+
html.should have_selector("td:nth-child(1)[class='cell_1_class'][id=cell_1_id][title=hello_1]")
|
148
|
+
html.should have_selector("td:nth-child(2)[class='cell_2_class'][id=cell_2_id][title=hello_2]")
|
149
|
+
html.should have_selector("td:nth-child(3)[class=cell_3_class][id=cell_3_id][title=hello_3]")
|
150
150
|
end
|
151
151
|
helper.output_buffer.concat(table_html)
|
152
|
-
helper.output_buffer.should
|
152
|
+
helper.output_buffer.should have_selector("table[class='table_class sorting_table_for'][id=table_id]")
|
153
153
|
end
|
154
154
|
|
155
155
|
end
|
@@ -163,9 +163,9 @@ describe SortingTableFor, :type => :helper do
|
|
163
163
|
'hello'
|
164
164
|
end
|
165
165
|
end
|
166
|
-
html.should
|
167
|
-
html.should
|
168
|
-
html.should
|
166
|
+
html.should have_selector("tfoot", :count => 1)
|
167
|
+
html.should have_selector("tr", :count => 1)
|
168
|
+
html.should have_selector("td", :count => 1)
|
169
169
|
end
|
170
170
|
end
|
171
171
|
|
@@ -182,9 +182,9 @@ describe SortingTableFor, :type => :helper do
|
|
182
182
|
'footer'
|
183
183
|
end
|
184
184
|
end
|
185
|
-
html.should
|
186
|
-
html.should
|
187
|
-
html.should
|
185
|
+
html.should have_selector("tfoot", :count => 1)
|
186
|
+
html.should have_selector("tr", :count => 1)
|
187
|
+
html.should have_selector("td", :count => 3)
|
188
188
|
end
|
189
189
|
end
|
190
190
|
|
@@ -195,7 +195,7 @@ describe SortingTableFor, :type => :helper do
|
|
195
195
|
:username
|
196
196
|
end
|
197
197
|
end
|
198
|
-
html.should_not
|
198
|
+
html.should_not have_selector('td', :content => 'UserFoot')
|
199
199
|
end
|
200
200
|
end
|
201
201
|
|
@@ -209,8 +209,8 @@ describe SortingTableFor, :type => :helper do
|
|
209
209
|
:price
|
210
210
|
end
|
211
211
|
end
|
212
|
-
html.should_not
|
213
|
-
html.should_not
|
212
|
+
html.should_not have_selector('td:nth-child(1)', :content => 'UserFoot')
|
213
|
+
html.should_not have_selector('td:nth-child(2)', :content => 'PriceFoot')
|
214
214
|
end
|
215
215
|
end
|
216
216
|
|
@@ -221,7 +221,7 @@ describe SortingTableFor, :type => :helper do
|
|
221
221
|
:username
|
222
222
|
end
|
223
223
|
end
|
224
|
-
html.should
|
224
|
+
html.should have_selector('td[colspan="5"]')
|
225
225
|
end
|
226
226
|
end
|
227
227
|
|
@@ -238,13 +238,13 @@ describe SortingTableFor, :type => :helper do
|
|
238
238
|
'hello'
|
239
239
|
end
|
240
240
|
end
|
241
|
-
html.should
|
242
|
-
html.should
|
243
|
-
html.should
|
244
|
-
html.should
|
241
|
+
html.should have_selector("tr[class=header_class][id=header_id]")
|
242
|
+
html.should have_selector("td:nth-child(1)[class='cell_1_class'][id=cell_1_id][title=hello_1]")
|
243
|
+
html.should have_selector("td:nth-child(2)[class='cell_2_class'][id=cell_2_id][title=hello_2]")
|
244
|
+
html.should have_selector("td:nth-child(3)[class=cell_3_class][id=cell_3_id][title=hello_3]")
|
245
245
|
end
|
246
246
|
helper.output_buffer.concat(table_html)
|
247
|
-
helper.output_buffer.should
|
247
|
+
helper.output_buffer.should have_selector("table[class='table_class sorting_table_for'][id=table_id]")
|
248
248
|
end
|
249
249
|
|
250
250
|
end
|
@@ -260,8 +260,8 @@ describe SortingTableFor, :type => :helper do
|
|
260
260
|
SortingTableFor::TableBuilder.i18n_add_footer_action_scope = :header
|
261
261
|
helper.sorting_table_for(@users) do |table|
|
262
262
|
html = table.footers :username, :price
|
263
|
-
html.should
|
264
|
-
html.should
|
263
|
+
html.should have_selector('td:nth-child(1)', :content => 'Usernames')
|
264
|
+
html.should have_selector('td:nth-child(2)', :content => 'Prices')
|
265
265
|
end
|
266
266
|
end
|
267
267
|
|
data/spec/helpers/header_spec.rb
CHANGED
@@ -8,10 +8,11 @@ include SortingTableForSpecHelper
|
|
8
8
|
describe SortingTableFor, :type => :helper do
|
9
9
|
|
10
10
|
before :all do
|
11
|
-
|
11
|
+
routes_rails
|
12
12
|
end
|
13
13
|
|
14
14
|
before :each do
|
15
|
+
SortingTableFor::TableBuilder.default_actions = [:edit, :delete]
|
15
16
|
@users = SortingTableForUser.all
|
16
17
|
helper.stub!(:params).and_return({ :controller => 'sorting_table_for_users', :action => 'index' })
|
17
18
|
helper.output_buffer = ''
|
@@ -24,44 +25,44 @@ describe SortingTableFor, :type => :helper do
|
|
24
25
|
it "should works" do
|
25
26
|
helper.sorting_table_for(@users) do |table|
|
26
27
|
html = table.headers
|
27
|
-
html.should
|
28
|
-
html.should
|
29
|
-
html.should
|
28
|
+
html.should have_selector("thead", :count => 1)
|
29
|
+
html.should have_selector("tr", :count => 1)
|
30
|
+
html.should have_selector("th", :count => 11)
|
30
31
|
end
|
31
32
|
end
|
32
33
|
|
33
34
|
it "should add sorting class on th" do
|
34
35
|
helper.sorting_table_for(@users) do |table|
|
35
|
-
table.headers.should
|
36
|
+
table.headers.should have_selector("th[class='cur-sort-not']", :count => 9)
|
36
37
|
end
|
37
38
|
end
|
38
39
|
|
39
40
|
it "should have link for sorting" do
|
40
41
|
helper.sorting_table_for(@users) do |table|
|
41
|
-
table.headers.should
|
42
|
+
table.headers.should have_selector("a", :count => 9)
|
42
43
|
end
|
43
44
|
end
|
44
45
|
|
45
46
|
it "should not sort" do
|
46
47
|
helper.sorting_table_for(@users, :sort => false) do |table|
|
47
|
-
table.headers.should_not
|
48
|
-
table.headers.should_not
|
48
|
+
table.headers.should_not have_selector("th[class='cur-sort-not']")
|
49
|
+
table.headers.should_not have_selector("a")
|
49
50
|
end
|
50
51
|
end
|
51
52
|
|
52
53
|
it "should be customize with html" do
|
53
54
|
table_html = helper.sorting_table_for(@users, :html => { :class => 'table_class', :id => 'table_id' }) do |table|
|
54
55
|
html = table.headers(:html => { :class => 'header_class', :id => 'header_id' })
|
55
|
-
html.should
|
56
|
+
html.should have_selector("tr[class=header_class][id=header_id]")
|
56
57
|
end
|
57
58
|
helper.output_buffer.concat(table_html)
|
58
|
-
helper.output_buffer.should
|
59
|
+
helper.output_buffer.should have_selector("table[class='table_class sorting_table_for'][id=table_id]")
|
59
60
|
end
|
60
61
|
|
61
62
|
it "should have option colspan" do
|
62
63
|
table_html = helper.sorting_table_for(@users) do |table|
|
63
64
|
html = table.headers :colspan => 5
|
64
|
-
html.should
|
65
|
+
html.should have_selector('th[colspan="5"]', :count => SortingTableForUser.content_columns.size)
|
65
66
|
end
|
66
67
|
end
|
67
68
|
|
@@ -71,58 +72,58 @@ describe SortingTableFor, :type => :helper do
|
|
71
72
|
|
72
73
|
it "should choose one column" do
|
73
74
|
helper.sorting_table_for(@users) do |table|
|
74
|
-
table.headers(:username).should
|
75
|
+
table.headers(:username).should have_selector("th", :count => 1)
|
75
76
|
end
|
76
77
|
end
|
77
78
|
|
78
79
|
it "should choose multi columns" do
|
79
80
|
helper.sorting_table_for(@users) do |table|
|
80
|
-
table.headers(:username, :price).should
|
81
|
+
table.headers(:username, :price).should have_selector("th", :count => 2)
|
81
82
|
end
|
82
83
|
end
|
83
84
|
|
84
85
|
it "should choose multi columns and one action" do
|
85
86
|
helper.sorting_table_for(@users) do |table|
|
86
|
-
table.headers(:username, :price, :actions => :edit).should
|
87
|
+
table.headers(:username, :price, :actions => :edit).should have_selector("th", :count => 3)
|
87
88
|
end
|
88
89
|
end
|
89
90
|
|
90
91
|
it "should choose multi columns and actions" do
|
91
92
|
helper.sorting_table_for(@users) do |table|
|
92
|
-
table.headers(:username, :price, :actions => [:edit, :edit_password]).should
|
93
|
+
table.headers(:username, :price, :actions => [:edit, :edit_password]).should have_selector("th", :count => 4)
|
93
94
|
end
|
94
95
|
end
|
95
96
|
|
96
97
|
it "should works with non symbol field" do
|
97
98
|
helper.sorting_table_for(@users) do |table|
|
98
99
|
html = table.headers(:username, 'test', image_tag('rails.png'))
|
99
|
-
html.should
|
100
|
-
html.should
|
101
|
-
html.should
|
100
|
+
html.should have_selector("th", :count => 3)
|
101
|
+
html.should have_selector("th:nth-child(2)", :content => 'test')
|
102
|
+
html.should have_selector("th:nth-child(3) img")
|
102
103
|
end
|
103
104
|
end
|
104
105
|
|
105
106
|
it "should works with non key symbol" do
|
106
107
|
helper.sorting_table_for(@users) do |table|
|
107
|
-
table.headers(:username, :test).should
|
108
|
+
table.headers(:username, :test).should have_selector("th", :count => 2)
|
108
109
|
end
|
109
110
|
end
|
110
111
|
|
111
112
|
it "should works with i18n for symbol" do
|
112
113
|
helper.sorting_table_for(@users) do |table|
|
113
114
|
html = table.headers(:username, :firstname, 'hello', :my_fake, :actions => :edit)
|
114
|
-
html.should
|
115
|
-
html.should
|
116
|
-
html.should
|
117
|
-
html.should
|
118
|
-
html.should
|
115
|
+
html.should have_selector("th:nth-child(1)", :content => 'Usernames')
|
116
|
+
html.should have_selector("th:nth-child(2)", :content => 'Firstnames')
|
117
|
+
html.should have_selector("th:nth-child(3)", :content => 'hello')
|
118
|
+
html.should have_selector("th:nth-child(4)", :content => 'Hello fake')
|
119
|
+
html.should have_selector("th:nth-child(5)", :content => 'Edit users')
|
119
120
|
end
|
120
121
|
end
|
121
122
|
|
122
123
|
it "should have option colspan" do
|
123
124
|
table_html = helper.sorting_table_for(@users) do |table|
|
124
125
|
html = table.headers :username, :colspan => 5
|
125
|
-
html.should
|
126
|
+
html.should have_selector('th[colspan="5"]', :count => 1)
|
126
127
|
end
|
127
128
|
end
|
128
129
|
|
@@ -135,9 +136,9 @@ describe SortingTableFor, :type => :helper do
|
|
135
136
|
html = table.headers do
|
136
137
|
table.header(:username)
|
137
138
|
end
|
138
|
-
html.should
|
139
|
-
html.should
|
140
|
-
html.should
|
139
|
+
html.should have_selector("thead", :count => 1)
|
140
|
+
html.should have_selector("tr", :count => 1)
|
141
|
+
html.should have_selector("th", :count => 1)
|
141
142
|
end
|
142
143
|
end
|
143
144
|
|
@@ -150,11 +151,11 @@ describe SortingTableFor, :type => :helper do
|
|
150
151
|
table.header image_tag('rails.png')
|
151
152
|
table.header I18n.t('my_test', :scope => [:fake_scope])
|
152
153
|
end
|
153
|
-
html.should
|
154
|
-
html.should
|
155
|
-
html.should
|
156
|
-
html.should
|
157
|
-
html.should
|
154
|
+
html.should have_selector("th", :count => 5)
|
155
|
+
html.should have_selector("th[class=cur-sort-not]", :count => 2)
|
156
|
+
html.should have_selector("th:nth-child(3)", :content => 'test')
|
157
|
+
html.should have_selector("th:nth-child(4) img")
|
158
|
+
html.should have_selector('th:nth-child(5)', :content => 'Hello')
|
158
159
|
end
|
159
160
|
end
|
160
161
|
|
@@ -165,13 +166,13 @@ describe SortingTableFor, :type => :helper do
|
|
165
166
|
table.header :firstname, :html => { :class => 'cell_2_class', :id => 'cell_2_id', :title => 'hello_2' }
|
166
167
|
table.header 'hello', :html => { :class => 'cell_3_class', :id => 'cell_3_id', :title => 'hello_3' }
|
167
168
|
end
|
168
|
-
html.should
|
169
|
-
html.should
|
170
|
-
html.should
|
171
|
-
html.should
|
169
|
+
html.should have_selector("tr[class=header_class][id=header_id]")
|
170
|
+
html.should have_selector("th:nth-child(1)[class='cell_1_class cur-sort-not'][id=cell_1_id][title=hello_1]")
|
171
|
+
html.should have_selector("th:nth-child(2)[class='cell_2_class cur-sort-not'][id=cell_2_id][title=hello_2]")
|
172
|
+
html.should have_selector("th:nth-child(3)[class=cell_3_class][id=cell_3_id][title=hello_3]")
|
172
173
|
end
|
173
174
|
helper.output_buffer.concat(table_html)
|
174
|
-
helper.output_buffer.should
|
175
|
+
helper.output_buffer.should have_selector("table[class='table_class sorting_table_for'][id=table_id]")
|
175
176
|
end
|
176
177
|
|
177
178
|
it "should works with i18n for symbol" do
|
@@ -183,11 +184,11 @@ describe SortingTableFor, :type => :helper do
|
|
183
184
|
table.header :my_fake
|
184
185
|
table.header :action => :edit
|
185
186
|
end
|
186
|
-
html.should
|
187
|
-
html.should
|
188
|
-
html.should
|
189
|
-
html.should
|
190
|
-
html.should
|
187
|
+
html.should have_selector("th:nth-child(1)", :content => 'Usernames')
|
188
|
+
html.should have_selector("th:nth-child(2)", :content => 'Firstnames')
|
189
|
+
html.should have_selector("th:nth-child(3)", :content => 'hello')
|
190
|
+
html.should have_selector("th:nth-child(4)", :content => 'Hello fake')
|
191
|
+
html.should have_selector("th:nth-child(5)", :content => 'Edit users')
|
191
192
|
end
|
192
193
|
end
|
193
194
|
|
@@ -197,7 +198,7 @@ describe SortingTableFor, :type => :helper do
|
|
197
198
|
table.header :username
|
198
199
|
table.header :price
|
199
200
|
end
|
200
|
-
html.should_not
|
201
|
+
html.should_not have_selector("th[class=cur-sort-not]")
|
201
202
|
end
|
202
203
|
end
|
203
204
|
|
@@ -207,8 +208,8 @@ describe SortingTableFor, :type => :helper do
|
|
207
208
|
table.header :username, :sort => true
|
208
209
|
table.header :price, :sort => false
|
209
210
|
end
|
210
|
-
html.should
|
211
|
-
html.should_not
|
211
|
+
html.should have_selector("th:nth-child(1)[class=cur-sort-not]")
|
212
|
+
html.should_not have_selector("th:nth-child(2)[class=cur-sort-not]")
|
212
213
|
end
|
213
214
|
end
|
214
215
|
|
@@ -218,8 +219,8 @@ describe SortingTableFor, :type => :helper do
|
|
218
219
|
table.header :username, :sort => true
|
219
220
|
table.header :price, :sort => false
|
220
221
|
end
|
221
|
-
html.should
|
222
|
-
html.should_not
|
222
|
+
html.should have_selector("th:nth-child(1)[class=cur-sort-not]")
|
223
|
+
html.should_not have_selector("th:nth-child(2)[class=cur-sort-not]")
|
223
224
|
end
|
224
225
|
end
|
225
226
|
|
@@ -228,8 +229,8 @@ describe SortingTableFor, :type => :helper do
|
|
228
229
|
html = table.headers do
|
229
230
|
table.header 'my name', :sort_as => :username
|
230
231
|
end
|
231
|
-
html.should
|
232
|
-
html.should
|
232
|
+
html.should have_selector("th:nth-child(1)", :content => 'my name')
|
233
|
+
html.should have_selector("th:nth-child(1)[class=cur-sort-not]")
|
233
234
|
end
|
234
235
|
end
|
235
236
|
|
@@ -239,9 +240,9 @@ describe SortingTableFor, :type => :helper do
|
|
239
240
|
table.header 'my name', :sort_as => :username, :sort => true
|
240
241
|
table.header :price
|
241
242
|
end
|
242
|
-
html.should
|
243
|
-
html.should
|
244
|
-
html.should_not
|
243
|
+
html.should have_selector("th:nth-child(1)", :content => 'my name')
|
244
|
+
html.should have_selector("th:nth-child(1)[class=cur-sort-not]")
|
245
|
+
html.should_not have_selector("th:nth-child(2)[class=cur-sort-not]")
|
245
246
|
end
|
246
247
|
end
|
247
248
|
|
@@ -251,8 +252,8 @@ describe SortingTableFor, :type => :helper do
|
|
251
252
|
table.header :username, :colspan => 5
|
252
253
|
table.header :price, :colspan => 3
|
253
254
|
end
|
254
|
-
html.should
|
255
|
-
html.should
|
255
|
+
html.should have_selector('th[colspan="5"]', :count => 1)
|
256
|
+
html.should have_selector('th[colspan="3"]', :count => 1)
|
256
257
|
end
|
257
258
|
end
|
258
259
|
|
@@ -270,7 +271,7 @@ describe SortingTableFor, :type => :helper do
|
|
270
271
|
:firstname
|
271
272
|
end
|
272
273
|
end
|
273
|
-
html.should
|
274
|
+
html.should have_selector("th", :count => 2)
|
274
275
|
end
|
275
276
|
end
|
276
277
|
|
@@ -281,7 +282,7 @@ describe SortingTableFor, :type => :helper do
|
|
281
282
|
:username
|
282
283
|
end
|
283
284
|
end
|
284
|
-
html.should_not
|
285
|
+
html.should_not have_selector("a")
|
285
286
|
end
|
286
287
|
end
|
287
288
|
|
@@ -292,7 +293,7 @@ describe SortingTableFor, :type => :helper do
|
|
292
293
|
:username
|
293
294
|
end
|
294
295
|
end
|
295
|
-
html.should_not
|
296
|
+
html.should_not have_selector("th[class=cur-sort-not]")
|
296
297
|
end
|
297
298
|
end
|
298
299
|
|
@@ -309,13 +310,9 @@ describe SortingTableFor, :type => :helper do
|
|
309
310
|
I18n.t(:my_test, :scope => :fake_scope)
|
310
311
|
end
|
311
312
|
end
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
html.should have_comp_tag("th:nth-child(1)", :text => 'username')
|
316
|
-
end
|
317
|
-
html.should have_comp_tag("th:nth-child(2)", :text => 'firstname')
|
318
|
-
html.should have_comp_tag("th:nth-child(3)", :text => 'Hello')
|
313
|
+
html.should have_selector("th:nth-child(1)", :content => '')
|
314
|
+
html.should have_selector("th:nth-child(2)", :content => 'firstname')
|
315
|
+
html.should have_selector("th:nth-child(3)", :content => 'Hello')
|
319
316
|
end
|
320
317
|
end
|
321
318
|
|
@@ -332,13 +329,13 @@ describe SortingTableFor, :type => :helper do
|
|
332
329
|
'hello'
|
333
330
|
end
|
334
331
|
end
|
335
|
-
html.should
|
336
|
-
html.should
|
337
|
-
html.should
|
338
|
-
html.should
|
332
|
+
html.should have_selector("tr[class=header_class][id=header_id]")
|
333
|
+
html.should have_selector("th:nth-child(1)[class='cell_1_class'][id=cell_1_id][title=hello_1]")
|
334
|
+
html.should have_selector("th:nth-child(2)[class='cell_2_class'][id=cell_2_id][title=hello_2]")
|
335
|
+
html.should have_selector("th:nth-child(3)[class=cell_3_class][id=cell_3_id][title=hello_3]")
|
339
336
|
end
|
340
337
|
helper.output_buffer.concat(table_html)
|
341
|
-
helper.output_buffer.should
|
338
|
+
helper.output_buffer.should have_selector("table[class='table_class sorting_table_for'][id=table_id]")
|
342
339
|
end
|
343
340
|
|
344
341
|
it "should have option colspan" do
|
@@ -351,8 +348,8 @@ describe SortingTableFor, :type => :helper do
|
|
351
348
|
'my_colspan_2'
|
352
349
|
end
|
353
350
|
end
|
354
|
-
html.should
|
355
|
-
html.should
|
351
|
+
html.should have_selector('th[colspan="5"]', :count => 1)
|
352
|
+
html.should have_selector('th[colspan="3"]', :count => 1)
|
356
353
|
end
|
357
354
|
end
|
358
355
|
|
@@ -371,28 +368,21 @@ describe SortingTableFor, :type => :helper do
|
|
371
368
|
it "should edit reserved columns" do
|
372
369
|
SortingTableFor::TableBuilder.reserved_columns = [:id, :firstname, :lastname, :position, :salary, :price, :active, :created_at, :updated_at]
|
373
370
|
helper.sorting_table_for(@users) do |table|
|
374
|
-
table.headers.should
|
371
|
+
table.headers.should have_selector("th", :count => 3)
|
375
372
|
end
|
376
373
|
end
|
377
374
|
|
378
375
|
it "should edit params sort table" do
|
379
|
-
pending("Check if the link is edit")
|
380
376
|
SortingTableFor::TableBuilder.params_sort_table = :hello_table
|
381
377
|
helper.sorting_table_for(@users) do |table|
|
378
|
+
table.headers.include?("<a href=\"/sorting_table_for_users?hello_table%5Busername%5D=asc\">").should be_true
|
382
379
|
end
|
383
380
|
end
|
384
381
|
|
385
382
|
it "should edit default actions" do
|
386
383
|
SortingTableFor::TableBuilder.default_actions = [:show, :edit_password, :edit, :delete]
|
387
384
|
helper.sorting_table_for(@users) do |table|
|
388
|
-
table.headers.should
|
389
|
-
end
|
390
|
-
end
|
391
|
-
|
392
|
-
it "should edit default actions" do
|
393
|
-
pending('check if the link is valid')
|
394
|
-
SortingTableFor::TableBuilder.default_actions = [:show, :edit_password]
|
395
|
-
helper.sorting_table_for(@users) do |table|
|
385
|
+
table.headers.should have_selector("th", :count => SortingTableForUser.column_names.size + 3)
|
396
386
|
end
|
397
387
|
end
|
398
388
|
|
@@ -400,8 +390,8 @@ describe SortingTableFor, :type => :helper do
|
|
400
390
|
SortingTableFor::TableBuilder.i18n_add_header_action_scope = :footer
|
401
391
|
helper.sorting_table_for(@users) do |table|
|
402
392
|
html = table.headers :username, :price
|
403
|
-
html.should
|
404
|
-
html.should
|
393
|
+
html.should have_selector('th:nth-child(1)', :content => 'UserFoot')
|
394
|
+
html.should have_selector('th:nth-child(2)', :content => 'PriceFoot')
|
405
395
|
end
|
406
396
|
end
|
407
397
|
|