dancroak-sortable_table 0.1.1 → 0.2.0

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/README.textile ADDED
@@ -0,0 +1,86 @@
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 test/test_helper.rb:
10
+
11
+ class Test::Unit::TestCase
12
+ include SortableTable::Test::TestHelper
13
+ end
14
+
15
+ In app/controllers/application_controller.rb:
16
+
17
+ class ApplicationController < ActionController::Base
18
+ include SortableTable::App::Controllers::ApplicationController
19
+ end
20
+
21
+ In app/helpers/application_helper.rb:
22
+
23
+ module ApplicationHelper
24
+ include SortableTable::App::Helpers::ApplicationHelper
25
+ end
26
+
27
+ h2. Conventions
28
+
29
+ params[:sort] and params[:order]
30
+
31
+ h2. Examples
32
+
33
+ Use the sortable_attributes macro to list the... sortable attributes.
34
+
35
+ Then, in your index action, pass the sort_order method to your usual
36
+ order parameter for will paginate or named scope call.
37
+
38
+ class UsersController < Admin::BaseController
39
+
40
+ sortable_attributes :name, :email
41
+
42
+ def index
43
+ @users = User.paginate :page => params[:page], :order => sort_order
44
+ end
45
+
46
+ end
47
+
48
+ Time-saving Shoulda macros for your tests:
49
+
50
+ class UsersControllerTest < ActionController::TestCase
51
+
52
+ context 'GET to index with sort and order params' do
53
+ setup do
54
+ 5.times do |each|
55
+ Factory :user,
56
+ :name => "name #{each}",
57
+ :email => "email#{each}@example.com"
58
+ end
59
+ end
60
+
61
+ should_sort_by :name
62
+ should_sort_by :email
63
+ end
64
+
65
+ end
66
+
67
+ And some sugar for your views:
68
+
69
+ %h1 Users
70
+
71
+ %table
72
+ %tr
73
+ = sortable_table_header :name => 'Name', :sort => 'name'
74
+ = sortable_table_header :name => 'E-mail', :sort => 'email'
75
+
76
+ - @users.each do |each|
77
+ %tr
78
+ %td= each.name
79
+ %td= each.email
80
+
81
+ Authors
82
+ -------
83
+
84
+ Dan Croak, Joe Ferris, and Boston.rb.
85
+
86
+ Copyright (c) 2008 Dan Croak, released under the MIT license
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- patch: 1
2
+ patch: 0
3
3
  major: 0
4
- minor: 1
4
+ minor: 2
@@ -20,3 +20,9 @@ config.action_controller.allow_forgery_protection = false
20
20
  # The :test delivery method accumulates sent emails in the
21
21
  # ActionMailer::Base.deliveries array.
22
22
  config.action_mailer.delivery_method = :test
23
+
24
+ require 'mocha'
25
+ require 'quietbacktrace'
26
+ require 'shoulda'
27
+ require 'factory_girl'
28
+ require 'redgreen'
@@ -690,3 +690,75 @@ Processing UsersController#index (for 0.0.0.0 at 2008-10-16 15:21:37) [GET]
690
690
  Rendering template within layouts/users
691
691
  Rendering users/index
