public
Fork of wycats/merb-plugins
Description: Merb Plugins: Even more modules to hook up your Merb installation
Homepage: http://www.merbivore.com
Clone URL: git://github.com/somebee/merb-plugins.git
Search Repo:
Merge git://github.com/wycats/merb-plugins
somebee (author)
Wed May 07 06:56:37 -0700 2008
commit  674e0d5d16fa2e77e222a7f215ccb8407f4972a0
tree    ca166686c8f33610a6b5649f38f9bef6d77ff8f7
parent  2e3edb1c4786de40a0a5b8679640bb439129b3dc parent  90a02219f878d039a1adb681a1ff7fd16d9c8cca
...
5
6
7
8
 
9
10
 
11
12
13
...
5
6
7
 
8
9
 
10
11
12
13
0
@@ -5,9 +5,9 @@
0
 
0
 SUDO = windows ? "" : "sudo"
0
 
0
-gems = %w[merb_activerecord merb_datamapper merb_helpers merb_sequel merb_param_protection merb_test_unit merb_stories]
0
+gems = %w[merb_activerecord merb_ merb_helpers merb_sequel merb_param_protection merb_test_unit merb_stories]
0
 
0
-orm_gems = %w[merb_activerecord merb_datamapper merb_sequel]
0
+orm_gems = %w[merb_activerecord merb_ merb_sequel]
0
 
0
 desc "Install it all"
0
 task :install => "install:gems"
...
3
4
5
6
 
7
8
9
...
20
21
22
23
 
24
25
26
...
3
4
5
 
6
7
8
9
...
20
21
22
 
23
24
25
26
0
@@ -3,7 +3,7 @@
0
 
0
 PLUGIN = "merb_activerecord"
0
 NAME = "merb_activerecord"
0
-VERSION = "0.9.2"
0
+VERSION = "0.9.3"
0
 AUTHOR = "Duane Johnson"
0
 EMAIL = "canadaduane@gmail.com"
0
 HOMEPAGE = "http://merbivore.com"
0
@@ -20,7 +20,7 @@
0
   s.author = AUTHOR
0
   s.email = EMAIL
0
   s.homepage = HOMEPAGE
0
- s.add_dependency("merb-core", ">= 0.9.2")
0
+ s.add_dependency("merb-core", ">= 0.9.3")
0
   s.require_path = "lib"
0
   s.autorequire = PLUGIN
0
   s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib,specs,activerecord_generators}/**/*")
...
284
285
286
287
288
 
 
289
290
291
...
307
308
309
310
 
311
312
313
...
284
285
286
 
 
287
288
289
290
291
...
307
308
309
 
310
311
312
313
0
@@ -284,8 +284,8 @@
0
           ActiveRecord::Base.connection.recreate_database(config[:database])
0
         when "postgresql"
0
           ENV['PGHOST'] = config[:host] if config[:host]
0
- ENV['PGPORT'] = configs[:port].to_s if config[:port]
0
- ENV['PGPASSWORD'] = configs[:password].to_s if config[:password]
0
+ ENV['PGPORT'] = config[:port].to_s if config[:port]
0
+ ENV['PGPASSWORD'] = config[:password].to_s if config[:password]
0
           enc_option = "-E #{config[:encoding]}" if config[:encoding]
0
           ActiveRecord::Base.clear_active_connections!
0
           `dropdb -U "#{config[:username]}" #{config[:database]}`
0
@@ -307,7 +307,7 @@
0
     end
0
 
0
     desc "Prepare the test database and load the schema"
0
- task :prepare => ["db:test:clone_structure", "db:test:clone"] do
0
+ task :prepare do
0
       if defined?(ActiveRecord::Base) && !Merb::Orms::ActiveRecord.configurations.blank?
0
         Rake::Task[{ :sql => "db:test:clone_structure", :ruby => "db:test:clone" }[ActiveRecord::Base.schema_format]].invoke
0
       end
...
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
 
...
13
14
15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
0
@@ -13,28 +13,5 @@
0
 
0
 #...
0
 
