presenting 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/presentation/base.rb +1 -1
- data/lib/presentation/form.rb +7 -4
- data/lib/presentation/grid.rb +2 -2
- data/lib/presenting/attribute.rb +6 -3
- data/lib/presenting/helpers.rb +5 -5
- data/lib/presenting/sanitize.rb +3 -3
- data/lib/presenting/search.rb +5 -5
- data/lib/presenting/sorting.rb +2 -2
- data/lib/presenting.rb +1 -1
- data/test/form_test.rb +5 -13
- data/test/grid_test.rb +1 -1
- data/test/helpers_test.rb +2 -2
- data/test/r3/Gemfile +5 -1
- data/test/r3/Gemfile.lock +70 -57
- data/test/r3/log/development.log +2 -0
- data/test/r3/log/test.log +9418 -0
- data/test/test_helper.rb +2 -5
- metadata +32 -52
data/lib/presentation/base.rb
CHANGED
@@ -9,7 +9,7 @@ module Presentation
|
|
9
9
|
attr_accessor :presentable
|
10
10
|
|
11
11
|
attr_accessor :controller
|
12
|
-
delegate :request, :form_authenticity_token, :url_for, :params, :to => 'controller'
|
12
|
+
delegate :request, :form_authenticity_token, :url_for, :params, :_prefixes, :to => 'controller'
|
13
13
|
|
14
14
|
protected
|
15
15
|
|
data/lib/presentation/form.rb
CHANGED
@@ -122,10 +122,13 @@ module Presentation
|
|
122
122
|
attr_writer :value
|
123
123
|
|
124
124
|
def value_from(obj) #:nodoc:
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
125
|
+
case value
|
126
|
+
when Symbol
|
127
|
+
obj.send(value)
|
128
|
+
when String
|
129
|
+
value
|
130
|
+
when Proc
|
131
|
+
value.call(obj)
|
129
132
|
end
|
130
133
|
end
|
131
134
|
|
data/lib/presentation/grid.rb
CHANGED
data/lib/presenting/attribute.rb
CHANGED
@@ -32,9 +32,12 @@ module Presenting
|
|
32
32
|
|
33
33
|
def value_from(obj) #:nodoc:
|
34
34
|
case value
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
when Symbol
|
36
|
+
obj.is_a?(Hash) ? obj[value] : obj.send(value)
|
37
|
+
when String
|
38
|
+
value
|
39
|
+
when Proc
|
40
|
+
value.call(obj)
|
38
41
|
end
|
39
42
|
end
|
40
43
|
|
data/lib/presenting/helpers.rb
CHANGED
@@ -84,14 +84,14 @@ module Presenting
|
|
84
84
|
|
85
85
|
def present_by_class(object, options = {})
|
86
86
|
case object
|
87
|
-
|
87
|
+
when Array
|
88
88
|
content_tag "ol" do
|
89
89
|
object.collect do |i|
|
90
90
|
content_tag "li", present(i, options)
|
91
91
|
end.join.html_safe
|
92
92
|
end
|
93
93
|
|
94
|
-
|
94
|
+
when Hash
|
95
95
|
# sort by keys
|
96
96
|
content_tag "dl" do
|
97
97
|
object.keys.sort.collect do |k|
|
@@ -100,13 +100,13 @@ module Presenting
|
|
100
100
|
end.join.html_safe
|
101
101
|
end
|
102
102
|
|
103
|
-
|
103
|
+
when TrueClass, FalseClass
|
104
104
|
object ? "True" : "False"
|
105
105
|
|
106
|
-
|
106
|
+
when Date, Time, DateTime
|
107
107
|
l(object, :format => :default)
|
108
108
|
|
109
|
-
|
109
|
+
else
|
110
110
|
options[:raw] ? object.to_s.html_safe : object.to_s
|
111
111
|
end
|
112
112
|
end
|
data/lib/presenting/sanitize.rb
CHANGED
@@ -5,13 +5,13 @@ module Presenting::Sanitize
|
|
5
5
|
# escape but preserve Arrays and Hashes
|
6
6
|
def h(val)
|
7
7
|
case val
|
8
|
-
|
8
|
+
when Array
|
9
9
|
val.map{|i| h(i)}
|
10
10
|
|
11
|
-
|
11
|
+
when Hash
|
12
12
|
val.clone.each{|k, v| val[h(k)] = h(v)}
|
13
13
|
|
14
|
-
|
14
|
+
else
|
15
15
|
html_escape(val)
|
16
16
|
end
|
17
17
|
end
|
data/lib/presenting/search.rb
CHANGED
@@ -19,10 +19,10 @@ module Presenting
|
|
19
19
|
# })
|
20
20
|
def fields=(obj)
|
21
21
|
case obj
|
22
|
-
|
22
|
+
when Array
|
23
23
|
obj.each do |name| fields << name end
|
24
24
|
|
25
|
-
|
25
|
+
when Hash
|
26
26
|
obj.each do |k, v|
|
27
27
|
fields << {k => v}
|
28
28
|
end
|
@@ -166,17 +166,17 @@ module Presenting
|
|
166
166
|
|
167
167
|
def typecast(val)
|
168
168
|
case type
|
169
|
-
|
169
|
+
when :date
|
170
170
|
val.is_a?(String) ?
|
171
171
|
(Time.zone ? Time.zone.parse(val) : Time.parse(val)).to_date :
|
172
172
|
val
|
173
173
|
|
174
|
-
|
174
|
+
when :time, :datetime
|
175
175
|
val.is_a?(String) ?
|
176
176
|
(Time.zone ? Time.zone.parse(val) : Time.parse(val)) :
|
177
177
|
val
|
178
178
|
|
179
|
-
|
179
|
+
else
|
180
180
|
val.to_s.strip
|
181
181
|
end
|
182
182
|
end
|
data/lib/presenting/sorting.rb
CHANGED
data/lib/presenting.rb
CHANGED
@@ -20,7 +20,7 @@ module Presenting
|
|
20
20
|
presenting_dir = __FILE__.sub(/\/lib\/.*/, '') # there must be a better way
|
21
21
|
%w(stylesheets javascripts).each do |asset_type|
|
22
22
|
source_dir = File.join(presenting_dir, 'app', 'assets', asset_type)
|
23
|
-
target_dir = File.join(Rails.application.paths
|
23
|
+
target_dir = File.join(Rails.application.paths["public/#{asset_type}"].first, 'presenting')
|
24
24
|
FileUtils.mkdir_p(target_dir)
|
25
25
|
|
26
26
|
Dir[File.join(source_dir, '*')].each do |asset|
|
data/test/form_test.rb
CHANGED
@@ -165,12 +165,13 @@ class FormRenderingTest < Presentation::RenderTest
|
|
165
165
|
end
|
166
166
|
|
167
167
|
def test_rendering_a_password_field
|
168
|
-
@presentation.presentable = User.new(:name => '
|
168
|
+
@presentation.presentable = User.new(:name => 'secret')
|
169
169
|
@presentation.fields = [{:name => :password}]
|
170
|
-
|
170
|
+
|
171
171
|
assert_select 'form div.field' do
|
172
172
|
assert_select 'label', 'Name'
|
173
|
-
assert_select "input[type=password][name='user[name]']
|
173
|
+
assert_select "input[type=password][name='user[name]']", true
|
174
|
+
assert_select "input[type=password][name='user[name]'][value='secret']", false
|
174
175
|
end
|
175
176
|
end
|
176
177
|
|
@@ -300,17 +301,8 @@ class FormRenderingTest < Presentation::RenderTest
|
|
300
301
|
##
|
301
302
|
|
302
303
|
extend ActiveModel::Naming
|
303
|
-
|
304
|
-
# i actually want this model's name to not include the FormRenderingTest namespace
|
305
|
-
# so i'm stubbing out the ActiveModel::Name with my own structure
|
306
304
|
def self.model_name
|
307
|
-
@_model_name ||= Name.new(
|
308
|
-
end
|
309
|
-
class Name
|
310
|
-
attr_accessor :plural, :singular
|
311
|
-
def initialize(hash)
|
312
|
-
hash.each { |k, v| self.instance_variable_set("@#{k}", v) }
|
313
|
-
end
|
305
|
+
@_model_name ||= ActiveModel::Name.new(self, FormRenderingTest)
|
314
306
|
end
|
315
307
|
end
|
316
308
|
end
|
data/test/grid_test.rb
CHANGED
@@ -239,7 +239,7 @@ class GridRenderTest < Presentation::RenderTest
|
|
239
239
|
@presentation.controller.request.env['QUERY_STRING'] = 'sort[name]=desc'
|
240
240
|
|
241
241
|
assert_select "#users thead" do
|
242
|
-
assert_select "th a.sortable[href='?sort
|
242
|
+
assert_select "th a.sortable[href='?sort%5Bname%5D=asc']", "Name"
|
243
243
|
end
|
244
244
|
end
|
245
245
|
end
|
data/test/helpers_test.rb
CHANGED
@@ -33,11 +33,11 @@ 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 +0000', present(Time.parse('02
|
36
|
+
assert_equal 'Fri, 13 Feb 2009 02:31:00 +0000', present(Time.zone.parse('2009-02-13 02:31 AM UTC'))
|
37
37
|
end
|
38
38
|
|
39
39
|
def test_presenting_a_date
|
40
|
-
assert_equal '2009-02-13', present(Time.parse('02
|
40
|
+
assert_equal '2009-02-13', present(Time.zone.parse('2009-02-13 02:31 AM UTC').to_date)
|
41
41
|
end
|
42
42
|
|
43
43
|
def test_presenting_a_string
|
data/test/r3/Gemfile
CHANGED
data/test/r3/Gemfile.lock
CHANGED
@@ -6,81 +6,94 @@ PATH
|
|
6
6
|
GEM
|
7
7
|
remote: http://rubygems.org/
|
8
8
|
specs:
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
rack (~> 1.2
|
20
|
-
rack-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
arel (
|
37
|
-
builder (
|
38
|
-
erubis (2.
|
39
|
-
|
40
|
-
i18n (0.
|
41
|
-
|
42
|
-
|
43
|
-
|
9
|
+
actionmailer (3.2.5)
|
10
|
+
actionpack (= 3.2.5)
|
11
|
+
mail (~> 2.4.4)
|
12
|
+
actionpack (3.2.5)
|
13
|
+
activemodel (= 3.2.5)
|
14
|
+
activesupport (= 3.2.5)
|
15
|
+
builder (~> 3.0.0)
|
16
|
+
erubis (~> 2.7.0)
|
17
|
+
journey (~> 1.0.1)
|
18
|
+
rack (~> 1.4.0)
|
19
|
+
rack-cache (~> 1.2)
|
20
|
+
rack-test (~> 0.6.1)
|
21
|
+
sprockets (~> 2.1.3)
|
22
|
+
activemodel (3.2.5)
|
23
|
+
activesupport (= 3.2.5)
|
24
|
+
builder (~> 3.0.0)
|
25
|
+
activerecord (3.2.5)
|
26
|
+
activemodel (= 3.2.5)
|
27
|
+
activesupport (= 3.2.5)
|
28
|
+
arel (~> 3.0.2)
|
29
|
+
tzinfo (~> 0.3.29)
|
30
|
+
activeresource (3.2.5)
|
31
|
+
activemodel (= 3.2.5)
|
32
|
+
activesupport (= 3.2.5)
|
33
|
+
activesupport (3.2.5)
|
34
|
+
i18n (~> 0.6)
|
35
|
+
multi_json (~> 1.0)
|
36
|
+
arel (3.0.2)
|
37
|
+
builder (3.0.0)
|
38
|
+
erubis (2.7.0)
|
39
|
+
hike (1.2.1)
|
40
|
+
i18n (0.6.0)
|
41
|
+
journey (1.0.3)
|
42
|
+
json (1.7.3)
|
43
|
+
mail (2.4.4)
|
44
44
|
i18n (>= 0.4.0)
|
45
45
|
mime-types (~> 1.16)
|
46
46
|
treetop (~> 1.4.8)
|
47
|
-
|
47
|
+
metaclass (0.0.1)
|
48
|
+
mime-types (1.18)
|
49
|
+
mocha (0.11.3)
|
50
|
+
metaclass (~> 0.0.1)
|
51
|
+
multi_json (1.3.6)
|
48
52
|
polyglot (0.3.3)
|
49
|
-
rack (1.
|
50
|
-
rack-
|
51
|
-
rack (>=
|
52
|
-
rack-
|
53
|
+
rack (1.4.1)
|
54
|
+
rack-cache (1.2)
|
55
|
+
rack (>= 0.4)
|
56
|
+
rack-ssl (1.3.2)
|
57
|
+
rack
|
58
|
+
rack-test (0.6.1)
|
53
59
|
rack (>= 1.0)
|
54
|
-
rails (3.
|
55
|
-
actionmailer (= 3.
|
56
|
-
actionpack (= 3.
|
57
|
-
activerecord (= 3.
|
58
|
-
activeresource (= 3.
|
59
|
-
activesupport (= 3.
|
60
|
+
rails (3.2.5)
|
61
|
+
actionmailer (= 3.2.5)
|
62
|
+
actionpack (= 3.2.5)
|
63
|
+
activerecord (= 3.2.5)
|
64
|
+
activeresource (= 3.2.5)
|
65
|
+
activesupport (= 3.2.5)
|
60
66
|
bundler (~> 1.0)
|
61
|
-
railties (= 3.
|
62
|
-
railties (3.
|
63
|
-
actionpack (= 3.
|
64
|
-
activesupport (= 3.
|
67
|
+
railties (= 3.2.5)
|
68
|
+
railties (3.2.5)
|
69
|
+
actionpack (= 3.2.5)
|
70
|
+
activesupport (= 3.2.5)
|
71
|
+
rack-ssl (~> 1.3.2)
|
65
72
|
rake (>= 0.8.7)
|
66
73
|
rdoc (~> 3.4)
|
67
|
-
thor (
|
74
|
+
thor (>= 0.14.6, < 2.0)
|
68
75
|
rake (0.9.2.2)
|
69
|
-
rdoc (3.
|
76
|
+
rdoc (3.12)
|
70
77
|
json (~> 1.4)
|
71
|
-
|
72
|
-
|
78
|
+
sprockets (2.1.3)
|
79
|
+
hike (~> 1.2)
|
80
|
+
rack (~> 1.0)
|
81
|
+
tilt (~> 1.1, != 1.3.0)
|
82
|
+
sqlite3 (1.3.6)
|
83
|
+
thor (0.15.2)
|
84
|
+
tilt (1.3.3)
|
73
85
|
treetop (1.4.10)
|
74
86
|
polyglot
|
75
87
|
polyglot (>= 0.3.1)
|
76
|
-
tzinfo (0.3.
|
77
|
-
will_paginate (3.0.
|
88
|
+
tzinfo (0.3.33)
|
89
|
+
will_paginate (3.0.3)
|
78
90
|
|
79
91
|
PLATFORMS
|
80
92
|
ruby
|
81
93
|
|
82
94
|
DEPENDENCIES
|
95
|
+
mocha
|
83
96
|
presenting!
|
84
|
-
rails (= 3.
|
97
|
+
rails (= 3.2.5)
|
85
98
|
sqlite3
|
86
99
|
will_paginate (~> 3.0.0)
|
@@ -0,0 +1,2 @@
|
|
1
|
+
DEPRECATION WARNING: ActionDispatch::ShowExceptions.rescue_responses is deprecated. Please configure your exceptions using a railtie or in your application config instead. (called from /Users/cainlevy/Code/presenting/test/r3/config/environment.rb:5)
|
2
|
+
Connecting to database specified by database.yml
|