Commit f6eaf20a37e2217811c019f6514ba9df632f8b77
1 parent
6afad29f
Exists in
stable-spb-1.4
and in
3 other branches
Minor fixes on date format
- also fixes one broken test on content_viewer_controller Signed-off-by: Tallys Martins <tallysmartins@yahoo.com.br> (cherry picked from branch stable-1.3 commit 6703903a12e7e05a0ad493b1fc096750fe15633c)
Showing
2 changed files
with
6 additions
and
4 deletions
Show diff stats
app/helpers/forms_helper.rb
| @@ -186,6 +186,7 @@ module FormsHelper | @@ -186,6 +186,7 @@ module FormsHelper | ||
| 186 | element_id = html_options[:id] || 'datepicker-date' | 186 | element_id = html_options[:id] || 'datepicker-date' |
| 187 | value = value.strftime(format) if value.present? | 187 | value = value.strftime(format) if value.present? |
| 188 | method = datepicker_options[:time] ? 'datetimepicker' : 'datepicker' | 188 | method = datepicker_options[:time] ? 'datetimepicker' : 'datepicker' |
| 189 | + current_date_or_nil = value.present? ? "new Date('#{value}')" : "null" | ||
| 189 | result = text_field_tag(name, value, html_options) | 190 | result = text_field_tag(name, value, html_options) |
| 190 | result += | 191 | result += |
| 191 | " | 192 | " |
| @@ -236,7 +237,7 @@ module FormsHelper | @@ -236,7 +237,7 @@ module FormsHelper | ||
| 236 | weekHeader: #{datepicker_options[:week_header].to_json}, | 237 | weekHeader: #{datepicker_options[:week_header].to_json}, |
| 237 | yearRange: #{datepicker_options[:year_range].to_json}, | 238 | yearRange: #{datepicker_options[:year_range].to_json}, |
| 238 | yearSuffix: #{datepicker_options[:year_suffix].to_json} | 239 | yearSuffix: #{datepicker_options[:year_suffix].to_json} |
| 239 | - }).datepicker('setDate', new Date('#{value}')) | 240 | + }).datepicker('setDate', current_date_or_nil) |
| 240 | </script> | 241 | </script> |
| 241 | ".html_safe | 242 | ".html_safe |
| 242 | result | 243 | result |
test/functional/content_viewer_controller_test.rb
| @@ -1163,9 +1163,10 @@ class ContentViewerControllerTest < ActionController::TestCase | @@ -1163,9 +1163,10 @@ class ContentViewerControllerTest < ActionController::TestCase | ||
| 1163 | 1163 | ||
| 1164 | should 'add an zero width space every 4 caracters of comment urls' do | 1164 | should 'add an zero width space every 4 caracters of comment urls' do |
| 1165 | url = 'www.an.url.to.be.splited.com' | 1165 | url = 'www.an.url.to.be.splited.com' |
| 1166 | - a = fast_create(TextileArticle, :profile_id => @profile.id, :path => 'textile', :language => 'en') | ||
| 1167 | - c = a.comments.create!(:author => @profile, :title => 'An url', :body => url) | ||
| 1168 | - get :view_page, :profile => @profile.identifier, :page => [ 'textile' ] | 1166 | + a = @profile.articles.build(:name => 'test') |
| 1167 | + a.save! | ||
| 1168 | + c = a.comments.create!(:author => @profile, :title => 'An url', :body => url, :source => a) | ||
| 1169 | + get :view_page, :profile => @profile.identifier, :page => [ 'test' ] | ||
| 1169 | assert_tag :a, :attributes => { :href => "http://" + url}, :content => url.scan(/.{4}/).join('​') | 1170 | assert_tag :a, :attributes => { :href => "http://" + url}, :content => url.scan(/.{4}/).join('​') |
| 1170 | end | 1171 | end |
| 1171 | 1172 |