0
-By default all modules of merb_helpers are loaded and are available to your merb app.
0
-
0
-You can selectively include/exclude modules from this list to keep you app lean if you like.
0
-The inclusions/exclusions are relative to all modules.
0
-
0
-\:include: will only include the specified modules.
0
-
0
-\:exclude: will include all except the specified modules.
0
-
0
-Do not use :include: and :exclude: options at the same time or an error will be raised.
0
-
0
-To set this up in config/plugins.yml
0
-
0
-To Include specified helpers
0
-
0
- \:merb_helpers:
0
- \:include: - date_time_helpers
0
- - form_helpers
0
-
0
-To Exclude specified helpers
0
-
0
- \:merb_helpers:
0
- \:exclude: - date_time_helpers
0
- - form_helpers
0
+# TODO: describe date_time_helpers, form_helpers, tag_helpers
...
5
6
7
8
 
9
10
11
...
26
27
28
29
 
30
31
32
...
5
6
7
 
8
9
10
11
...
26
27
28
 
29
30
31
32
0
@@ -5,7 +5,7 @@
0
 
0
 PLUGIN = "merb_helpers"
0
 NAME = "merb_helpers"
0
-VERSION = "0.9.2"
0
+VERSION = "0.9.3"
0
 AUTHOR = "Yehuda Katz"
0
 EMAIL = "wycats@gmail.com"
0
 HOMEPAGE = "http://merb.rubyforge.org/"
0
@@ -26,7 +26,7 @@
0
   s.author = AUTHOR
0
   s.email = EMAIL
0
   s.homepage = HOMEPAGE
0
- s.add_dependency("merb-core", ">=0.9.2")
0
+ s.add_dependency("merb-core", ">=0.9.3")
0
   s.require_path = 'lib'
0
   s.autorequire = PLUGIN
0
   s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib,specs}/**/*")
...
9
10
11
 
 
 
 
 
 
 
12
13
14
...
31
32
33
34
 
35
...
9
10
11
12
13
14
15
16
17
18
19
20
21
...
38
39
40
 
41
42
0
@@ -9,6 +9,13 @@
0
     end
0
     
0
     def self.load
0
+ require HELPERS_DIR + '/time_dsl'
0
+ require HELPERS_DIR + '/ordinalize'
0
+ # TODO remove with and without and only allow 2 options:
0
+ # config[:load]
0
+ # if defined then load the modules passed along
0
+ # otherwise load everything
0
+
0
       if Merb::Plugins.config[:merb_helpers]
0
         config = Merb::Plugins.config[:merb_helpers]
0
         raise "With and Without options cannot be used with merb_helpers plugin configuration" if config[:with] && config[:without]
0
@@ -31,6 +38,6 @@
0
 end
0
 
0
 Merb::BootLoader.before_app_loads do
0
- Merb::Helpers.load if defined?(Merb::Plugins)
0
+ Merb::Helpers.load
0
 end
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
 
 
 
 
 
58
59
60
 
 
61
62
63
64
65
 
66
67
68
69
...
103
104
105
106
107
 
 
108
109
110
111
112
113
114
 
115
116
117
...
120
121
122
 
 
 
 
 
 
 
 
 
 
 
 
123
124
125
126
127
128
129
...
134
135
136
137
 
138
139
 
140
141
 
142
143
 
144
145
146
 
 
147
148
149
...
167
168
169
170
 
171
172
173
...
201
202
203
204
 
205
206
207
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
3
4
5
6
7
8
9
10
11
12
 
 
13
14
15
16
17
18
 
19
20
21
22
23
...
57
58
59
 
 
60
61
62
63
64
65
66
67
 
68
69
70
71
...
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
...
100
101
102
 
103
104
 
105
106
 
107
108
 
109
110
 
 
111
112
113
114
115
...
133
134
135
 
136
137
138
139
...
167
168
169
 
170
171
172
173
0
@@ -1,68 +1,22 @@
0
-module TimeDSL
0
- {:second => 1,
0
- :minute => 60,
0
- :hour => 3600,
0
- :day => [24,:hours],
0
- :week => [7,:days],
0
- :month => [30,:days],
0
- :year => [364.25, :days]}.each do |meth, amount|
0
- define_method meth do
0
- amount = amount.is_a?(Array) ? amount[0].send(amount[1]) : amount
0
- self * amount
0
- end
0
- alias_method "#{meth}s".intern, meth
0
- end
0
-
0
- # Reads best without arguments: 10.minutes.ago
0
- def ago(time = ::Time.now)
0
- time - self
0
- end
0
- alias :until :ago
0
-
0
- # Reads best with argument: 10.minutes.since(time)
0
- def since(time = ::Time.now)
0
- time + self
0
- end
0
- alias :from_now :since
0
-end
0
 