692
692
  Completed in 0.00504 (198 reqs/sec) | Rendering: 0.00305 (60%) | DB: 0.00258 (51%) | 200 OK [http://test.host/users?order=descending&sort=name]
693
+ User Create (0.000534) INSERT INTO "users" ("name", "updated_at", "admin", "age", "email", "created_at") VALUES('name1', '2008-10-16 20:12:20', NULL, 1, 'email1@example.com', '2008-10-16 20:12:20')
694
+ User Create (0.000111) INSERT INTO "users" ("name", "updated_at", "admin", "age", "email", "created_at") VALUES('name2', '2008-10-16 20:12:20', NULL, 2, 'email2@example.com', '2008-10-16 20:12:20')
695
+ User Load (0.000499) SELECT * FROM "users" 
696
+
697
+
698
+ Processing UsersController#index (for 0.0.0.0 at 2008-10-16 16:12:20) [GET]
699
+ Session ID:
700
+ Parameters: {"order"=>"ascending", "action"=>"index", "controller"=>"users", "sort"=>"age"}
701
+ User Load (0.001521) SELECT * FROM "users" ORDER BY age asc
702
+ Rendering template within layouts/users
703
+ Rendering users/index
704
+ Completed in 0.04991 (20 reqs/sec) | Rendering: 0.04470 (89%) | DB: 0.00266 (5%) | 200 OK [http://test.host/users?order=ascending&sort=age]
705
+ User Create (0.000524) INSERT INTO "users" ("name", "updated_at", "admin", "age", "email", "created_at") VALUES('name3', '2008-10-16 20:12:20', NULL, 3, 'email3@example.com', '2008-10-16 20:12:20')
706
+ User Create (0.000182) INSERT INTO "users" ("name", "updated_at", "admin", "age", "email", "created_at") VALUES('name4', '2008-10-16 20:12:20', NULL, 4, 'email4@example.com', '2008-10-16 20:12:20')
707
+ User Load (0.000692) SELECT * FROM "users" 
708
+
709
+
710
+ Processing UsersController#index (for 0.0.0.0 at 2008-10-16 16:12:20) [GET]
711
+ Session ID:
712
+ Parameters: {"order"=>"descending", "action"=>"index", "controller"=>"users", "sort"=>"age"}
713
+ User Load (0.001342) SELECT * FROM "users" ORDER BY age desc
714
+ Rendering template within layouts/users
715
+ Rendering users/index
716
+ Completed in 0.09649 (10 reqs/sec) | Rendering: 0.09439 (97%) | DB: 0.00274 (2%) | 200 OK [http://test.host/users?order=descending&sort=age]
717
+ User Create (0.000418) INSERT INTO "users" ("name", "updated_at", "admin", "age", "email", "created_at") VALUES('name5', '2008-10-16 20:12:20', NULL, 5, 'email5@example.com', '2008-10-16 20:12:20')
718
+ User Create (0.000117) INSERT INTO "users" ("name", "updated_at", "admin", "age", "email", "created_at") VALUES('name6', '2008-10-16 20:12:20', NULL, 6, 'email6@example.com', '2008-10-16 20:12:20')
719
+ User Load (0.000577) SELECT * FROM "users" 
720
+
721
+
722
+ Processing UsersController#index (for 0.0.0.0 at 2008-10-16 16:12:20) [GET]
723
+ Session ID:
724
+ Parameters: {"order"=>"ascending", "action"=>"index", "controller"=>"users", "sort"=>"email"}
725
+ User Load (0.001013) SELECT * FROM "users" ORDER BY users.email asc
726
+ Rendering template within layouts/users
727
+ Rendering users/index
728
+ Completed in 0.00416 (240 reqs/sec) | Rendering: 0.00256 (61%) | DB: 0.00213 (51%) | 200 OK [http://test.host/users?order=ascending&sort=email]
729
+ User Create (0.000362) INSERT INTO "users" ("name", "updated_at", "admin", "age", "email", "created_at") VALUES('name7', '2008-10-16 20:12:20', NULL, 7, 'email7@example.com', '2008-10-16 20:12:20')
730
+ User Create (0.000112) INSERT INTO "users" ("name", "updated_at", "admin", "age", "email", "created_at") VALUES('name8', '2008-10-16 20:12:20', NULL, 8, 'email8@example.com', '2008-10-16 20:12:20')
731
+ User Load (0.000486) SELECT * FROM "users" 
732
+
733
+
734
+ Processing UsersController#index (for 0.0.0.0 at 2008-10-16 16:12:20) [GET]
735
+ Session ID:
736
+ Parameters: {"order"=>"descending", "action"=>"index", "controller"=>"users", "sort"=>"email"}
737
+ User Load (0.000859) SELECT * FROM "users" ORDER BY users.email desc
738
+ Rendering template within layouts/users
739
+ Rendering users/index
740
+ Completed in 0.00385 (259 reqs/sec) | Rendering: 0.00238 (61%) | DB: 0.00182 (47%) | 200 OK [http://test.host/users?order=descending&sort=email]
741
+ User Create (0.000348) INSERT INTO "users" ("name", "updated_at", "admin", "age", "email", "created_at") VALUES('name9', '2008-10-16 20:12:20', NULL, 9, 'email9@example.com', '2008-10-16 20:12:20')
742
+ User Create (0.000116) INSERT INTO "users" ("name", "updated_at", "admin", "age", "email", "created_at") VALUES('name10', '2008-10-16 20:12:20', NULL, 10, 'email10@example.com', '2008-10-16 20:12:20')
743
+ User Load (0.000485) SELECT * FROM "users" 
744
+
745
+
746
+ Processing UsersController#index (for 0.0.0.0 at 2008-10-16 16:12:20) [GET]
747
+ Session ID:
748
+ Parameters: {"order"=>"ascending", "action"=>"index", "controller"=>"users", "sort"=>"name"}
749
+ User Load (0.000839) SELECT * FROM "users" ORDER BY name asc
750
+ Rendering template within layouts/users
751
+ Rendering users/index
752
+ Completed in 0.00378 (264 reqs/sec) | Rendering: 0.00238 (62%) | DB: 0.00179 (47%) | 200 OK [http://test.host/users?order=ascending&sort=name]
753
+ User Create (0.000407) INSERT INTO "users" ("name", "updated_at", "admin", "age", "email", "created_at") VALUES('name11', '2008-10-16 20:12:20', NULL, 11, 'email11@example.com', '2008-10-16 20:12:20')
754
+ User Create (0.000150) INSERT INTO "users" ("name", "updated_at", "admin", "age", "email", "created_at") VALUES('name12', '2008-10-16 20:12:20', NULL, 12, 'email12@example.com', '2008-10-16 20:12:20')
755
+ User Load (0.000521) SELECT * FROM "users" 
756
+
757
+
758
+ Processing UsersController#index (for 0.0.0.0 at 2008-10-16 16:12:20) [GET]
759
+ Session ID:
760
+ Parameters: {"order"=>"descending", "action"=>"index", "controller"=>"users", "sort"=>"name"}
761
+ User Load (0.000986) SELECT * FROM "users" ORDER BY name desc
762
+ Rendering template within layouts/users
763
+ Rendering users/index
764
+ Completed in 0.00440 (227 reqs/sec) | Rendering: 0.00279 (63%) | DB: 0.00206 (46%) | 200 OK [http://test.host/users?order=descending&sort=name]
@@ -0,0 +1,38 @@
1
+ # TODO Add this to your test_helper.rb
2
+ #require File.expand_path(File.dirname(__FILE__) + '/helper_testcase')
3
+
4
+ # Re-raise errors caught by the controller.
5
+ class StubController < ApplicationController
6
+ def rescue_action(e) raise e end;
7
+ attr_accessor :request, :url
8
+ end
9
+
10
+ class HelperTestCase < Test::Unit::TestCase
11
+
12
+ # Add other helpers here if you need them
13
+ include ActionView::Helpers::ActiveRecordHelper
14
+ include ActionView::Helpers::TagHelper
15
+ include ActionView::Helpers::FormTagHelper
16
+ include ActionView::Helpers::FormOptionsHelper
17
+ include ActionView::Helpers::FormHelper
18
+ include ActionView::Helpers::UrlHelper
19
+ include ActionView::Helpers::AssetTagHelper
20
+ include ActionView::Helpers::PrototypeHelper
21
+
22
+ def setup
23
+ super
24
+
25
+ @request = ActionController::TestRequest.new
26
+ @controller = StubController.new
27
+ @controller.request = @request
28
+
29
+ # Fake url rewriter so we can test url_for
30
+ @controller.url = ActionController::UrlRewriter.new @request, {}
31
+
32
+ ActionView::Helpers::AssetTagHelper::reset_javascript_include_default
33
+ end
34
+
35
+ def test_dummy
36
+ # do nothing - required by test/unit
37
+ end
38
+ end
@@ -3,17 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
3
3
  require 'test_help'
4
4
  require 'rubygems'
5
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'
6
+ require File.expand_path(File.dirname(__FILE__) + '/helper_testcase')
17
7
 
18
8
  Dir[File.join(RAILS_ROOT, 'test', 'factories', '*.rb')].each do |file|
19
9
  require file
@@ -0,0 +1,53 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+
3
+ class ApplicationHelperTest < HelperTestCase
4
+
5
+ include ApplicationHelper
6
+
7
+ context 'sortable_table_header' do
8
+ setup do
9
+ self.stubs(:params).returns({ :controller => :jobs, :action => :index, :sort => nil, :order => nil })
10
+ end
11
+
12
+ [:name, :sort].each do |param|
13
+ should "raise an error without default param #{param}" do
14
+ opts = { :name => 'name', :sort => 'sort' }
15
+ opts.delete param
16
+ assert_raise(ArgumentError) do
17
+ sortable_table_header opts
18
+ end
19
+ end
20
+ end
21
+
22
+ context 'with no params[:sort] or params[:order]' do
23
+ setup do
24
+ @html = sortable_table_header(:name => 'Title', :sort => 'title', :title => 'Sort by title')
25
+ end
26
+
27
+ should 'return a table header without a class attribute' do
28
+ assert @html.include?('<th>')
29
+ end
30
+ end
31
+
32
+ context "without an :anchor" do
33
+ setup do
34
+ @html = sortable_table_header(:name => 'Title', :sort => 'title', :title => 'Sort by title')
35
+ end
36
+
37
+ should 'return a link that contains a url with no anchor' do
38
+ assert @html.match(/href="[^#]+?"/)
39
+ end
40
+ end
41
+
42
+ context "with an :anchor" do
43
+ setup do
44
+ @html = sortable_table_header(:name => 'Title', :sort => 'title', :title => 'Sort by title', :anchor => 'search-results')
45
+ end
46
+
47
+ should 'return a link that contains a url with that anchor' do
48
+ assert @html.match(/href="[^"]*?#search-results"/)
49
+ end
50
+ end
51
+ end
52
+
53
+ end
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2006 Geoffrey Grosenbach
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,33 @@
1
+ = Helper Test Generator
2
+
3
+ Makes stubs so you can test helpers.
4
+
5
+ The helpers are placed in test/unit/helpers and will be run automatically when you run unit tests.
6
+
7
+ = Usage
8
+
9
+ Run the helper_test generator with the shortened name of the helper you want to test.
10
+
11
+ # For TaskHelper
12
+ ./script/generate helper_test Task
13
+
14
+ Require the parent testcase class in your test_helper.rb
15
+
16
+ require File.expand_path(File.dirname(__FILE__) + '/helper_testcase')
17
+
18
+ The testcase includes common helpers, but you can add others if necessary.
19
+
20
+ = Examples
21
+
22
+ # Make a test for the BlogHelper
23
+ ./script/generate helper_test Blog
24
+
25
+ # Make a test for Admin::UsersHelper
26
+ ./script/generate helper_test Admin::Users
27
+
28
+ Sub-folders will be made, if necessary.
29
+
30
+ = Authors
31
+
32
+ * Test stub by Ryan Davis http://zenspider.com
33
+ * Generator by Geoffrey Grosenbach http://nubyonrails.com
@@ -0,0 +1,7 @@
1
+ author: topfunky
2
+ summary: Generates a test case for testing plugins that work as view helpers.
3
+ homepage: http://nubyonrails.com
4
+ plugin: http://topfunky.net/svn/plugins/helper_test
5
+ license: MIT
6
+ version: 0.2
7
+ rails_version: 1.0+
@@ -0,0 +1,22 @@
1
+ class HelperTestGenerator < Rails::Generator::NamedBase
2
+
3
+ attr_reader :helper_class_name, :directory_slashes
4
+
5
+ def initialize(runtime_args, runtime_options = {})
6
+ @helper_class_name = Inflector.camelize(runtime_args.first)
7
+ super
8
+ end
9
+
10
+ def manifest
11
+ record do |m|
12
+ m.template 'helper_testcase.rb', 'test/helper_testcase.rb'
13
+
14
+ output_path = File.join('test/unit/helpers', "#{@helper_class_name.underscore}_helper_test.rb")
15
+ m.directory File.join(File.dirname(output_path))
16
+
17
+ # Make slashes relative to the test/unit/helpers folder
18
+ @directory_slashes = '/..' * (output_path.split('/').length - 3)
19
+ m.template 'helper_test.rb', File.join(output_path)
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,13 @@
1
+ require File.dirname(__FILE__) + '<%= directory_slashes %>/../test_helper'
2
+
3
+ class <%= helper_class_name %>HelperTest < HelperTestCase
4
+
5
+ include <%= helper_class_name %>Helper
6
+
7
+ #fixtures :users, :articles
8
+
9
+ def setup
10
+ super
11
+ end
12
+
13
+ end
@@ -0,0 +1,38 @@
1
+ # TODO Add this to your test_helper.rb
2
+ #require File.expand_path(File.dirname(__FILE__) + '/helper_testcase')
3
+
4
+ # Re-raise errors caught by the controller.
5
+ class StubController < ApplicationController
6
+ def rescue_action(e) raise e end;
7
+ attr_accessor :request, :url
8
+ end
9
+
10
+ class HelperTestCase < Test::Unit::TestCase
11
+
12
+ # Add other helpers here if you need them
13
+ include ActionView::Helpers::ActiveRecordHelper
14
+ include ActionView::Helpers::TagHelper
15
+ include ActionView::Helpers::FormTagHelper
16
+ include ActionView::Helpers::FormOptionsHelper
17
+ include ActionView::Helpers::FormHelper
18
+ include ActionView::Helpers::UrlHelper
19
+ include ActionView::Helpers::AssetTagHelper
20
+ include ActionView::Helpers::PrototypeHelper
21
+
22
+ def setup
23
+ super
24
+
25
+ @request = ActionController::TestRequest.new
26
+ @controller = StubController.new
27
+ @controller.request = @request
28
+
29
+ # Fake url rewriter so we can test url_for
30
+ @controller.url = ActionController::UrlRewriter.new @request, {}
31
+
32
+ ActionView::Helpers::AssetTagHelper::reset_javascript_include_default
33
+ end
34
+
35
+ def test_dummy
36
+ # do nothing - required by test/unit
37
+ end
38
+ 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.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Croak
@@ -26,7 +26,7 @@ extra_rdoc_files: []
26
26
  files:
27
27
  - MIT-LICENSE
28
28
  - Rakefile
29
- - README.markdown
29
+ - README.textile
30
30
  - VERSION.yml
31
31
  - lib/sortable_table
32
32
  - lib/sortable_table/app
@@ -122,16 +122,30 @@ files:
122
122
  - test/rails_root/test/factories/user_factory.rb
123
123
  - test/rails_root/test/functional
124
124
  - test/rails_root/test/functional/users_controller_test.rb
125
+ - test/rails_root/test/helper_testcase.rb
125
126
  - test/rails_root/test/test_helper.rb
127
+ - test/rails_root/test/unit
128
+ - test/rails_root/test/unit/helpers
129
+ - test/rails_root/test/unit/helpers/application_helper_test.rb
126
130
  - test/rails_root/test/units
127
131
  - test/rails_root/test/units/helpers
128
- - test/rails_root/test/units/helpers/application_helper_test.rb
129
132
  - test/rails_root/tmp
130
133
  - test/rails_root/tmp/cache
131
134
  - test/rails_root/tmp/pids
132
135
  - test/rails_root/tmp/sessions
133
136
  - test/rails_root/tmp/sockets
134
137
  - test/rails_root/vendor
138
+ - test/rails_root/vendor/plugins
139
+ - test/rails_root/vendor/plugins/helper_test
140
+ - test/rails_root/vendor/plugins/helper_test/about.yml
141
+ - test/rails_root/vendor/plugins/helper_test/generators
142
+ - test/rails_root/vendor/plugins/helper_test/generators/helper_test
143
+ - test/rails_root/vendor/plugins/helper_test/generators/helper_test/helper_test_generator.rb
144
+ - test/rails_root/vendor/plugins/helper_test/generators/helper_test/templates
145
+ - test/rails_root/vendor/plugins/helper_test/generators/helper_test/templates/helper_test.rb
146
+ - test/rails_root/vendor/plugins/helper_test/generators/helper_test/templates/helper_testcase.rb
147
+ - test/rails_root/vendor/plugins/helper_test/MIT-LICENSE
148
+ - test/rails_root/vendor/plugins/helper_test/README
135
149
  has_rdoc: false
136
150
  homepage: http://github.com/dancroak/sortable_table
137
151
  post_install_message:
data/README.markdown DELETED
@@ -1,72 +0,0 @@
1
- Sortable Table
2
- ==============
3
-
4
- Rails plugin to sort tables of ActiveRecord data.
5
-
6
- Install
7
- -------
8
-
9
- script/plugin install git://github.com/dancroak/sortable_table.git
10
-
11
- Conventions
12
- -----------
13
-
14
- params[:sort] and params[:order]
15
-
16
- Examples
17
- --------
18
-
19
- Use the sortable_attributes macro to list the... sortable attributes.
20
-
21
- Then, in your index action, pass the sort_order method to your usual
22
- order parameter for will paginate or named scope call.
23
-
24
- class UsersController < Admin::BaseController
25
-
26
- sortable_attributes :name, :email
27
-
28
- def index
29
- @users = User.paginate :page => params[:page], :order => sort_order
30
- end
31
-
32
- end
33
-
34
- Time-saving Shoulda macros for your tests:
35
-
36
- class UsersControllerTest < ActionController::TestCase
37
-
38
- context 'GET to index with sort and order params' do
39
- setup do
40
- 5.times do |each|
41
- Factory :user,
42
- :name => "name #{each}",
43
- :email => "email#{each}@example.com"
44
- end
45
- end
46
-
47
- should_sort_by :name
48
- should_sort_by :email
49
- end
50
-
51
- end
52
-
53
- And some sugar for your views:
54
-
55
- %h1 Users
56
-
57
- %table
58
- %tr
59
- = sortable_table_header 'Name', :sort => 'name'
60
- = sortable_table_header 'E-mail', :sort => 'email'
61
-
62
- - @users.each do |each|
63
- %tr
64
- %td= each.name
65
- %td= each.email
66
-
67
- Authors
68
- -------
69
-
70
- Dan Croak, Joe Ferris, and Boston.rb.
71
-
72
- Copyright (c) 2008 Dan Croak, released under the MIT license
@@ -1,46 +0,0 @@
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