Commit 035b178eab3696f52b01cfc553ed428c189cce60
Exists in
production-vendorized
and in
1 other branch
Merge branch 'staging' into production
Showing
6 changed files
with
26 additions
and
22 deletions
Show diff stats
app/helpers/forms_helper.rb
| @@ -50,14 +50,14 @@ module FormsHelper | @@ -50,14 +50,14 @@ module FormsHelper | ||
| 50 | 50 | ||
| 51 | def select_city( simple=false ) | 51 | def select_city( simple=false ) |
| 52 | states = State.find(:all, :order => 'name') | 52 | states = State.find(:all, :order => 'name') |
| 53 | - | 53 | + |
| 54 | state_id = 'state-' + FormsHelper.next_id_number | 54 | state_id = 'state-' + FormsHelper.next_id_number |
| 55 | city_id = 'city-' + FormsHelper.next_id_number | 55 | city_id = 'city-' + FormsHelper.next_id_number |
| 56 | 56 | ||
| 57 | if states.length < 1 | 57 | if states.length < 1 |
| 58 | return | 58 | return |
| 59 | end | 59 | end |
| 60 | - | 60 | + |
| 61 | if simple | 61 | if simple |
| 62 | states = [State.new(:name => _('Select the State'))] + states | 62 | states = [State.new(:name => _('Select the State'))] + states |
| 63 | cities = [City.new(:name => _('Select the City'))] | 63 | cities = [City.new(:name => _('Select the City'))] |
| @@ -81,7 +81,7 @@ module FormsHelper | @@ -81,7 +81,7 @@ module FormsHelper | ||
| 81 | states = [State.new(:name => '---')] + states | 81 | states = [State.new(:name => '---')] + states |
| 82 | cities = [City.new(:name => '---')] | 82 | cities = [City.new(:name => '---')] |
| 83 | 83 | ||
| 84 | - html = | 84 | + html = |
| 85 | content_tag( 'div', | 85 | content_tag( 'div', |
| 86 | labelled_select( _('State:'), 'state', :id, :name, nil, states, :id => state_id ), | 86 | labelled_select( _('State:'), 'state', :id, :name, nil, states, :id => state_id ), |
| 87 | :class => 'select_state_for_origin' ) + | 87 | :class => 'select_state_for_origin' ) + |
| @@ -89,7 +89,7 @@ module FormsHelper | @@ -89,7 +89,7 @@ module FormsHelper | ||
| 89 | labelled_select( _('City:'), 'city', :id, :name, nil, cities, :id => city_id ), | 89 | labelled_select( _('City:'), 'city', :id, :name, nil, cities, :id => city_id ), |
| 90 | :class => 'select_city_for_origin' ) | 90 | :class => 'select_city_for_origin' ) |
| 91 | end | 91 | end |
| 92 | - | 92 | + |
| 93 | html + | 93 | html + |
| 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') | 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 | end | 95 | end |
| @@ -237,7 +237,7 @@ module FormsHelper | @@ -237,7 +237,7 @@ module FormsHelper | ||
| 237 | weekHeader: #{datepicker_options[:week_header].to_json}, | 237 | weekHeader: #{datepicker_options[:week_header].to_json}, |
| 238 | yearRange: #{datepicker_options[:year_range].to_json}, | 238 | yearRange: #{datepicker_options[:year_range].to_json}, |
| 239 | yearSuffix: #{datepicker_options[:year_suffix].to_json} | 239 | yearSuffix: #{datepicker_options[:year_suffix].to_json} |
| 240 | - }).datepicker('setDate', #{current_date_or_nil}) | 240 | + }).datepicker('setDate', current_date_or_nil) |
| 241 | </script> | 241 | </script> |
| 242 | ".html_safe | 242 | ".html_safe |
| 243 | result | 243 | result |
| @@ -296,3 +296,4 @@ protected | @@ -296,3 +296,4 @@ protected | ||
| 296 | end | 296 | end |
| 297 | end | 297 | end |
| 298 | end | 298 | end |
| 299 | + |
plugins/comment_group/lib/comment_group_plugin/comments_report.rb
| 1 | +require 'csv' | ||
| 2 | + | ||
| 1 | module CommentGroupPlugin::CommentsReport | 3 | module CommentGroupPlugin::CommentsReport |
| 2 | 4 | ||
| 3 | #FIXME make this test | 5 | #FIXME make this test |
| @@ -27,7 +29,7 @@ module CommentGroupPlugin::CommentsReport | @@ -27,7 +29,7 @@ module CommentGroupPlugin::CommentsReport | ||
| 27 | return _("No comments for article[%{id}]: %{path}\n\n") % {:id => article.id, :path => article.path} if @export.empty? | 29 | return _("No comments for article[%{id}]: %{path}\n\n") % {:id => article.id, :path => article.path} if @export.empty? |
| 28 | 30 | ||
| 29 | column_names = @export.first.keys | 31 | column_names = @export.first.keys |
| 30 | - CSV.generate do |csv| | 32 | + CSV.generate(force_quotes: true) do |csv| |
| 31 | csv << column_names | 33 | csv << column_names |
| 32 | @export.each { |x| csv << x.values } | 34 | @export.each { |x| csv << x.values } |
| 33 | end | 35 | end |
plugins/comment_paragraph/controllers/profile/comment_paragraph_plugin_profile_controller.rb
plugins/comment_paragraph/lib/comment_paragraph_plugin/comments_report.rb
| 1 | +require 'csv' | ||
| 2 | + | ||
| 1 | module CommentParagraphPlugin::CommentsReport | 3 | module CommentParagraphPlugin::CommentsReport |
| 2 | 4 | ||
| 3 | #FIXME make this test | 5 | #FIXME make this test |
| @@ -15,7 +17,7 @@ module CommentParagraphPlugin::CommentsReport | @@ -15,7 +17,7 @@ module CommentParagraphPlugin::CommentsReport | ||
| 15 | @export << create_comment_element(comment, paragraph, paragraph_id) | 17 | @export << create_comment_element(comment, paragraph, paragraph_id) |
| 16 | end | 18 | end |
| 17 | else # There are no comments for this paragraph | 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 | end | 21 | end |
| 20 | paragraph_id += 1 | 22 | paragraph_id += 1 |
| 21 | end | 23 | end |
| @@ -27,7 +29,7 @@ module CommentParagraphPlugin::CommentsReport | @@ -27,7 +29,7 @@ module CommentParagraphPlugin::CommentsReport | ||
| 27 | return _("No comments for article[%{id}]: %{path}\n\n") % {:id => article.id, :path => article.path} if @export.empty? | 29 | return _("No comments for article[%{id}]: %{path}\n\n") % {:id => article.id, :path => article.path} if @export.empty? |
| 28 | 30 | ||
| 29 | column_names = @export.first.keys | 31 | column_names = @export.first.keys |
| 30 | - CSV.generate do |csv| | 32 | + CSV.generate(force_quotes: true) do |csv| |
| 31 | csv << column_names | 33 | csv << column_names |
| 32 | @export.each { |x| csv << x.values } | 34 | @export.each { |x| csv << x.values } |
| 33 | end | 35 | end |
| @@ -38,13 +40,13 @@ module CommentParagraphPlugin::CommentsReport | @@ -38,13 +40,13 @@ module CommentParagraphPlugin::CommentsReport | ||
| 38 | def create_comment_element(comment, paragraph, paragraph_id) | 40 | def create_comment_element(comment, paragraph, paragraph_id) |
| 39 | { | 41 | { |
| 40 | paragraph_id: paragraph_id, | 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 | end | 51 | end |
| 50 | 52 |
plugins/comment_paragraph/test/functional/comment_paragraph_plugin_profile_controller_test.rb
| @@ -56,8 +56,8 @@ class CommentParagraphPluginProfileControllerTest < ActionController::TestCase | @@ -56,8 +56,8 @@ class CommentParagraphPluginProfileControllerTest < ActionController::TestCase | ||
| 56 | xhr :get, :export_comments, :profile => @profile.identifier, :id => article.id | 56 | xhr :get, :export_comments, :profile => @profile.identifier, :id => article.id |
| 57 | assert_equal 'text/csv; charset=UTF-8; header=present', @response.content_type | 57 | assert_equal 'text/csv; charset=UTF-8; header=present', @response.content_type |
| 58 | lines = @response.body.split("\n") | 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 | end | 61 | end |
| 62 | 62 | ||
| 63 | should 'not export any comments as CSV' do | 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 < ActiveSupport::TestCase | @@ -69,7 +69,7 @@ class CommentParagraphPluginTest < ActiveSupport::TestCase | ||
| 69 | article = fast_create(Article, :profile_id => profile.id) | 69 | article = fast_create(Article, :profile_id => profile.id) |
| 70 | article.expects(:comment_paragraph_plugin_enabled?).returns(true) | 70 | article.expects(:comment_paragraph_plugin_enabled?).returns(true) |
| 71 | article.expects(:allow_edit?).with(user).returns(true) | 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 | assert_equal 'Activate Comments', plugin.article_extra_toolbar_buttons(article).first[:title] | 74 | assert_equal 'Activate Comments', plugin.article_extra_toolbar_buttons(article).first[:title] |
| 75 | end | 75 | end |
| @@ -79,7 +79,7 @@ class CommentParagraphPluginTest < ActiveSupport::TestCase | @@ -79,7 +79,7 @@ class CommentParagraphPluginTest < ActiveSupport::TestCase | ||
| 79 | article = fast_create(Article, :profile_id => profile.id) | 79 | article = fast_create(Article, :profile_id => profile.id) |
| 80 | article.expects(:comment_paragraph_plugin_enabled?).returns(true) | 80 | article.expects(:comment_paragraph_plugin_enabled?).returns(true) |
| 81 | article.expects(:allow_edit?).with(user).returns(true) | 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 | assert_equal 'Deactivate Comments', plugin.article_extra_toolbar_buttons(article).first[:title] | 84 | assert_equal 'Deactivate Comments', plugin.article_extra_toolbar_buttons(article).first[:title] |
| 85 | end | 85 | end |
| @@ -89,9 +89,9 @@ class CommentParagraphPluginTest < ActiveSupport::TestCase | @@ -89,9 +89,9 @@ class CommentParagraphPluginTest < ActiveSupport::TestCase | ||
| 89 | article = fast_create(Article, :profile_id => profile.id) | 89 | article = fast_create(Article, :profile_id => profile.id) |
| 90 | article.expects(:comment_paragraph_plugin_enabled?).returns(true) | 90 | article.expects(:comment_paragraph_plugin_enabled?).returns(true) |
| 91 | article.expects(:allow_edit?).with(user).returns(true) | 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 | end | 95 | end |
| 96 | 96 | ||
| 97 | end | 97 | end |