0
-class Integer
0
- # Ordinalize turns a number into an ordinal string used to denote the
0
- # position in an ordered sequence such as 1st, 2nd, 3rd, 4th.
0
- #
0
- # Examples
0
- # 1.ordinalize # => "1st"
0
- # 2.ordinalize # => "2nd"
0
- # 1002.ordinalize # => "1002nd"
0
- # 1003.ordinalize # => "1003rd"
0
- def ordinalize
0
- if (11..13).include?(self % 100)
0
- "#{self}th"
0
- else
0
- case self % 10
0
- when 1; "#{self}st"
0
- when 2; "#{self}nd"
0
- when 3; "#{self}rd"
0
- else "#{self}th"
0
- end
0
- end
0
- end
0
-end
0
-
0
-Numeric.send :include, TimeDSL
0
 # Everything above here has pretty much been implemented in the assistance gem...
0
 
0
 # Time.now.to_ordinalized_s :long
0
 # => "February 28th, 2006 21:10"
0
 module OrdinalizedFormatting
0
+
0
+ def self.extended(obj)
0
+ include Merb::Helpers::DateAndTime
0
+ end
0
+
0
   def to_ordinalized_s(format = :default)
0
- format = Merb::Helpers::DateAndTime::DATE_FORMATS[format]
0
- return to_default_s if format.nil?
0
+ format = Merb::Helpers::DateAndTime.date_formats[format]
0
+ return self.to_s if format.nil?
0
     strftime_ordinalized(format)
0
   end
0
 
0
   def strftime_ordinalized(fmt)
0
- strftime(fmt.gsub(/%d/, '_%d_')).gsub(/_(\d+)_/) { |s| s.to_i.ordinalize }
0
+ strftime(fmt.gsub(/(^|[^-])%d/, '\1_%d_')).gsub(/_(\d+)_/) { |s| s.to_i.ordinalize }
0
   end
0
 end
0
 
0
0
@@ -103,15 +57,15 @@
0
     # The key methods are `relative_date`, `relative_date_span`, and `relative_time_span`. This also gives
0
     # you the Rails style Time DSL for working with numbers eg. 3.months.ago or 5.days.until(1.year.from_now)
0
     module DateAndTime
