Commit 035b178eab3696f52b01cfc553ed428c189cce60

Authored by Victor Costa
2 parents 7e85741b c2743b18
Exists in production

Merge branch 'staging' into production

app/helpers/forms_helper.rb
... ... @@ -50,14 +50,14 @@ module FormsHelper
50 50  
51 51 def select_city( simple=false )
52 52 states = State.find(:all, :order => 'name')
53   -
  53 +
54 54 state_id = 'state-' + FormsHelper.next_id_number
55 55 city_id = 'city-' + FormsHelper.next_id_number
56 56  
57 57 if states.length < 1
58 58 return
59 59 end
60   -
  60 +
61 61 if simple
62 62 states = [State.new(:name => _('Select the State'))] + states
63 63 cities = [City.new(:name => _('Select the City'))]
... ... @@ -81,7 +81,7 @@ module FormsHelper
81 81 states = [State.new(:name => '---')] + states
82 82 cities = [City.new(:name => '---')]
83 83  
84   - html =
  84 + html =
85 85 content_tag( 'div',
86 86 labelled_select( _('State:'), 'state', :id, :name, nil, states, :id => state_id ),
87 87 :class => 'select_state_for_origin' ) +
... ... @@ -89,7 +89,7 @@ module FormsHelper
89 89 labelled_select( _('City:'), 'city', :id, :name, nil, cities, :id => city_id ),
90 90 :class => 'select_city_for_origin' )
91 91 end
92   -
  92 +
93 93 html +
94 94 observe_field( state_id, :update => city_id, :function => "new Ajax.Updater(#{city_id.inspect}, #{url_for(:controller => 'search', :action => 'cities').inspect}, {asynchronous:true, evalScripts:true, parameters:'state_id=' + value}); $(#{city_id.inspect}).innerHTML = '<option>#{_('Loading...')}</option>'", :with => 'state_id')
95 95 end
... ... @@ -237,7 +237,7 @@ module FormsHelper
237 237 weekHeader: #{datepicker_options[:week_header].to_json},
238 238 yearRange: #{datepicker_options[:year_range].to_json},
239 239 yearSuffix: #{datepicker_options[:year_suffix].to_json}
240   - }).datepicker('setDate', #{current_date_or_nil})
  240 + }).datepicker('setDate', current_date_or_nil)
241 241 </script>
242 242 ".html_safe
243 243 result
... ... @@ -296,3 +296,4 @@ protected
296 296 end
297 297 end
298 298 end
  299 +
... ...
plugins/comment_group/lib/comment_group_plugin/comments_report.rb
  1 +require 'csv'
  2 +
1 3 module CommentGroupPlugin::CommentsReport
2 4  
3 5 #FIXME make this test
... ... @@ -27,7 +29,7 @@ module CommentGroupPlugin::CommentsReport
27 29 return _("No comments for article[%{id}]: %{path}\n\n") % {:id => article.id, :path => article.path} if @export.empty?
28 30  
29 31 column_names = @export.first.keys
30   - CSV.generate do |csv|
  32 + CSV.generate(force_quotes: true) do |csv|
31 33 csv << column_names
32 34 @export.each { |x| csv << x.values }
33 35 end
... ...
plugins/comment_paragraph/controllers/profile/comment_paragraph_plugin_profile_controller.rb
1   -require 'csv'
2 1 class CommentParagraphPluginProfileController < CommentController
3 2 append_view_path File.join(File.dirname(__FILE__) + '/../../views')
4 3  
... ...
plugins/comment_paragraph/lib/comment_paragraph_plugin/comments_report.rb
  1 +require 'csv'
  2 +
1 3 module CommentParagraphPlugin::CommentsReport
2 4  
3 5 #FIXME make this test
... ... @@ -15,7 +17,7 @@ module CommentParagraphPlugin::CommentsReport
15 17 @export << create_comment_element(comment, paragraph, paragraph_id)
16 18 end
17 19 else # There are no comments for this paragraph
18   - @export << { paragraph_id: paragraph_id, paragraph_text: paragraph }
  20 + @export << create_comment_element(nil, paragraph, paragraph_id)
19 21 end
20 22 paragraph_id += 1
21 23 end
... ... @@ -27,7 +29,7 @@ module CommentParagraphPlugin::CommentsReport
27 29 return _("No comments for article[%{id}]: %{path}\n\n") % {:id => article.id, :path => article.path} if @export.empty?
28 30  
29 31 column_names = @export.first.keys
30   - CSV.generate do |csv|
  32 + CSV.generate(force_quotes: true) do |csv|
