presenting 1.0.0 → 2.0.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/app/controllers/presentation/assets_controller.rb +1 -1
- data/app/views/presentations/_details.erb +1 -1
- data/app/views/presentations/_field_search.erb +1 -1
- data/app/views/presentations/_form.erb +1 -1
- data/app/views/presentations/_grid.erb +1 -1
- data/app/views/presentations/_search.erb +1 -1
- data/config/routes.rb +7 -2
- data/lib/presentation/base.rb +10 -27
- data/lib/presentation/details.rb +2 -0
- data/lib/presentation/field_search.rb +2 -0
- data/lib/presentation/grid.rb +1 -1
- data/lib/presenting/engine.rb +7 -0
- data/lib/presenting/form_helpers.rb +1 -1
- data/lib/presenting/helpers.rb +7 -3
- data/lib/presenting/view.rb +3 -3
- data/lib/presenting.rb +38 -5
- data/test/assets_test.rb +5 -7
- data/test/details_test.rb +1 -1
- data/test/field_search_test.rb +1 -1
- data/test/form_test.rb +316 -287
- data/test/grid_test.rb +28 -8
- data/test/helpers_test.rb +2 -2
- data/test/presenting_test.rb +1 -1
- data/test/r3/Gemfile +7 -0
- data/test/r3/Gemfile.lock +82 -0
- data/test/r3/config/application.rb +12 -0
- data/test/r3/config/boot.rb +6 -0
- data/test/{rails → r3}/config/database.yml +6 -1
- data/test/r3/config/environment.rb +5 -0
- data/test/r3/config/environments/test.rb +35 -0
- data/test/r3/config.ru +4 -0
- data/test/r3/db/test.sqlite3 +0 -0
- data/test/r3/log/test.log +2354 -0
- data/test/r3/public/javascripts/presenting/grid.js +0 -0
- data/test/r3/public/javascripts/presenting/search.js +13 -0
- data/test/r3/public/stylesheets/presenting/details-color.css +7 -0
- data/test/r3/public/stylesheets/presenting/details.css +10 -0
- data/test/r3/public/stylesheets/presenting/form.css +1 -0
- data/test/r3/public/stylesheets/presenting/grid-color.css +71 -0
- data/test/r3/public/stylesheets/presenting/grid.css +64 -0
- data/test/r3/public/stylesheets/presenting/search-color.css +16 -0
- data/test/r3/public/stylesheets/presenting/search.css +45 -0
- data/test/search_conditions_test.rb +2 -2
- data/test/search_test.rb +1 -1
- data/test/test_helper.rb +8 -39
- metadata +45 -79
- data/rails/init.rb +0 -12
- data/test/rails/app/controllers/application_controller.rb +0 -15
- data/test/rails/app/controllers/users_controller.rb +0 -36
- data/test/rails/app/helpers/application_helper.rb +0 -3
- data/test/rails/app/helpers/users_helper.rb +0 -2
- data/test/rails/app/models/user.rb +0 -2
- data/test/rails/app/views/layouts/application.html.erb +0 -15
- data/test/rails/app/views/users/index.html.erb +0 -10
- data/test/rails/app/views/users/new.html.erb +0 -2
- data/test/rails/app/views/users/show.html.erb +0 -1
- data/test/rails/config/boot.rb +0 -109
- data/test/rails/config/environment.rb +0 -13
- data/test/rails/config/environments/development.rb +0 -17
- data/test/rails/config/environments/production.rb +0 -24
- data/test/rails/config/environments/test.rb +0 -22
- data/test/rails/config/locales/en.yml +0 -5
- data/test/rails/config/routes.rb +0 -5
- data/test/rails/db/development.sqlite3 +0 -0
- data/test/rails/db/migrate/20090213085444_create_users.rb +0 -13
- data/test/rails/db/migrate/20090213085607_populate_users.rb +0 -13
- data/test/rails/db/schema.rb +0 -23
- data/test/rails/db/test.sqlite3 +0 -0
- data/test/rails/log/development.log +0 -858
- data/test/rails/public/404.html +0 -30
- data/test/rails/public/422.html +0 -30
- data/test/rails/public/500.html +0 -33
- data/test/rails/public/javascripts/application.js +0 -2
- data/test/rails/public/javascripts/jquery.livequery.min.js +0 -11
- data/test/rails/public/javascripts/prototype.js +0 -4320
- data/test/rails/script/console +0 -3
- data/test/rails/script/dbconsole +0 -3
- data/test/rails/script/destroy +0 -3
- data/test/rails/script/generate +0 -3
- data/test/rails/script/plugin +0 -3
- data/test/rails/script/runner +0 -3
- data/test/rails/script/server +0 -3
- /data/app/assets/{javascript → javascripts}/grid.js +0 -0
- /data/app/assets/{javascript → javascripts}/search.js +0 -0
data/test/grid_test.rb
CHANGED
@@ -58,7 +58,7 @@ class GridTest < Presenting::Test
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
-
def
|
61
|
+
def test_arrays_will_not_paginate
|
62
62
|
@g.presentable = []
|
63
63
|
assert !@g.paginate?
|
64
64
|
end
|
@@ -67,6 +67,21 @@ class GridTest < Presenting::Test
|
|
67
67
|
@g.presentable = WillPaginate::Collection.new(1, 1)
|
68
68
|
assert @g.paginate?
|
69
69
|
end
|
70
|
+
|
71
|
+
def test_unpaged_relations_will_not_paginate
|
72
|
+
klass = Class.new(ActiveRecord::Base)
|
73
|
+
table = Arel::Table.new('users')
|
74
|
+
@g.presentable = ActiveRecord::Relation.new(klass, table)
|
75
|
+
assert !@g.paginate?
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_paginated_relations_will_paginate
|
79
|
+
klass = Class.new(ActiveRecord::Base)
|
80
|
+
table = Arel::Table.new('users')
|
81
|
+
@g.presentable = ActiveRecord::Relation.new(klass, table).page(1)
|
82
|
+
assert @g.paginate?
|
83
|
+
end
|
84
|
+
|
70
85
|
end
|
71
86
|
|
72
87
|
class GridFieldTest < Presenting::Test
|
@@ -102,22 +117,27 @@ end
|
|
102
117
|
|
103
118
|
class GridRenderTest < Presentation::RenderTest
|
104
119
|
def setup
|
120
|
+
Rails.application.routes.draw do resources :users end
|
105
121
|
@presentation = Presentation::Grid.new(:id => "users", :fields => [:name, :email])
|
106
122
|
@records = [
|
107
123
|
stub('user', :name => 'foo', :email => 'foo@example.com'),
|
108
124
|
stub('user', :name => 'bar', :email => 'bar@example.com')
|
109
125
|
]
|
110
126
|
@presentation.presentable = @records
|
111
|
-
@presentation.controller = TestController.new
|
127
|
+
@presentation.controller = ActionView::TestCase::TestController.new
|
112
128
|
@presentation.controller.params = {:controller => 'users', :action => 'index'} # WillPaginate reuses existing params
|
113
129
|
end
|
130
|
+
|
131
|
+
def teardown
|
132
|
+
Rails.application.reload_routes!
|
133
|
+
end
|
114
134
|
|
115
135
|
def test_rendering_the_title
|
116
136
|
assert_select "#users table caption", 'Users'
|
117
137
|
end
|
118
138
|
|
119
139
|
def test_rendering_links
|
120
|
-
@presentation.links = ['<a href="/foo" class="foo">bar</a>']
|
140
|
+
@presentation.links = ['<a href="/foo" class="foo">bar</a>'.html_safe]
|
121
141
|
|
122
142
|
assert_select '#users caption ul.actions' do
|
123
143
|
assert_select 'li a.foo', 'bar'
|
@@ -125,8 +145,8 @@ class GridRenderTest < Presentation::RenderTest
|
|
125
145
|
end
|
126
146
|
|
127
147
|
def test_rendering_record_links
|
128
|
-
@presentation.record_links = [proc{|r| "<a href='/foo' class='record-link'>#{r.name}</a>"}]
|
129
|
-
|
148
|
+
@presentation.record_links = [proc{|r| "<a href='/foo' class='record-link'>#{r.name}</a>".html_safe}]
|
149
|
+
|
130
150
|
assert_select '#users tbody tr td ul.actions' do
|
131
151
|
assert_select 'li a.record-link', 'foo'
|
132
152
|
assert_select 'li a.record-link', 'bar'
|
@@ -209,10 +229,10 @@ class GridRenderTest < Presentation::RenderTest
|
|
209
229
|
|
210
230
|
def test_rendering_a_sorted_column
|
211
231
|
@presentation.fields.each{|f| f.sortable = true}
|
212
|
-
@presentation.controller.request.
|
213
|
-
|
232
|
+
@presentation.controller.request.env['QUERY_STRING'] = 'sort[name]=desc'
|
233
|
+
|
214
234
|
assert_select "#users thead" do
|
215
|
-
assert_select "th a.sortable[href='
|
235
|
+
assert_select "th a.sortable[href='?sort[name]=asc']", "Name"
|
216
236
|
end
|
217
237
|
end
|
218
238
|
end
|
data/test/helpers_test.rb
CHANGED
@@ -33,7 +33,7 @@ class Presenting::HelpersTest < ActionView::TestCase
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def test_presenting_a_time
|
36
|
-
assert_equal 'Fri, 13 Feb 2009 02:31:00
|
36
|
+
assert_equal 'Fri, 13 Feb 2009 02:31:00 +0000', present(Time.parse('02/13/2009 02:31 AM UTC').to_time)
|
37
37
|
end
|
38
38
|
|
39
39
|
def test_presenting_a_date
|
@@ -53,7 +53,7 @@ class Presenting::HelpersTest < ActionView::TestCase
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def test_presenting_a_named_presentation
|
56
|
-
self.expects(:controller).returns(TestController.new)
|
56
|
+
self.expects(:controller).returns(ActionView::TestCase::TestController.new)
|
57
57
|
Presentation::Grid.any_instance.expects(:render)
|
58
58
|
present('hello', :grid)
|
59
59
|
end
|
data/test/presenting_test.rb
CHANGED
@@ -6,7 +6,7 @@ class PresentationTest < Test::Unit::TestCase
|
|
6
6
|
# TODO: create a "hello world" test-only setup so i can test rendering
|
7
7
|
@p = Presentation::Grid.new(:id => "hello_world")
|
8
8
|
@p.presentable = []
|
9
|
-
@p.controller = TestController.new
|
9
|
+
@p.controller = ActionView::TestCase::TestController.new
|
10
10
|
assert_nothing_raised do
|
11
11
|
assert @p.render
|
12
12
|
end
|
data/test/r3/Gemfile
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
PATH
|
2
|
+
remote: /home/cainlevy/development/presenting
|
3
|
+
specs:
|
4
|
+
presenting (2.0.0rc3)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: http://rubygems.org/
|
8
|
+
specs:
|
9
|
+
abstract (1.0.0)
|
10
|
+
actionmailer (3.0.7)
|
11
|
+
actionpack (= 3.0.7)
|
12
|
+
mail (~> 2.2.15)
|
13
|
+
actionpack (3.0.7)
|
14
|
+
activemodel (= 3.0.7)
|
15
|
+
activesupport (= 3.0.7)
|
16
|
+
builder (~> 2.1.2)
|
17
|
+
erubis (~> 2.6.6)
|
18
|
+
i18n (~> 0.5.0)
|
19
|
+
rack (~> 1.2.1)
|
20
|
+
rack-mount (~> 0.6.14)
|
21
|
+
rack-test (~> 0.5.7)
|
22
|
+
tzinfo (~> 0.3.23)
|
23
|
+
activemodel (3.0.7)
|
24
|
+
activesupport (= 3.0.7)
|
25
|
+
builder (~> 2.1.2)
|
26
|
+
i18n (~> 0.5.0)
|
27
|
+
activerecord (3.0.7)
|
28
|
+
activemodel (= 3.0.7)
|
29
|
+
activesupport (= 3.0.7)
|
30
|
+
arel (~> 2.0.2)
|
31
|
+
tzinfo (~> 0.3.23)
|
32
|
+
activeresource (3.0.7)
|
33
|
+
activemodel (= 3.0.7)
|
34
|
+
activesupport (= 3.0.7)
|
35
|
+
activesupport (3.0.7)
|
36
|
+
arel (2.0.10)
|
37
|
+
builder (2.1.2)
|
38
|
+
erubis (2.6.6)
|
39
|
+
abstract (>= 1.0.0)
|
40
|
+
i18n (0.5.0)
|
41
|
+
mail (2.2.19)
|
42
|
+
activesupport (>= 2.3.6)
|
43
|
+
i18n (>= 0.4.0)
|
44
|
+
mime-types (~> 1.16)
|
45
|
+
treetop (~> 1.4.8)
|
46
|
+
mime-types (1.16)
|
47
|
+
polyglot (0.3.2)
|
48
|
+
rack (1.2.3)
|
49
|
+
rack-mount (0.6.14)
|
50
|
+
rack (>= 1.0.0)
|
51
|
+
rack-test (0.5.7)
|
52
|
+
rack (>= 1.0)
|
53
|
+
rails (3.0.7)
|
54
|
+
actionmailer (= 3.0.7)
|
55
|
+
actionpack (= 3.0.7)
|
56
|
+
activerecord (= 3.0.7)
|
57
|
+
activeresource (= 3.0.7)
|
58
|
+
activesupport (= 3.0.7)
|
59
|
+
bundler (~> 1.0)
|
60
|
+
railties (= 3.0.7)
|
61
|
+
railties (3.0.7)
|
62
|
+
actionpack (= 3.0.7)
|
63
|
+
activesupport (= 3.0.7)
|
64
|
+
rake (>= 0.8.7)
|
65
|
+
thor (~> 0.14.4)
|
66
|
+
rake (0.9.2)
|
67
|
+
sqlite3 (1.3.3)
|
68
|
+
thor (0.14.6)
|
69
|
+
treetop (1.4.10)
|
70
|
+
polyglot
|
71
|
+
polyglot (>= 0.3.1)
|
72
|
+
tzinfo (0.3.29)
|
73
|
+
will_paginate (3.0.0)
|
74
|
+
|
75
|
+
PLATFORMS
|
76
|
+
ruby
|
77
|
+
|
78
|
+
DEPENDENCIES
|
79
|
+
presenting!
|
80
|
+
rails (= 3.0.7)
|
81
|
+
sqlite3
|
82
|
+
will_paginate (~> 3.0.0)
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require 'rails/all'
|
4
|
+
|
5
|
+
Bundler.require(:default, Rails.env) if defined?(Bundler)
|
6
|
+
|
7
|
+
module R3
|
8
|
+
class Application < Rails::Application
|
9
|
+
config.encoding = "utf-8"
|
10
|
+
config.filter_parameters += [:password]
|
11
|
+
end
|
12
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# SQLite version 3.x
|
2
|
-
# gem install sqlite3
|
2
|
+
# gem install sqlite3
|
3
3
|
development:
|
4
4
|
adapter: sqlite3
|
5
5
|
database: db/development.sqlite3
|
@@ -15,3 +15,8 @@ test:
|
|
15
15
|
pool: 5
|
16
16
|
timeout: 5000
|
17
17
|
|
18
|
+
production:
|
19
|
+
adapter: sqlite3
|
20
|
+
database: db/production.sqlite3
|
21
|
+
pool: 5
|
22
|
+
timeout: 5000
|
@@ -0,0 +1,35 @@
|
|
1
|
+
R3::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# The test environment is used exclusively to run your application's
|
5
|
+
# test suite. You never need to work with it otherwise. Remember that
|
6
|
+
# your test database is "scratch space" for the test suite and is wiped
|
7
|
+
# and recreated between test runs. Don't rely on the data there!
|
8
|
+
config.cache_classes = true
|
9
|
+
|
10
|
+
# Log error messages when you accidentally call methods on nil.
|
11
|
+
config.whiny_nils = true
|
12
|
+
|
13
|
+
# Show full error reports and disable caching
|
14
|
+
config.consider_all_requests_local = true
|
15
|
+
config.action_controller.perform_caching = false
|
16
|
+
|
17
|
+
# Raise exceptions instead of rendering exception templates
|
18
|
+
config.action_dispatch.show_exceptions = false
|
19
|
+
|
20
|
+
# Disable request forgery protection in test environment
|
21
|
+
config.action_controller.allow_forgery_protection = false
|
22
|
+
|
23
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
24
|
+
# The :test delivery method accumulates sent emails in the
|
25
|
+
# ActionMailer::Base.deliveries array.
|
26
|
+
config.action_mailer.delivery_method = :test
|
27
|
+
|
28
|
+
# Use SQL instead of Active Record's schema dumper when creating the test database.
|
29
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
30
|
+
# like if you have constraints or database-specific column types
|
31
|
+
# config.active_record.schema_format = :sql
|
32
|
+
|
33
|
+
# Print deprecation notices to the stderr
|
34
|
+
config.active_support.deprecation = :stderr
|
35
|
+
end
|
data/test/r3/config.ru
ADDED
File without changes
|