dancroak-sortable_table 0.0.4 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +72 -0
- data/Rakefile +9 -9
- data/VERSION.yml +4 -0
- data/lib/sortable_table/app/controllers/application_controller.rb +15 -47
- data/lib/sortable_table/app/helpers/application_helper.rb +47 -31
- data/lib/sortable_table/test/test_helper.rb +65 -0
- data/lib/sortable_table.rb +1 -0
- data/test/rails_root/Rakefile +10 -0
- data/test/rails_root/app/controllers/application.rb +5 -0
- data/test/rails_root/app/controllers/users_controller.rb +9 -0
- data/test/rails_root/app/helpers/application_helper.rb +3 -0
- data/test/rails_root/app/helpers/users_helper.rb +2 -0
- data/test/rails_root/app/models/user.rb +2 -0
- data/test/rails_root/app/views/layouts/users.html.erb +17 -0
- data/test/rails_root/app/views/users/index.html.erb +19 -0
- data/test/rails_root/config/boot.rb +109 -0
- data/test/rails_root/config/database.yml +19 -0
- data/test/rails_root/config/environment.rb +26 -0
- data/test/rails_root/config/environments/development.rb +17 -0
- data/test/rails_root/config/environments/test.rb +22 -0
- data/test/rails_root/config/initializers/new_rails_defaults.rb +15 -0
- data/test/rails_root/config/routes.rb +6 -0
- data/test/rails_root/db/development.sqlite3 +0 -0
- data/test/rails_root/db/migrate/20080819225020_create_users.rb +15 -0
- data/test/rails_root/db/production.sqlite3 +0 -0
- data/test/rails_root/db/schema.rb +23 -0
- data/test/rails_root/db/test.sqlite3 +0 -0
- data/test/rails_root/log/development.log +2710 -0
- data/test/rails_root/log/production.log +0 -0
- data/test/rails_root/log/server.log +0 -0
- data/test/rails_root/public/404.html +30 -0
- data/test/rails_root/public/422.html +30 -0
- data/test/rails_root/public/500.html +30 -0
- data/test/rails_root/public/dispatch.cgi +10 -0
- data/test/rails_root/public/dispatch.fcgi +24 -0
- data/test/rails_root/public/dispatch.rb +10 -0
- data/test/rails_root/public/favicon.ico +0 -0
- data/test/rails_root/public/images/rails.png +0 -0
- data/test/rails_root/public/images/sort-ascending-arrow.gif +0 -0
- data/test/rails_root/public/images/sort-descending-arrow.gif +0 -0
- data/test/rails_root/public/index.html +274 -0
- data/test/rails_root/public/javascripts/application.js +2 -0
- data/test/rails_root/public/javascripts/controls.js +963 -0
- data/test/rails_root/public/javascripts/dragdrop.js +972 -0
- data/test/rails_root/public/javascripts/effects.js +1120 -0
- data/test/rails_root/public/javascripts/prototype.js +4225 -0
- data/test/rails_root/public/robots.txt +5 -0
- data/test/rails_root/public/stylesheets/scaffold.css +53 -0
- data/test/rails_root/public/stylesheets/sortable.css +10 -0
- data/test/rails_root/script/about +3 -0
- data/test/rails_root/script/console +3 -0
- data/test/rails_root/script/dbconsole +3 -0
- data/test/rails_root/script/destroy +3 -0
- data/test/rails_root/script/generate +3 -0
- data/test/rails_root/script/performance/benchmarker +3 -0
- data/test/rails_root/script/performance/profiler +3 -0
- data/test/rails_root/script/performance/request +3 -0
- data/test/rails_root/script/plugin +3 -0
- data/test/rails_root/script/process/inspector +3 -0
- data/test/rails_root/script/process/reaper +3 -0
- data/test/rails_root/script/process/spawner +3 -0
- data/test/rails_root/script/runner +3 -0
- data/test/rails_root/script/server +3 -0
- data/test/rails_root/test/factories/user_factory.rb +17 -0
- data/test/rails_root/test/functional/users_controller_test.rb +15 -0
- data/test/rails_root/test/test_helper.rb +32 -0
- data/test/rails_root/test/units/helpers/application_helper_test.rb +46 -0
- metadata +220 -4
- data/README.textile +0 -136
- data/TODO.textile +0 -2
@@ -0,0 +1,53 @@
|
|
1
|
+
body { background-color: #fff; color: #333; }
|
2
|
+
|
3
|
+
body, p, ol, ul, td {
|
4
|
+
font-family: verdana, arial, helvetica, sans-serif;
|
5
|
+
font-size: 13px;
|
6
|
+
line-height: 18px;
|
7
|
+
}
|
8
|
+
|
9
|
+
pre {
|
10
|
+
background-color: #eee;
|
11
|
+
padding: 10px;
|
12
|
+
font-size: 11px;
|
13
|
+
}
|
14
|
+
|
15
|
+
a { color: #000; }
|
16
|
+
a:hover { color: #666; }
|
17
|
+
|
18
|
+
.fieldWithErrors {
|
19
|
+
padding: 2px;
|
20
|
+
background-color: red;
|
21
|
+
display: table;
|
22
|
+
}
|
23
|
+
|
24
|
+
#errorExplanation {
|
25
|
+
width: 400px;
|
26
|
+
border: 2px solid red;
|
27
|
+
padding: 7px;
|
28
|
+
padding-bottom: 12px;
|
29
|
+
margin-bottom: 20px;
|
30
|
+
background-color: #f0f0f0;
|
31
|
+
}
|
32
|
+
|
33
|
+
#errorExplanation h2 {
|
34
|
+
text-align: left;
|
35
|
+
font-weight: bold;
|
36
|
+
padding: 5px 5px 5px 15px;
|
37
|
+
font-size: 12px;
|
38
|
+
margin: -7px;
|
39
|
+
background-color: #c00;
|
40
|
+
color: #fff;
|
41
|
+
}
|
42
|
+
|
43
|
+
#errorExplanation p {
|
44
|
+
color: #333;
|
45
|
+
margin-bottom: 0;
|
46
|
+
padding: 5px;
|
47
|
+
}
|
48
|
+
|
49
|
+
#errorExplanation ul li {
|
50
|
+
font-size: 12px;
|
51
|
+
list-style: square;
|
52
|
+
}
|
53
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
Factory.define :user do |user|
|
2
|
+
user.email { Factory.next :email }
|
3
|
+
user.name { Factory.next :name }
|
4
|
+
user.age { Factory.next :age }
|
5
|
+
end
|
6
|
+
|
7
|
+
Factory.sequence :email do |each|
|
8
|
+
"email#{each}@example.com"
|
9
|
+
end
|
10
|
+
|
11
|
+
Factory.sequence :name do |each|
|
12
|
+
"name#{each}"
|
13
|
+
end
|
14
|
+
|
15
|
+
Factory.sequence :age do |each|
|
16
|
+
each
|
17
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
|
3
|
+
class UsersControllerTest < ActionController::TestCase
|
4
|
+
|
5
|
+
context 'GET to index with sort and order params' do
|
6
|
+
setup do
|
7
|
+
2.times { |each| Factory :user }
|
8
|
+
end
|
9
|
+
|
10
|
+
# should_sort_by :name
|
11
|
+
should_sort_by :email # Hash syntax
|
12
|
+
should_sort_by :age
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
ENV["RAILS_ENV"] = "test"
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
|
3
|
+
require 'test_help'
|
4
|
+
require 'rubygems'
|
5
|
+
|
6
|
+
gem 'mocha'
|
7
|
+
gem 'thoughtbot-quietbacktrace'
|
8
|
+
gem 'thoughtbot-shoulda'
|
9
|
+
gem 'thoughtbot-factory_girl'
|
10
|
+
gem 'redgreen'
|
11
|
+
|
12
|
+
require 'mocha'
|
13
|
+
require 'quietbacktrace'
|
14
|
+
require 'shoulda'
|
15
|
+
require 'factory_girl'
|
16
|
+
require 'redgreen'
|
17
|
+
|
18
|
+
Dir[File.join(RAILS_ROOT, 'test', 'factories', '*.rb')].each do |file|
|
19
|
+
require file
|
20
|
+
end
|
21
|
+
|
22
|
+
class Test::Unit::TestCase
|
23
|
+
|
24
|
+
self.backtrace_silencers << :rails_vendor
|
25
|
+
self.backtrace_filters << :rails_root
|
26
|
+
|
27
|
+
self.use_transactional_fixtures = true
|
28
|
+
self.use_instantiated_fixtures = false
|
29
|
+
|
30
|
+
include SortableTable::Test::TestHelper
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# this needs way more tests
|
2
|
+
context 'sortable_table_header' do
|
3
|
+
setup do
|
4
|
+
self.stubs(:params).returns({ :controller => :jobs, :action => :index, :sort => nil, :order => nil })
|
5
|
+
end
|
6
|
+
|
7
|
+
[:name, :sort].each do |param|
|
8
|
+
should "raise an error without default param #{param}" do
|
9
|
+
opts = { :name => 'name', :sort => 'sort' }
|
10
|
+
opts.delete param
|
11
|
+
assert_raise(ArgumentError) do
|
12
|
+
sortable_table_header opts
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'with no params[:sort] or params[:order]' do
|
18
|
+
setup do
|
19
|
+
@html = sortable_table_header(:name => 'Title', :sort => 'title', :title => 'Sort by title')
|
20
|
+
end
|
21
|
+
|
22
|
+
should 'return a table header without a class attribute' do
|
23
|
+
assert @html.include?('<th>')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context "without an :anchor" do
|
28
|
+
setup do
|
29
|
+
@html = sortable_table_header(:name => 'Title', :sort => 'title', :title => 'Sort by title')
|
30
|
+
end
|
31
|
+
|
32
|
+
should 'return a link that contains a url with no anchor' do
|
33
|
+
assert @html.match(/href="[^#]+?"/)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "with an :anchor" do
|
38
|
+
setup do
|
39
|
+
@html = sortable_table_header(:name => 'Title', :sort => 'title', :title => 'Sort by title', :anchor => 'search-results')
|
40
|
+
end
|
41
|
+
|
42
|
+
should 'return a link that contains a url with that anchor' do
|
43
|
+
assert @html.match(/href="[^"]*?#search-results"/)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dancroak-sortable_table
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Croak
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date:
|
14
|
+
date: 2008-10-16 00:00:00 -07:00
|
15
15
|
default_executable:
|
16
16
|
dependencies: []
|
17
17
|
|
@@ -26,16 +26,232 @@ extra_rdoc_files: []
|
|
26
26
|
files:
|
27
27
|
- MIT-LICENSE
|
28
28
|
- Rakefile
|
29
|
-
- README.
|
30
|
-
-
|
29
|
+
- README.markdown
|
30
|
+
- VERSION.yml
|
31
31
|
- lib/sortable_table
|
32
32
|
- lib/sortable_table/app
|
33
33
|
- lib/sortable_table/app/controllers
|
34
34
|
- lib/sortable_table/app/controllers/application_controller.rb
|
35
35
|
- lib/sortable_table/app/helpers
|
36
36
|
- lib/sortable_table/app/helpers/application_helper.rb
|
37
|
+
- lib/sortable_table/test
|
38
|
+
- lib/sortable_table/test/test_helper.rb
|
37
39
|
- lib/sortable_table.rb
|
38
40
|
- rails/init.rb
|
41
|
+
- test/rails_root
|
42
|
+
- test/rails_root/app
|
43
|
+
- test/rails_root/app/controllers
|
44
|
+
- test/rails_root/app/controllers/application.rb
|
45
|
+
- test/rails_root/app/controllers/users_controller.rb
|
46
|
+
- test/rails_root/app/helpers
|
47
|
+
- test/rails_root/app/helpers/application_helper.rb
|
48
|
+
- test/rails_root/app/helpers/users_helper.rb
|
49
|
+
- test/rails_root/app/models
|
50
|
+
- test/rails_root/app/models/user.rb
|
51
|
+
- test/rails_root/app/views
|
52
|
+
- test/rails_root/app/views/layouts
|
53
|
+
- test/rails_root/app/views/layouts/users.html.erb
|
54
|
+
- test/rails_root/app/views/users
|
55
|
+
- test/rails_root/app/views/users/index.html.erb
|
56
|
+
- test/rails_root/config
|
57
|
+
- test/rails_root/config/boot.rb
|
58
|
+
- test/rails_root/config/database.yml
|
59
|
+
- test/rails_root/config/environment.rb
|
60
|
+
- test/rails_root/config/environments
|
61
|
+
- test/rails_root/config/environments/development.rb
|
62
|
+
- test/rails_root/config/environments/test.rb
|
63
|
+
- test/rails_root/config/initializers
|
64
|
+
- test/rails_root/config/initializers/new_rails_defaults.rb
|
65
|
+
- test/rails_root/config/routes.rb
|
66
|
+
- test/rails_root/db
|
67
|
+
- test/rails_root/db/development.sqlite3
|
68
|
+
- test/rails_root/db/migrate
|
69
|
+
- test/rails_root/db/migrate/20080819225020_create_users.rb
|
70
|
+
- test/rails_root/db/production.sqlite3
|
71
|
+
- test/rails_root/db/schema.rb
|
72
|
+
- test/rails_root/db/test.sqlite3
|
73
|
+
- test/rails_root/log
|
74
|
+
- test/rails_root/log/development.log
|
75
|
+
- test/rails_root/log/production.log
|
76
|
+
- test/rails_root/log/server.log
|
77
|
+
- test/rails_root/public
|
78
|
+
- test/rails_root/public/404.html
|
79
|
+
- test/rails_root/public/422.html
|
80
|
+
- test/rails_root/public/500.html
|
81
|
+
- test/rails_root/public/dispatch.cgi
|
82
|
+
- test/rails_root/public/dispatch.fcgi
|
83
|
+
- test/rails_root/public/dispatch.rb
|
84
|
+
- test/rails_root/public/favicon.ico
|
85
|
+
- test/rails_root/public/images
|
86
|
+
- test/rails_root/public/images/rails.png
|
87
|
+
- test/rails_root/public/images/sort-ascending-arrow.gif
|
88
|
+
- test/rails_root/public/images/sort-descending-arrow.gif
|
89
|
+
- test/rails_root/public/index.html
|
90
|
+
- test/rails_root/public/javascripts
|
91
|
+
- test/rails_root/public/javascripts/application.js
|
92
|
+
- test/rails_root/public/javascripts/controls.js
|
93
|
+
- test/rails_root/public/javascripts/dragdrop.js
|
94
|
+
- test/rails_root/public/javascripts/effects.js
|
95
|
+
- test/rails_root/public/javascripts/prototype.js
|
96
|
+
- test/rails_root/public/robots.txt
|
97
|
+
- test/rails_root/public/stylesheets
|
98
|
+
- test/rails_root/public/stylesheets/scaffold.css
|
99
|
+
- test/rails_root/public/stylesheets/sortable.css
|
100
|
+
- test/rails_root/Rakefile
|
101
|
+
- test/rails_root/script
|
102
|
+
- test/rails_root/script/about
|
103
|
+
- test/rails_root/script/console
|
104
|
+
- test/rails_root/script/dbconsole
|
105
|
+
- test/rails_root/script/destroy
|
106
|
+
- test/rails_root/script/generate
|
107
|
+
- test/rails_root/script/performance
|
108
|
+
- test/rails_root/script/performance/benchmarker
|
109
|
+
- test/rails_root/script/performance/profiler
|
110
|
+
- test/rails_root/script/performance/request
|
111
|
+
- test/rails_root/script/plugin
|
112
|
+
- test/rails_root/script/process
|
113
|
+
- test/rails_root/script/process/inspector
|
114
|
+
- test/rails_root/script/process/reaper
|
115
|
+
- test/rails_root/script/process/spawner
|
116
|
+
- test/rails_root/script/runner
|
117
|
+
- test/rails_root/script/server
|
118
|
+
- test/rails_root/test
|
119
|
+
- test/rails_root/test/factories
|
120
|
+
- test/rails_root/test/factories/user_factory.rb
|
121
|
+
- test/rails_root/test/functional
|
122
|
+
- test/rails_root/test/functional/users_controller_test.rb
|
123
|
+
- test/rails_root/test/test_helper.rb
|
124
|
+
- test/rails_root/test/units
|
125
|
+
- test/rails_root/test/units/helpers
|
126
|
+
- test/rails_root/test/units/helpers/application_helper_test.rb
|
127
|
+
- test/rails_root/tmp
|
128
|
+
- test/rails_root/tmp/cache
|
129
|
+
- test/rails_root/tmp/pids
|
130
|
+
- test/rails_root/tmp/sessions
|
131
|
+
- test/rails_root/tmp/sockets
|
132
|
+
- test/rails_root/vendor
|
133
|
+
- test/rails_root/vendor/plugins
|
134
|
+
- test/rails_root/vendor/plugins/shoulda
|
135
|
+
- test/rails_root/vendor/plugins/shoulda/bin
|
136
|
+
- test/rails_root/vendor/plugins/shoulda/bin/convert_to_should_syntax
|
137
|
+
- test/rails_root/vendor/plugins/shoulda/CONTRIBUTION_GUIDELINES.rdoc
|
138
|
+
- test/rails_root/vendor/plugins/shoulda/init.rb
|
139
|
+
- test/rails_root/vendor/plugins/shoulda/lib
|
140
|
+
- test/rails_root/vendor/plugins/shoulda/lib/shoulda
|
141
|
+
- test/rails_root/vendor/plugins/shoulda/lib/shoulda/active_record_helpers.rb
|
142
|
+
- test/rails_root/vendor/plugins/shoulda/lib/shoulda/color.rb
|
143
|
+
- test/rails_root/vendor/plugins/shoulda/lib/shoulda/controller_tests
|
144
|
+
- test/rails_root/vendor/plugins/shoulda/lib/shoulda/controller_tests/controller_tests.rb
|
145
|
+
- test/rails_root/vendor/plugins/shoulda/lib/shoulda/controller_tests/formats
|
146
|
+
- test/rails_root/vendor/plugins/shoulda/lib/shoulda/controller_tests/formats/html.rb
|
147
|
+
- test/rails_root/vendor/plugins/shoulda/lib/shoulda/controller_tests/formats/xml.rb
|
148
|
+
- test/rails_root/vendor/plugins/shoulda/lib/shoulda/gem
|
149
|
+
- test/rails_root/vendor/plugins/shoulda/lib/shoulda/gem/proc_extensions.rb
|
150
|
+
- test/rails_root/vendor/plugins/shoulda/lib/shoulda/gem/shoulda.rb
|
151
|
+
- test/rails_root/vendor/plugins/shoulda/lib/shoulda/general.rb
|
152
|
+
- test/rails_root/vendor/plugins/shoulda/lib/shoulda/private_helpers.rb
|
153
|
+
- test/rails_root/vendor/plugins/shoulda/lib/shoulda.rb
|
154
|
+
- test/rails_root/vendor/plugins/shoulda/MIT-LICENSE
|
155
|
+
- test/rails_root/vendor/plugins/shoulda/Rakefile
|
156
|
+
- test/rails_root/vendor/plugins/shoulda/README.rdoc
|
157
|
+
- test/rails_root/vendor/plugins/shoulda/tasks
|
158
|
+
- test/rails_root/vendor/plugins/shoulda/tasks/list_tests.rake
|
159
|
+
- test/rails_root/vendor/plugins/shoulda/tasks/yaml_to_shoulda.rake
|
160
|
+
- test/rails_root/vendor/plugins/shoulda/test
|
161
|
+
- test/rails_root/vendor/plugins/shoulda/test/fixtures
|
162
|
+
- test/rails_root/vendor/plugins/shoulda/test/fixtures/addresses.yml
|
163
|
+
- test/rails_root/vendor/plugins/shoulda/test/fixtures/posts.yml
|
164
|
+
- test/rails_root/vendor/plugins/shoulda/test/fixtures/products.yml
|
165
|
+
- test/rails_root/vendor/plugins/shoulda/test/fixtures/taggings.yml
|
166
|
+
- test/rails_root/vendor/plugins/shoulda/test/fixtures/tags.yml
|
167
|
+
- test/rails_root/vendor/plugins/shoulda/test/fixtures/users.yml
|
168
|
+
- test/rails_root/vendor/plugins/shoulda/test/functional
|
169
|
+
- test/rails_root/vendor/plugins/shoulda/test/functional/posts_controller_test.rb
|
170
|
+
- test/rails_root/vendor/plugins/shoulda/test/functional/users_controller_test.rb
|
171
|
+
- test/rails_root/vendor/plugins/shoulda/test/other
|
172
|
+
- test/rails_root/vendor/plugins/shoulda/test/other/context_test.rb
|
173
|
+
- test/rails_root/vendor/plugins/shoulda/test/other/convert_to_should_syntax_test.rb
|
174
|
+
- test/rails_root/vendor/plugins/shoulda/test/other/helpers_test.rb
|
175
|
+
- test/rails_root/vendor/plugins/shoulda/test/other/private_helpers_test.rb
|
176
|
+
- test/rails_root/vendor/plugins/shoulda/test/other/should_test.rb
|
177
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root
|
178
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/app
|
179
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/app/controllers
|
180
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/app/controllers/application.rb
|
181
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/app/controllers/posts_controller.rb
|
182
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/app/controllers/users_controller.rb
|
183
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/app/helpers
|
184
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/app/helpers/application_helper.rb
|
185
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/app/helpers/posts_helper.rb
|
186
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/app/helpers/users_helper.rb
|
187
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/app/models
|
188
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/app/models/address.rb
|
189
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/app/models/dog.rb
|
190
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/app/models/flea.rb
|
191
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/app/models/post.rb
|
192
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/app/models/product.rb
|
193
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/app/models/tag.rb
|
194
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/app/models/tagging.rb
|
195
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/app/models/user.rb
|
196
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/app/views
|
197
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/app/views/layouts
|
198
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/app/views/layouts/posts.rhtml
|
199
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/app/views/layouts/users.rhtml
|
200
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/app/views/posts
|
201
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/app/views/posts/edit.rhtml
|
202
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/app/views/posts/index.rhtml
|
203
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/app/views/posts/new.rhtml
|
204
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/app/views/posts/show.rhtml
|
205
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/app/views/users
|
206
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/app/views/users/edit.rhtml
|
207
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/app/views/users/index.rhtml
|
208
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/app/views/users/new.rhtml
|
209
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/app/views/users/show.rhtml
|
210
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/config
|
211
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/config/boot.rb
|
212
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/config/database.yml
|
213
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/config/environment.rb
|
214
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/config/environments
|
215
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/config/environments/sqlite3.rb
|
216
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/config/initializers
|
217
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/config/initializers/new_rails_defaults.rb
|
218
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/config/initializers/shoulda.rb
|
219
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/config/routes.rb
|
220
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/db
|
221
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/db/migrate
|
222
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/db/migrate/001_create_users.rb
|
223
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/db/migrate/002_create_posts.rb
|
224
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/db/migrate/003_create_taggings.rb
|
225
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/db/migrate/004_create_tags.rb
|
226
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/db/migrate/005_create_dogs.rb
|
227
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/db/migrate/006_create_addresses.rb
|
228
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/db/migrate/007_create_fleas.rb
|
229
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/db/migrate/008_create_dogs_fleas.rb
|
230
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/db/migrate/009_create_products.rb
|
231
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/db/schema.rb
|
232
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/log
|
233
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/public
|
234
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/public/404.html
|
235
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/public/422.html
|
236
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/public/500.html
|
237
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/script
|
238
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/script/console
|
239
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/script/generate
|
240
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/vendor
|
241
|
+
- test/rails_root/vendor/plugins/shoulda/test/rails_root/vendor/plugins
|
242
|
+
- test/rails_root/vendor/plugins/shoulda/test/README
|
243
|
+
- test/rails_root/vendor/plugins/shoulda/test/test_helper.rb
|
244
|
+
- test/rails_root/vendor/plugins/shoulda/test/unit
|
245
|
+
- test/rails_root/vendor/plugins/shoulda/test/unit/address_test.rb
|
246
|
+
- test/rails_root/vendor/plugins/shoulda/test/unit/dog_test.rb
|
247
|
+
- test/rails_root/vendor/plugins/shoulda/test/unit/flea_test.rb
|
248
|
+
- test/rails_root/vendor/plugins/shoulda/test/unit/post_test.rb
|
249
|
+
- test/rails_root/vendor/plugins/shoulda/test/unit/product_test.rb
|
250
|
+
- test/rails_root/vendor/plugins/shoulda/test/unit/tag_test.rb
|
251
|
+
- test/rails_root/vendor/plugins/shoulda/test/unit/tagging_test.rb
|
252
|
+
- test/rails_root/vendor/plugins/shoulda/test/unit/user_test.rb
|
253
|
+
- test/rails_root/vendor/plugins/sortable
|
254
|
+
- test/rails_root/vendor/plugins/sortable/init.rb
|
39
255
|
has_rdoc: false
|
40
256
|
homepage: http://github.com/dancroak/sortable_table
|
41
257
|
post_install_message:
|
data/README.textile
DELETED
@@ -1,136 +0,0 @@
|
|
1
|
-
h1. Sortable Table
|
2
|
-
|
3
|
-
Sort HTML tables in a Rails app.
|
4
|
-
|
5
|
-
h2. Install
|
6
|
-
|
7
|
-
script/plugin install git://github.com/dancroak/sortable_table.git
|
8
|
-
|
9
|
-
In app/controllers/application_controller.rb:
|
10
|
-
|
11
|
-
class ApplicationController < ActionController::Base
|
12
|
-
include SortableTable::App::Controllers::ApplicationController
|
13
|
-
end
|
14
|
-
|
15
|
-
In app/helpers/application_helper.rb:
|
16
|
-
|
17
|
-
module ApplicationHelper
|
18
|
-
include SortableTable::App::Helpers::ApplicationHelper
|
19
|
-
end
|
20
|
-
|
21
|
-
h2. Testing
|
22
|
-
|
23
|
-
context "enough Users to sort" do
|
24
|
-
setup do
|
25
|
-
5.times { Factory :user }
|
26
|
-
end
|
27
|
-
|
28
|
-
should_sort_by_attributes :name, :email, :age, :group => "groups.name"
|
29
|
-
|
30
|
-
context "GET to #index" do
|
31
|
-
setup { get :index }
|
32
|
-
|
33
|
-
should_display_sortable_table_header_for :name, :email, :age, :group
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
This is the common case for a RESTful UsersController.
|
38
|
-
|
39
|
-
* should_sort_by_attributes tests that the controller's index action can sort by the attributes.
|
40
|
-
* should_display_sortable_header_for tests that a sortable header displays for the attributes.
|
41
|
-
|
42
|
-
h2. Controller
|
43
|
-
|
44
|
-
class UsersController < Admin::BaseController
|
45
|
-
sortable_attributes :name, :email, :age, :group => "groups.name"
|
46
|
-
|
47
|
-
def index
|
48
|
-
@users = User.paginate :page => params[:page], :order => sort_order
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
sortable_attributes defines a sort_order method that gets called in your action.
|
53
|
-
|
54
|
-
If the index action is rendered without a params[:sort] option, @users will be sorted by :name, the first option in the list of sortable_attributes.
|
55
|
-
|
56
|
-
h2. View
|
57
|
-
|
58
|
-
<pre><code>
|
59
|
-
<h1>Users</h1>
|
60
|
-
<table>
|
61
|
-
<tr>
|
62
|
-
<%= sortable_table_header :name => "Name", :sort => "name" %>
|
63
|
-
<%= sortable_table_header :name => "Email", :sort => "email" %>
|
64
|
-
<%= sortable_table_header :name => "Age", :sort => "age" %>
|
65
|
-
<%= sortable_table_header :name => "Group", :sort => "group" %>
|
66
|
-
</tr>
|
67
|
-
<% @users.each do |user| %>
|
68
|
-
<tr>
|
69
|
-
<td><%= html_escape(user.name) %></td>
|
70
|
-
<td><%= html_escape(user.email) %></td>
|
71
|
-
<td><%= html_escape(user.age) %></td>
|
72
|
-
<td><%= html_escape(user.group.name) %></td>
|
73
|
-
</tr>
|
74
|
-
<% end %>
|
75
|
-
</table>
|
76
|
-
</code></pre>
|
77
|
-
|
78
|
-
sortable_table_header creates a table header containing a link with the correct :sort and :order params. It also has a class of "ascending" or "descending" so you can add styles with arrows.
|
79
|
-
|
80
|
-
h2. Example styles
|
81
|
-
|
82
|
-
th.ascending a {
|
83
|
-
background: url(/images/sort-ascending-arrow.gif) 0% 50% no-repeat;
|
84
|
-
padding-left: 15px;
|
85
|
-
}
|
86
|
-
|
87
|
-
th.descending a {
|
88
|
-
background: url(/images/sort-descending-arrow.gif) 0% 50% no-repeat;
|
89
|
-
padding-left: 15px;
|
90
|
-
}
|
91
|
-
|
92
|
-
h2. Overriding defaults
|
93
|
-
|
94
|
-
h3. should_sort_by_attributes
|
95
|
-
|
96
|
-
Opinionated defaults:
|
97
|
-
|
98
|
-
* GET to :index
|
99
|
-
* collection same name as controller (@users for UsersController)
|
100
|
-
* model name same name as controller (User for UsersController
|
101
|
-
|
102
|
-
If you need to test another action (or a nested controller), pass a block:
|
103
|
-
|
104
|
-
should_sort_by_attributes :age do |sort, order|
|
105
|
-
get :show, :sort => sort, :order => order, :group_id => @group.id
|
106
|
-
end
|
107
|
-
|
108
|
-
If you need to test another collection or model name, use should_sort_by.
|
109
|
-
|
110
|
-
h3. should_sort_by
|
111
|
-
|
112
|
-
The :collection, :model_name, and :action options of should_sort_by.
|
113
|
-
|
114
|
-
context "with a non-standard collection name" do
|
115
|
-
action = lambda { |sort, order| get :members, :sort => sort, :order => order }
|
116
|
-
should_sort_by :name, { :collection => "members",
|
117
|
-
:model_name => "user",
|
118
|
-
:action => action } do |user|
|
119
|
-
user.name
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
h3. sort_order
|
124
|
-
|
125
|
-
The default sort order is descending. This applies to the first time you click on a table header. You can override this to be ascending:
|
126
|
-
|
127
|
-
def index
|
128
|
-
@users = User.find :all, :order => sort_order("ascending")
|
129
|
-
end
|
130
|
-
|
131
|
-
Authors
|
132
|
-
-------
|
133
|
-
|
134
|
-
Dan Croak, Joe Ferris, Jason Morrison and Boston.rb.
|
135
|
-
|
136
|
-
Copyright (c) 2008 Dan Croak, released under the MIT license
|
data/TODO.textile
DELETED