31 33 csv << column_names
32 34 @export.each { |x| csv << x.values }
33 35 end
... ... @@ -38,13 +40,13 @@ module CommentParagraphPlugin::CommentsReport
38 40 def create_comment_element(comment, paragraph, paragraph_id)
39 41 {
40 42 paragraph_id: paragraph_id,
41   - paragraph_text: paragraph.present? ? paragraph.text : nil,
42   - comment_id: comment.id,
43   - comment_reply_to: comment.reply_of_id,
44   - comment_title: comment.title,
45   - comment_content: comment.body,
46   - comment_author_name: comment.author_name,
47   - comment_author_email: comment.author_email
  43 + paragraph_text: paragraph.present? ? paragraph.text.strip : nil,
  44 + comment_id: comment.present? ? comment.id : '-',
  45 + comment_reply_to: comment.present? ? comment.reply_of_id : '-',
  46 + comment_title: comment.present? ? comment.title : '-',
  47 + comment_content: comment.present? ? comment.body : '-',
  48 + comment_author_name: comment.present? ? comment.author_name : '-',
  49 + comment_author_email: comment.present? ? comment.author_email : '-'
48 50 }
49 51 end
50 52  
... ...
plugins/comment_paragraph/test/functional/comment_paragraph_plugin_profile_controller_test.rb
... ... @@ -56,8 +56,8 @@ class CommentParagraphPluginProfileControllerTest &lt; ActionController::TestCase
56 56 xhr :get, :export_comments, :profile => @profile.identifier, :id => article.id
57 57 assert_equal 'text/csv; charset=UTF-8; header=present', @response.content_type
58 58 lines = @response.body.split("\n")
59   - assert_equal "paragraph_text,comment_id,comment_title,comment_content,comment_author_name,comment_author_email", lines.first
60   - assert_equal ",#{comment2.id},b comment,b comment,#{comment2.author_name},#{comment2.author_email}", lines.second
  59 + assert_equal '"paragraph_id","paragraph_text","comment_id","comment_reply_to","comment_title","comment_content","comment_author_name","comment_author_email"', lines.first
  60 + assert_equal "\"\",\"\",\"#{comment2.id}\",\"\",\"b comment\",\"b comment\",\"#{comment2.author_name}\",\"#{comment2.author_email}\"", lines.second
61 61 end
62 62  
63 63 should 'not export any comments as CSV' do
... ...
plugins/comment_paragraph/test/unit/comment_paragraph_plugin_test.rb
... ... @@ -69,7 +69,7 @@ class CommentParagraphPluginTest &lt; ActiveSupport::TestCase
69 69 article = fast_create(Article, :profile_id => profile.id)
70 70 article.expects(:comment_paragraph_plugin_enabled?).returns(true)
71 71 article.expects(:allow_edit?).with(user).returns(true)
72   - article.expects(:comment_paragraph_plugin_activated?).returns(false)
  72 + article.expects(:comment_paragraph_plugin_activated?).at_least_once.returns(false)
73 73  
74 74 assert_equal 'Activate Comments', plugin.article_extra_toolbar_buttons(article).first[:title]
75 75 end
... ... @@ -79,7 +79,7 @@ class CommentParagraphPluginTest &lt; ActiveSupport::TestCase
79 79 article = fast_create(Article, :profile_id => profile.id)
80 80 article.expects(:comment_paragraph_plugin_enabled?).returns(true)
81 81 article.expects(:allow_edit?).with(user).returns(true)
82   - article.expects(:comment_paragraph_plugin_activated?).returns(true)
  82 + article.expects(:comment_paragraph_plugin_activated?).at_least_once.returns(true)
83 83  
84 84 assert_equal 'Deactivate Comments', plugin.article_extra_toolbar_buttons(article).first[:title]
85 85 end
... ... @@ -89,9 +89,9 @@ class CommentParagraphPluginTest &lt; ActiveSupport::TestCase
89 89 article = fast_create(Article, :profile_id => profile.id)
90 90 article.expects(:comment_paragraph_plugin_enabled?).returns(true)
91 91 article.expects(:allow_edit?).with(user).returns(true)
92   - article.expects(:comment_paragraph_plugin_activated?).returns(false)
  92 + article.expects(:comment_paragraph_plugin_activated?).at_least_once.returns(true)
93 93  
94   - assert_equal 'Export Comments', plugin.article_extra_toolbar_buttons(article).last[:title]
  94 + assert_includes plugin.article_extra_toolbar_buttons(article).map {|b| b[:title]}, 'Export Comments'
95 95 end
96 96  
97 97 end
... ...