0
- TIME_CLASS = Time
0
- TIME_OUTPUT = {
0
+ @@time_class = Time
0
+ @@time_output = {
0
         :today => 'today',
0
         :yesterday => 'yesterday',
0
         :tomorrow => 'tomorrow',
0
         :initial_format => '%b %d',
0
         :year_format => ', %Y'
0
       }
0
- DATE_FORMATS = {
0
+ @@date_formats = {
0
         :db => "%Y-%m-%d %H:%M:%S",
0
         :time => "%H:%M",
0
         :short => "%d %b %H:%M",
0
@@ -120,6 +74,18 @@
0
         :rfc822 => "%a, %d %b %Y %H:%M:%S %z"
0
       }
0
       
0
+ def self.time_class
0
+ @@time_class
0
+ end
0
+
0
+ def time_output
0
+ @@time_output
0
+ end
0
+
0
+ def date_formats
0
+ @@date_formats
0
+ end
0
+
0
       # Gives you a relative date in an attractive format
0
       #
0
       # ==== Parameters
0
0
0
0
0
@@ -134,16 +100,16 @@
0
       # relative_date(1.year.ago) => "March 10th, 2007"
0
       def relative_date(time)
0
         date = time.to_date
0
- today = TIME_CLASS.now.to_date
0
+ today = DateAndTime.time_class.now.to_date
0
         if date == today
0
- TIME_OUTPUT[:today]
0
+ DateAndTime.time_output[:today]
0
         elsif date == (today - 1)
0
- TIME_OUTPUT[:yesterday]
0
+ DateAndTime.time_output[:yesterday]
0
         elsif date == (today + 1)
0
- TIME_OUTPUT[:tomorrow]
0
+ DateAndTime.time_output[:tomorrow]
0
         else
0
- fmt = TIME_OUTPUT[:initial_format].dup
0
- fmt << TIME_OUTPUT[:year_format] unless date.year == today.year
0
+ fmt = DateAndTime.time_output[:initial_format].dup
0
+ fmt << DateAndTime.time_output[:year_format] unless date.year == today.year
0
           time.strftime_ordinalized(fmt)
0
         end
0
       end
0
@@ -167,7 +133,7 @@
0
         if times.first == times.last
0
           relative_date(times.first)
0
         else
0
- first = times.first; last = times.last; now = TIME_CLASS.now
0
+ first = times.first; last = times.last; now = DateAndTime.time_class.now
0
           arr = [first.strftime_ordinalized('%b %d')]
0
           arr << ", #{first.year}" unless first.year == last.year
0
           arr << ' - '
0
@@ -201,7 +167,7 @@
0
             "#{prettier_time(times.first, !same_half)} - #{prettier_time(times.last)} #{relative_date(times.first)}"
0
       
0
         else
0
- first = times.first; last = times.last; now = TIME_CLASS.now
0
+ first = times.first; last = times.last; now = DateAndTime.time_class.now
0
           arr = [prettier_time(first)]
0
           arr << ' '
0
           arr << first.strftime_ordinalized('%b %d')
...
80
81
82
83
 
84
85
86
87
...
241
242
243
244
 
 
245
246
 
 
247
248
249
...
449
450
451
452
 
453
454
455
...
80
81
82
 
83
84
85
86
87
...
241
242
243
 
244
245
246
 
247
248
249
250
251
...
451
452
453
 
454
455
456
457
0
@@ -80,7 +80,7 @@
0
             <ul>
0
         }
0
         
0
- error_collection.each {|error| markup << build_li.call(error) }
0
+ error_collection.each {|error, message| markup << build_li.call([error, message])}
0
 
0
         markup << %Q{
0
             </ul>
0
0
@@ -241,9 +241,11 @@
0
       # <%= checkbox_control :is_activated, :label => "Activated?" %>
0
       def checkbox_control(col, attrs = {}, hidden_attrs={})
0
         errorify_field(attrs, col)
0
- attrs.merge!(:checked => "checked") if col_val_to_bool(@_obj.send(col))
0
+ method_name = @_obj.respond_to?(col) ? col : :"#{col}?"
0
+ attrs.merge!(:checked => "checked") if col_val_to_bool(@_obj.send(method_name))
0
         attrs.merge!(:id => control_id(col))
0
- checkbox_field(control_name_value(col, attrs), hidden_attrs)
0
+ attrs = {:name => control_name(col), :value => control_value(method_name)}.merge(attrs)
0
+ checkbox_field(attrs, hidden_attrs)
0
       end
0
 
0
       # Provides a generic HTML checkbox input tag.
0
@@ -449,7 +451,7 @@
0
             end
0
           else
0
             collection.each do |value,text|
0
- options = selected.to_a.include?(value) ? {:selected => 'selected'} : {}
0
+ options = Array(selected).include?(value) ? {:selected => 'selected'} : {}
0
               ret << tag( 'option', text, {:value => value}.merge(options) )
0
             end
0
           end
...
1
2
3
4
5
...
 
 
 
 
 
0
@@ -1,6 +1 @@
0
-module Merb
0
- class FormModel
0
-
0
- end
0
-end
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
0
@@ -1 +1,24 @@
0
+module Ordinalize
0
+ # Ordinalize turns a number into an ordinal string used to denote the
0
+ # position in an ordered sequence such as 1st, 2nd, 3rd, 4th.
0
+ #
0
+ # Examples
0
+ # 1.ordinalize # => "1st"
0
+ # 2.ordinalize # => "2nd"
0
+ # 1002.ordinalize # => "1002nd"
0
+ # 1003.ordinalize # => "1003rd"
0
+ def ordinalize
0
+ if (11..13).include?(self % 100)
0
+ "#{self}th"
0
+ else
0
+ case self % 10
0
+ when 1; "#{self}st"
0
+ when 2; "#{self}nd"
0
+ when 3; "#{self}rd"
0
+ else "#{self}th"
0
+ end
0
+ end
0
+ end
0
+end
0
+Integer.send :include, Ordinalize
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
0
@@ -1 +1,59 @@
0
+# Provides a a simple way of calling time units and to see the elapsed time between 2 moments
0
+# ==== Examples
0
+# 142.minutes => returns a value in seconds
0
+# 7.days => returns a value in seconds
0
+# 1.week => returns a value in seconds
0
+# 2.weeks.ago => returns a date
0
+# 1.year.since(time) => returns a date
0
+# 5.months.since(2.weeks.from_now) => returns a date
0
+module TimeDSL
0
+
0
+ def second
0
+ self * 1
0
+ end
0
+ alias_method :seconds, :second
0
+
0
+ def minute
0
+ self * 60
0
+ end
0
+ alias_method :minutes, :minute
0
+
0
+ def hour
0
+ self * 3600
0
+ end
0
+ alias_method :hours, :hour
0
+
0
+ def day
0
+ self * 86400
0
+ end
0
+ alias_method :days, :day
0
+
0
+ def week
0
+ self * 604800
0
+ end
0
+ alias_method :weeks, :week
0
+
0
+ def month
0
+ self * 2592000
0
+ end
0
+ alias_method :months, :month
0
+
0
+ def year
0
+ self * 31471200
0
+ end
0
+ alias_method :years, :year
0
+
0
+ # Reads best without arguments: 10.minutes.ago
0
+ def ago(time = ::Time.now)
0
+ time - self
0
+ end
0
+ alias :until :ago
0
+
0
+ # Reads best with argument: 10.minutes.since(time)
0
+ def since(time = ::Time.now)
0
+ time + self
0
+ end
0
+ alias :from_now :since
0
+end
0
+Numeric.send :include, TimeDSL
...
15
16
17
 
18
19
20
...
15
16
17
18
19
20
21
0
@@ -15,6 +15,7 @@
0
   def reload_merb_helpers
0
     unload_merb_helpers
0
     load(MERB_HELPERS_ROOT + "/lib/merb_helpers.rb")
0
+ Merb::Helpers.load
0
   end
0
   
0
   before :each do
...
212
213
214
215
216
217
218
219
220
 
221
222
223
 
 
 
224
225
226
227
228
229
230
231
232
233
234
235
 
 
236
237
238
239
 
 
240
241
242
243
 
 
 
244
245
246
247
 
 
 
248
249
250
251
 
 
 
252
253
254
255
256
 
 
 
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
...
212
213
214
 
 
 
 
 
 
215
216
 
 
217
218
219
220
 
 
 
 
 
 
 
 
221
 
 
222
223
224
225
 
 
226
227
228
229
 
 
230
231
232
233
234
 
 
235
236
237
238
239
 
 
240
241
242
243
244
 
 
 
245
246
247
248
249
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
250
 
0
@@ -212,115 +212,40 @@
0
   end
0
 end
0
 
0
-=begin
0
- def setup
0
- @current_time_class = ActiveReload::RelativeTimeHelpers.time class"
0
- ActiveReload::RelativeTimeHelpers.time_class = Time
0
- Time.stubs(:now).returns(Time.utc(2007, 6, 1, 11))
0
- end
0
+describe "to_ordinalized_s" do
0
   
0
- def teardown
0
- ActiveReload::RelativeTimeHelpers.time_class = @current time_class"
0
+ before(:each) do
0
+ @date = Date.parse('2008-5-3')
0
+ @time = Time.parse('2008-5-3 14:00')
0
   end
0
-
0
- it "Should show_today" do
0
- assert_equal 'today', relative_date(Time.now.utc)
0
- end
0
-
0
- it "Should show_yesterday" do
0
- assert_equal 'yesterday', relative_date(1.day.ago.utc)
0
- end
0
   
0
- it "Should show_tomorrow" do
0
- assert_equal 'tomorrow', relative_date(1.day.from_now.utc)
0
+ it "should render a date using #to_s if no format is passed" do
0
+ @date.to_ordinalized_s.should == @date.to_s
0
   end
0
   
0
- it "Should show_date_with_year" do
0
- assert_equal 'Nov 15th, 2005', relative_date(Time.utc(2005, 11, 15))
0
+ it "should render a time using #to_s if no format is passed" do
0
+ @time.to_ordinalized_s.should == @time.to_s
0
   end
0
   
0
- it "Should show_date" do
0
- assert_equal 'Nov 15th', relative_date(Time.utc(2007, 11, 15))
0
+ it "should render a date or time using the db format" do
0
+ @date.to_ordinalized_s(:db).should == "2008-05-03 00:00:00"
0
+ @time.to_ordinalized_s(:db).should == "2008-05-03 14:00:00"
0
   end
0
   
0
- it "Should show_date_span_on_the_same_day" do
0
- assert_equal 'Nov 15th', relative_date_span([Time.utc(2007, 11, 15), Time.utc(2007, 11, 15)])
0
+ it "should render a date or time using the long format" do
0
+ @date.to_ordinalized_s(:long).should == "May 3rd, 2008 00:00"
0
+ @time.to_ordinalized_s(:long).should == "May 3rd, 2008 14:00"
0
   end
0
   
0
- it "Should show_date_span_on_the_same_day_on_different_year" do
0
- assert_equal 'Nov 15th, 2006', relative_date_span([Time.utc(2006, 11, 15), Time.utc(2006, 11, 15)])
0
+ it "should render a date or time using the time format" do
0
+ @date.to_ordinalized_s(:time).should == "00:00"
0
+ @time.to_ordinalized_s(:time).should == "14:00"
0
   end
0
   
0
- it "Should show_date_span_on_the_same_month" do
0
- assert_equal 'Nov 15th - 16th', relative_date_span([Time.utc(2007, 11, 15), Time.utc(2007, 11, 16)])
0
- assert_equal 'Nov 15th - 16th', relative_date_span([Time.utc(2007, 11, 16), Time.utc(2007, 11, 15)])
0
+ it "should render a date or a time using the short format" do
0
+ @date.to_ordinalized_s(:short).should == "3rd May 00:00"
0
+ @time.to_ordinalized_s(:short).should == "3rd May 14:00"
0
   end
0
   
0
- it "Should show_date_span_on_the_same_month_on_different_year" do
0
- assert_equal 'Nov 15th - 16th, 2006', relative_date_span([Time.utc(2006, 11, 15), Time.utc(2006, 11, 16)])
0
- assert_equal 'Nov 15th - 16th, 2006', relative_date_span([Time.utc(2006, 11, 16), Time.utc(2006, 11, 15)])
0
- end
0
-
0
- it "Should show_date_span_on_the_different_month" do
0
- assert_equal 'Nov 15th - Dec 16th', relative_date_span([Time.utc(2007, 11, 15), Time.utc(2007, 12, 16)])
0
- assert_equal 'Nov 15th - Dec 16th', relative_date_span([Time.utc(2007, 12, 16), Time.utc(2007, 11, 15)])
0
- end
0
-
0
- it "Should show_date_span_on_the_different_month_on_different_year" do
0
- assert_equal 'Nov 15th - Dec 16th, 2006', relative_date_span([Time.utc(2006, 11, 15), Time.utc(2006, 12, 16)])
0
- assert_equal 'Nov 15th - Dec 16th, 2006', relative_date_span([Time.utc(2006, 12, 16), Time.utc(2006, 11, 15)])
0
- end
0
-
0
- it "Should show_date_span_on_the_different_year" do
0
- assert_equal 'Nov 15th, 2006 - Dec 16th, 2007', relative_date_span([Time.utc(2006, 11, 15), Time.utc(2007, 12, 16)])
0
- assert_equal 'Nov 15th, 2006 - Dec 16th, 2007', relative_date_span([Time.utc(2007, 12, 16), Time.utc(2006, 11, 15)])
0
- end
0
-
0
- # Time, Single Date
0
- it "Should show_time_span_on_the_same_day_with_same_time" do
0
- assert_equal '5:00 PM Nov 15th', relative_time_span([Time.utc(2007, 11, 15, 17, 00, 00), Time.utc(2007, 11, 15, 17, 00, 00)])
0
- end
0
-
0
- it "Should show_time_span_on_the_same_day_with_same_time_on_different_year" do
0
- assert_equal '5:00 PM Nov 15th, 2006', relative_time_span([Time.utc(2006, 11, 15, 17, 0), Time.utc(2006, 11, 15, 17, 0)])
0
- end
0
-
0
- it "Should show_time_span_on_the_same_day_with_different_times_in_same_half_of_day" do
0
- assert_equal '10:00 - 11:00 AM Nov 15th', relative_time_span([Time.utc(2007, 11, 15, 10), Time.utc(2007, 11, 15, 11, 0)])
0
- end
0
-
0
- it "Should show_time_span_on_the_same_day_with_different_times_in_different_half_of_day" do
0
- assert_equal '10:00 AM - 2:00 PM Nov 15th', relative_time_span([Time.utc(2007, 11, 15, 10, 0), Time.utc(2007, 11, 15, 14, 0)])
0
- end
0
-
0
- it "Should show_time_span_on_the_same_day_with_different_times_in_different_half_of_day_in_different_year" do
0
- assert_equal '10:00 AM - 2:00 PM Nov 15th, 2006', relative_time_span([Time.utc(2006, 11, 15, 10, 0), Time.utc(2006, 11, 15, 14, 0)])
0
- end
0
-
0
- it "Should show_time_span_on_different_days_in_same_year" do
0
- assert_equal '10:00 AM Nov 15th - 2:00 PM Dec 16th, 2006', relative_time_span([Time.utc(2006, 11, 15, 10, 0), Time.utc(2006, 12, 16, 14, 0)])
0
- end
0
-
0
- it "Should show_time_span_on_different_days_in_different_years" do
0
- assert_equal '10:00 AM Nov 15th, 2006 - 2:00 PM Dec 16th, 2007', relative_time_span([Time.utc(2006, 11, 15, 10, 0), Time.utc(2007, 12, 16, 14, 0)])
0
- end
0
-
0
- it "Should show_time_span_on_different_days_in_current_year" do
0
- assert_equal '10:00 AM Nov 15th - 2:00 PM Dec 16th', relative_time_span([Time.utc(2007, 11, 15, 10, 0), Time.utc(2007, 12, 16, 14, 0)])
0
- end
0
-
0
- # prettier time"
0
- it "Should not_show_leading_zero_in_hour" do
0
- assert_equal '2:00 PM', prettier_time(Time.utc(2007, 11, 15, 14, 0))
0
- end
0
-
0
- it "Should convert_to_12_hour_time" do
0
- assert_equal '2:00 AM', prettier_time(Time.utc(2007, 11, 15, 2, 0))
0
- end
0
-
0
- it "Should handle_midnight_correctly" do
0
- assert_equal '12:00 AM', prettier_time(Time.utc(2007, 11, 15, 0, 0))
0
- end
0
 end
0
-=end
...
312
313
314
 
 
 
 
 
 
 
 
315
316
317
...
312
313
314
315
316
317
318
319
320
321
322
323
324
325
0
@@ -312,6 +312,14 @@
0
     end
0
   end
0
   
0
+ it "should support models from datamapper" do
0
+ @dm_obj = FakeDMModel.new
0
+ form_for :dm_obj do
0
+ checkbox_control(:baz).should match_tag(:input, :type =>"checkbox", :name => "fake_d_m_model[baz]", :class => "checkbox", :value => "1", :checked => "checked", :id => "fake_d_m_model_baz")
0
+ checkbox_control(:bat).should match_tag(:input, :type =>"checkbox", :name => "fake_d_m_model[bat]", :class => "checkbox", :value => "0")
0
+ end
0
+ end
0
+
0
   it "should allow a user to set the :off value" do
0
     form_for :obj do
0
       checkbox_control(:baz, :off => "off", :on => "on").should match_tag(:input, :type =>"checkbox", :name => "fake_model[baz]", :class => "checkbox", :value => "on", :checked => "checked")
...
3
4
5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
7
8
...
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
0
@@ -3,6 +3,23 @@
0
 require 'rubygems'
0
 require 'merb-core'
0
 
0
+class FakeDMModel
0
+ def self.properties
0
+ [FakeColumn.new(:baz, TrueClass),
0
+ FakeColumn.new(:bat, TrueClass)
0
+ ]
0
+ end
0
+
0
+ def baz?
0
+ true
0
+ end
0
+
0
+ def bat?
0
+ false
0
+ end
0
+end
0
+
0
+
0
 class FakeModel
0
   
0
   attr_accessor :vin, :make, :model