Skip to content
Newer
Older
100644 499 lines (443 sloc) 44.1 KB
408978e @ludicast adding time tags
authored Mar 9, 2010
1 require File.dirname(__FILE__) + '/spec_helper'
2
aefe0da @ludicast added select_month
authored Mar 13, 2010
3 def get_month(val)
4 months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
5 months[val - 1]
6 end
7
6522759 @ludicast added 0 prefix
authored Mar 15, 2010
8
9 def fill_zeros(val)
10 if val < 10
11 "0#{val}"
12 else
13 val
14 end
15 end
16
17
90715ad @ludicast added short month
authored Mar 13, 2010
18 def get_short_month(val)
19 get_month(val)[0..2]
20 end
21
504ee6b @ludicast added prompt and foreign month option
authored Mar 13, 2010
22 def spanish_month_names
23 ["enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"]
24 end
25
26 def get_spanish_month_name(val)
27 spanish_month_names[val]
28 end
90715ad @ludicast added short month
authored Mar 13, 2010
29
30 def get_month_with_numbers(val)
31 "#{val} - #{get_month val}"
32 end
aefe0da @ludicast added select_month
authored Mar 13, 2010
33
34 def get_options(from_val,to_val, hash = {})
408978e @ludicast adding time tags
authored Mar 9, 2010
35 options = ""
a229998 @ludicast added select_year tag
authored Mar 13, 2010
36 range = (from_val..to_val)
aefe0da @ludicast added select_month
authored Mar 13, 2010
37 if hash[:reverse]
a229998 @ludicast added select_year tag
authored Mar 13, 2010
38 range = range.to_a.reverse
39 end
aefe0da @ludicast added select_month
authored Mar 13, 2010
40
a229998 @ludicast added select_year tag
authored Mar 13, 2010
41 range.each do |val|
aefe0da @ludicast added select_month
authored Mar 13, 2010
42 if hash[:label_func]
43 print_val = send(hash[:label_func], val)
d7cdb23 @ludicast modified date/time zerio padding
authored Apr 3, 2010
44 elsif hash[:ignore_zeros]
45 print_val = val
aefe0da @ludicast added select_month
authored Mar 13, 2010
46 else
6522759 @ludicast added 0 prefix
authored Mar 15, 2010
47 print_val = fill_zeros(val)
aefe0da @ludicast added select_month
authored Mar 13, 2010
48 end
49 options << %{<option value="#{val}">#{print_val}</option>}
408978e @ludicast adding time tags
authored Mar 9, 2010
50 end
51 options
52 end
53
d7cdb23 @ludicast modified date/time zerio padding
authored Apr 3, 2010
54 describe "for date and time tags" do
408978e @ludicast adding time tags
authored Mar 9, 2010
55 context "for select_second" do
56 it "should take a number" do
57 @tag = "{% select_second 33 %}"
49446ce @ludicast added minute tag
authored Mar 9, 2010
58 @tag.should parse_to('<select id="date_second" name="date[second]">' + get_options(0,32) + '<option selected="selected" value="33">33</option>' + get_options(34,59) + "</select>")
59 end
30568b3 @ludicast added hours
authored Mar 11, 2010
60 it "should take a prompt" do
61 @tag = "{% select_second 33, prompt:'Choose seconds' %}"
62 @tag.should parse_to('<select id="date_second" name="date[second]"><option value="">Choose seconds</option>' + get_options(0,32) + '<option selected="selected" value="33">33</option>' + get_options(34,59) + "</select>")
63 end
64 it "should take a prompt" do
65 @tag = "{% select_second 33, prompt:true %}"
66 @tag.should parse_to('<select id="date_second" name="date[second]"><option value="">Seconds</option>' + get_options(0,32) + '<option selected="selected" value="33">33</option>' + get_options(34,59) + "</select>")
67 end
70eb28c @ludicast added fieldname part
authored Mar 9, 2010
68 it "should take a field_name" do
69 @tag = "{% select_second 33,field_name:'stride' %}"
70 @tag.should parse_to('<select id="date_stride" name="date[stride]">' + get_options(0,32) + '<option selected="selected" value="33">33</option>' + get_options(34,59) + "</select>")
71 end
49446ce @ludicast added minute tag
authored Mar 9, 2010
72 it "should take a Time" do
73 time = Time.now
74 @tag = "{% select_second time %}"
515a846 @ludicast cleanup
authored Mar 15, 2010
75 @tag.should parse_with_vars_to('<select id="date_second" name="date[second]">' + get_options(0,(time.sec - 1)) + %{<option selected="selected" value="#{time.sec}">#{fill_zeros time.sec}</option>} + get_options((time.sec + 1),59) + "</select>", 'time' => time)
49446ce @ludicast added minute tag
authored Mar 9, 2010
76 end
77 end
78
79 context "for select_minute" do
80 it "should take a number" do
81 @tag = "{% select_minute 33 %}"
82 @tag.should parse_to('<select id="date_minute" name="date[minute]">' + get_options(0,32) + '<option selected="selected" value="33">33</option>' + get_options(34,59) + "</select>")
83 end
30568b3 @ludicast added hours
authored Mar 11, 2010
84 it "should take a prompt" do
85 @tag = "{% select_minute 33, prompt:'Choose minutes' %}"
86 @tag.should parse_to('<select id="date_minute" name="date[minute]"><option value="">Choose minutes</option>' + get_options(0,32) + '<option selected="selected" value="33">33</option>' + get_options(34,59) + "</select>")
87 end
88 it "should take a prompt" do
89 @tag = "{% select_minute 33, prompt:true %}"
90 @tag.should parse_to('<select id="date_minute" name="date[minute]"><option value="">Minutes</option>' + get_options(0,32) + '<option selected="selected" value="33">33</option>' + get_options(34,59) + "</select>")
91 end
92 it "should take a field_name" do
93 @tag = "{% select_minute 33,field_name:'stride' %}"
94 @tag.should parse_to('<select id="date_stride" name="date[stride]">' + get_options(0,32) + '<option selected="selected" value="33">33</option>' + get_options(34,59) + "</select>")
95 end
49446ce @ludicast added minute tag
authored Mar 9, 2010
96 it "should take a Time" do
97 time = Time.now
98 @tag = "{% select_minute time %}"
515a846 @ludicast cleanup
authored Mar 15, 2010
99 @tag.should parse_with_vars_to('<select id="date_minute" name="date[minute]">' + get_options(0,(time.min - 1)) + %{<option selected="selected" value="#{time.min}">#{fill_zeros time.min}</option>} + get_options((time.min + 1),59) + "</select>", 'time' => time)
408978e @ludicast adding time tags
authored Mar 9, 2010
100 end
101 end
49446ce @ludicast added minute tag
authored Mar 9, 2010
102
30568b3 @ludicast added hours
authored Mar 11, 2010
103 context "for select_hour" do
104 it "should take a number" do
73a20cd @ludicast cut off hours at 23
authored Apr 3, 2010
105 @tag = "{% select_hour 13 %}"
106 @tag.should parse_to('<select id="date_hour" name="date[hour]">' + get_options(0,12) + '<option selected="selected" value="13">13</option>' + get_options(14,23) + "</select>")
30568b3 @ludicast added hours
authored Mar 11, 2010
107 end
108 it "should take a prompt" do
73a20cd @ludicast cut off hours at 23
authored Apr 4, 2010
109 @tag = "{% select_hour 13, prompt:'Choose hours' %}"
110 @tag.should parse_to('<select id="date_hour" name="date[hour]"><option value="">Choose hours</option>' + get_options(0,12) + '<option selected="selected" value="13">13</option>' + get_options(14,23) + "</select>")
30568b3 @ludicast added hours
authored Mar 11, 2010
111 end
112 it "should take a prompt" do
73a20cd @ludicast cut off hours at 23
authored Apr 4, 2010
113 @tag = "{% select_hour 13, prompt:true %}"
114 @tag.should parse_to('<select id="date_hour" name="date[hour]"><option value="">Hours</option>' + get_options(0,12) + '<option selected="selected" value="13">13</option>' + get_options(14,23) + "</select>")
30568b3 @ludicast added hours
authored Mar 11, 2010
115 end
116 it "should take a field_name" do
73a20cd @ludicast cut off hours at 23
authored Apr 4, 2010
117 @tag = "{% select_hour 13,field_name:'stride' %}"
118 @tag.should parse_to('<select id="date_stride" name="date[stride]">' + get_options(0,12) + '<option selected="selected" value="13">13</option>' + get_options(14,23) + "</select>")
30568b3 @ludicast added hours
authored Mar 11, 2010
119 end
120 it "should take a Time" do
121 time = Time.now
122 @tag = "{% select_hour time %}"
73a20cd @ludicast cut off hours at 23
authored Apr 4, 2010
123 @tag.should parse_with_vars_to('<select id="date_hour" name="date[hour]">' + get_options(0,(time.hour - 1)) + %{<option selected="selected" value="#{time.hour}">#{fill_zeros time.hour}</option>} + get_options((time.hour + 1),23) + "</select>", 'time' => time)
30568b3 @ludicast added hours
authored Mar 11, 2010
124 end
125 end
126
9ad8348 @ludicast added hours
authored Mar 11, 2010
127 context "for select_day" do
128 it "should take a number" do
e8360fc @ludicast added year
authored Mar 12, 2010
129 @tag = "{% select_day 14 %}"
d7cdb23 @ludicast modified date/time zerio padding
authored Apr 3, 2010
130 @tag.should parse_to('<select id="date_day" name="date[day]">' + get_options(1,13,:ignore_zeros => true) + '<option selected="selected" value="14">14</option>' + get_options(15,31,:ignore_zeros => true) + "</select>")
9ad8348 @ludicast added hours
authored Mar 11, 2010
131 end
132 it "should take a prompt" do
e8360fc @ludicast added year
authored Mar 12, 2010
133 @tag = "{% select_day 14, prompt:'Choose day' %}"
d7cdb23 @ludicast modified date/time zerio padding
authored Apr 3, 2010
134 @tag.should parse_to('<select id="date_day" name="date[day]"><option value="">Choose day</option>' + get_options(1,13,:ignore_zeros => true) + '<option selected="selected" value="14">14</option>' + get_options(15,31,:ignore_zeros => true) + "</select>")
9ad8348 @ludicast added hours
authored Mar 11, 2010
135 end
136 it "should take a prompt" do
e8360fc @ludicast added year
authored Mar 12, 2010
137 @tag = "{% select_day 14, prompt:true %}"
d7cdb23 @ludicast modified date/time zerio padding
authored Apr 3, 2010
138 @tag.should parse_to('<select id="date_day" name="date[day]"><option value="">Days</option>' + get_options(1,13,:ignore_zeros => true) + '<option selected="selected" value="14">14</option>' + get_options(15,31,:ignore_zeros => true) + "</select>")
9ad8348 @ludicast added hours
authored Mar 11, 2010
139 end
140 it "should take a field_name" do
e8360fc @ludicast added year
authored Mar 12, 2010
141 @tag = "{% select_day 14,field_name:'stride' %}"
d7cdb23 @ludicast modified date/time zerio padding
authored Apr 3, 2010
142 @tag.should parse_to('<select id="date_stride" name="date[stride]">' + get_options(1,13,:ignore_zeros => true) + '<option selected="selected" value="14">14</option>' + get_options(15,31,:ignore_zeros => true) + "</select>")
9ad8348 @ludicast added hours
authored Mar 11, 2010
143 end
144 it "should take a Time" do
145 time = Time.now
146 @tag = "{% select_day time %}"
d7cdb23 @ludicast modified date/time zerio padding
authored Apr 3, 2010
147 @tag.should parse_with_vars_to('<select id="date_day" name="date[day]">' + get_options(1,(time.day - 1),:ignore_zeros => true) + %{<option selected="selected" value="#{time.day}">#{time.day}</option>} + get_options((time.day + 1),31,:ignore_zeros => true) + "</select>", 'time' => time)
e8360fc @ludicast added year
authored Mar 12, 2010
148 end
149 end
150
151 context "for select_year" do
152 it "should set default year" do
153 @tag = "{% select_year 2009 %}"
154 @tag.should parse_to('<select id="date_year" name="date[year]">' + get_options(2004,2008) + %{<option selected="selected" value="2009">2009</option>} + get_options(2010,2014) + "</select>")
9ad8348 @ludicast added hours
authored Mar 11, 2010
155 end
a229998 @ludicast added select_year tag
authored Mar 13, 2010
156 it "should set take start and end in ascending order" do
91a562f @ludicast added start/end year
authored Mar 12, 2010
157 time = Time.now
158 @tag = "{% select_year time,start_year:1992,end_year:2020 %}"
159 @tag.should parse_with_vars_to('<select id="date_year" name="date[year]">' + get_options(1992,time.year - 1) + %{<option selected="selected" value="#{time.year}">#{time.year}</option>} + get_options(time.year + 1,2020) + "</select>", 'time' => time)
160 end
e8360fc @ludicast added year
authored Mar 12, 2010
161
a229998 @ludicast added select_year tag
authored Mar 13, 2010
162 it "should set take start and end in descending order" do
163 time = Time.now
164 @tag = "{% select_year time,start_year:2020,end_year:1992 %}"
aefe0da @ludicast added select_month
authored Mar 13, 2010
165 @tag.should parse_with_vars_to('<select id="date_year" name="date[year]">' + get_options(time.year + 1,2020, {:reverse => true}) + %{<option selected="selected" value="#{time.year}">#{time.year}</option>} + get_options(1992,time.year - 1, {:reverse => true}) + "</select>", 'time' => time)
a229998 @ludicast added select_year tag
authored Mar 13, 2010
166 end
e8360fc @ludicast added year
authored Mar 12, 2010
167
a229998 @ludicast added select_year tag
authored Mar 13, 2010
168 it "should set take start and end in ascending order with year" do
169 @tag = "{% select_year 2006,start_year:1992,end_year:2020 %}"
170 @tag.should parse_to('<select id="date_year" name="date[year]">' + get_options(1992,2005) + %{<option selected="selected" value="2006">2006</option>} + get_options(2007,2020) + "</select>")
171 end
e8360fc @ludicast added year
authored Mar 12, 2010
172
a229998 @ludicast added select_year tag
authored Mar 13, 2010
173 it "should take a prompt parameter" do
174 @tag = "{% select_year 14,prompt:'Choose year' %}"
175 @tag.should parse_to('<select id="date_year" name="date[year]"><option value="">Choose year</option>' + get_options(9,13) + %{<option selected="selected" value="14">14</option>} + get_options(15,19) + "</select>")
176 end
e8360fc @ludicast added year
authored Mar 12, 2010
177
a229998 @ludicast added select_year tag
authored Mar 13, 2010
178 it "should take a field_name parameter" do
179 time = Time.now
180 @tag = "{% select_year time,field_name:'birth' %}"
181 @tag.should parse_with_vars_to('<select id="date_birth" name="date[birth]">' + get_options(time.year-5,time.year - 1) + %{<option selected="selected" value="#{time.year}">#{time.year}</option>} + get_options(time.year + 1,time.year + 5) + "</select>", 'time' => time)
182 end
9ad8348 @ludicast added hours
authored Mar 11, 2010
183 end
9bae121 @ludicast added select_month test
authored Mar 13, 2010
184
185 context "for select_month" do
9cda47b @ludicast added select_month
authored Mar 13, 2010
186 it "should take number produce month names by default" do
aefe0da @ludicast added select_month
authored Mar 13, 2010
187 @tag = "{% select_month 5 %}"
188 @tag.should parse_to('<select id="date_month" name="date[month]">' + get_options(1,4,{:label_func => :get_month}) + %{<option selected="selected" value="5">May</option>} + get_options(6,12,{:label_func => :get_month}) + "</select>")
9bae121 @ludicast added select_month test
authored Mar 13, 2010
189 end
9cda47b @ludicast added select_month
authored Mar 13, 2010
190 it "should take time object produce month names by default" do
191 time = Time.now
192 @tag = "{% select_month time %}"
193 @tag.should parse_with_vars_to('<select id="date_month" name="date[month]">' + get_options(1,time.month - 1,{:label_func => :get_month}) + %{<option selected="selected" value="#{time.month}">#{get_month time.month}</option>} + get_options(time.month + 1,12,{:label_func => :get_month}) + "</select>", 'time' => time)
194 end
504ee6b @ludicast added prompt and foreign month option
authored Mar 13, 2010
195 it "should take a prompt" do
196 time = Time.now
197 @tag = "{% select_month time, prompt:'Choose month...' %}"
198 @tag.should parse_with_vars_to('<select id="date_month" name="date[month]"><option value="">Choose month...</option>' + get_options(1,time.month - 1,{:label_func => :get_month}) + %{<option selected="selected" value="#{time.month}">#{get_month time.month}</option>} + get_options(time.month + 1,12,{:label_func => :get_month}) + "</select>", 'time' => time)
199 end
a8cfed2 @ludicast added select_month
authored Mar 13, 2010
200 it "should take different field_name" do
201 time = Time.now
202 @tag = "{% select_month time, field_name:'start' %}"
203 @tag.should parse_with_vars_to('<select id="date_start" name="date[start]">' + get_options(1,time.month - 1,{:label_func => :get_month}) + %{<option selected="selected" value="#{time.month}">#{get_month time.month}</option>} + get_options(time.month + 1,12,{:label_func => :get_month}) + "</select>", 'time' => time)
204 end
7259b57 @ludicast added month number option
authored Mar 13, 2010
205 it "should let you use numbers for months" do
206 time = Time.now
207 @tag = "{% select_month time, use_month_numbers:true %}"
d7cdb23 @ludicast modified date/time zerio padding
authored Apr 3, 2010
208 @tag.should parse_with_vars_to('<select id="date_month" name="date[month]">' + get_options(1,time.month - 1,:ignore_zeros => true) + %{<option selected="selected" value="#{time.month}">#{time.month}</option>} + get_options(time.month + 1,12,:ignore_zeros => true) + "</select>", 'time' => time)
7259b57 @ludicast added month number option
authored Mar 13, 2010
209 end
210
90715ad @ludicast added short month
authored Mar 13, 2010
211 it "should let you add numbers for months" do
212 time = Time.now
213 @tag = "{% select_month time, add_month_numbers:true %}"
214 @tag.should parse_with_vars_to('<select id="date_month" name="date[month]">' + get_options(1,time.month - 1,{:label_func => :get_month_with_numbers}) + %{<option selected="selected" value="#{time.month}">#{time.month} - #{get_month time.month}</option>} + get_options(time.month + 1,12,{:label_func => :get_month_with_numbers}) + "</select>", 'time' => time)
215 end
9bae121 @ludicast added select_month test
authored Mar 13, 2010
216
90715ad @ludicast added short month
authored Mar 13, 2010
217 it "should let you use short name for months" do
218 time = Time.now
504ee6b @ludicast added prompt and foreign month option
authored Mar 13, 2010
219 @tag = "{% select_month time, use_month_names:spanish_month_names %}"
220 @tag.should parse_with_vars_to('<select id="date_month" name="date[month]">' + get_options(1,time.month - 1,{:label_func => :get_spanish_month_name}) + %{<option selected="selected" value="#{time.month}">#{get_spanish_month_name time.month}</option>} + get_options(time.month + 1,12,{:label_func => :get_spanish_month_name}) + "</select>", 'time' => time, 'spanish_month_names' => spanish_month_names)
221 end
222 it "should let you use alternate names for months" do
223 time = Time.now
90715ad @ludicast added short month
authored Mar 13, 2010
224 @tag = "{% select_month time, use_short_month:true %}"
225 @tag.should parse_with_vars_to('<select id="date_month" name="date[month]">' + get_options(1,time.month - 1,{:label_func => :get_short_month}) + %{<option selected="selected" value="#{time.month}">#{get_short_month time.month}</option>} + get_options(time.month + 1,12,{:label_func => :get_short_month}) + "</select>", 'time' => time)
226 end
7682ec8 @ludicast added data and time selects
authored Mar 13, 2010
227 end
228
229 context "for select_date tag" do
230 it "should take default time" do
231 time = Time.now
232 @tag = "{% select_date time %}"
233 @year_string = '<select id="date_year" name="date[year]">' + get_options(time.year-5,time.year - 1) + %{<option selected="selected" value="#{time.year}">#{time.year}</option>} + get_options(time.year + 1,time.year + 5) + "</select>"
234 @month_string = '<select id="date_month" name="date[month]">' + get_options(1,time.month - 1,{:label_func => :get_month}) + %{<option selected="selected" value="#{time.month}">#{get_month time.month}</option>} + get_options(time.month + 1,12,{:label_func => :get_month}) + "</select>"
d7cdb23 @ludicast modified date/time zerio padding
authored Apr 3, 2010
235 @day_string = '<select id="date_day" name="date[day]">' + get_options(1,(time.day - 1),:ignore_zeros => true) + %{<option selected="selected" value="#{time.day}">#{time.day}</option>} + get_options((time.day + 1),31,:ignore_zeros => true) + "</select>"
7682ec8 @ludicast added data and time selects
authored Mar 13, 2010
236 @tag.should parse_with_vars_to(@year_string + @month_string + @day_string, 'time' => time)
237 end
c946e60 @ludicast added order option
authored Mar 13, 2010
238 it "should allow other orders" do
239 time = Time.now
240 @tag = "{% select_date time,order:['day' 'month' 'year'] %}"
241 @year_string = '<select id="date_year" name="date[year]">' + get_options(time.year-5,time.year - 1) + %{<option selected="selected" value="#{time.year}">#{time.year}</option>} + get_options(time.year + 1,time.year + 5) + "</select>"
242 @month_string = '<select id="date_month" name="date[month]">' + get_options(1,time.month - 1,{:label_func => :get_month}) + %{<option selected="selected" value="#{time.month}">#{get_month time.month}</option>} + get_options(time.month + 1,12,{:label_func => :get_month}) + "</select>"
d7cdb23 @ludicast modified date/time zerio padding
authored Apr 3, 2010
243 @day_string = '<select id="date_day" name="date[day]">' + get_options(1,(time.day - 1),:ignore_zeros => true) + %{<option selected="selected" value="#{time.day}">#{time.day}</option>} + get_options((time.day + 1),31,:ignore_zeros => true) + "</select>"
c946e60 @ludicast added order option
authored Mar 14, 2010
244 @tag.should parse_with_vars_to(@day_string + @month_string + @year_string, 'time' => time)
245 end
d6c2a78 @ludicast added date
authored Mar 13, 2010
246 it "should allow discarding of type" do
247 time = Time.now
248 @tag = "{% select_date time,discard_type:true %}"
249 @year_string = '<select id="date" name="date">' + get_options(time.year-5,time.year - 1) + %{<option selected="selected" value="#{time.year}">#{time.year}</option>} + get_options(time.year + 1,time.year + 5) + "</select>"
250 @month_string = '<select id="date" name="date">' + get_options(1,time.month - 1,{:label_func => :get_month}) + %{<option selected="selected" value="#{time.month}">#{get_month time.month}</option>} + get_options(time.month + 1,12,{:label_func => :get_month}) + "</select>"
d7cdb23 @ludicast modified date/time zerio padding
authored Apr 3, 2010
251 @day_string = '<select id="date" name="date">' + get_options(1,(time.day - 1),:ignore_zeros => true) + %{<option selected="selected" value="#{time.day}">#{time.day}</option>} + get_options((time.day + 1),31,:ignore_zeros => true) + "</select>"
d6c2a78 @ludicast added date
authored Mar 14, 2010
252 @tag.should parse_with_vars_to(@year_string + @month_string + @day_string, 'time' => time)
253 end
7682ec8 @ludicast added data and time selects
authored Mar 13, 2010
254 it "should set default time to current time" do
255 time = Time.now
256 @tag = "{% select_date %}"
257 @year_string = '<select id="date_year" name="date[year]">' + get_options(time.year-5,time.year - 1) + %{<option selected="selected" value="#{time.year}">#{time.year}</option>} + get_options(time.year + 1,time.year + 5) + "</select>"
258 @month_string = '<select id="date_month" name="date[month]">' + get_options(1,time.month - 1,{:label_func => :get_month}) + %{<option selected="selected" value="#{time.month}">#{get_month time.month}</option>} + get_options(time.month + 1,12,{:label_func => :get_month}) + "</select>"
d7cdb23 @ludicast modified date/time zerio padding
authored Apr 3, 2010
259 @day_string = '<select id="date_day" name="date[day]">' + get_options(1,(time.day - 1),:ignore_zeros => true) + %{<option selected="selected" value="#{time.day}">#{time.day}</option>} + get_options((time.day + 1),31,:ignore_zeros => true) + "</select>"
7682ec8 @ludicast added data and time selects
authored Mar 13, 2010
260 @tag.should parse_to(@year_string + @month_string + @day_string)
1f03b5b @ludicast added separator
authored Mar 13, 2010
261 end
504ee6b @ludicast added prompt and foreign month option
authored Mar 13, 2010
262
1f03b5b @ludicast added separator
authored Mar 14, 2010
263 it "should take separator option" do
264 time = Time.now
265 @tag = "{% select_date time,date_separator:'/' %}"
266 @year_string = '<select id="date_year" name="date[year]">' + get_options(time.year-5,time.year - 1) + %{<option selected="selected" value="#{time.year}">#{time.year}</option>} + get_options(time.year + 1,time.year + 5) + "</select>"
267 @month_string = '<select id="date_month" name="date[month]">' + get_options(1,time.month - 1,{:label_func => :get_month}) + %{<option selected="selected" value="#{time.month}">#{get_month time.month}</option>} + get_options(time.month + 1,12,{:label_func => :get_month}) + "</select>"
d7cdb23 @ludicast modified date/time zerio padding
authored Apr 3, 2010
268 @day_string = '<select id="date_day" name="date[day]">' + get_options(1,(time.day - 1),:ignore_zeros => true) + %{<option selected="selected" value="#{time.day}">#{time.day}</option>} + get_options((time.day + 1),31,:ignore_zeros => true) + "</select>"
1f03b5b @ludicast added separator
authored Mar 14, 2010
269 @tag.should parse_with_vars_to(@year_string + "/" + @month_string + "/" + @day_string, 'time' => time)
7682ec8 @ludicast added data and time selects
authored Mar 13, 2010
270 end
441beb9 @ludicast added prompt
authored Mar 14, 2010
271 it "should take prefix option" do
272 time = Time.now
273 @tag = "{% select_date time,prefix:'payday' %}"
274 @year_string = '<select id="payday_year" name="payday[year]">' + get_options(time.year-5,time.year - 1) + %{<option selected="selected" value="#{time.year}">#{time.year}</option>} + get_options(time.year + 1,time.year + 5) + "</select>"
275 @month_string = '<select id="payday_month" name="payday[month]">' + get_options(1,time.month - 1,{:label_func => :get_month}) + %{<option selected="selected" value="#{time.month}">#{get_month time.month}</option>} + get_options(time.month + 1,12,{:label_func => :get_month}) + "</select>"
d7cdb23 @ludicast modified date/time zerio padding
authored Apr 3, 2010
276 @day_string = '<select id="payday_day" name="payday[day]">' + get_options(1,(time.day - 1),:ignore_zeros => true) + %{<option selected="selected" value="#{time.day}">#{time.day}</option>} + get_options((time.day + 1),31,:ignore_zeros => true) + "</select>"
441beb9 @ludicast added prompt
authored Mar 14, 2010
277 @tag.should parse_with_vars_to(@year_string + @month_string + @day_string, 'time' => time)
278 end
279
69fa315 @ludicast refactored select_time, select_date classes
authored Mar 14, 2010
280 it "should take prompt" do
441beb9 @ludicast added prompt
authored Mar 14, 2010
281 time = Time.now
282 @tag = %{{% select_date time, day_prompt:"Choose Day", month_prompt:"Choose Month", year_prompt:"Choose Year" %}}
283 @year_string = '<select id="date_year" name="date[year]"><option value="">Choose Year</option>' + get_options(time.year-5,time.year - 1) + %{<option selected="selected" value="#{time.year}">#{time.year}</option>} + get_options(time.year + 1,time.year + 5) + "</select>"
284 @month_string = '<select id="date_month" name="date[month]"><option value="">Choose Month</option>' + get_options(1,time.month - 1,{:label_func => :get_month}) + %{<option selected="selected" value="#{time.month}">#{get_month time.month}</option>} + get_options(time.month + 1,12,{:label_func => :get_month}) + "</select>"
d7cdb23 @ludicast modified date/time zerio padding
authored Apr 3, 2010
285 @day_string = '<select id="date_day" name="date[day]"><option value="">Choose Day</option>' + get_options(1,(time.day - 1),:ignore_zeros => true) + %{<option selected="selected" value="#{time.day}">#{time.day}</option>} + get_options((time.day + 1),31,:ignore_zeros => true) + "</select>"
441beb9 @ludicast added prompt
authored Mar 14, 2010
286 @tag.should parse_to(@year_string + @month_string + @day_string)
287 end
69fa315 @ludicast refactored select_time, select_date classes
authored Mar 14, 2010
288 it "should take generic prompts" do
289 time = Time.now
290 @tag = %{{% select_date time, day_prompt:true, month_prompt:true, year_prompt:true %}}
291 @year_string = '<select id="date_year" name="date[year]"><option value="">Years</option>' + get_options(time.year-5,time.year - 1) + %{<option selected="selected" value="#{time.year}">#{time.year}</option>} + get_options(time.year + 1,time.year + 5) + "</select>"
292 @month_string = '<select id="date_month" name="date[month]"><option value="">Months</option>' + get_options(1,time.month - 1,{:label_func => :get_month}) + %{<option selected="selected" value="#{time.month}">#{get_month time.month}</option>} + get_options(time.month + 1,12,{:label_func => :get_month}) + "</select>"
d7cdb23 @ludicast modified date/time zerio padding
authored Apr 3, 2010
293 @day_string = '<select id="date_day" name="date[day]"><option value="">Days</option>' + get_options(1,(time.day - 1),:ignore_zeros => true) + %{<option selected="selected" value="#{time.day}">#{time.day}</option>} + get_options((time.day + 1),31,:ignore_zeros => true) + "</select>"
69fa315 @ludicast refactored select_time, select_date classes
authored Mar 14, 2010
294 @tag.should parse_to(@year_string + @month_string + @day_string)
295 end
296 it "should take generic prompts for all" do
297 time = Time.now
298 @tag = %{{% select_date time, prompt:true %}}
299 @year_string = '<select id="date_year" name="date[year]"><option value="">Years</option>' + get_options(time.year-5,time.year - 1) + %{<option selected="selected" value="#{time.year}">#{time.year}</option>} + get_options(time.year + 1,time.year + 5) + "</select>"
300 @month_string = '<select id="date_month" name="date[month]"><option value="">Months</option>' + get_options(1,time.month - 1,{:label_func => :get_month}) + %{<option selected="selected" value="#{time.month}">#{get_month time.month}</option>} + get_options(time.month + 1,12,{:label_func => :get_month}) + "</select>"
d7cdb23 @ludicast modified date/time zerio padding
authored Apr 3, 2010
301 @day_string = '<select id="date_day" name="date[day]"><option value="">Days</option>' + get_options(1,(time.day - 1),:ignore_zeros => true) + %{<option selected="selected" value="#{time.day}">#{time.day}</option>} + get_options((time.day + 1),31,:ignore_zeros => true) + "</select>"
69fa315 @ludicast refactored select_time, select_date classes
authored Mar 14, 2010
302 @tag.should parse_to(@year_string + @month_string + @day_string)
303 end
90715ad @ludicast added short month
authored Mar 13, 2010
304 end
305
7682ec8 @ludicast added data and time selects
authored Mar 13, 2010
306 context "for select_time tag" do
307 it "should take default time" do
308 time = Time.now
309 @tag = "{% select_time time %}"
73a20cd @ludicast cut off hours at 23
authored Apr 4, 2010
310 @hour_string = '<select id="date_hour" name="date[hour]">' + get_options(0,(time.hour - 1)) + %{<option selected="selected" value="#{time.hour}">#{fill_zeros time.hour}</option>} + get_options((time.hour + 1),23) + "</select>"
515a846 @ludicast cleanup
authored Mar 15, 2010
311 @minute_string = '<select id="date_minute" name="date[minute]">' + get_options(0,(time.min - 1)) + %{<option selected="selected" value="#{time.min}">#{fill_zeros time.min}</option>} + get_options((time.min + 1),59) + "</select>"
7682ec8 @ludicast added data and time selects
authored Mar 13, 2010
312 @tag.should parse_with_vars_to(@hour_string + @minute_string, 'time' => time)
313 end
314
315 it "should set default time to current time" do
316 time = Time.now
317 @tag = "{% select_time %}"
73a20cd @ludicast cut off hours at 23
authored Apr 4, 2010
318 @hour_string = '<select id="date_hour" name="date[hour]">' + get_options(0,(time.hour - 1)) + %{<option selected="selected" value="#{time.hour}">#{fill_zeros time.hour}</option>} + get_options((time.hour + 1),23) + "</select>"
515a846 @ludicast cleanup
authored Mar 15, 2010
319 @minute_string = '<select id="date_minute" name="date[minute]">' + get_options(0,(time.min - 1)) + %{<option selected="selected" value="#{time.min}">#{fill_zeros time.min}</option>} + get_options((time.min + 1),59) + "</select>"
7682ec8 @ludicast added data and time selects
authored Mar 13, 2010
320 @tag.should parse_to(@hour_string + @minute_string)
321 end
697d7d1 @ludicast added time_separator, allowing : in strings
authored Mar 14, 2010
322 it "should allow separator" do
323 time = Time.now
324 @tag = "{% select_time time, time_separator:':' %}"
73a20cd @ludicast cut off hours at 23
authored Apr 4, 2010
325 @hour_string = '<select id="date_hour" name="date[hour]">' + get_options(0,(time.hour - 1)) + %{<option selected="selected" value="#{time.hour}">#{fill_zeros time.hour}</option>} + get_options((time.hour + 1),23) + "</select>"
515a846 @ludicast cleanup
authored Mar 15, 2010
326 @minute_string = '<select id="date_minute" name="date[minute]">' + get_options(0,(time.min - 1)) + %{<option selected="selected" value="#{time.min}">#{fill_zeros time.min}</option>} + get_options((time.min + 1),59) + "</select>"
697d7d1 @ludicast added time_separator, allowing : in strings
authored Mar 14, 2010
327 @tag.should parse_with_vars_to(@hour_string + ":" + @minute_string, 'time' => time)
328 end
d6c2a78 @ludicast added date
authored Mar 14, 2010
329
527f15a @ludicast added second option
authored Mar 14, 2010
330 it "should allow seconds" do
331 time = Time.now
332 @tag = "{% select_time time, include_seconds:true %}"
73a20cd @ludicast cut off hours at 23
authored Apr 4, 2010
333 @hour_string = '<select id="date_hour" name="date[hour]">' + get_options(0,(time.hour - 1)) + %{<option selected="selected" value="#{time.hour}">#{fill_zeros time.hour}</option>} + get_options((time.hour + 1),23) + "</select>"
515a846 @ludicast cleanup
authored Mar 15, 2010
334 @minute_string = '<select id="date_minute" name="date[minute]">' + get_options(0,(time.min - 1)) + %{<option selected="selected" value="#{time.min}">#{fill_zeros time.min}</option>} + get_options((time.min + 1),59) + "</select>"
335 @second_string = '<select id="date_second" name="date[second]">' + get_options(0,(time.sec - 1)) + %{<option selected="selected" value="#{time.sec}">#{fill_zeros time.sec}</option>} + get_options((time.sec + 1),59) + "</select>"
527f15a @ludicast added second option
authored Mar 14, 2010
336 @tag.should parse_with_vars_to(@hour_string + @minute_string + @second_string, 'time' => time)
337 end
338
de93e29 @ludicast pulling up functions
authored Mar 14, 2010
339 it "should allow seconds and separator" do
340 time = Time.now
341 @tag = "{% select_time time, include_seconds:true, time_separator:':' %}"
73a20cd @ludicast cut off hours at 23
authored Apr 4, 2010
342 @hour_string = '<select id="date_hour" name="date[hour]">' + get_options(0,(time.hour - 1)) + %{<option selected="selected" value="#{time.hour}">#{fill_zeros time.hour}</option>} + get_options((time.hour + 1),23) + "</select>"
515a846 @ludicast cleanup
authored Mar 15, 2010
343 @minute_string = '<select id="date_minute" name="date[minute]">' + get_options(0,(time.min - 1)) + %{<option selected="selected" value="#{time.min}">#{fill_zeros time.min}</option>} + get_options((time.min + 1),59) + "</select>"
344 @second_string = '<select id="date_second" name="date[second]">' + get_options(0,(time.sec - 1)) + %{<option selected="selected" value="#{time.sec}">#{fill_zeros time.sec}</option>} + get_options((time.sec + 1),59) + "</select>"
de93e29 @ludicast pulling up functions
authored Mar 14, 2010
345 @tag.should parse_with_vars_to(@hour_string + ":" + @minute_string + ":" + @second_string, 'time' => time)
346 end
347
4db524b @ludicast added datetime tag
authored Mar 14, 2010
348 it "should allow prompts" do
349 time = Time.now
350 @tag = "{% select_time time, include_seconds:true, second_prompt:'input seconds',minute_prompt:'input minutes',hour_prompt:'input hours' %}"
73a20cd @ludicast cut off hours at 23
authored Apr 4, 2010
351 @hour_string = '<select id="date_hour" name="date[hour]"><option value="">input hours</option>' + get_options(0,(time.hour - 1)) + %{<option selected="selected" value="#{time.hour}">#{fill_zeros time.hour}</option>} + get_options((time.hour + 1),23) + "</select>"
515a846 @ludicast cleanup
authored Mar 15, 2010
352 @minute_string = '<select id="date_minute" name="date[minute]"><option value="">input minutes</option>' + get_options(0,(time.min - 1)) + %{<option selected="selected" value="#{time.min}">#{fill_zeros time.min}</option>} + get_options((time.min + 1),59) + "</select>"
353 @second_string = '<select id="date_second" name="date[second]"><option value="">input seconds</option>' + get_options(0,(time.sec - 1)) + %{<option selected="selected" value="#{time.sec}">#{fill_zeros time.sec}</option>} + get_options((time.sec + 1),59) + "</select>"
4db524b @ludicast added datetime tag
authored Mar 14, 2010
354 @tag.should parse_with_vars_to(@hour_string + @minute_string + @second_string, 'time' => time)
355 end
356
357 it "should allow default prompt" do
358 time = Time.now
359 @tag = "{% select_time time,hour_prompt:true %}"
73a20cd @ludicast cut off hours at 23
authored Apr 4, 2010
360 @hour_string = '<select id="date_hour" name="date[hour]"><option value="">Hours</option>' + get_options(0,(time.hour - 1)) + %{<option selected="selected" value="#{time.hour}">#{fill_zeros time.hour}</option>} + get_options((time.hour + 1),23) + "</select>"
515a846 @ludicast cleanup
authored Mar 15, 2010
361 @minute_string = '<select id="date_minute" name="date[minute]">' + get_options(0,(time.min - 1)) + %{<option selected="selected" value="#{time.min}">#{fill_zeros time.min}</option>} + get_options((time.min + 1),59) + "</select>"
4db524b @ludicast added datetime tag
authored Mar 14, 2010
362 @tag.should parse_with_vars_to(@hour_string + @minute_string, 'time' => time)
363 end
364
365 it "should allow default prompt" do
366 time = Time.now
367 @tag = "{% select_time time,prompt:true %}"
73a20cd @ludicast cut off hours at 23
authored Apr 4, 2010
368 @hour_string = '<select id="date_hour" name="date[hour]"><option value="">Hours</option>' + get_options(0,(time.hour - 1)) + %{<option selected="selected" value="#{time.hour}">#{fill_zeros time.hour}</option>} + get_options((time.hour + 1),23) + "</select>"
515a846 @ludicast cleanup
authored Mar 15, 2010
369 @minute_string = '<select id="date_minute" name="date[minute]"><option value="">Minutes</option>' + get_options(0,(time.min - 1)) + %{<option selected="selected" value="#{time.min}">#{fill_zeros time.min}</option>} + get_options((time.min + 1),59) + "</select>"
4db524b @ludicast added datetime tag
authored Mar 14, 2010
370 @tag.should parse_with_vars_to(@hour_string + @minute_string, 'time' => time)
371 end
372
373 end
374
375
376 context "for select_datetime" do
377 it "should work with default time" do
378 time = Time.now
73a20cd @ludicast cut off hours at 23
authored Apr 4, 2010
379 @hour_string = '<select id="date_hour" name="date[hour]">' + get_options(0,(time.hour - 1)) + %{<option selected="selected" value="#{time.hour}">#{fill_zeros time.hour}</option>} + get_options((time.hour + 1),23) + "</select>"
515a846 @ludicast cleanup
authored Mar 15, 2010
380 @minute_string = '<select id="date_minute" name="date[minute]">' + get_options(0,(time.min - 1)) + %{<option selected="selected" value="#{time.min}">#{fill_zeros time.min}</option>} + get_options((time.min + 1),59) + "</select>"
4db524b @ludicast added datetime tag
authored Mar 14, 2010
381 @year_string = '<select id="date_year" name="date[year]">' + get_options(time.year-5,time.year - 1) + %{<option selected="selected" value="#{time.year}">#{time.year}</option>} + get_options(time.year + 1,time.year + 5) + "</select>"
382 @month_string = '<select id="date_month" name="date[month]">' + get_options(1,time.month - 1,{:label_func => :get_month}) + %{<option selected="selected" value="#{time.month}">#{get_month time.month}</option>} + get_options(time.month + 1,12,{:label_func => :get_month}) + "</select>"
d7cdb23 @ludicast modified date/time zerio padding
authored Apr 3, 2010
383 @day_string = '<select id="date_day" name="date[day]">' + get_options(1,(time.day - 1),:ignore_zeros => true) + %{<option selected="selected" value="#{time.day}">#{time.day}</option>} + get_options((time.day + 1),31,:ignore_zeros => true) + "</select>"
4db524b @ludicast added datetime tag
authored Mar 14, 2010
384
385 @tag = "{% select_datetime %}"
386 @tag.should parse_to(@year_string + @month_string +@day_string + @hour_string + @minute_string)
14dfe73 @ludicast further cleaning
authored Mar 14, 2010
387 end
388
389 it "should work with inputted time" do
390 time = Time.now
73a20cd @ludicast cut off hours at 23
authored Apr 4, 2010
391 @hour_string = '<select id="date_hour" name="date[hour]">' + get_options(0,(time.hour - 1)) + %{<option selected="selected" value="#{time.hour}">#{fill_zeros time.hour}</option>} + get_options((time.hour + 1),23) + "</select>"
515a846 @ludicast cleanup
authored Mar 15, 2010
392 @minute_string = '<select id="date_minute" name="date[minute]">' + get_options(0,(time.min - 1)) + %{<option selected="selected" value="#{time.min}">#{fill_zeros time.min}</option>} + get_options((time.min + 1),59) + "</select>"
14dfe73 @ludicast further cleaning
authored Mar 14, 2010
393 @year_string = '<select id="date_year" name="date[year]">' + get_options(time.year-5,time.year - 1) + %{<option selected="selected" value="#{time.year}">#{time.year}</option>} + get_options(time.year + 1,time.year + 5) + "</select>"
394 @month_string = '<select id="date_month" name="date[month]">' + get_options(1,time.month - 1,{:label_func => :get_month}) + %{<option selected="selected" value="#{time.month}">#{get_month time.month}</option>} + get_options(time.month + 1,12,{:label_func => :get_month}) + "</select>"
d7cdb23 @ludicast modified date/time zerio padding
authored Apr 3, 2010
395 @day_string = '<select id="date_day" name="date[day]">' + get_options(1,(time.day - 1),:ignore_zeros => true) + %{<option selected="selected" value="#{time.day}">#{time.day}</option>} + get_options((time.day + 1),31,:ignore_zeros => true) + "</select>"
14dfe73 @ludicast further cleaning
authored Mar 14, 2010
396
397 @tag = "{% select_datetime time %}"
398 @tag.should parse_with_vars_to(@year_string + @month_string +@day_string + @hour_string + @minute_string, 'time' => time)
399 end
400
401 it "should work with inputted order" do
402 time = Time.now
73a20cd @ludicast cut off hours at 23
authored Apr 4, 2010
403 @hour_string = '<select id="date_hour" name="date[hour]">' + get_options(0,(time.hour - 1)) + %{<option selected="selected" value="#{time.hour}">#{fill_zeros time.hour}</option>} + get_options((time.hour + 1),23) + "</select>"
515a846 @ludicast cleanup
authored Mar 15, 2010
404 @minute_string = '<select id="date_minute" name="date[minute]">' + get_options(0,(time.min - 1)) + %{<option selected="selected" value="#{time.min}">#{fill_zeros time.min}</option>} + get_options((time.min + 1),59) + "</select>"
14dfe73 @ludicast further cleaning
authored Mar 14, 2010
405 @year_string = '<select id="date_year" name="date[year]">' + get_options(time.year-5,time.year - 1) + %{<option selected="selected" value="#{time.year}">#{time.year}</option>} + get_options(time.year + 1,time.year + 5) + "</select>"
406 @month_string = '<select id="date_month" name="date[month]">' + get_options(1,time.month - 1,{:label_func => :get_month}) + %{<option selected="selected" value="#{time.month}">#{get_month time.month}</option>} + get_options(time.month + 1,12,{:label_func => :get_month}) + "</select>"
d7cdb23 @ludicast modified date/time zerio padding
authored Apr 3, 2010
407 @day_string = '<select id="date_day" name="date[day]">' + get_options(1,(time.day - 1),:ignore_zeros => true) + %{<option selected="selected" value="#{time.day}">#{time.day}</option>} + get_options((time.day + 1),31,:ignore_zeros => true) + "</select>"
14dfe73 @ludicast further cleaning
authored Mar 14, 2010
408
409 @tag = "{% select_datetime time,order:['month' 'day' 'year'] %}"
410 @tag.should parse_with_vars_to(@month_string + @day_string + @year_string + @hour_string + @minute_string, 'time' => time)
4db524b @ludicast added datetime tag
authored Mar 14, 2010
411
412 end
413
14dfe73 @ludicast further cleaning
authored Mar 14, 2010
414 it "should work with date separators" do
415 time = Time.now
73a20cd @ludicast cut off hours at 23
authored Apr 4, 2010
416 @hour_string = '<select id="date_hour" name="date[hour]">' + get_options(0,(time.hour - 1)) + %{<option selected="selected" value="#{time.hour}">#{fill_zeros time.hour}</option>} + get_options((time.hour + 1),23) + "</select>"
515a846 @ludicast cleanup
authored Mar 15, 2010
417 @minute_string = '<select id="date_minute" name="date[minute]">' + get_options(0,(time.min - 1)) + %{<option selected="selected" value="#{time.min}">#{fill_zeros time.min}</option>} + get_options((time.min + 1),59) + "</select>"
14dfe73 @ludicast further cleaning
authored Mar 14, 2010
418 @year_string = '<select id="date_year" name="date[year]">' + get_options(time.year-5,time.year - 1) + %{<option selected="selected" value="#{time.year}">#{time.year}</option>} + get_options(time.year + 1,time.year + 5) + "</select>"
419 @month_string = '<select id="date_month" name="date[month]">' + get_options(1,time.month - 1,{:label_func => :get_month}) + %{<option selected="selected" value="#{time.month}">#{get_month time.month}</option>} + get_options(time.month + 1,12,{:label_func => :get_month}) + "</select>"
d7cdb23 @ludicast modified date/time zerio padding
authored Apr 3, 2010
420 @day_string = '<select id="date_day" name="date[day]">' + get_options(1,(time.day - 1),:ignore_zeros => true) + %{<option selected="selected" value="#{time.day}">#{time.day}</option>} + get_options((time.day + 1),31,:ignore_zeros => true) + "</select>"
14dfe73 @ludicast further cleaning
authored Mar 14, 2010
421
422 @tag = "{% select_datetime time,date_separator:'/' %}"
423 @tag.should parse_with_vars_to(@year_string + '/' + @month_string + '/' + @day_string + @hour_string + @minute_string, 'time' => time)
424 end
425
426 it "should work with total separators" do
427 time = Time.now
73a20cd @ludicast cut off hours at 23
authored Apr 4, 2010
428 @hour_string = '<select id="date_hour" name="date[hour]">' + get_options(0,(time.hour - 1)) + %{<option selected="selected" value="#{time.hour}">#{fill_zeros time.hour}</option>} + get_options((time.hour + 1),23) + "</select>"
515a846 @ludicast cleanup
authored Mar 15, 2010
429 @minute_string = '<select id="date_minute" name="date[minute]">' + get_options(0,(time.min - 1)) + %{<option selected="selected" value="#{time.min}">#{fill_zeros time.min}</option>} + get_options((time.min + 1),59) + "</select>"
14dfe73 @ludicast further cleaning
authored Mar 14, 2010
430 @year_string = '<select id="date_year" name="date[year]">' + get_options(time.year-5,time.year - 1) + %{<option selected="selected" value="#{time.year}">#{time.year}</option>} + get_options(time.year + 1,time.year + 5) + "</select>"
431 @month_string = '<select id="date_month" name="date[month]">' + get_options(1,time.month - 1,{:label_func => :get_month}) + %{<option selected="selected" value="#{time.month}">#{get_month time.month}</option>} + get_options(time.month + 1,12,{:label_func => :get_month}) + "</select>"
d7cdb23 @ludicast modified date/time zerio padding
authored Apr 3, 2010
432 @day_string = '<select id="date_day" name="date[day]">' + get_options(1,(time.day - 1),:ignore_zeros => true) + %{<option selected="selected" value="#{time.day}">#{time.day}</option>} + get_options((time.day + 1),31,:ignore_zeros => true) + "</select>"
4db524b @ludicast added datetime tag
authored Mar 14, 2010
433
14dfe73 @ludicast further cleaning
authored Mar 14, 2010
434 @tag = "{% select_datetime time,date_separator:'/',time_separator:':',datetime_separator:'---' %}"
435 @tag.should parse_with_vars_to(@year_string + '/' + @month_string + '/' + @day_string + "---" + @hour_string + ":" + @minute_string, 'time' => time)
436 end
4db524b @ludicast added datetime tag
authored Mar 14, 2010
437
14dfe73 @ludicast further cleaning
authored Mar 14, 2010
438 it "should work discard type" do
439 time = Time.now
73a20cd @ludicast cut off hours at 23
authored Apr 4, 2010
440 @hour_string = '<select id="date" name="date">' + get_options(0,(time.hour - 1)) + %{<option selected="selected" value="#{time.hour}">#{fill_zeros time.hour}</option>} + get_options((time.hour + 1),23) + "</select>"
ea1a45a @ludicast added date_select functionality
authored Mar 15, 2010
441 @minute_string = '<select id="date" name="date">' + get_options(0,(time.min - 1)) + %{<option selected="selected" value="#{time.min}">#{fill_zeros time.min}</option>} + get_options((time.min + 1),59) + "</select>"
14dfe73 @ludicast further cleaning
authored Mar 14, 2010
442 @year_string = '<select id="date" name="date">' + get_options(time.year-5,time.year - 1) + %{<option selected="selected" value="#{time.year}">#{time.year}</option>} + get_options(time.year + 1,time.year + 5) + "</select>"
443 @month_string = '<select id="date" name="date">' + get_options(1,time.month - 1,{:label_func => :get_month}) + %{<option selected="selected" value="#{time.month}">#{get_month time.month}</option>} + get_options(time.month + 1,12,{:label_func => :get_month}) + "</select>"
d7cdb23 @ludicast modified date/time zerio padding
authored Apr 3, 2010
444 @day_string = '<select id="date" name="date">' + get_options(1,(time.day - 1),:ignore_zeros => true) + %{<option selected="selected" value="#{time.day}">#{time.day}</option>} + get_options((time.day + 1),31,:ignore_zeros => true) + "</select>"
14dfe73 @ludicast further cleaning
authored Mar 14, 2010
445
446 @tag = "{% select_datetime time,discard_type:true %}"
447 @tag.should parse_with_vars_to(@year_string + @month_string +@day_string + @hour_string + @minute_string, 'time' => time)
448 end
ef61201 @ludicast added time_select tag
authored Mar 15, 2010
449 it "should work with new prefix" do
14dfe73 @ludicast further cleaning
authored Mar 14, 2010
450 time = Time.now
73a20cd @ludicast cut off hours at 23
authored Apr 4, 2010
451 @hour_string = '<select id="payday_hour" name="payday[hour]">' + get_options(0,(time.hour - 1)) + %{<option selected="selected" value="#{time.hour}">#{fill_zeros time.hour}</option>} + get_options((time.hour + 1),23) + "</select>"
ea1a45a @ludicast added date_select functionality
authored Mar 15, 2010
452 @minute_string = '<select id="payday_minute" name="payday[minute]">' + get_options(0,(time.min - 1)) + %{<option selected="selected" value="#{time.min}">#{fill_zeros time.min}</option>} + get_options((time.min + 1),59) + "</select>"
14dfe73 @ludicast further cleaning
authored Mar 14, 2010
453 @year_string = '<select id="payday_year" name="payday[year]">' + get_options(time.year-5,time.year - 1) + %{<option selected="selected" value="#{time.year}">#{time.year}</option>} + get_options(time.year + 1,time.year + 5) + "</select>"
454 @month_string = '<select id="payday_month" name="payday[month]">' + get_options(1,time.month - 1,{:label_func => :get_month}) + %{<option selected="selected" value="#{time.month}">#{get_month time.month}</option>} + get_options(time.month + 1,12,{:label_func => :get_month}) + "</select>"
d7cdb23 @ludicast modified date/time zerio padding
authored Apr 3, 2010
455 @day_string = '<select id="payday_day" name="payday[day]">' + get_options(1,(time.day - 1),:ignore_zeros => true) + %{<option selected="selected" value="#{time.day}">#{time.day}</option>} + get_options((time.day + 1),31,:ignore_zeros => true) + "</select>"
14dfe73 @ludicast further cleaning
authored Mar 14, 2010
456
457 @tag = "{% select_datetime time,prefix:'payday' %}"
458 @tag.should parse_with_vars_to(@year_string + @month_string +@day_string + @hour_string + @minute_string, 'time' => time)
459 end
460
461 it "should work with take prompts" do
462 time = Time.now
73a20cd @ludicast cut off hours at 23
authored Apr 4, 2010
463 @hour_string = '<select id="date_hour" name="date[hour]"><option value="">foo</option>' + get_options(0,(time.hour - 1)) + %{<option selected="selected" value="#{time.hour}">#{fill_zeros time.hour}</option>} + get_options((time.hour + 1),23) + "</select>"
ea1a45a @ludicast added date_select functionality
authored Mar 15, 2010
464 @minute_string = '<select id="date_minute" name="date[minute]">' + get_options(0,(time.min - 1)) + %{<option selected="selected" value="#{time.min}">#{fill_zeros time.min}</option>} + get_options((time.min + 1),59) + "</select>"
14dfe73 @ludicast further cleaning
authored Mar 14, 2010
465 @year_string = '<select id="date_year" name="date[year]">' + get_options(time.year-5,time.year - 1) + %{<option selected="selected" value="#{time.year}">#{time.year}</option>} + get_options(time.year + 1,time.year + 5) + "</select>"
466 @month_string = '<select id="date_month" name="date[month]"><option value="">bar</option>' + get_options(1,time.month - 1,{:label_func => :get_month}) + %{<option selected="selected" value="#{time.month}">#{get_month time.month}</option>} + get_options(time.month + 1,12,{:label_func => :get_month}) + "</select>"
d7cdb23 @ludicast modified date/time zerio padding
authored Apr 3, 2010
467 @day_string = '<select id="date_day" name="date[day]">' + get_options(1,(time.day - 1),:ignore_zeros => true) + %{<option selected="selected" value="#{time.day}">#{time.day}</option>} + get_options((time.day + 1),31,:ignore_zeros => true) + "</select>"
14dfe73 @ludicast further cleaning
authored Mar 14, 2010
468
469 @tag = "{% select_datetime time,hour_prompt:'foo',month_prompt:'bar' %}"
470 @tag.should parse_with_vars_to(@year_string + @month_string +@day_string + @hour_string + @minute_string, 'time' => time)
471 end
472
473 it "should work with take default prompts" do
474 time = Time.now
73a20cd @ludicast cut off hours at 23
authored Apr 4, 2010
475 @hour_string = '<select id="date_hour" name="date[hour]"><option value="">Hours</option>' + get_options(0,(time.hour - 1)) + %{<option selected="selected" value="#{time.hour}">#{fill_zeros time.hour}</option>} + get_options((time.hour + 1),23) + "</select>"
515a846 @ludicast cleanup
authored Mar 15, 2010
476 @minute_string = '<select id="date_minute" name="date[minute]">' + get_options(0,(time.min - 1)) + %{<option selected="selected" value="#{time.min}">#{fill_zeros time.min}</option>} + get_options((time.min + 1),59) + "</select>"
14dfe73 @ludicast further cleaning
authored Mar 14, 2010
477 @year_string = '<select id="date_year" name="date[year]">' + get_options(time.year-5,time.year - 1) + %{<option selected="selected" value="#{time.year}">#{time.year}</option>} + get_options(time.year + 1,time.year + 5) + "</select>"
478 @month_string = '<select id="date_month" name="date[month]"><option value="">Months</option>' + get_options(1,time.month - 1,{:label_func => :get_month}) + %{<option selected="selected" value="#{time.month}">#{get_month time.month}</option>} + get_options(time.month + 1,12,{:label_func => :get_month}) + "</select>"
d7cdb23 @ludicast modified date/time zerio padding
authored Apr 3, 2010
479 @day_string = '<select id="date_day" name="date[day]">' + get_options(1,(time.day - 1),:ignore_zeros => true) + %{<option selected="selected" value="#{time.day}">#{time.day}</option>} + get_options((time.day + 1),31,:ignore_zeros => true) + "</select>"
14dfe73 @ludicast further cleaning
authored Mar 14, 2010
480
481 @tag = "{% select_datetime time,hour_prompt:true,month_prompt:true %}"
482 @tag.should parse_with_vars_to(@year_string + @month_string +@day_string + @hour_string + @minute_string, 'time' => time)
483 end
484
485 it "should work with take default prompt" do
486 time = Time.now
73a20cd @ludicast cut off hours at 23
authored Apr 4, 2010
487 @hour_string = '<select id="date_hour" name="date[hour]"><option value="">Hours</option>' + get_options(0,(time.hour - 1)) + %{<option selected="selected" value="#{time.hour}">#{fill_zeros time.hour}</option>} + get_options((time.hour + 1),23) + "</select>"
515a846 @ludicast cleanup
authored Mar 15, 2010
488 @minute_string = '<select id="date_minute" name="date[minute]"><option value="">Minutes</option>' + get_options(0,(time.min - 1)) + %{<option selected="selected" value="#{time.min}">#{fill_zeros time.min}</option>} + get_options((time.min + 1),59) + "</select>"
14dfe73 @ludicast further cleaning
authored Mar 14, 2010
489 @year_string = '<select id="date_year" name="date[year]"><option value="">Years</option>' + get_options(time.year-5,time.year - 1) + %{<option selected="selected" value="#{time.year}">#{time.year}</option>} + get_options(time.year + 1,time.year + 5) + "</select>"
490 @month_string = '<select id="date_month" name="date[month]"><option value="">Months</option>' + get_options(1,time.month - 1,{:label_func => :get_month}) + %{<option selected="selected" value="#{time.month}">#{get_month time.month}</option>} + get_options(time.month + 1,12,{:label_func => :get_month}) + "</select>"
d7cdb23 @ludicast modified date/time zerio padding
authored Apr 3, 2010
491 @day_string = '<select id="date_day" name="date[day]"><option value="">Days</option>' + get_options(1,(time.day - 1),:ignore_zeros => true) + %{<option selected="selected" value="#{time.day}">#{time.day}</option>} + get_options((time.day + 1),31,:ignore_zeros => true) + "</select>"
14dfe73 @ludicast further cleaning
authored Mar 14, 2010
492
493 @tag = "{% select_datetime time,prompt:true %}"
494 @tag.should parse_with_vars_to(@year_string + @month_string +@day_string + @hour_string + @minute_string, 'time' => time)
495 end
4db524b @ludicast added datetime tag
authored Mar 14, 2010
496
7682ec8 @ludicast added data and time selects
authored Mar 13, 2010
497 end
4db524b @ludicast added datetime tag
authored Mar 14, 2010
498
7682ec8 @ludicast added data and time selects
authored Mar 13, 2010
499 end
Something went wrong with that request. Please try again.