Commit 13e6bd4af21120abc4edced4f5a4af8d629ad217

Authored by Victor Costa
2 parents 45a508d7 9fb3ad5a
Exists in staging and in 1 other branch production

Merge branch 'master' into staging

Conflicts:
	.travis.yml
	app/controllers/my_profile/tasks_controller.rb
	app/helpers/application_helper.rb
	app/views/profile_editor/_pending_tasks.html.erb
	app/views/tasks/processed.html.erb
	test/functional/tasks_controller_test.rb
Showing 292 changed files with 1077 additions and 1016 deletions   Show diff stats
.gitlab-ci.yml
@@ -30,14 +30,47 @@ integration: @@ -30,14 +30,47 @@ integration:
30 script: bundle exec rake test:integration 30 script: bundle exec rake test:integration
31 stage: all-tests 31 stage: all-tests
32 32
33 -cucumber:  
34 - script: bundle exec rake cucumber 33 +cucumber-1:
  34 + script: SLICE=1/2 bundle exec rake cucumber
  35 + stage: all-tests
  36 +cucumber-2:
  37 + script: SLICE=2/2 bundle exec rake cucumber
35 stage: all-tests 38 stage: all-tests
36 39
37 -selenium:  
38 - script: bundle exec rake selenium 40 +selenium-1:
  41 + script: SLICE=1/6 bundle exec rake selenium
  42 + stage: all-tests
  43 +selenium-2:
  44 + script: SLICE=2/6 bundle exec rake selenium
  45 + stage: all-tests
  46 +selenium-3:
  47 + script: SLICE=3/6 bundle exec rake selenium
  48 + stage: all-tests
  49 +selenium-4:
  50 + script: SLICE=4/6 bundle exec rake selenium
  51 + stage: all-tests
  52 +selenium-5:
  53 + script: SLICE=5/6 bundle exec rake selenium
  54 + stage: all-tests
  55 +selenium-6:
  56 + script: SLICE=6/6 bundle exec rake selenium
39 stage: all-tests 57 stage: all-tests
40 58
41 -plugins:  
42 - script: bundle exec rake test:noosfero_plugins 59 +# NOOSFERO_BUNDLE_OPTS=install makes migrations fails
  60 +# probably because of rubygems-integration
  61 +plugins-1:
  62 + script: SLICE=1/5 bundle exec rake test:noosfero_plugins
43 stage: all-tests 63 stage: all-tests
  64 +plugins-2:
  65 + script: SLICE=2/5 bundle exec rake test:noosfero_plugins
  66 + stage: all-tests
  67 +plugins-3:
  68 + script: SLICE=3/5 bundle exec rake test:noosfero_plugins
  69 + stage: all-tests
  70 +plugins-4:
  71 + script: SLICE=4/5 bundle exec rake test:noosfero_plugins
  72 + stage: all-tests
  73 +plugins-5:
  74 + script: SLICE=5/5 bundle exec rake test:noosfero_plugins
  75 + stage: all-tests
  76 +
@@ -61,11 +61,11 @@ env: @@ -61,11 +61,11 @@ env:
61 - SLICE=2/4 TASK=selenium 61 - SLICE=2/4 TASK=selenium
62 - SLICE=3/4 TASK=selenium 62 - SLICE=3/4 TASK=selenium
63 - SLICE=4/4 TASK=selenium 63 - SLICE=4/4 TASK=selenium
64 - - SLICE=1/5 TASK=test:noosfero_plugins BUNDLE_OPTS=install  
65 - - SLICE=2/5 TASK=test:noosfero_plugins BUNDLE_OPTS=install  
66 - - SLICE=3/5 TASK=test:noosfero_plugins BUNDLE_OPTS=install  
67 - - SLICE=4/5 TASK=test:noosfero_plugins BUNDLE_OPTS=install  
68 - - SLICE=5/5 TASK=test:noosfero_plugins BUNDLE_OPTS=install 64 + - SLICE=1/5 TASK=test:noosfero_plugins NOOSFERO_BUNDLE_OPTS=install
  65 + - SLICE=2/5 TASK=test:noosfero_plugins NOOSFERO_BUNDLE_OPTS=install
  66 + - SLICE=3/5 TASK=test:noosfero_plugins NOOSFERO_BUNDLE_OPTS=install
  67 + - SLICE=4/5 TASK=test:noosfero_plugins NOOSFERO_BUNDLE_OPTS=install
  68 + - SLICE=5/5 TASK=test:noosfero_plugins NOOSFERO_BUNDLE_OPTS=install
69 69
70 script: 70 script:
71 - ./script/ci 71 - ./script/ci
README.rails.md
@@ -99,7 +99,7 @@ Description of contents @@ -99,7 +99,7 @@ Description of contents
99 Holds controllers that should be named like weblog_controller.rb for automated URL mapping. All controllers should descend from `ActionController::Base`. 99 Holds controllers that should be named like weblog_controller.rb for automated URL mapping. All controllers should descend from `ActionController::Base`.
100 100
101 * `app/models` 101 * `app/models`
102 - Holds models that should be named like post.rb. Most models will descend from `ActiveRecord::Base`. 102 + Holds models that should be named like post.rb. Most models will descend from `ApplicationRecord`.
103 103
104 * `app/views` 104 * `app/views`
105 Holds the template files for the view that should be named like `weblog/index.rhtml` for the `WeblogController#index` action. All views use eRuby syntax. This directory can also be used to keep stylesheets, images, and so on that can be symlinked to public. 105 Holds the template files for the view that should be named like `weblog/index.rhtml` for the `WeblogController#index` action. All views use eRuby syntax. This directory can also be used to keep stylesheets, images, and so on that can be symlinked to public.
app/controllers/my_profile/cms_controller.rb
@@ -108,7 +108,7 @@ class CmsController < MyProfileController @@ -108,7 +108,7 @@ class CmsController < MyProfileController
108 end 108 end
109 109
110 def new 110 def new
111 - # FIXME this method should share some logic wirh edit !!! 111 + # FIXME this method should share some logic with edit !!!
112 112
113 @success_back_to = params[:success_back_to] 113 @success_back_to = params[:success_back_to]
114 # user must choose an article type first 114 # user must choose an article type first
@@ -365,7 +365,7 @@ class CmsController < MyProfileController @@ -365,7 +365,7 @@ class CmsController < MyProfileController
365 def search 365 def search
366 query = params[:q] 366 query = params[:q]
367 results = find_by_contents(:uploaded_files, profile, profile.files.published, query)[:results] 367 results = find_by_contents(:uploaded_files, profile, profile.files.published, query)[:results]
368 - render :text => article_list_to_json(results), :content_type => 'application/json' 368 + render :text => article_list_to_json(results).html_safe, :content_type => 'application/json'
369 end 369 end
370 370
371 def search_article_privacy_exceptions 371 def search_article_privacy_exceptions
app/controllers/my_profile/profile_editor_controller.rb
@@ -32,6 +32,7 @@ class ProfileEditorController < MyProfileController @@ -32,6 +32,7 @@ class ProfileEditorController < MyProfileController
32 Image.transaction do 32 Image.transaction do
33 begin 33 begin
34 @plugins.dispatch(:profile_editor_transaction_extras) 34 @plugins.dispatch(:profile_editor_transaction_extras)
  35 + # TODO: This is unsafe! Add sanitizer
35 @profile_data.update!(params[:profile_data]) 36 @profile_data.update!(params[:profile_data])
36 redirect_to :action => 'index', :profile => profile.identifier 37 redirect_to :action => 'index', :profile => profile.identifier
37 rescue Exception => ex 38 rescue Exception => ex
app/controllers/my_profile/tasks_controller.rb
@@ -162,34 +162,25 @@ class TasksController < MyProfileController @@ -162,34 +162,25 @@ class TasksController < MyProfileController
162 162
163 protected 163 protected
164 164
165 - def filter_by_closed_date(filter, tasks)  
166 - filter[:closed_from] = Date.parse(filter[:closed_from]) unless filter[:closed_from].blank?  
167 - filter[:closed_until] = Date.parse(filter[:closed_until]) unless filter[:closed_until].blank?  
168 -  
169 - tasks = tasks.where('tasks.end_date >= ?', filter[:closed_from].beginning_of_day) unless filter[:closed_from].blank?  
170 - tasks = tasks.where('tasks.end_date <= ?', filter[:closed_until].end_of_day) unless filter[:closed_until].blank?  
171 - tasks  
172 - end 165 + def filter_tasks(filter, tasks)
  166 + tasks = tasks.eager_load(:requestor, :closed_by)
  167 + tasks = tasks.of(filter[:type].presence)
  168 + tasks = tasks.where(:status => filter[:status]) unless filter[:status].blank?
173 169
174 - def filter_by_creation_date(filter, tasks)  
175 filter[:created_from] = Date.parse(filter[:created_from]) unless filter[:created_from].blank? 170 filter[:created_from] = Date.parse(filter[:created_from]) unless filter[:created_from].blank?
176 filter[:created_until] = Date.parse(filter[:created_until]) unless filter[:created_until].blank? 171 filter[:created_until] = Date.parse(filter[:created_until]) unless filter[:created_until].blank?
  172 + filter[:closed_from] = Date.parse(filter[:closed_from]) unless filter[:closed_from].blank?
  173 + filter[:closed_until] = Date.parse(filter[:closed_until]) unless filter[:closed_until].blank?
177 174
178 - tasks = tasks.where('tasks.created_at >= ?', filter[:created_from].beginning_of_day) unless filter[:created_from].blank?  
179 - tasks = tasks.where('tasks.created_at <= ?', filter[:created_until].end_of_day) unless filter[:created_until].blank?  
180 - tasks  
181 - end 175 + tasks = tasks.from_creation_date filter[:created_from] unless filter[:created_from].blank?
  176 + tasks = tasks.until_creation_date filter[:created_until] unless filter[:created_until].blank?
182 177
183 - def filter_tasks(filter, tasks)  
184 - tasks = tasks.eager_load(:requestor, :closed_by)  
185 - tasks = tasks.of(filter[:type].presence)  
186 - tasks = tasks.where(:status => filter[:status]) unless filter[:status].blank?  
187 - tasks = filter_by_creation_date(filter, tasks)  
188 - tasks = filter_by_closed_date(filter, tasks) 178 + tasks = tasks.from_closed_date filter[:closed_from] unless filter[:closed_from].blank?
  179 + tasks = tasks.until_closed_date filter[:closed_until] unless filter[:closed_until].blank?
189 180
190 - tasks = tasks.like('profiles.name', filter[:requestor]) unless filter[:requestor].blank?  
191 - tasks = tasks.like('closed_bies_tasks.name', filter[:closed_by]) unless filter[:closed_by].blank?  
192 - tasks = tasks.like('tasks.data', filter[:text]) unless filter[:text].blank? 181 + tasks = tasks.where('profiles.name LIKE ?', filter[:requestor]) unless filter[:requestor].blank?
  182 + tasks = tasks.where('closed_bies_tasks.name LIKE ?', filter[:closed_by]) unless filter[:closed_by].blank?
  183 + tasks = tasks.where('tasks.data LIKE ?', "%#{filter[:text]}%") unless filter[:text].blank?
193 tasks 184 tasks
194 end 185 end
195 186
app/helpers/action_tracker_helper.rb
@@ -5,22 +5,22 @@ module ActionTrackerHelper @@ -5,22 +5,22 @@ module ActionTrackerHelper
5 end 5 end
6 6
7 def new_friendship_description ta 7 def new_friendship_description ta
8 - n_('has made 1 new friend:<br />%{name}', 'has made %{num} new friends:<br />%{name}', ta.get_friend_name.size) % { 8 + n_('has made 1 new friend:<br />%{name}', 'has made %{num} new friends:<br />%{name}', ta.get_friend_name.size).html_safe % {
9 num: ta.get_friend_name.size, 9 num: ta.get_friend_name.size,
10 - name: ta.collect_group_with_index(:friend_name) do |n,i| 10 + name: safe_join(ta.collect_group_with_index(:friend_name) do |n,i|
11 link_to image_tag(ta.get_friend_profile_custom_icon[i] || default_or_themed_icon("/images/icons-app/person-icon.png")), 11 link_to image_tag(ta.get_friend_profile_custom_icon[i] || default_or_themed_icon("/images/icons-app/person-icon.png")),
12 ta.get_friend_url[i], title: n 12 ta.get_friend_url[i], title: n
13 - end.join 13 + end)
14 } 14 }
15 end 15 end
16 16
17 def join_community_description ta 17 def join_community_description ta
18 - n_('has joined 1 community:<br />%{name}', 'has joined %{num} communities:<br />%{name}', ta.get_resource_name.size) % { 18 + n_('has joined 1 community:<br />%{name}'.html_safe, 'has joined %{num} communities:<br />%{name}'.html_safe, ta.get_resource_name.size) % {
19 num: ta.get_resource_name.size, 19 num: ta.get_resource_name.size,
20 name: ta.collect_group_with_index(:resource_name) do |n,i| 20 name: ta.collect_group_with_index(:resource_name) do |n,i|
21 - link_to image_tag(ta.get_resource_profile_custom_icon[i] || default_or_themed_icon("/images/icons-app/community-icon.png")), 21 + link = link_to image_tag(ta.get_resource_profile_custom_icon[i] || default_or_themed_icon("/images/icons-app/community-icon.png")),
22 ta.get_resource_url[i], title: n 22 ta.get_resource_url[i], title: n
23 - end.join 23 + end.join.html_safe
24 } 24 }
25 end 25 end
26 26
app/helpers/application_helper.rb
@@ -101,7 +101,6 @@ module ApplicationHelper @@ -101,7 +101,6 @@ module ApplicationHelper
101 # 101 #
102 # TODO: implement correcly the 'Help' button click 102 # TODO: implement correcly the 'Help' button click
103 def help(content = nil, link_name = nil, options = {}, &block) 103 def help(content = nil, link_name = nil, options = {}, &block)
104 -  
105 link_name ||= _('Help') 104 link_name ||= _('Help')
106 105
107 @help_message_id ||= 1 106 @help_message_id ||= 1
@@ -124,7 +123,7 @@ module ApplicationHelper @@ -124,7 +123,7 @@ module ApplicationHelper
124 button = link_to_function(content_tag('span', link_name), "Element.show('#{help_id}')", options ) 123 button = link_to_function(content_tag('span', link_name), "Element.show('#{help_id}')", options )
125 close_button = content_tag("div", link_to_function(_("Close"), "Element.hide('#{help_id}')", :class => 'close_help_button')) 124 close_button = content_tag("div", link_to_function(_("Close"), "Element.hide('#{help_id}')", :class => 'close_help_button'))
126 125
127 - text = content_tag('div', button + content_tag('div', content_tag('div', content) + close_button, :class => 'help_message', :id => help_id, :style => 'display: none;'), :class => 'help_box') 126 + text = content_tag('div', button + content_tag('div', content_tag('div', content.html_safe) + close_button, :class => 'help_message', :id => help_id, :style => 'display: none;'), :class => 'help_box')
128 127
129 unless block.nil? 128 unless block.nil?
130 concat(text) 129 concat(text)
@@ -364,8 +363,8 @@ module ApplicationHelper @@ -364,8 +363,8 @@ module ApplicationHelper
364 def popover_menu(title,menu_title,links,html_options={}) 363 def popover_menu(title,menu_title,links,html_options={})
365 html_options[:class] = "" unless html_options[:class] 364 html_options[:class] = "" unless html_options[:class]
366 html_options[:class] << " menu-submenu-trigger" 365 html_options[:class] << " menu-submenu-trigger"
367 - html_options[:onclick] = "toggleSubmenu(this, '#{menu_title}', #{CGI::escapeHTML(links.to_json)}); return false"  
368 366
  367 + html_options[:onclick] = "toggleSubmenu(this, '#{menu_title}', #{CGI::escapeHTML(links.to_json)}); return false".html_safe
369 link_to(content_tag(:span, title), '#', html_options) 368 link_to(content_tag(:span, title), '#', html_options)
370 end 369 end
371 370
@@ -475,9 +474,9 @@ module ApplicationHelper @@ -475,9 +474,9 @@ module ApplicationHelper
475 map(&:role) 474 map(&:role)
476 names = [] 475 names = []
477 roles.each do |role| 476 roles.each do |role|
478 - names << content_tag('span', role.name, :style => "color: #{role_color(role, resource.environment.id)}") 477 + names << content_tag('span', role.name, :style => "color: #{role_color(role, resource.environment.id)}").html_safe
479 end 478 end
480 - names.join(', ') 479 + safe_join(names, ', ')
481 end 480 end
482 481
483 def role_color(role, env_id) 482 def role_color(role, env_id)
@@ -913,7 +912,8 @@ module ApplicationHelper @@ -913,7 +912,8 @@ module ApplicationHelper
913 end 912 end
914 913
915 def admin_link 914 def admin_link
916 - user.is_admin?(environment) ? link_to('<i class="icon-menu-admin"></i><strong>' + _('Administration') + '</strong>', environment.admin_url, :title => _("Configure the environment"), :class => 'admin-link') : '' 915 + admin_icon = '<i class="icon-menu-admin"></i><strong>' + _('Administration') + '</strong>'
  916 + user.is_admin?(environment) ? link_to(admin_icon.html_safe, environment.admin_url, :title => _("Configure the environment"), :class => 'admin-link') : ''
917 end 917 end
918 918
919 def usermenu_logged_in 919 def usermenu_logged_in
@@ -922,23 +922,39 @@ module ApplicationHelper @@ -922,23 +922,39 @@ module ApplicationHelper
922 if count > 0 922 if count > 0
923 pending_tasks_count = link_to("<i class=\"icon-menu-tasks\"></i><span class=\"task-count\">#{count}</span>", user.tasks_url, :id => 'pending-tasks-count', :title => _("Manage your pending tasks")) 923 pending_tasks_count = link_to("<i class=\"icon-menu-tasks\"></i><span class=\"task-count\">#{count}</span>", user.tasks_url, :id => 'pending-tasks-count', :title => _("Manage your pending tasks"))
924 end 924 end
  925 + user_identifier = "<i style='background-image:url(#{user.profile_custom_icon(gravatar_default)})'></i><strong>#{user.identifier}</strong>"
  926 + welcome_link = link_to(user_identifier.html_safe, user.public_profile_url, :id => "homepage-link", :title => _('Go to your homepage'))
  927 + welcome_span = _("<span class='welcome'>Welcome,</span> %s") % welcome_link.html_safe
  928 + ctrl_panel_icon = '<i class="icon-menu-ctrl-panel"></i>'
  929 + ctrl_panel_section = '<strong>' + ctrl_panel_icon + _('Control panel') + '</strong>'
  930 + ctrl_panel_link = link_to(ctrl_panel_section.html_safe, user.admin_url, :class => 'ctrl-panel', :title => _("Configure your personal account and content"))
  931 + logout_icon = '<i class="icon-menu-logout"></i><strong>' + _('Logout') + '</strong>'
  932 + logout_link = link_to(logout_icon.html_safe, { :controller => 'account', :action => 'logout'} , :id => "logout", :title => _("Leave the system"))
  933 + join_result = safe_join(
  934 + [welcome_span.html_safe, render_environment_features(:usermenu).html_safe, admin_link.html_safe,
  935 + manage_enterprises.html_safe, manage_communities.html_safe, ctrl_panel_link.html_safe,
  936 + pending_tasks_count.html_safe, logout_link.html_safe], "")
  937 + join_result
  938 + end
925 939
926 - (_("<span class='welcome'>Welcome,</span> %s") % link_to("<i style='background-image:url(#{user.profile_custom_icon(gravatar_default)})'></i><strong>#{user.identifier}</strong>", user.url, :id => "homepage-link", :title => _('Go to your homepage'))) +  
927 - render_environment_features(:usermenu) +  
928 - admin_link +  
929 - manage_enterprises +  
930 - manage_communities +  
931 - link_to('<i class="icon-menu-ctrl-panel"></i><strong>' + _('Control panel') + '</strong>', user.admin_url, :class => 'ctrl-panel', :title => _("Configure your personal account and content")) +  
932 - pending_tasks_count +  
933 - link_to('<i class="icon-menu-logout"></i><strong>' + _('Logout') + '</strong>', { :controller => 'account', :action => 'logout'} , :id => "logout", :title => _("Leave the system")) 940 + def usermenu_notlogged_in
  941 + login_str = '<i class="icon-menu-login"></i><strong>' + _('Login') + '</strong>'
  942 + ret = _("<span class='login'>%s</span>") % modal_inline_link_to(login_str.html_safe, login_url, '#inlineLoginBox', :id => 'link_login')
  943 + return ret.html_safe
934 end 944 end
935 945
  946 + def usermenu_signup
  947 + signup_str = '<strong>' + _('Sign up') + '</strong>'
  948 + ret = _("<span class='or'>or</span> <span class='signup'>%s</span>") % link_to(signup_str.html_safe, :controller => 'account', :action => 'signup')
  949 + return ret.html_safe
  950 +
  951 + end
936 def limited_text_area(object_name, method, limit, text_area_id, options = {}) 952 def limited_text_area(object_name, method, limit, text_area_id, options = {})
937 - content_tag(:div, [ 953 + content_tag(:div, safe_join([
938 text_area(object_name, method, { :id => text_area_id, :onkeyup => "limited_text_area('#{text_area_id}', #{limit})" }.merge(options)), 954 text_area(object_name, method, { :id => text_area_id, :onkeyup => "limited_text_area('#{text_area_id}', #{limit})" }.merge(options)),
939 content_tag(:p, content_tag(:span, limit) + ' ' + _(' characters left'), :id => text_area_id + '_left'), 955 content_tag(:p, content_tag(:span, limit) + ' ' + _(' characters left'), :id => text_area_id + '_left'),
940 content_tag(:p, _('Limit of characters reached'), :id => text_area_id + '_limit', :style => 'display: none') 956 content_tag(:p, _('Limit of characters reached'), :id => text_area_id + '_limit', :style => 'display: none')
941 - ].join, :class => 'limited-text-area') 957 + ]), :class => 'limited-text-area')
942 end 958 end
943 959
944 def expandable_text_area(object_name, method, text_area_id, options = {}) 960 def expandable_text_area(object_name, method, text_area_id, options = {})
@@ -1034,8 +1050,8 @@ module ApplicationHelper @@ -1034,8 +1050,8 @@ module ApplicationHelper
1034 end 1050 end
1035 1051
1036 def render_tabs(tabs) 1052 def render_tabs(tabs)
1037 - titles = tabs.inject(''){ |result, tab| result << content_tag(:li, link_to(tab[:title], '#'+tab[:id]), :class => 'tab') }  
1038 - contents = tabs.inject(''){ |result, tab| result << content_tag(:div, tab[:content], :id => tab[:id]) } 1053 + titles = tabs.inject(''.html_safe){ |result, tab| result << content_tag(:li, link_to(tab[:title], '#'+tab[:id]), :class => 'tab') }
  1054 + contents = tabs.inject(''.html_safe){ |result, tab| result << content_tag(:div, tab[:content], :id => tab[:id]) }
1039 1055
1040 content_tag(:div, content_tag(:ul, titles) + raw(contents), :class => 'ui-tabs') 1056 content_tag(:div, content_tag(:ul, titles) + raw(contents), :class => 'ui-tabs')
1041 end 1057 end
@@ -1053,7 +1069,7 @@ module ApplicationHelper @@ -1053,7 +1069,7 @@ module ApplicationHelper
1053 def expirable_link_to(expired, content, url, options = {}) 1069 def expirable_link_to(expired, content, url, options = {})
1054 if expired 1070 if expired
1055 options[:class] = (options[:class] || '') + ' disabled' 1071 options[:class] = (options[:class] || '') + ' disabled'
1056 - content_tag('a', '&nbsp;'+content_tag('span', content), options) 1072 + content_tag('a', '&nbsp;'.html_safe+content_tag('span', content), options)
1057 else 1073 else
1058 if options[:modal] 1074 if options[:modal]
1059 options.delete(:modal) 1075 options.delete(:modal)
@@ -1082,29 +1098,18 @@ module ApplicationHelper @@ -1082,29 +1098,18 @@ module ApplicationHelper
1082 def template_options(kind, field_name) 1098 def template_options(kind, field_name)
1083 templates = environment.send(kind).templates 1099 templates = environment.send(kind).templates
1084 return '' if templates.count == 0 1100 return '' if templates.count == 0
1085 - if templates.count == 1  
1086 - if templates.first.custom_fields == {}  
1087 - return hidden_field_tag("#{field_name}[template_id]", templates.first.id)  
1088 - else  
1089 - custom_fields = ""  
1090 - templates.first.custom_fields.each { |field, value|  
1091 - custom_fields += content_tag('div', content_tag('label', value[:title].capitalize, :class => 'formlabel') +  
1092 - content_tag('div', text_field_tag( "profile_data[custom_fields][#{field}][title]", ''), :class => 'formfield type-text'), :class => "formfieldline" ) if value[:signup] == 'on'  
1093 - }  
1094 - content_tag('div', custom_fields)  
1095 - end  
1096 - else  
1097 - radios = templates.map do |template|  
1098 - content_tag('li', labelled_radio_button(link_to(template.name, template.url, :target => '_blank'), "#{field_name}[template_id]", template.id, environment.is_default_template?(template), :onchange => 'show_fields_for_template(this);'))  
1099 - end.join("\n")  
1100 -  
1101 - content_tag('div', content_tag('label', _('Profile organization'), :for => 'template-options', :class => 'formlabel') +  
1102 - content_tag('p', _('Your profile will be created according to the selected template. Click on the options to view them.'), :style => 'margin: 5px 15px;padding: 0px 10px;') +  
1103 - content_tag('ul', radios, :style => 'list-style: none; padding-left: 20px; margin-top: 0.5em;'),  
1104 - :id => 'template-options',  
1105 - :style => 'margin-top: 1em'  
1106 - )  
1107 - end 1101 + return hidden_field_tag("#{field_name}[template_id]", templates.first.id) if templates.count == 1
  1102 +
  1103 + radios = templates.map do |template|
  1104 + content_tag('li', labelled_radio_button(link_to(template.name, template.url, :target => '_blank'), "#{field_name}[template_id]", template.id, environment.is_default_template?(template)))
  1105 + end.join("\n").html_safe
  1106 +
  1107 + content_tag('div', content_tag('label', _('Profile organization'), :for => 'template-options', :class => 'formlabel') +
  1108 + content_tag('p', _('Your profile will be created according to the selected template. Click on the options to view them.'), :style => 'margin: 5px 15px;padding: 0px 10px;') +
  1109 + content_tag('ul', radios, :style => 'list-style: none; padding-left: 20px; margin-top: 0.5em;'),
  1110 + :id => 'template-options',
  1111 + :style => 'margin-top: 1em'
  1112 + )
1108 end 1113 end
1109 1114
1110 def expirable_content_reference(content, action, text, url, options = {}) 1115 def expirable_content_reference(content, action, text, url, options = {})
@@ -1137,7 +1142,7 @@ module ApplicationHelper @@ -1137,7 +1142,7 @@ module ApplicationHelper
1137 content_tag(:div, :class => 'errorExplanation', :id => 'errorExplanation') do 1142 content_tag(:div, :class => 'errorExplanation', :id => 'errorExplanation') do
1138 content_tag(:h2, _('Errors while saving')) + 1143 content_tag(:h2, _('Errors while saving')) +
1139 content_tag(:ul) do 1144 content_tag(:ul) do
1140 - errors.map { |err| content_tag(:li, err) }.join 1145 + safe_join(errors.map { |err| content_tag(:li, err) })
1141 end 1146 end
1142 end 1147 end
1143 end 1148 end
@@ -1247,6 +1252,7 @@ module ApplicationHelper @@ -1247,6 +1252,7 @@ module ApplicationHelper
1247 :href=>"#", 1252 :href=>"#",
1248 :title=>_("Exit full screen mode") 1253 :title=>_("Exit full screen mode")
1249 }) 1254 })
  1255 + content.html_safe
1250 end 1256 end
1251 1257
1252 end 1258 end
app/helpers/block_helper.rb
@@ -3,13 +3,13 @@ module BlockHelper @@ -3,13 +3,13 @@ module BlockHelper
3 def block_title(title, subtitle=nil) 3 def block_title(title, subtitle=nil)
4 block_header = block_heading title 4 block_header = block_heading title
5 block_header += block_heading(subtitle, 'h4') if subtitle 5 block_header += block_heading(subtitle, 'h4') if subtitle
6 - content_tag 'div', block_header, :class => 'block-header' 6 + content_tag('div', block_header, :class => 'block-header').html_safe
7 end 7 end
8 8
9 def block_heading(title, heading='h3') 9 def block_heading(title, heading='h3')
10 tag_class = 'block-' + (heading == 'h3' ? 'title' : 'subtitle') 10 tag_class = 'block-' + (heading == 'h3' ? 'title' : 'subtitle')
11 tag_class += ' empty' if title.empty? 11 tag_class += ' empty' if title.empty?
12 - content_tag heading, content_tag('span', h(title)), :class => tag_class 12 + content_tag heading, content_tag('span', h(title)), :class => tag_class.html_safe
13 end 13 end
14 14
15 def highlights_block_config_image_fields(block, image={}, row_number=nil) 15 def highlights_block_config_image_fields(block, image={}, row_number=nil)
app/helpers/blog_helper.rb
@@ -41,12 +41,12 @@ module BlogHelper @@ -41,12 +41,12 @@ module BlogHelper
41 css_add << position 41 css_add << position
42 content << (content_tag 'div', id: "post-#{art.id}", class: css_add do 42 content << (content_tag 'div', id: "post-#{art.id}", class: css_add do
43 content_tag 'div', class: position + '-inner blog-post-inner' do 43 content_tag 'div', class: position + '-inner blog-post-inner' do
44 - display_post(art, conf[:format]).html_safe +  
45 - '<br style="clear:both"/>'.html_safe 44 + display_post(art, conf[:format]) +
  45 + '<br style="clear:both"/>'
46 end 46 end
47 - end) 47 + end).html_safe
48 } 48 }
49 - content.join("\n<hr class='sep-posts'/>\n") + (pagination or '') 49 + safe_join(content, "\n<hr class='sep-posts'/>\n") + (pagination or '').html_safe
50 end 50 end
51 51
52 def display_post(article, format = 'full') 52 def display_post(article, format = 'full')
@@ -61,7 +61,8 @@ module BlogHelper @@ -61,7 +61,8 @@ module BlogHelper
61 else 61 else
62 '<div class="post-pic" style="background-image:url('+img+')"></div>' 62 '<div class="post-pic" style="background-image:url('+img+')"></div>'
63 end 63 end
64 - end.to_s + title + html 64 + end.to_s.html_safe +
  65 + title.html_safe + html
65 end 66 end
66 67
67 def display_compact_format(article) 68 def display_compact_format(article)
app/helpers/box_organizer_helper.rb
@@ -38,7 +38,7 @@ module BoxOrganizerHelper @@ -38,7 +38,7 @@ module BoxOrganizerHelper
38 content_tag(:ul, 38 content_tag(:ul,
39 images_path.map do |preview| 39 images_path.map do |preview|
40 content_tag(:li, image_tag(preview, height: '240', alt: '')) 40 content_tag(:li, image_tag(preview, height: '240', alt: ''))
41 - end.join("\n") 41 + end.join("\n").html_safe
42 ) 42 )
43 end 43 end
44 44
app/helpers/boxes_helper.rb
@@ -44,7 +44,7 @@ module BoxesHelper @@ -44,7 +44,7 @@ module BoxesHelper
44 44
45 def display_boxes(holder, main_content) 45 def display_boxes(holder, main_content)
46 boxes = holder.boxes.with_position.first(boxes_limit(holder)) 46 boxes = holder.boxes.with_position.first(boxes_limit(holder))
47 - content = boxes.reverse.map { |item| display_box(item, main_content) }.join("\n") 47 + content = safe_join(boxes.reverse.map { |item| display_box(item, main_content) }, "\n")
48 content = main_content if (content.blank?) 48 content = main_content if (content.blank?)
49 49
50 content_tag('div', content, :class => 'boxes', :id => 'boxes' ) 50 content_tag('div', content, :class => 'boxes', :id => 'boxes' )
@@ -54,7 +54,7 @@ module BoxesHelper @@ -54,7 +54,7 @@ module BoxesHelper
54 if holder.respond_to?(element) 54 if holder.respond_to?(element)
55 content_tag('div', holder.send(element), options) 55 content_tag('div', holder.send(element), options)
56 else 56 else
57 - '' 57 + ''.html_safe
58 end 58 end
59 end 59 end
60 60
@@ -70,9 +70,10 @@ module BoxesHelper @@ -70,9 +70,10 @@ module BoxesHelper
70 70
71 def display_box_content(box, main_content) 71 def display_box_content(box, main_content)
72 context = { :article => @page, :request_path => request.path, :locale => locale, :params => request.params, :user => user, :controller => controller } 72 context = { :article => @page, :request_path => request.path, :locale => locale, :params => request.params, :user => user, :controller => controller }
73 - box_decorator.select_blocks(box, box.blocks.includes(:box), context).map do |item| 73 + blocks = box_decorator.select_blocks(box, box.blocks.includes(:box), context).map do |item|
74 display_block item, main_content 74 display_block item, main_content
75 - end.join("\n") + box_decorator.block_target(box) 75 + end
  76 + safe_join(blocks, "\n") + box_decorator.block_target(box)
76 end 77 end
77 78
78 def select_blocks box, arr, context 79 def select_blocks box, arr, context
@@ -136,17 +137,18 @@ module BoxesHelper @@ -136,17 +137,18 @@ module BoxesHelper
136 137
137 result = filter_html(result, block) 138 result = filter_html(result, block)
138 139
139 - content_tag('div',  
140 - box_decorator.block_target(block.box, block) +  
141 - content_tag('div',  
142 - content_tag('div',  
143 - content_tag('div',  
144 - result + footer_content + box_decorator.block_edit_buttons(block),  
145 - :class => 'block-inner-2'),  
146 - :class => 'block-inner-1'),  
147 - options),  
148 - :class => 'block-outer') +  
149 - box_decorator.block_handle(block) 140 + join_result = safe_join([result, footer_content, box_decorator.block_edit_buttons(block)])
  141 + content_tag_inner_1 = content_tag('div', join_result, :class => 'block-inner-2')
  142 +
  143 + content_tag_inner_2 = content_tag('div', content_tag_inner_1, :class => 'block-inner-1')
  144 + content_tag_inner_3 = content_tag('div', content_tag_inner_2, options)
  145 + content_tag_inner_4 = box_decorator.block_target(block.box, block) + content_tag_inner_3
  146 + c = content_tag('div', content_tag_inner_4, :class => 'block-outer')
  147 + box_decorator_result = box_decorator.block_handle(block)
  148 + result_final = safe_join([c, box_decorator_result], "")
  149 +
  150 +
  151 + return result_final
150 end 152 end
151 153
152 def wrap_main_content(content) 154 def wrap_main_content(content)
@@ -156,17 +158,17 @@ module BoxesHelper @@ -156,17 +158,17 @@ module BoxesHelper
156 def extract_block_content(content) 158 def extract_block_content(content)
157 case content 159 case content
158 when Hash 160 when Hash
159 - content_tag('iframe', '', :src => url_for(content)) 161 + content_tag('iframe', ''.html_safe, :src => url_for(content))
160 when String 162 when String
161 if content.split("\n").size == 1 and content =~ /^https?:\/\// 163 if content.split("\n").size == 1 and content =~ /^https?:\/\//
162 - content_tag('iframe', '', :src => content) 164 + content_tag('iframe', ''.html_safe, :src => content)
163 else 165 else
164 content 166 content
165 end 167 end
166 when Proc 168 when Proc
167 self.instance_eval(&content) 169 self.instance_eval(&content)
168 when NilClass 170 when NilClass
169 - '' 171 + ''.html_safe
170 else 172 else
171 raise "Unsupported content for block (#{content.class})" 173 raise "Unsupported content for block (#{content.class})"
172 end 174 end
@@ -175,14 +177,14 @@ module BoxesHelper @@ -175,14 +177,14 @@ module BoxesHelper
175 module DontMoveBlocks 177 module DontMoveBlocks
176 # does nothing 178 # does nothing
177 def self.block_target(box, block = nil) 179 def self.block_target(box, block = nil)
178 - '' 180 + ''.html_safe
179 end 181 end
180 # does nothing 182 # does nothing
181 def self.block_handle(block) 183 def self.block_handle(block)
182 - '' 184 + ''.html_safe
183 end 185 end
184 def self.block_edit_buttons(block) 186 def self.block_edit_buttons(block)
185 - '' 187 + ''.html_safe
186 end 188 end
187 def self.select_blocks box, arr, context 189 def self.select_blocks box, arr, context
188 arr = arr.select{ |block| block.visible? context } 190 arr = arr.select{ |block| block.visible? context }
@@ -229,9 +231,9 @@ module BoxesHelper @@ -229,9 +231,9 @@ module BoxesHelper
229 # makes the given block draggable so it can be moved away. 231 # makes the given block draggable so it can be moved away.
230 def block_handle(block) 232 def block_handle(block)
231 return "" unless movable?(block) 233 return "" unless movable?(block)
232 - icon = "<div><div>#{display_icon(block.class)}</div><span>#{_(block.class.pretty_name)}</span></div>" 234 + icon = "<div><div>#{display_icon(block.class)}</div><span>#{_(block.class.pretty_name)}</span></div>".html_safe
233 block_draggable("block-#{block.id}", 235 block_draggable("block-#{block.id}",
234 - :helper => "function() {return cloneDraggableBlock($(this), '#{icon}')}") 236 + :helper => "function() {return cloneDraggableBlock($(this), '#{icon}')}".html_safe)
235 end 237 end
236 238
237 def block_draggable(element_id, options={}) 239 def block_draggable(element_id, options={})
@@ -302,7 +304,7 @@ module BoxesHelper @@ -302,7 +304,7 @@ module BoxesHelper
302 buttons << modal_inline_icon(:embed, _('Embed code'), {}, "#embed-code-box-#{block.id}") << html 304 buttons << modal_inline_icon(:embed, _('Embed code'), {}, "#embed-code-box-#{block.id}") << html
303 end 305 end
304 306
305 - content_tag('div', buttons.join("\n") + tag('br', :style => 'clear: left'), :class => 'button-bar') 307 + content_tag('div', buttons.join("\n").html_safe + tag('br', :style => 'clear: left'), :class => 'button-bar')
306 end 308 end
307 309
308 def current_blocks 310 def current_blocks
app/helpers/buttons_helper.rb
@@ -15,9 +15,9 @@ module ButtonsHelper @@ -15,9 +15,9 @@ module ButtonsHelper
15 end 15 end
16 the_title = html_options[:title] || label 16 the_title = html_options[:title] || label
17 if html_options[:disabled] 17 if html_options[:disabled]
18 - content_tag('a', '&nbsp;'+content_tag('span', label), html_options.merge(:class => the_class, :title => the_title)) 18 + content_tag('a', '&nbsp;'.html_safe+content_tag('span', label), html_options.merge(:class => the_class, :title => the_title))
19 else 19 else
20 - link_to('&nbsp;'+content_tag('span', label), url, html_options.merge(:class => the_class, :title => the_title)) 20 + link_to('&nbsp;'.html_safe+content_tag('span', label), url, html_options.merge(:class => the_class, :title => the_title))
21 end 21 end
22 end 22 end
23 23
app/helpers/catalog_helper.rb
@@ -19,18 +19,18 @@ module CatalogHelper @@ -19,18 +19,18 @@ module CatalogHelper
19 ancestors = category.ancestors.map { |c| link_to(c.name, {:controller => :catalog, :action => 'index', :level => c.id}) }.reverse 19 ancestors = category.ancestors.map { |c| link_to(c.name, {:controller => :catalog, :action => 'index', :level => c.id}) }.reverse
20 current_level = content_tag('strong', category.name) 20 current_level = content_tag('strong', category.name)
21 all_items = [start] + ancestors + [current_level] 21 all_items = [start] + ancestors + [current_level]
22 - content_tag('div', all_items.join(' &rarr; '), :id => 'breadcrumb') 22 + content_tag('div', safe_join(all_items, ' &rarr; '), :id => 'breadcrumb')
23 end 23 end
24 24
25 def category_link(category) 25 def category_link(category)
26 count = profile.products.from_category(category).count 26 count = profile.products.from_category(category).count
27 name = truncate(category.name, :length => 22 - count.to_s.size) 27 name = truncate(category.name, :length => 22 - count.to_s.size)
28 link = link_to(name, {:controller => 'catalog', :action => 'index', :level => category.id}, :title => category.name) 28 link = link_to(name, {:controller => 'catalog', :action => 'index', :level => category.id}, :title => category.name)
29 - content_tag('div', "#{link} <span class=\"count\">#{count}</span>") if count > 0 29 + content_tag('div', "#{link} <span class=\"count\">#{count}</span>".html_safe) if count > 0
30 end 30 end
31 31
32 def category_with_sub_list(category) 32 def category_with_sub_list(category)
33 - content_tag 'li', "#{category_link(category)}\n#{sub_category_list(category)}" 33 + content_tag 'li', "#{category_link(category)}\n#{sub_category_list(category)}".html_safe
34 end 34 end
35 35
36 def sub_category_list(category) 36 def sub_category_list(category)
@@ -39,7 +39,7 @@ module CatalogHelper @@ -39,7 +39,7 @@ module CatalogHelper
39 cat_link = category_link sub_category 39 cat_link = category_link sub_category
40 sub_categories << content_tag('li', cat_link) unless cat_link.nil? 40 sub_categories << content_tag('li', cat_link) unless cat_link.nil?
41 end 41 end
42 - content_tag('ul', sub_categories.join) if sub_categories.size > 0 42 + content_tag('ul', sub_categories.join.html_safe) if sub_categories.size > 0
43 end 43 end
44 44
45 end 45 end
app/helpers/content_viewer_helper.rb
@@ -7,7 +7,8 @@ module ContentViewerHelper @@ -7,7 +7,8 @@ module ContentViewerHelper
7 def display_number_of_comments(n) 7 def display_number_of_comments(n)
8 base_str = "<span class='comment-count hide'>#{n}</span>" 8 base_str = "<span class='comment-count hide'>#{n}</span>"
9 amount_str = n == 0 ? _('no comments yet') : (n == 1 ? _('One comment') : _('%s comments') % n) 9 amount_str = n == 0 ? _('no comments yet') : (n == 1 ? _('One comment') : _('%s comments') % n)
10 - base_str + "<span class='comment-count-write-out'>#{amount_str}</span>" 10 + base_str += "<span class='comment-count-write-out'>#{amount_str}</span>"
  11 + base_str.html_safe
11 end 12 end
12 13
13 def number_of_comments(article) 14 def number_of_comments(article)
@@ -19,11 +20,11 @@ module ContentViewerHelper @@ -19,11 +20,11 @@ module ContentViewerHelper
19 title = content_tag('h1', h(title), :class => 'title') 20 title = content_tag('h1', h(title), :class => 'title')
20 if article.belongs_to_blog? || article.belongs_to_forum? 21 if article.belongs_to_blog? || article.belongs_to_forum?
21 unless args[:no_link] 22 unless args[:no_link]
22 - title = content_tag('h1', link_to(article.name, article.url), :class => 'title') 23 + title = content_tag('h1', link_to(article.name, url_for(article.url)), :class => 'title')
23 end 24 end
24 comments = '' 25 comments = ''
25 unless args[:no_comments] || !article.accept_comments 26 unless args[:no_comments] || !article.accept_comments
26 - comments = (" - %s") % link_to_comments(article) 27 + comments = (" - %s").html_safe % link_to_comments(article)
27 end 28 end
28 date_format = show_with_right_format_date article 29 date_format = show_with_right_format_date article
29 title << content_tag('span', 30 title << content_tag('span',
app/helpers/display_helper.rb
@@ -53,18 +53,19 @@ module DisplayHelper @@ -53,18 +53,19 @@ module DisplayHelper
53 end 53 end
54 54
55 def txt2html(txt) 55 def txt2html(txt)
56 - txt.strip. 56 + ret = txt.strip.
57 gsub( /\s*\n\s*\n\s*/, "\r<p/>\r" ). 57 gsub( /\s*\n\s*\n\s*/, "\r<p/>\r" ).
58 gsub( /\s*\n\s*/, "\n<br/>\n" ). 58 gsub( /\s*\n\s*/, "\n<br/>\n" ).
59 gsub( /\r/, "\n" ). 59 gsub( /\r/, "\n" ).
60 gsub( /(^|\s)(www\.[^\s]+|https?:\/\/[^\s]+)/ ) do 60 gsub( /(^|\s)(www\.[^\s]+|https?:\/\/[^\s]+)/ ) do
61 pre_char, href = $1, $2 61 pre_char, href = $1, $2
62 href = 'http://'+href if ! href.match /^https?:/ 62 href = 'http://'+href if ! href.match /^https?:/
63 - content = href.gsub(/^https?:\/\//, '').scan(/.{1,4}/).join('&#x200B;') 63 + content = safe_join(href.gsub(/^https?:\/\//, '').scan(/.{1,4}/), '&#x200B;'.html_safe)
64 pre_char + 64 pre_char +
65 content_tag(:a, content, :href => href, :target => '_blank', 65 content_tag(:a, content, :href => href, :target => '_blank',
66 - :rel => 'nofolow', :onclick => "return confirm('%s')" % 66 + :rel => 'nofolow', :onclick => "return confirm('%s')".html_safe %
67 _('Are you sure you want to visit this web site?')) 67 _('Are you sure you want to visit this web site?'))
68 end 68 end
  69 + ret.html_safe
69 end 70 end
70 end 71 end
app/helpers/events_helper.rb
1 module EventsHelper 1 module EventsHelper
2 2
3 include DatesHelper 3 include DatesHelper
  4 + include ActionView::Helpers::OutputSafetyHelper
  5 +
4 def list_events(date, events) 6 def list_events(date, events)
5 title = _('Events for %s') % show_date_month(date) 7 title = _('Events for %s') % show_date_month(date)
  8 + user_events = events.select { |item| item.display_to?(user) }
  9 + events_for_month = safe_join(user_events.map {|item| display_event_in_listing(item)}, '')
6 content_tag('h2', title) + 10 content_tag('h2', title) +
7 content_tag('div', 11 content_tag('div',
8 (events.any? ? 12 (events.any? ?
9 - content_tag('table', events.select { |item| item.display_to?(user) }.map {|item| display_event_in_listing(item)}.join('')) :  
10 - content_tag('em', _('No events for this month'), :class => 'no-events') 13 + content_tag('table', events_for_month) :
  14 + content_tag('em', _('No events for this month'), :class => 'no-events')
11 ), :id => 'agenda-items' 15 ), :id => 'agenda-items'
12 ) 16 )
13 end 17 end
app/helpers/forms_helper.rb
@@ -101,7 +101,7 @@ module FormsHelper @@ -101,7 +101,7 @@ module FormsHelper
101 101
102 def required_fields_message 102 def required_fields_message
103 content_tag('p', content_tag('span', 103 content_tag('p', content_tag('span',
104 - _("The <label class='pseudoformlabel'>highlighted</label> fields are mandatory."), 104 + _("The <label class='pseudoformlabel'>highlighted</label> fields are mandatory.").html_safe,
105 :class => 'required-field' 105 :class => 'required-field'
106 )) 106 ))
107 end 107 end
@@ -112,10 +112,11 @@ module FormsHelper @@ -112,10 +112,11 @@ module FormsHelper
112 options_for_select = container.inject([]) do |options, element| 112 options_for_select = container.inject([]) do |options, element|
113 text, value = option_text_and_value(element) 113 text, value = option_text_and_value(element)
114 selected_attribute = ' selected="selected"' if option_value_selected?(value, selected) 114 selected_attribute = ' selected="selected"' if option_value_selected?(value, selected)
115 - options << %(<option title="#{html_escape(text.to_s)}" value="#{html_escape(value.to_s)}"#{selected_attribute}>#{html_escape(text.to_s)}</option>) 115 + opt = %(<option title="#{html_escape(text.to_s)}" value="#{html_escape(value.to_s)}"#{selected_attribute}>#{html_escape(text.to_s)}</option>)
  116 + options << opt.html_safe
116 end 117 end
117 118
118 - options_for_select.join("\n") 119 + safe_join(options_for_select, "\n")
119 end 120 end
120 121
121 def balanced_table(items, per_row=3) 122 def balanced_table(items, per_row=3)
@@ -248,8 +249,8 @@ module FormsHelper @@ -248,8 +249,8 @@ module FormsHelper
248 def date_range_field(from_name, to_name, from_value, to_value, datepicker_options = {}, html_options = {}) 249 def date_range_field(from_name, to_name, from_value, to_value, datepicker_options = {}, html_options = {})
249 from_id = html_options[:from_id] || 'datepicker-from-date' 250 from_id = html_options[:from_id] || 'datepicker-from-date'
250 to_id = html_options[:to_id] || 'datepicker-to-date' 251 to_id = html_options[:to_id] || 'datepicker-to-date'
251 - return _('From') +' '+ date_field(from_name, from_value, datepicker_options, html_options.merge({:id => from_id})) +  
252 - ' ' + _('until') +' '+ date_field(to_name, to_value, datepicker_options, html_options.merge({:id => to_id})) 252 + return (_('From') +' '+ date_field(from_name, from_value, datepicker_options, html_options.merge({:id => from_id})) +
  253 + ' ' + _('until') +' '+ date_field(to_name, to_value, datepicker_options, html_options.merge({:id => to_id}))).html_safe
253 end 254 end
254 255
255 def select_folder(label_text, field_id, collection, default_value=nil, html_options = {}, js_options = {}) 256 def select_folder(label_text, field_id, collection, default_value=nil, html_options = {}, js_options = {})
app/helpers/forum_helper.rb
@@ -35,7 +35,7 @@ module ForumHelper @@ -35,7 +35,7 @@ module ForumHelper
35 :id => "post-#{art.id}" 35 :id => "post-#{art.id}"
36 ) 36 )
37 } 37 }
38 - content_tag('table', content.join) + (pagination or '') 38 + content_tag('table', safe_join(content, "")) + (pagination or '').html_safe
39 end 39 end
40 40
41 def last_topic_update(article) 41 def last_topic_update(article)
app/helpers/language_helper.rb
@@ -40,7 +40,7 @@ module LanguageHelper @@ -40,7 +40,7 @@ module LanguageHelper
40 else 40 else
41 link_to(name, params.merge(:lang => code), :rel => 'nofollow') 41 link_to(name, params.merge(:lang => code), :rel => 'nofollow')
42 end 42 end
43 - end.join(separator) 43 + end.join(separator).html_safe
44 content_tag('div', languages, :id => 'language-chooser', :help => _('The language you choose here is the language used for options, buttons, etc. It does not affect the language of the content created by other users.')) 44 content_tag('div', languages, :id => 'language-chooser', :help => _('The language you choose here is the language used for options, buttons, etc. It does not affect the language of the content created by other users.'))
45 end 45 end
46 end 46 end
app/helpers/layout_helper.rb
@@ -40,7 +40,8 @@ module LayoutHelper @@ -40,7 +40,8 @@ module LayoutHelper
40 40
41 output += templete_javascript_ng.to_s 41 output += templete_javascript_ng.to_s
42 42
43 - output 43 + # This output should be safe!
  44 + output.html_safe
44 end 45 end
45 46
46 def noosfero_stylesheets 47 def noosfero_stylesheets
@@ -64,7 +65,9 @@ module LayoutHelper @@ -64,7 +65,9 @@ module LayoutHelper
64 output << stylesheet_link_tag(global_css_pub) 65 output << stylesheet_link_tag(global_css_pub)
65 end 66 end
66 output << stylesheet_link_tag(theme_stylesheet_path) 67 output << stylesheet_link_tag(theme_stylesheet_path)
67 - output.join "\n" 68 +
  69 + # This output should be safe!
  70 + output.join("\n").html_safe
68 end 71 end
69 72
70 def noosfero_layout_features 73 def noosfero_layout_features
app/helpers/manage_products_helper.rb
@@ -38,10 +38,11 @@ module ManageProductsHelper @@ -38,10 +38,11 @@ module ManageProductsHelper
38 end 38 end
39 39
40 def options_for_select_categories(categories, selected = nil) 40 def options_for_select_categories(categories, selected = nil)
41 - categories.sort_by{|cat| cat.name.transliterate}.map do |category|  
42 - selected_attribute = selected.nil? ? '' : (category == selected ? "selected='selected'" : '')  
43 - "<option value='#{category.id}' title='#{category.name}' #{selected_attribute}>#{category.name + (category.leaf? ? '': ' &raquo;')}</option>"  
44 - end.join("\n") 41 + safe_join(categories.sort_by{ |cat|
  42 + cat.name.transliterate}.map do |category|
  43 + selected_attribute = selected.nil? ? '' : (category == selected ? "selected='selected'" : '')
  44 + "<option value='#{category.id}' title='#{category.name}' #{selected_attribute}>#{category.name + (category.leaf? ? '': ' &raquo;')}</option>".html_safe
  45 + end, "\n")
45 end 46 end
46 47
47 def build_selects_for_ancestors(ancestors, current_category) 48 def build_selects_for_ancestors(ancestors, current_category)
@@ -76,10 +77,13 @@ module ManageProductsHelper @@ -76,10 +77,13 @@ module ManageProductsHelper
76 77
77 def categories_container(categories_selection_html, hierarchy_html = '') 78 def categories_container(categories_selection_html, hierarchy_html = '')
78 content_tag 'div', 79 content_tag 'div',
79 - render('categories_autocomplete') +  
80 - hidden_field_tag('selected_category_id') +  
81 - content_tag('div', hierarchy_html, :id => 'hierarchy_navigation') +  
82 - content_tag('div', categories_selection_html, :id => 'categories_container_wrapper'), 80 + safe_join(
  81 + [
  82 + render('categories_autocomplete'),
  83 + hidden_field_tag('selected_category_id'),
  84 + content_tag('div', hierarchy_html, :id => 'hierarchy_navigation'),
  85 + content_tag('div', categories_selection_html, :id => 'categories_container_wrapper')
  86 + ], ''),
83 :id => 'categories-container' 87 :id => 'categories-container'
84 end 88 end
85 89
app/helpers/profile_editor_helper.rb
@@ -129,7 +129,11 @@ module ProfileEditorHelper @@ -129,7 +129,11 @@ module ProfileEditorHelper
129 else 129 else
130 domains = environment.domains 130 domains = environment.domains
131 end 131 end
132 - labelled_form_field(_('Preferred domain name:'), select(object, :preferred_domain_id, domains.map {|item| [item.name, item.id]}, :prompt => '&lt;' + _('Select domain') + '&gt;')) 132 + select_domain_prompt = '&lt;'.html_safe + _('Select domain').html_safe + '&gt;'.html_safe
  133 + select_field = select(object, :preferred_domain_id, domains.map {
  134 + |item| [item.name, item.id]}, :prompt => select_domain_prompt.html_safe)
  135 +
  136 + labelled_form_field(_('Preferred domain name:'), select_field)
133 end 137 end
134 138
135 def control_panel(&block) 139 def control_panel(&block)
app/helpers/profile_image_helper.rb
@@ -131,7 +131,7 @@ module ProfileImageHelper @@ -131,7 +131,7 @@ module ProfileImageHelper
131 links = links_for_balloon(profile) 131 links = links_for_balloon(profile)
132 content_tag('div', content_tag(tag, 132 content_tag('div', content_tag(tag,
133 (environment.enabled?(:show_balloon_with_profile_links_when_clicked) ? 133 (environment.enabled?(:show_balloon_with_profile_links_when_clicked) ?
134 - popover_menu(_('Profile links'),profile.short_name,links,{:class => trigger_class, :url => url}) : "") + 134 + popover_menu(_('Profile links'),profile.short_name,links,{:class => trigger_class, :url => url}) : "").html_safe +
135 link_to( 135 link_to(
136 content_tag( 'span', profile_image( profile, size ), :class => img_class ) + 136 content_tag( 'span', profile_image( profile, size ), :class => img_class ) +
137 content_tag( 'span', h(name), :class => ( profile.class == Person ? 'fn' : 'org' ) ) + 137 content_tag( 'span', h(name), :class => ( profile.class == Person ? 'fn' : 'org' ) ) +
@@ -139,7 +139,7 @@ module ProfileImageHelper @@ -139,7 +139,7 @@ module ProfileImageHelper
139 profile.url, 139 profile.url,
140 :class => 'profile_link url', 140 :class => 'profile_link url',
141 :help => _('Click on this icon to go to the <b>%s</b>\'s home page') % profile.name, 141 :help => _('Click on this icon to go to the <b>%s</b>\'s home page') % profile.name,
142 - :title => profile.name ), 142 + :title => profile.name ).html_safe,
143 :class => 'vcard'), :class => 'common-profile-list-block') 143 :class => 'vcard'), :class => 'common-profile-list-block')
144 end 144 end
145 end 145 end
app/helpers/search_helper.rb
@@ -124,10 +124,10 @@ module SearchHelper @@ -124,10 +124,10 @@ module SearchHelper
124 def filters(asset) 124 def filters(asset)
125 return if !asset 125 return if !asset
126 klass = asset_class(asset) 126 klass = asset_class(asset)
127 - content_tag('div', klass::SEARCH_FILTERS.map do |name, options| 127 + content_tag('div', safe_join(klass::SEARCH_FILTERS.map do |name, options|
128 default = klass.respond_to?("default_search_#{name}") ? klass.send("default_search_#{name}".to_s) : nil 128 default = klass.respond_to?("default_search_#{name}") ? klass.send("default_search_#{name}".to_s) : nil
129 select_filter(name, options, default) 129 select_filter(name, options, default)
130 - end.join("\n"), :id => 'search-filters') 130 + end, "\n"), :id => 'search-filters')
131 end 131 end
132 132
133 def assets_menu(selected) 133 def assets_menu(selected)
@@ -137,11 +137,11 @@ module SearchHelper @@ -137,11 +137,11 @@ module SearchHelper
137 # menu. 137 # menu.
138 assets.delete(:events) 138 assets.delete(:events)
139 content_tag('ul', 139 content_tag('ul',
140 - assets.map do |asset| 140 + safe_join(assets.map do |asset|
141 options = {} 141 options = {}
142 options.merge!(:class => 'selected') if selected.to_s == asset.to_s 142 options.merge!(:class => 'selected') if selected.to_s == asset.to_s
143 content_tag('li', asset_link(asset), options) 143 content_tag('li', asset_link(asset), options)
144 - end.join("\n"), 144 + end, "\n"),
145 :id => 'assets-menu') 145 :id => 'assets-menu')
146 end 146 end
147 147
app/helpers/tags_helper.rb
@@ -58,7 +58,7 @@ module TagsHelper @@ -58,7 +58,7 @@ module TagsHelper
58 58
59 if options[:show_count] 59 if options[:show_count]
60 display_count = options[:show_count] ? "<small><sup>(#{count})</sup></small>" : "" 60 display_count = options[:show_count] ? "<small><sup>(#{count})</sup></small>" : ""
61 - link_to tag + display_count, destination, :style => style 61 + link_to (tag + display_count).html_safe, destination, :style => style
62 else 62 else
63 link_to h(tag) , destination, :style => style, 63 link_to h(tag) , destination, :style => style,
64 :title => n_( 'one item', '%d items', count ) % count 64 :title => n_( 'one item', '%d items', count ) % count
app/helpers/tinymce_helper.rb
@@ -7,7 +7,7 @@ module TinymceHelper @@ -7,7 +7,7 @@ module TinymceHelper
7 output += javascript_include_tag 'tinymce/js/tinymce/jquery.tinymce.min.js' 7 output += javascript_include_tag 'tinymce/js/tinymce/jquery.tinymce.min.js'
8 output += javascript_include_tag 'tinymce.js' 8 output += javascript_include_tag 'tinymce.js'
9 output += include_macro_js_files.to_s 9 output += include_macro_js_files.to_s
10 - output 10 + output.html_safe
11 end 11 end
12 12
13 def tinymce_init_js options = {} 13 def tinymce_init_js options = {}
@@ -37,7 +37,7 @@ module TinymceHelper @@ -37,7 +37,7 @@ module TinymceHelper
37 #cleanup non tinymce options 37 #cleanup non tinymce options
38 options = options.except :mode 38 options = options.except :mode
39 39
40 - "noosfero.tinymce.init(#{options.to_json})" 40 + "noosfero.tinymce.init(#{options.to_json})".html_safe
41 end 41 end
42 42
43 def menubar mode 43 def menubar mode
app/mailers/mailing.rb
1 require_dependency 'mailing_job' 1 require_dependency 'mailing_job'
2 2
3 -class Mailing < ActiveRecord::Base 3 +class Mailing < ApplicationRecord
4 4
5 acts_as_having_settings :field => :data 5 acts_as_having_settings :field => :data
6 6
app/models/abuse_report.rb
1 -class AbuseReport < ActiveRecord::Base 1 +class AbuseReport < ApplicationRecord
2 2
3 attr_accessible :content, :reason 3 attr_accessible :content, :reason
4 4
app/models/action_tracker_notification.rb
1 -class ActionTrackerNotification < ActiveRecord::Base 1 +class ActionTrackerNotification < ApplicationRecord
2 2
3 belongs_to :profile 3 belongs_to :profile
4 belongs_to :action_tracker, :class_name => 'ActionTracker::Record', :foreign_key => 'action_tracker_id' 4 belongs_to :action_tracker, :class_name => 'ActionTracker::Record', :foreign_key => 'action_tracker_id'
app/models/application_record.rb 0 → 100644
@@ -0,0 +1,64 @@ @@ -0,0 +1,64 @@
  1 +class ApplicationRecord < ActiveRecord::Base
  2 +
  3 + self.abstract_class = true
  4 +
  5 + def self.postgresql?
  6 + self.connection.adapter_name == 'PostgreSQL'
  7 + end
  8 +
  9 + # an ActionView instance for rendering views on models
  10 + def self.action_view
  11 + @action_view ||= begin
  12 + view_paths = ::ActionController::Base.view_paths
  13 + action_view = ::ActionView::Base.new view_paths
  14 + # for using Noosfero helpers inside render calls
  15 + action_view.extend ::ApplicationHelper
  16 + action_view
  17 + end
  18 + end
  19 +
  20 + # default value needed for the above ActionView
  21 + def to_partial_path
  22 + self.class.name.underscore
  23 + end
  24 +
  25 + alias :meta_cache_key :cache_key
  26 + def cache_key
  27 + key = [Noosfero::VERSION, meta_cache_key]
  28 + key.unshift(ApplicationRecord.connection.schema_search_path) if ApplicationRecord.postgresql?
  29 + key.join('/')
  30 + end
  31 +
  32 + def self.like_search(query, options={})
  33 + if defined?(self::SEARCHABLE_FIELDS) || options[:fields].present?
  34 + fields_per_table = {}
  35 + fields_per_table[table_name] = (options[:fields].present? ? options[:fields] : self::SEARCHABLE_FIELDS.keys.map(&:to_s)) & column_names
  36 +
  37 + if options[:joins].present?
  38 + join_asset = options[:joins].to_s.classify.constantize
  39 + if defined?(join_asset::SEARCHABLE_FIELDS) || options[:fields].present?
  40 + fields_per_table[join_asset.table_name] = (options[:fields].present? ? options[:fields] : join_asset::SEARCHABLE_FIELDS.keys.map(&:to_s)) & join_asset.column_names
  41 + end
  42 + end
  43 +
  44 + query = query.downcase.strip
  45 + fields_per_table.delete_if { |table,fields| fields.blank? }
  46 + conditions = fields_per_table.map do |table,fields|
  47 + fields.map do |field|
  48 + "lower(#{table}.#{field}) LIKE '%#{query}%'"
  49 + end.join(' OR ')
  50 + end.join(' OR ')
  51 +
  52 + if options[:joins].present?
  53 + joins(options[:joins]).where(conditions)
  54 + else
  55 + where(conditions)
  56 + end
  57 +
  58 + else
  59 + raise "No searchable fields defined for #{self.name}"
  60 + end
  61 + end
  62 +
  63 +end
  64 +
app/models/approve_article.rb
@@ -86,7 +86,7 @@ class ApproveArticle &lt; Task @@ -86,7 +86,7 @@ class ApproveArticle &lt; Task
86 86
87 def information 87 def information
88 if article 88 if article
89 - {:message => _('%{requestor} wants to publish the article: %{linked_subject}.')} 89 + {:message => _('%{requestor} wants to publish the article: %{linked_subject}.').html_safe}
90 else 90 else
91 {:message => _("The article was removed.")} 91 {:message => _("The article was removed.")}
92 end 92 end
app/models/article.rb
1 1
2 -class Article < ActiveRecord::Base 2 +class Article < ApplicationRecord
3 3
4 include SanitizeHelper 4 include SanitizeHelper
5 5
app/models/article_categorization.rb
1 -class ArticleCategorization < ActiveRecord::Base 1 +class ArticleCategorization < ApplicationRecord
2 self.table_name = :articles_categories 2 self.table_name = :articles_categories
3 3
4 belongs_to :article 4 belongs_to :article
app/models/article_follower.rb
1 -class ArticleFollower < ActiveRecord::Base 1 +class ArticleFollower < ApplicationRecord
2 2
3 attr_accessible :article_id, :person_id, :since 3 attr_accessible :article_id, :person_id, :since
4 belongs_to :article, :counter_cache => :followers_count 4 belongs_to :article, :counter_cache => :followers_count
app/models/block.rb
1 -class Block < ActiveRecord::Base 1 +class Block < ApplicationRecord
2 2
3 attr_accessible :title, :subtitle, :display, :limit, :box_id, :posts_per_page, 3 attr_accessible :title, :subtitle, :display, :limit, :box_id, :posts_per_page,
4 :visualization_format, :language, :display_user, 4 :visualization_format, :language, :display_user,
app/models/box.rb
1 -class Box < ActiveRecord::Base 1 +class Box < ApplicationRecord
2 2
3 acts_as_list scope: -> box { where owner_id: box.owner_id, owner_type: box.owner_type } 3 acts_as_list scope: -> box { where owner_id: box.owner_id, owner_type: box.owner_type }
4 4
app/models/category.rb
1 -class Category < ActiveRecord::Base 1 +class Category < ApplicationRecord
2 2
3 attr_accessible :name, :parent_id, :display_color, :display_in_menu, :image_builder, :environment, :parent 3 attr_accessible :name, :parent_id, :display_color, :display_in_menu, :image_builder, :environment, :parent
4 4
app/models/certifier.rb
1 -class Certifier < ActiveRecord::Base 1 +class Certifier < ApplicationRecord
2 2
3 attr_accessible :name, :environment 3 attr_accessible :name, :environment
4 4
app/models/chat_message.rb
1 -class ChatMessage < ActiveRecord::Base 1 +class ChatMessage < ApplicationRecord
  2 +
2 attr_accessible :body, :from, :to 3 attr_accessible :body, :from, :to
3 4
4 belongs_to :to, :class_name => 'Profile' 5 belongs_to :to, :class_name => 'Profile'
app/models/comment.rb
1 -class Comment < ActiveRecord::Base 1 +class Comment < ApplicationRecord
2 2
3 SEARCHABLE_FIELDS = { 3 SEARCHABLE_FIELDS = {
4 :title => {:label => _('Title'), :weight => 10}, 4 :title => {:label => _('Title'), :weight => 10},
app/models/contact_list.rb
1 -class ContactList < ActiveRecord::Base 1 +class ContactList < ApplicationRecord
2 2
3 serialize :list, Array 3 serialize :list, Array
4 4
app/models/create_community.rb
@@ -60,9 +60,9 @@ class CreateCommunity &lt; Task @@ -60,9 +60,9 @@ class CreateCommunity &lt; Task
60 60
61 def information 61 def information
62 if description.blank? 62 if description.blank?
63 - { :message => _('%{requestor} wants to create community %{subject} with no description.') } 63 + { :message => _('%{requestor} wants to create community %{subject} with no description.').html_safe }
64 else 64 else
65 - { :message => _('%{requestor} wants to create community %{subject} with this description:<p><em>%{description}</em></p>'), 65 + { :message => _('%{requestor} wants to create community %{subject} with this description:<p><em>%{description}</em></p>').html_safe,
66 :variables => {:description => description} } 66 :variables => {:description => description} }
67 end 67 end
68 end 68 end
app/models/create_enterprise.rb
@@ -163,7 +163,7 @@ class CreateEnterprise &lt; Task @@ -163,7 +163,7 @@ class CreateEnterprise &lt; Task
163 end 163 end
164 164
165 def information 165 def information
166 - {:message => _('%{requestor} wants to create enterprise %{subject}.')} 166 + {:message => _('%{requestor} wants to create enterprise %{subject}.').html_safe}
167 end 167 end
168 168
169 def task_created_message 169 def task_created_message
app/models/custom_field.rb
1 -class CustomField < ActiveRecord::Base 1 +class CustomField < ApplicationRecord
  2 +
2 attr_accessible :name, :default_value, :format, :extras, :customized_type, :active, :required, :signup, :environment, :moderation_task 3 attr_accessible :name, :default_value, :format, :extras, :customized_type, :active, :required, :signup, :environment, :moderation_task
3 serialize :customized_type 4 serialize :customized_type
4 serialize :extras 5 serialize :extras
app/models/custom_field_value.rb
1 -class CustomFieldValue < ActiveRecord::Base 1 +class CustomFieldValue < ApplicationRecord
  2 +
2 belongs_to :custom_field 3 belongs_to :custom_field
3 belongs_to :customized, :polymorphic => true 4 belongs_to :customized, :polymorphic => true
4 attr_accessible :value, :public, :customized, :custom_field, :customized_type 5 attr_accessible :value, :public, :customized, :custom_field, :customized_type
app/models/doc_item.rb
@@ -17,7 +17,7 @@ class DocItem @@ -17,7 +17,7 @@ class DocItem
17 else 17 else
18 match 18 match
19 end 19 end
20 - end 20 + end.html_safe
21 end 21 end
22 22
23 private 23 private
app/models/domain.rb
1 require 'noosfero/multi_tenancy' 1 require 'noosfero/multi_tenancy'
2 2
3 -class Domain < ActiveRecord::Base 3 +class Domain < ApplicationRecord
4 4
5 attr_accessible :name, :owner, :is_default 5 attr_accessible :name, :owner, :is_default
6 6
app/models/email_template.rb
1 -class EmailTemplate < ActiveRecord::Base 1 +class EmailTemplate < ApplicationRecord
2 2
3 belongs_to :owner, :polymorphic => true 3 belongs_to :owner, :polymorphic => true
4 4
app/models/environment.rb
1 # A Environment is like a website to be hosted in the platform. It may 1 # A Environment is like a website to be hosted in the platform. It may
2 # contain multiple Profile's and can be identified by several different 2 # contain multiple Profile's and can be identified by several different
3 # domains. 3 # domains.
4 -class Environment < ActiveRecord::Base 4 +class Environment < ApplicationRecord
5 5
6 attr_accessible :name, :is_default, :signup_welcome_text_subject, 6 attr_accessible :name, :is_default, :signup_welcome_text_subject,
7 :signup_welcome_text_body, :terms_of_use, 7 :signup_welcome_text_body, :terms_of_use,
@@ -731,7 +731,7 @@ class Environment &lt; ActiveRecord::Base @@ -731,7 +731,7 @@ class Environment &lt; ActiveRecord::Base
731 url << (Noosfero.url_options.key?(:host) ? Noosfero.url_options[:host] : default_hostname) 731 url << (Noosfero.url_options.key?(:host) ? Noosfero.url_options[:host] : default_hostname)
732 url << ':' << Noosfero.url_options[:port].to_s if Noosfero.url_options.key?(:port) 732 url << ':' << Noosfero.url_options[:port].to_s if Noosfero.url_options.key?(:port)
733 url << Noosfero.root('') 733 url << Noosfero.root('')
734 - url 734 + url.html_safe
735 end 735 end
736 736
737 def to_s 737 def to_s
app/models/external_feed.rb
1 -class ExternalFeed < ActiveRecord::Base 1 +class ExternalFeed < ApplicationRecord
2 2
3 belongs_to :blog 3 belongs_to :blog
4 validates_presence_of :blog_id 4 validates_presence_of :blog_id
app/models/favorite_enterprise_person.rb
1 -class FavoriteEnterprisePerson < ActiveRecord::Base 1 +class FavoriteEnterprisePerson < ApplicationRecord
2 2
3 attr_accessible :person, :enterprise 3 attr_accessible :person, :enterprise
4 4
app/models/friendship.rb
1 -class Friendship < ActiveRecord::Base 1 +class Friendship < ApplicationRecord
2 track_actions :new_friendship, :after_create, :keep_params => ["friend.name", "friend.url", "friend.profile_custom_icon"], :custom_user => :person 2 track_actions :new_friendship, :after_create, :keep_params => ["friend.name", "friend.url", "friend.profile_custom_icon"], :custom_user => :person
3 3
4 extend CacheCounterHelper 4 extend CacheCounterHelper
app/models/image.rb
1 -class Image < ActiveRecord::Base 1 +class Image < ApplicationRecord
2 2
3 attr_accessible :uploaded_data, :label, :remove_image 3 attr_accessible :uploaded_data, :label, :remove_image
4 attr_accessor :remove_image 4 attr_accessor :remove_image
app/models/input.rb
1 -class Input < ActiveRecord::Base 1 +class Input < ApplicationRecord
2 2
3 attr_accessible :product, :product_id, :product_category, :product_category_id, 3 attr_accessible :product, :product_id, :product_category, :product_category_id,
4 :amount_used, :unit_id, :price_per_unit, :relevant_to_price, :is_from_solidarity_economy 4 :amount_used, :unit_id, :price_per_unit, :relevant_to_price, :is_from_solidarity_economy
app/models/invite_friend.rb
@@ -13,7 +13,7 @@ class InviteFriend &lt; Invitation @@ -13,7 +13,7 @@ class InviteFriend &lt; Invitation
13 end 13 end
14 14
15 def information 15 def information
16 - {:message => _('%{requestor} wants to be your friend.')} 16 + {:message => _('%{requestor} wants to be your friend.').html_safe}
17 end 17 end
18 18
19 def accept_details 19 def accept_details
@@ -25,7 +25,7 @@ class InviteFriend &lt; Invitation @@ -25,7 +25,7 @@ class InviteFriend &lt; Invitation
25 end 25 end
26 26
27 def target_notification_description 27 def target_notification_description
28 - _('%{requestor} wants to be your friend.') % {:requestor => requestor.name} 28 + (_('%{requestor} wants to be your friend.') % {:requestor => requestor.name}).html_safe
29 end 29 end
30 30
31 def permission 31 def permission
app/models/invite_member.rb
@@ -25,7 +25,7 @@ class InviteMember &lt; Invitation @@ -25,7 +25,7 @@ class InviteMember &lt; Invitation
25 end 25 end
26 26
27 def information 27 def information
28 - {:message => _('%{requestor} invited you to join %{linked_subject}.')} 28 + {:message => _('%{requestor} invited you to join %{linked_subject}.').html_safe}
29 end 29 end
30 30
31 def url 31 def url
@@ -37,7 +37,7 @@ class InviteMember &lt; Invitation @@ -37,7 +37,7 @@ class InviteMember &lt; Invitation
37 end 37 end
38 38
39 def target_notification_description 39 def target_notification_description
40 - _('%{requestor} invited you to join %{community}.') % {:requestor => requestor.name, :community => community.name} 40 + (_('%{requestor} invited you to join %{community}.') % {:requestor => requestor.name, :community => community.name}).html_safe
41 end 41 end
42 42
43 def target_notification_message 43 def target_notification_message
app/models/license.rb
1 -class License < ActiveRecord::Base 1 +class License < ApplicationRecord
2 2
3 attr_accessible :name, :url 3 attr_accessible :name, :url
4 4
app/models/mailing_sent.rb
1 -class MailingSent < ActiveRecord::Base 1 +class MailingSent < ApplicationRecord
  2 +
2 attr_accessible :person 3 attr_accessible :person
3 belongs_to :mailing 4 belongs_to :mailing
4 belongs_to :person 5 belongs_to :person
app/models/national_region.rb
1 -class NationalRegion < ActiveRecord::Base 1 +class NationalRegion < ApplicationRecord
2 2
3 SEARCHABLE_FIELDS = { 3 SEARCHABLE_FIELDS = {
4 :name => {:label => _('Name'), :weight => 1}, 4 :name => {:label => _('Name'), :weight => 1},
app/models/national_region_type.rb
1 -class NationalRegionType < ActiveRecord::Base 1 +class NationalRegionType < ApplicationRecord
2 COUNTRY = 1 2 COUNTRY = 1
3 STATE = 2 3 STATE = 2
4 CITY = 3 4 CITY = 3
app/models/person.rb
@@ -341,7 +341,7 @@ class Person &lt; Profile @@ -341,7 +341,7 @@ class Person &lt; Profile
341 environment ||= self.environment 341 environment ||= self.environment
342 role_assignments.includes([:role, :resource]).select { |ra| ra.resource == environment }.map{|ra|ra.role.permissions}.any? do |ps| 342 role_assignments.includes([:role, :resource]).select { |ra| ra.resource == environment }.map{|ra|ra.role.permissions}.any? do |ps|
343 ps.any? do |p| 343 ps.any? do |p|
344 - ActiveRecord::Base::PERMISSIONS['Environment'].keys.include?(p) 344 + ApplicationRecord::PERMISSIONS['Environment'].keys.include?(p)
345 end 345 end
346 end 346 end
347 end 347 end
app/models/price_detail.rb
1 -class PriceDetail < ActiveRecord::Base 1 +class PriceDetail < ApplicationRecord
2 2
3 attr_accessible :price, :production_cost_id 3 attr_accessible :price, :production_cost_id
4 4
app/models/product.rb
1 -class Product < ActiveRecord::Base 1 +class Product < ApplicationRecord
2 2
3 SEARCHABLE_FIELDS = { 3 SEARCHABLE_FIELDS = {
4 :name => {:label => _('Name'), :weight => 10}, 4 :name => {:label => _('Name'), :weight => 10},
app/models/product_qualifier.rb
1 -class ProductQualifier < ActiveRecord::Base 1 +class ProductQualifier < ApplicationRecord
2 2
3 attr_accessible :qualifier, :product, :certifier 3 attr_accessible :qualifier, :product, :certifier
4 4
app/models/production_cost.rb
1 -class ProductionCost < ActiveRecord::Base 1 +class ProductionCost < ApplicationRecord
2 2
3 attr_accessible :name, :owner 3 attr_accessible :name, :owner
4 4
app/models/profile.rb
1 # A Profile is the representation and web-presence of an individual or an 1 # A Profile is the representation and web-presence of an individual or an
2 # organization. Every Profile is attached to its Environment of origin, 2 # organization. Every Profile is attached to its Environment of origin,
3 # which by default is the one returned by Environment:default. 3 # which by default is the one returned by Environment:default.
4 -class Profile < ActiveRecord::Base 4 +class Profile < ApplicationRecord
5 5
6 attr_accessible :name, :identifier, :public_profile, :nickname, :custom_footer, :custom_header, :address, :zip_code, :contact_phone, :image_builder, :description, :closed, :template_id, :environment, :lat, :lng, :is_template, :fields_privacy, :preferred_domain_id, :category_ids, :country, :city, :state, :national_region_code, :email, :contact_email, :redirect_l10n, :notification_time, 6 attr_accessible :name, :identifier, :public_profile, :nickname, :custom_footer, :custom_header, :address, :zip_code, :contact_phone, :image_builder, :description, :closed, :template_id, :environment, :lat, :lng, :is_template, :fields_privacy, :preferred_domain_id, :category_ids, :country, :city, :state, :national_region_code, :email, :contact_email, :redirect_l10n, :notification_time,
7 :redirection_after_login, :custom_url_redirection, 7 :redirection_after_login, :custom_url_redirection,
@@ -675,7 +675,7 @@ class Profile &lt; ActiveRecord::Base @@ -675,7 +675,7 @@ class Profile &lt; ActiveRecord::Base
675 url << url_options[:host] 675 url << url_options[:host]
676 url << ':' << url_options[:port].to_s if url_options.key?(:port) 676 url << ':' << url_options[:port].to_s if url_options.key?(:port)
677 url << Noosfero.root('') 677 url << Noosfero.root('')
678 - url 678 + url.html_safe
679 end 679 end
680 680
681 private :generate_url, :url_options 681 private :generate_url, :url_options
app/models/profile_activity.rb
1 -class ProfileActivity < ActiveRecord::Base 1 +class ProfileActivity < ApplicationRecord
2 2
3 self.record_timestamps = false 3 self.record_timestamps = false
4 4
app/models/profile_categorization.rb
1 -class ProfileCategorization < ActiveRecord::Base 1 +class ProfileCategorization < ApplicationRecord
2 self.table_name = :categories_profiles 2 self.table_name = :categories_profiles
3 belongs_to :profile 3 belongs_to :profile
4 belongs_to :category 4 belongs_to :category
app/models/profile_suggestion.rb
1 -class ProfileSuggestion < ActiveRecord::Base 1 +class ProfileSuggestion < ApplicationRecord
  2 +
2 belongs_to :person 3 belongs_to :person
3 belongs_to :suggestion, :class_name => 'Profile', :foreign_key => :suggestion_id 4 belongs_to :suggestion, :class_name => 'Profile', :foreign_key => :suggestion_id
4 5
app/models/qualifier.rb
1 -class Qualifier < ActiveRecord::Base 1 +class Qualifier < ApplicationRecord
2 2
3 attr_accessible :name, :environment 3 attr_accessible :name, :environment
4 4
app/models/qualifier_certifier.rb
1 -class QualifierCertifier < ActiveRecord::Base 1 +class QualifierCertifier < ApplicationRecord
2 belongs_to :qualifier 2 belongs_to :qualifier
3 belongs_to :certifier 3 belongs_to :certifier
4 4
app/models/reported_image.rb
1 -class ReportedImage < ActiveRecord::Base 1 +class ReportedImage < ApplicationRecord
2 belongs_to :abuse_report 2 belongs_to :abuse_report
3 3
4 validates_presence_of :abuse_report 4 validates_presence_of :abuse_report
app/models/scrap.rb
1 -class Scrap < ActiveRecord::Base 1 +class Scrap < ApplicationRecord
2 2
3 include SanitizeHelper 3 include SanitizeHelper
4 4
app/models/search_term.rb
1 -class SearchTerm < ActiveRecord::Base 1 +class SearchTerm < ApplicationRecord
2 validates_presence_of :term, :context 2 validates_presence_of :term, :context
3 validates_uniqueness_of :term, :scope => [:context_id, :context_type, :asset] 3 validates_uniqueness_of :term, :scope => [:context_id, :context_type, :asset]
4 4
@@ -25,7 +25,7 @@ class SearchTerm &lt; ActiveRecord::Base @@ -25,7 +25,7 @@ class SearchTerm &lt; ActiveRecord::Base
25 # Therefore the score is 97. Them we sum every score to get the total score 25 # Therefore the score is 97. Them we sum every score to get the total score
26 # for a search term. 26 # for a search term.
27 def self.occurrences_scores 27 def self.occurrences_scores
28 - Hash[*ActiveRecord::Base.connection.execute( 28 + Hash[*ApplicationRecord.connection.execute(
29 joins(:occurrences). 29 joins(:occurrences).
30 select("search_terms.id, sum(#{SearchTermOccurrence::EXPIRATION_TIME.to_i} - extract(epoch from (now() - search_term_occurrences.created_at))) as value"). 30 select("search_terms.id, sum(#{SearchTermOccurrence::EXPIRATION_TIME.to_i} - extract(epoch from (now() - search_term_occurrences.created_at))) as value").
31 where("search_term_occurrences.created_at > ?", DateTime.now - SearchTermOccurrence::EXPIRATION_TIME). 31 where("search_term_occurrences.created_at > ?", DateTime.now - SearchTermOccurrence::EXPIRATION_TIME).
app/models/search_term_occurrence.rb
1 -class SearchTermOccurrence < ActiveRecord::Base 1 +class SearchTermOccurrence < ApplicationRecord
2 2
3 belongs_to :search_term 3 belongs_to :search_term
4 validates_presence_of :search_term 4 validates_presence_of :search_term
app/models/suggest_article.rb
@@ -65,7 +65,7 @@ class SuggestArticle &lt; Task @@ -65,7 +65,7 @@ class SuggestArticle &lt; Task
65 65
66 def information 66 def information
67 variables = requestor.blank? ? {:requestor => sender} : {} 67 variables = requestor.blank? ? {:requestor => sender} : {}
68 - { :message => _('%{requestor} suggested the publication of the article: %{subject}.'), 68 + { :message => _('%{requestor} suggested the publication of the article: %{subject}.').html_safe,
69 :variables => variables } 69 :variables => variables }
70 end 70 end
71 71
@@ -78,7 +78,7 @@ class SuggestArticle &lt; Task @@ -78,7 +78,7 @@ class SuggestArticle &lt; Task
78 end 78 end
79 79
80 def target_notification_description 80 def target_notification_description
81 - _('%{requestor} suggested the publication of the article: %{article}.') % 81 + _('%{requestor} suggested the publication of the article: %{article}.').html_safe %
82 {:requestor => sender, :article => article_name} 82 {:requestor => sender, :article => article_name}
83 end 83 end
84 84
app/models/suggestion_connection.rb
1 -class SuggestionConnection < ActiveRecord::Base 1 +class SuggestionConnection < ApplicationRecord
  2 +
2 attr_accessible :suggestion, :suggestion_id, :connection_type, :connection_id 3 attr_accessible :suggestion, :suggestion_id, :connection_type, :connection_id
3 4
4 belongs_to :suggestion, :class_name => 'ProfileSuggestion', :foreign_key => 'suggestion_id' 5 belongs_to :suggestion, :class_name => 'ProfileSuggestion', :foreign_key => 'suggestion_id'
app/models/task.rb
@@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
9 # This class has a +data+ field of type <tt>text</tt>, where you can store any 9 # This class has a +data+ field of type <tt>text</tt>, where you can store any
10 # type of data (as serialized Ruby objects) you need for your subclass (which 10 # type of data (as serialized Ruby objects) you need for your subclass (which
11 # will need to declare <ttserialize</tt> itself). 11 # will need to declare <ttserialize</tt> itself).
12 -class Task < ActiveRecord::Base 12 +class Task < ApplicationRecord
13 13
14 acts_as_having_settings :field => :data 14 acts_as_having_settings :field => :data
15 acts_as_ordered_taggable 15 acts_as_ordered_taggable
@@ -347,6 +347,21 @@ class Task &lt; ActiveRecord::Base @@ -347,6 +347,21 @@ class Task &lt; ActiveRecord::Base
347 where [environment_condition, profile_condition].compact.join(' OR ') 347 where [environment_condition, profile_condition].compact.join(' OR ')
348 } 348 }
349 349
  350 + scope :from_closed_date, -> closed_from {
  351 + where('tasks.end_date >= ?', closed_from.beginning_of_day) unless closed_from.blank?
  352 + }
  353 +
  354 + scope :until_closed_date, -> closed_until {
  355 + where('tasks.end_date <= ?', closed_until.end_of_day) unless closed_until.blank?
  356 + }
  357 +
  358 + scope :from_creation_date, -> created_from {
  359 + where('tasks.created_at >= ?', created_from.beginning_of_day) unless created_from.blank?
  360 + }
  361 +
  362 + scope :until_creation_date, -> created_until {
  363 + where('tasks.created_at <= ?', created_until.end_of_day) unless created_until.blank?
  364 + }
350 365
351 def self.pending_types_for(profile) 366 def self.pending_types_for(profile)
352 Task.to(profile).pending.select('distinct type').map { |t| [t.class.name, t.title] } 367 Task.to(profile).pending.select('distinct type').map { |t| [t.class.name, t.title] }
app/models/thumbnail.rb
1 -class Thumbnail < ActiveRecord::Base 1 +class Thumbnail < ApplicationRecord
2 2
3 attr_accessible :uploaded_data 3 attr_accessible :uploaded_data
4 # mass assigned by attachment_fu 4 # mass assigned by attachment_fu
app/models/unit.rb
1 -class Unit < ActiveRecord::Base 1 +class Unit < ApplicationRecord
2 2
3 acts_as_list scope: -> unit { where environment_id: unit.environment_id } 3 acts_as_list scope: -> unit { where environment_id: unit.environment_id }
4 4
app/models/user.rb
@@ -4,7 +4,7 @@ require &#39;securerandom&#39; @@ -4,7 +4,7 @@ require &#39;securerandom&#39;
4 4
5 # User models the system users, and is generated by the acts_as_authenticated 5 # User models the system users, and is generated by the acts_as_authenticated
6 # Rails generator. 6 # Rails generator.
7 -class User < ActiveRecord::Base 7 +class User < ApplicationRecord
8 8
9 attr_accessible :login, :email, :password, :password_confirmation, :activated_at 9 attr_accessible :login, :email, :password, :password_confirmation, :activated_at
10 10
app/models/validation_info.rb
1 -class ValidationInfo < ActiveRecord::Base 1 +class ValidationInfo < ApplicationRecord
2 2
3 attr_accessible :validation_methodology, :restrictions, :organization 3 attr_accessible :validation_methodology, :restrictions, :organization
4 4
app/views/account/_signup_form.html.erb
@@ -107,7 +107,7 @@ @@ -107,7 +107,7 @@
107 <%= render :partial => 'profile_editor/person_form', :locals => {:f => f} %> 107 <%= render :partial => 'profile_editor/person_form', :locals => {:f => f} %>
108 <% end %> 108 <% end %>
109 109
110 - <%= @plugins.dispatch(:signup_extra_contents).collect { |content| instance_eval(&content) }.join("") %> 110 + <%= safe_join(@plugins.dispatch(:signup_extra_contents).collect { |content| instance_eval(&content) }, "") %>
111 111
112 <% unless @terms_of_use.blank? %> 112 <% unless @terms_of_use.blank? %>
113 <div id='terms-of-use-box' class='formfieldline'> 113 <div id='terms-of-use-box' class='formfieldline'>
app/views/account/activate_enterprise.html.erb
@@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
14 <div id="enterprise-activation-create-user-form" style="display: none"> 14 <div id="enterprise-activation-create-user-form" style="display: none">
15 <h3><%= _('Personal signup form') %></h3> 15 <h3><%= _('Personal signup form') %></h3>
16 <%= render :partial => 'signup_form', :locals => { :hidden_atention => true } %> 16 <%= render :partial => 'signup_form', :locals => { :hidden_atention => true } %>
17 - <p><%= message = _('<b>Warning</b>: this form is for your personal information, not of your enterprise. So you will have a personal account that can manage your enterprise.') %></p> 17 + <p><%= message = _('<b>Warning</b>: this form is for your personal information, not of your enterprise. So you will have a personal account that can manage your enterprise.').html_safe %></p>
18 </div> 18 </div>
19 19
20 <div id="enterprise-activation-login-form" style="display: none"> 20 <div id="enterprise-activation-login-form" style="display: none">
app/views/account/invalid_change_password_code.html.erb
1 <h1><%= _("Invalid change password code") %></h1> 1 <h1><%= _("Invalid change password code") %></h1>
2 2
3 <p> 3 <p>
4 -<%= _('The code you are using for password change is not valid. Please try to request password change using the <a href="%s">"I forgot my password"</a> functionality.') % url_for(:action => 'forgot_password') %> 4 +<%= _('The code you are using for password change is not valid. Please try to request password change using the <a href="%s">"I forgot my password"</a> functionality.') % url_for(:action => 'forgot_password').html_safe %>
5 </p> 5 </p>
app/views/account/login.html.erb
@@ -20,7 +20,7 @@ @@ -20,7 +20,7 @@
20 </label> 20 </label>
21 </div> 21 </div>
22 22
23 - <%= @plugins.dispatch(:login_extra_contents).collect { |content| instance_exec(&content) }.join("") %> 23 + <%= safe_join(@plugins.dispatch(:login_extra_contents).collect { |content| instance_exec(&content) }, "") %>
24 24
25 <% button_bar do %> 25 <% button_bar do %>
26 <%= submit_button( 'login', _('Log in') )%> 26 <%= submit_button( 'login', _('Log in') )%>
app/views/account/login_block.html.erb
@@ -15,7 +15,7 @@ @@ -15,7 +15,7 @@
15 15
16 <%= f.password_field :password %> 16 <%= f.password_field :password %>
17 17
18 - <%= @plugins.dispatch(:login_extra_contents).collect { |content| instance_eval(&content) }.join("") %> 18 + <%= safe_join(@plugins.dispatch(:login_extra_contents).collect { |content| instance_eval(&content) }, "") %>
19 19
20 <% button_bar do %> 20 <% button_bar do %>
21 <%= submit_button( 'login', _('Log in') )%> 21 <%= submit_button( 'login', _('Log in') )%>
app/views/account/new_password_ok.html.erb
@@ -5,5 +5,5 @@ @@ -5,5 +5,5 @@
5 </p> 5 </p>
6 6
7 <p> 7 <p>
8 -<%= _("You can <a href='%s'>login</a> now.") % url_for(:action => 'login') %> 8 +<%= _("You can <a href='%s'>login</a> now.").html_safe % url_for(:action => 'login') %>
9 </p> 9 </p>
app/views/blocks/blog_archives.html.erb
@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 <%= content_tag('li', content_tag('strong', "#{year.to_i} (#{count})")) %> 6 <%= content_tag('li', content_tag('strong', "#{year.to_i} (#{count})")) %>
7 <ul class='<%= year.to_i %>-archive'> 7 <ul class='<%= year.to_i %>-archive'>
8 <% block.blog.total_number_of_posts(:by_month, year).each do |month, count| %> 8 <% block.blog.total_number_of_posts(:by_month, year).each do |month, count| %>
9 - <%= content_tag('li', link_to("#{month_name(month.to_i)} (#{count})", block.blog.url.merge(year: year.to_i, month: month.to_i))) %> 9 + <%= content_tag('li', link_to("#{month_name(month.to_i)} (#{count})", url_for(block.blog.url.merge(year: year.to_i, month: month.to_i)).html_safe)) %>
10 <% end %> 10 <% end %>
11 </ul> 11 </ul>
12 <% end %> 12 <% end %>
app/views/blocks/link_list.html.erb
@@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
8 <%= block.sanitize_link(link_to(link[:name], block.expand_address(link[:address]), 8 <%= block.sanitize_link(link_to(link[:name], block.expand_address(link[:address]),
9 :target => link[:target], 9 :target => link[:target],
10 :class => (link[:icon] ? "icon-#{link[:icon]}" : ''), 10 :class => (link[:icon] ? "icon-#{link[:icon]}" : ''),
11 - :title => link[:title])) %> 11 + :title => link[:title])).html_safe %>
12 </li> 12 </li>
13 <% end %> 13 <% end %>
14 </ul> 14 </ul>
app/views/blocks/login.html.erb
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 <h2><%= _('Logged in as %s') % user.identifier %></h2> 3 <h2><%= _('Logged in as %s') % user.identifier %></h2>
4 <ul> 4 <ul>
5 <li><%= _('User since %s/%s') % [user.created_at.month, user.created_at.year] %></li> 5 <li><%= _('User since %s/%s') % [user.created_at.month, user.created_at.year] %></li>
6 - <li><%= link_to _('Homepage'), user.public_profile_url %></li> 6 + <li><%= link_to _('Homepage'), url_for(user.public_profile_url) %></li>
7 </ul> 7 </ul>
8 <div class="user-actions"> 8 <div class="user-actions">
9 <%= button(:'menu-logout', _('Logout'), :controller => 'account', :action => 'logout') %> 9 <%= button(:'menu-logout', _('Logout'), :controller => 'account', :action => 'logout') %>
app/views/blocks/profile_list.html.erb
@@ -10,8 +10,8 @@ @@ -10,8 +10,8 @@
10 <% if list.empty? %> 10 <% if list.empty? %>
11 <div class='common-profile-list-block-none'><%= _('None') %></div> 11 <div class='common-profile-list-block-none'><%= _('None') %></div>
12 <% else %> 12 <% else %>
13 - <ul><%= list %></ul> 13 + <ul><%= list.html_safe %></ul>
14 <% end %> 14 <% end %>
15 </div> 15 </div>
16 - 16 +
17 <br style='clear:both'/> 17 <br style='clear:both'/>
app/views/box_organizer/_article_block.html.erb
@@ -9,7 +9,8 @@ @@ -9,7 +9,8 @@
9 first_text = articles[articles.find_index{|a| a.kind_of? TextArticle}||-1] 9 first_text = articles[articles.find_index{|a| a.kind_of? TextArticle}||-1]
10 selected = @block.article || first_text 10 selected = @block.article || first_text
11 %> 11 %>
12 - <%= select_tag( 12 + <%=
  13 + select_tag(
13 'block[article_id]', 14 'block[article_id]',
14 options_for_select_with_title(articles.map {|item| [item.path, item.id]}, selected.id), 15 options_for_select_with_title(articles.map {|item| [item.path, item.id]}, selected.id),
15 :onchange => 'this.changedTo(this.value)' 16 :onchange => 'this.changedTo(this.value)'
app/views/catalog/index.html.erb
@@ -35,7 +35,7 @@ @@ -35,7 +35,7 @@
35 <% else %> 35 <% else %>
36 <div class="no-image"><%= _('No image') %></div> 36 <div class="no-image"><%= _('No image') %></div>
37 <% end %> 37 <% end %>
38 - <div class="catalog-item-extras"><%= extra_content.join("\n") %></div> 38 + <div class="catalog-item-extras"><%= safe_join(extra_content, "\n") %></div>
39 </li> 39 </li>
40 40
41 <li class="product-link"><%= link_to_product product %></li> 41 <li class="product-link"><%= link_to_product product %></li>
app/views/cms/_blog.html.erb
@@ -35,7 +35,7 @@ @@ -35,7 +35,7 @@
35 <div id="article-formitem"> 35 <div id="article-formitem">
36 <%= labelled_form_field( _('Address'), 36 <%= labelled_form_field( _('Address'),
37 content_tag('code', 37 content_tag('code',
38 - url_for(@article.url).gsub(/#{@article.slug}$/, '') + 38 + url_for(@article.url).gsub(/#{@article.slug}$/, '').html_safe +
39 text_field(:article, :slug, :onchange => "warn_value_change()", :size => 25) 39 text_field(:article, :slug, :onchange => "warn_value_change()", :size => 25)
40 ) + 40 ) +
41 content_tag('div', 41 content_tag('div',
app/views/cms/_textile_quick_reference.html.erb
@@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
14 <p><%= _('Numbered lists:') %></p> 14 <p><%= _('Numbered lists:') %></p>
15 <pre># <%= _('first item') %> 15 <pre># <%= _('first item') %>
16 # <%= _('second item') %></pre> 16 # <%= _('second item') %></pre>
17 - <p><%= h(_('For code, use HTML tags <pre> and <code>, and indent the code inside them:')) %> 17 + <p><%= h(_('For code, use HTML tags <pre> and <code>, and indent the code inside them:').html_safe) %>
18 </p> 18 </p>
19 <pre> 19 <pre>
20 &lt;pre&gt; 20 &lt;pre&gt;
@@ -23,7 +23,7 @@ @@ -23,7 +23,7 @@
23 &lt;/code&gt; 23 &lt;/code&gt;
24 &lt;/pre&gt; 24 &lt;/pre&gt;
25 </pre> 25 </pre>
26 - <p><%= _('See also a more complete <a href="%s">Textile Reference</a>.') % 'http://redcloth.org/hobix.com/textile/' %></p> 26 + <p><%= _('See also a more complete <a href="%s">Textile Reference</a>.').html_safe % 'http://redcloth.org/hobix.com/textile/' %></p>
27 </div> 27 </div>
28 </div> 28 </div>
29 29
app/views/cms/edit.html.erb
@@ -39,7 +39,7 @@ @@ -39,7 +39,7 @@
39 39
40 <script> 40 <script>
41 jQuery('#article_tag_list').inputosaurus({ 41 jQuery('#article_tag_list').inputosaurus({
42 - autoCompleteSource: <%= "'/myprofile/#{profile.identifier}/cms/search_tags'," %> 42 + autoCompleteSource: <%= "'/myprofile/#{profile.identifier}/cms/search_tags',".html_safe %>
43 activateFinalResult : true 43 activateFinalResult : true
44 }) 44 })
45 </script> 45 </script>
app/views/cms/select_article_type.html.erb
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 <ul class="article-types"> 5 <ul class="article-types">
6 <% for type in @article_types %> 6 <% for type in @article_types %>
7 <% action = type[:class].name == 'UploadedFile' ? {:action => 'upload_files'} : {:action => 'new', :type => type[:class].name} %> 7 <% action = type[:class].name == 'UploadedFile' ? {:action => 'upload_files'} : {:action => 'new', :type => type[:class].name} %>
8 - <%= content_tag('a', :href => url_for(action.merge(:parent_id => @parent_id, :back_to => @back_to))) do %> 8 + <%= content_tag('a', :href => url_for(action.merge(:parent_id => @parent_id, :back_to => @back_to)).html_safe) do %>
9 <li class="<%= icon_for_new_article(type[:class]) %>" onmouseover="javascript: jQuery(this).addClass('mouseover')" onmouseout="jQuery(this).removeClass('mouseover')"> 9 <li class="<%= icon_for_new_article(type[:class]) %>" onmouseover="javascript: jQuery(this).addClass('mouseover')" onmouseout="jQuery(this).removeClass('mouseover')">
10 <strong><%= type[:short_description] %></strong> 10 <strong><%= type[:short_description] %></strong>
11 <div class='description'><%= type[:description] %></div> 11 <div class='description'><%= type[:description] %></div>
app/views/cms/upload_files.html.erb
@@ -17,11 +17,11 @@ @@ -17,11 +17,11 @@
17 <h3><%= _("Select the files you want to upload (max size %s):") % UploadedFile.max_size.to_humanreadable %></h3> 17 <h3><%= _("Select the files you want to upload (max size %s):") % UploadedFile.max_size.to_humanreadable %></h3>
18 <h4><%= _('Documents, Images, Videos, Audio') %></h4> 18 <h4><%= _('Documents, Images, Videos, Audio') %></h4>
19 19
20 -<h5><%= _('Uploading files to %s') % content_tag('code', @target) %></h5> 20 +<h5><%= (_('Uploading files to %s') % content_tag('code', @target)).html_safe%></h5>
21 21
22 <%= form_for('uploaded_file', :url => { :action => 'upload_files' }, :html => {:multipart => true}) do |f| %> 22 <%= form_for('uploaded_file', :url => { :action => 'upload_files' }, :html => {:multipart => true}) do |f| %>
23 23
24 - <%= @plugins.dispatch(:upload_files_extra_fields, params[:parent_id]).collect { |content| instance_exec(&content) }.join("") %> 24 + <%= safe_join(@plugins.dispatch(:upload_files_extra_fields, params[:parent_id]).collect { |content| instance_exec(&content) }, "") %>
25 25
26 <%= render :partial => 'upload_file_form', :locals => { :size => '45'} %> 26 <%= render :partial => 'upload_file_form', :locals => { :size => '45'} %>
27 27
app/views/cms/view.html.erb
@@ -17,7 +17,7 @@ @@ -17,7 +17,7 @@
17 <% button_bar(:style => 'margin-bottom: 1em;') do %> 17 <% button_bar(:style => 'margin-bottom: 1em;') do %>
18 <% parent_id = ((@article && @article.allow_children?) ? @article : nil) %> 18 <% parent_id = ((@article && @article.allow_children?) ? @article : nil) %>
19 19
20 - <%= modal_button('new', _('New content'), :action => 'new', :parent_id => parent_id, :cms => true) %> 20 + <%= modal_button('new', _('New content'), url_for({:action => 'new', :parent_id => parent_id, :cms => true}).html_safe) %>
21 <%= button(:back, _('Back to control panel'), :controller => 'profile_editor', :action => "index") %> 21 <%= button(:back, _('Back to control panel'), :controller => 'profile_editor', :action => "index") %>
22 <% end %> 22 <% end %>
23 23
@@ -26,7 +26,7 @@ @@ -26,7 +26,7 @@
26 <strong><%= _('Current folder: ') %></strong> 26 <strong><%= _('Current folder: ') %></strong>
27 <%= link_to profile.identifier, :action => 'index' %> 27 <%= link_to profile.identifier, :action => 'index' %>
28 <% @article.hierarchy.each do |item| %> 28 <% @article.hierarchy.each do |item| %>
29 - <%= " / " + ((item == @article) ? item.name.html_safe : link_to(item.slug, :id => item.id).html_safe) %> 29 + <%= " / ".html_safe + ((item == @article) ? item.name.html_safe : link_to(item.slug, :id => item.id).html_safe) %>
30 <% end %> 30 <% end %>
31 </div> 31 </div>
32 <% end %> 32 <% end %>
@@ -45,9 +45,9 @@ @@ -45,9 +45,9 @@
45 <tr> 45 <tr>
46 <td> 46 <td>
47 <% if @article.parent %> 47 <% if @article.parent %>
48 - <%= link_to '.. (' + _('parent folder') + ')', {:action => 'view', :id => @article.parent.id}, :class => 'icon-parent-folder' %> 48 + <%= link_to '.. ('.html_safe + _('parent folder') + ')', {:action => 'view', :id => @article.parent.id}, :class => 'icon-parent-folder' %>
49 <% else %> 49 <% else %>
50 - <%= link_to '.. (' + _('parent folder') + ')', {:action => 'index'}, :class => 'icon-parent-folder' %> 50 + <%= link_to '.. ('.html_safe + _('parent folder') + ')', {:action => 'index'}, :class => 'icon-parent-folder' %>
51 <% end %> 51 <% end %>
52 </td> 52 </td>
53 <td><%= Folder.short_description %></td> 53 <td><%= Folder.short_description %></td>
app/views/comment/_comment.html.erb
@@ -43,7 +43,7 @@ @@ -43,7 +43,7 @@
43 <p/> 43 <p/>
44 <%= txt2html sanitize(comment.body) %> 44 <%= txt2html sanitize(comment.body) %>
45 </div> 45 </div>
46 - <%= @plugins.dispatch(:comment_extra_contents, local_assigns).collect { |content| instance_exec(&content) }.join("") %> 46 + <%= safe_join(@plugins.dispatch(:comment_extra_contents, local_assigns).collect { |content| instance_exec(&content) }, "") %>
47 </div> 47 </div>
48 48
49 <div class="comment_reply post_comment_box closed" id="comment_reply_to_<%= comment.id %>"> 49 <div class="comment_reply post_comment_box closed" id="comment_reply_to_<%= comment.id %>">
app/views/comment/_comment_form.html.erb
@@ -85,7 +85,7 @@ function check_captcha(button, confirm_action) { @@ -85,7 +85,7 @@ function check_captcha(button, confirm_action) {
85 <%= hidden_field_tag(:view, params[:view])%> 85 <%= hidden_field_tag(:view, params[:view])%>
86 <%= f.hidden_field(:reply_of_id) %> 86 <%= f.hidden_field(:reply_of_id) %>
87 87
88 - <%= @plugins.dispatch(:comment_form_extra_contents, local_assigns.merge(:comment => @comment)).collect { |content| instance_exec(&content) }.join("") %> 88 + <%= safe_join(@plugins.dispatch(:comment_form_extra_contents, local_assigns.merge(:comment => @comment)).collect { |content| instance_exec(&content) }, "") %>
89 89
90 <% button_bar do %> 90 <% button_bar do %>
91 <%= submit_button('add', _('Post comment'), :onclick => "if(check_captcha(this)) { save_comment(this) } else { check_captcha(this, save_comment)};return false;") %> 91 <%= submit_button('add', _('Post comment'), :onclick => "if(check_captcha(this)) { save_comment(this) } else { check_captcha(this, save_comment)};return false;") %>
app/views/content_viewer/_article_toolbar.html.erb
@@ -26,7 +26,7 @@ @@ -26,7 +26,7 @@
26 <% content = _('Add translation') %> 26 <% content = _('Add translation') %>
27 <% parent_id = (@page.folder? ? @page : (@page.parent.nil? ? nil : @page.parent)) %> 27 <% parent_id = (@page.folder? ? @page : (@page.parent.nil? ? nil : @page.parent)) %>
28 <% url = profile.admin_url.merge(:controller => 'cms', :action => 'new', :parent_id => parent_id, :type => @page.type, :article => { :translation_of_id => @page.native_translation.id })%> 28 <% url = profile.admin_url.merge(:controller => 'cms', :action => 'new', :parent_id => parent_id, :type => @page.type, :article => { :translation_of_id => @page.native_translation.id })%>
29 - <%= expirable_button @page, :locale, content, url %> 29 + <%= expirable_button @page, :locale, content, url_for(url).html_safe %>
30 <% end %> 30 <% end %>
31 31
32 <% if !@page.archived? %> 32 <% if !@page.archived? %>
@@ -67,7 +67,7 @@ @@ -67,7 +67,7 @@
67 <div class="blog-cover"><%= image_tag(@page.image.public_filename())%></div> 67 <div class="blog-cover"><%= image_tag(@page.image.public_filename())%></div>
68 <% end %> 68 <% end %>
69 <%= button_without_text(:feed, _('RSS feed'), @page.feed.url, :class => 'blog-feed-link') if @page.has_posts? && @page.feed %> 69 <%= button_without_text(:feed, _('RSS feed'), @page.feed.url, :class => 'blog-feed-link') if @page.has_posts? && @page.feed %>
70 - <%= @plugins.dispatch(:article_header_extra_contents, @page).collect { |content| instance_exec(&content) }.join("") %> 70 + <%= safe_join(@plugins.dispatch(:article_header_extra_contents, @page).collect { |content| instance_exec(&content) }) %>
71 <% if @page.archived? %> 71 <% if @page.archived? %>
72 <%= render :partial => 'cms/archived_warning', :locals => {:article => @page} %> 72 <%= render :partial => 'cms/archived_warning', :locals => {:article => @page} %>
73 <% end %> 73 <% end %>
app/views/content_viewer/_publishing_info.html.erb
@@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
7 </span> 7 </span>
8 <% unless @no_comments %> 8 <% unless @no_comments %>
9 <span class="comments"> 9 <span class="comments">
10 - <%= (" - %s") % link_to_comments(@page)%> 10 + <%= (" - %s").html_safe % link_to_comments(@page) %>
11 </span> 11 </span>
12 <% end %> 12 <% end %>
13 13
app/views/content_viewer/event_page.html.erb
@@ -35,7 +35,7 @@ @@ -35,7 +35,7 @@
35 </div> 35 </div>
36 <% end %> 36 <% end %>
37 <div class="event-content"> 37 <div class="event-content">
38 - <%= event.body %> 38 + <%= raw event.body %>
39 </div> 39 </div>
40 <% end %> 40 <% end %>
41 </div> 41 </div>
app/views/content_viewer/versions_diff.html.erb
@@ -2,9 +2,9 @@ @@ -2,9 +2,9 @@
2 <%= button(:back, _('Back to the versions'), {:action => 'article_versions'}) %> 2 <%= button(:back, _('Back to the versions'), {:action => 'article_versions'}) %>
3 </div> 3 </div>
4 4
5 -<h1><%= _('Changes on "%s"') % @page.title %></h1> 5 +<h1><%= _('Changes on "%s"').html_safe % @page.title %></h1>
6 6
7 -<p> <%= _('Changes from %s &rarr; %s') % [show_time(@v1.updated_at), show_time(@v2.updated_at)] %> </p> 7 +<p> <%= _('Changes from %s &rarr; %s').html_safe % [show_time(@v1.updated_at), show_time(@v2.updated_at)] %> </p>
8 8
9 <% diffContent = Diffy::Diff.new(@v1.body, @v2.body, :context => 1) %> 9 <% diffContent = Diffy::Diff.new(@v1.body, @v2.body, :context => 1) %>
10 <% if diffContent.to_s(:text).blank? %> 10 <% if diffContent.to_s(:text).blank? %>
@@ -12,5 +12,5 @@ @@ -12,5 +12,5 @@
12 <%= _('These versions range have no differences.')%> 12 <%= _('These versions range have no differences.')%>
13 </p> 13 </p>
14 <% else %> 14 <% else %>
15 - <%= diffContent.to_s(:html) %> 15 + <%= diffContent.to_s(:html).html_safe %>
16 <% end %> 16 <% end %>
app/views/content_viewer/view_page.html.erb
@@ -45,24 +45,24 @@ @@ -45,24 +45,24 @@
45 <% if ! @page.categories.empty? %> 45 <% if ! @page.categories.empty? %>
46 <div id="article-cat"> 46 <div id="article-cat">
47 <h4><%= _('Categories') %></h4> 47 <h4><%= _('Categories') %></h4>
48 - <%= @page.categories.map {|item| link_to_category(item, false) }.join(", ") %> 48 + <%= safe_join(@page.categories.map {|item| link_to_category(item, false) }, ", ") %>
49 </div> 49 </div>
50 <% end %> 50 <% end %>
51 51
52 <% if !@page.tags.empty? %> 52 <% if !@page.tags.empty? %>
53 <div id="article-tags"> 53 <div id="article-tags">
54 - <%= _("This article's tags:") %>  
55 - <%= @page.tags.map { |t| link_to(t, :controller => 'profile', :profile => @profile.identifier, :action => 'tags', :id => t.name ) }.join("\n") %> 54 + <%= _("This article's tags:").html_safe %>
  55 + <%= safe_join(@page.tags.map { |t| link_to(t, :controller => 'profile', :profile => @profile.identifier, :action => 'tags', :id => t.name ) }, "\n") %>
56 </div> 56 </div>
57 <% end %> 57 <% end %>
58 58
59 <%= display_source_info(@page) %> 59 <%= display_source_info(@page) %>
60 60
61 -<%= @plugins.dispatch(:article_extra_contents, @page).collect { |content| instance_exec(&content) }.join("") %> 61 +<%= safe_join(@plugins.dispatch(:article_extra_contents, @page).collect { |content| instance_exec(&content) }, "") %>
62 62
63 <% if @page.accept_comments? || @comments_count > 0 %> 63 <% if @page.accept_comments? || @comments_count > 0 %>
64 <div class="comments" id="comments_list"> 64 <div class="comments" id="comments_list">
65 - <h3 <%= 'class="no-comments-yet"' if @comments_count == 0 %>> 65 + <h3 <%= 'class="no-comments-yet"'.html_safe if @comments_count == 0 %>>
66 <%= display_number_of_comments(@comments_count) %> 66 <%= display_number_of_comments(@comments_count) %>
67 </h3> 67 </h3>
68 68
app/views/doc/_toc.html.erb
@@ -5,5 +5,5 @@ @@ -5,5 +5,5 @@
5 <li><%= link_to text, link, :target => '_blank' %></li> 5 <li><%= link_to text, link, :target => '_blank' %></li>
6 <% end %> 6 <% end %>
7 </ul> 7 </ul>
8 - <%= @toc.text %> 8 + <%= raw @toc.text %>
9 </div> 9 </div>
app/views/features/index.html.erb
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 <p> 5 <p>
6 <%= _('Here you can enable or disable several features of your environment. Each feature represents some funcionality that your environment can use if you enable it. 6 <%= _('Here you can enable or disable several features of your environment. Each feature represents some funcionality that your environment can use if you enable it.
7 7
8 -Check all the features you want to enable for your environment, uncheck all the ones you don\'t want, and use the <em>"Save changes" button</em> to confirm your changes.') %> 8 +Check all the features you want to enable for your environment, uncheck all the ones you don\'t want, and use the <em>"Save changes" button</em> to confirm your changes.').html_safe %>
9 </p> 9 </p>
10 10
11 <%= labelled_form_for(:environment, :url => {:action => 'update'}) do |f| %> 11 <%= labelled_form_for(:environment, :url => {:action => 'update'}) do |f| %>
app/views/home/index.html.erb
@@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
7 <div class='highlighted-news-item post-<%= index + 1 %>-inner'> 7 <div class='highlighted-news-item post-<%= index + 1 %>-inner'>
8 <h2><%= link_to(h(highlighted.title), highlighted.url, :class => 'post-title') %></h2> 8 <h2><%= link_to(h(highlighted.title), highlighted.url, :class => 'post-title') %></h2>
9 <span class="post-date"><%= show_date(highlighted.published_at, true) %> </span> 9 <span class="post-date"><%= show_date(highlighted.published_at, true) %> </span>
10 - <div class='headline'><%= highlighted.lead %></div> 10 + <div class='headline'><%= raw highlighted.lead %></div>
11 <p class='highlighted-news-read-more'> 11 <p class='highlighted-news-read-more'>
12 <%= link_to(_('Read more'), highlighted.url) %> 12 <%= link_to(_('Read more'), highlighted.url) %>
13 </p> 13 </p>
@@ -49,7 +49,7 @@ @@ -49,7 +49,7 @@
49 <% end %> 49 <% end %>
50 <% end %> 50 <% end %>
51 <% else %> 51 <% else %>
52 - <%= environment.description %> 52 + <%= environment.description.html_safe %>
53 <% end %> 53 <% end %>
54 54
55 <% if environment.enabled?('search_in_home') %> 55 <% if environment.enabled?('search_in_home') %>
app/views/invite/_select_address_book.html.erb
@@ -3,12 +3,12 @@ @@ -3,12 +3,12 @@
3 3
4 <%= form_tag do %> 4 <%= form_tag do %>
5 5
6 - <%= [ 6 + <%= safe_join([
7 radio_button_tag(:import_from, "manual", @import_from == "manual", :onclick => 'hide_invite_friend_login_password()') + content_tag('label', _('Manually (empty field)'), :for => "import_from_manual"), 7 radio_button_tag(:import_from, "manual", @import_from == "manual", :onclick => 'hide_invite_friend_login_password()') + content_tag('label', _('Manually (empty field)'), :for => "import_from_manual"),
8 radio_button_tag(:import_from, "gmail", @import_from == "gmail", :onclick => 'show_invite_friend_login_password(this.value)') + content_tag('label', 'Gmail', :for => 'import_from_gmail'), 8 radio_button_tag(:import_from, "gmail", @import_from == "gmail", :onclick => 'show_invite_friend_login_password(this.value)') + content_tag('label', 'Gmail', :for => 'import_from_gmail'),
9 radio_button_tag(:import_from, "yahoo", @import_from == "yahoo", :onclick => 'show_invite_friend_login_password(this.value)') + content_tag('label', 'Yahoo', :for => "import_from_yahoo"), 9 radio_button_tag(:import_from, "yahoo", @import_from == "yahoo", :onclick => 'show_invite_friend_login_password(this.value)') + content_tag('label', 'Yahoo', :for => "import_from_yahoo"),
10 radio_button_tag(:import_from, "hotmail", @import_from == "hotmail", :onclick => 'show_invite_friend_login_password(this.value)') + content_tag('label', 'Hotmail', :for => "import_from_hotmail") 10 radio_button_tag(:import_from, "hotmail", @import_from == "hotmail", :onclick => 'show_invite_friend_login_password(this.value)') + content_tag('label', 'Hotmail', :for => "import_from_hotmail")
11 - ].join("\n<br/>\n") %> 11 + ], "\n<br/>\n".html_safe) %>
12 12
13 <script type="text/javascript"> 13 <script type="text/javascript">
14 function hide_invite_friend_login_password() { 14 function hide_invite_friend_login_password() {
app/views/layouts/_user.html.erb
@@ -7,22 +7,23 @@ @@ -7,22 +7,23 @@
7 </span> 7 </span>
8 <% else %> 8 <% else %>
9 <span class='not-logged-in'> 9 <span class='not-logged-in'>
10 - <%= _("<span class='login'>%s</span>") % modal_inline_link_to('<i class="icon-menu-login"></i><strong>' + _('Login') + '</strong>', login_url, '#inlineLoginBox', :id => 'link_login') %>  
11 - <%= @plugins.dispatch(:alternative_authentication_link).collect { |content| instance_exec(&content) }.join("") %> 10 + <%= usermenu_notlogged_in %>
  11 + <% @plugins.dispatch(:alternative_authentication_link).collect do |content|%>
  12 + <%= instance_exec(&content) %>
  13 + <%end%>
12 14
13 - <div id='inlineLoginBox' style='display: none;'>  
14 - <%= render :file => 'account/login', :locals => { :is_popin => true } %>  
15 - </div> 15 + <div id='inlineLoginBox' style='display: none;'>
  16 + <%= render :file => 'account/login', :locals => { :is_popin => true } %>
  17 + </div>
16 18
17 - <% unless @plugins.dispatch(:allow_user_registration).include?(false) %>  
18 - <%= _("<span class='or'>or</span> <span class='signup'>%s</span>") % link_to('<strong>' + _('Sign up') + '</strong>', :controller => 'account', :action => 'signup')%>  
19 - <% end %>  
20 -  
21 - </span> 19 + <% unless @plugins.dispatch(:allow_user_registration).include?(false) %>
  20 + <%= usermenu_signup %>
  21 + <% end %>
  22 + </span>
22 <% end %> 23 <% end %>
23 <form action="/search/articles" id="top-search" class="search_form clean" method="get"> 24 <form action="/search/articles" id="top-search" class="search_form clean" method="get">
24 <input name="query" size="15" title="<%=_('Search...')%>" onfocus="this.form.className='focused';" onblur="this.form.className=''" /> 25 <input name="query" size="15" title="<%=_('Search...')%>" onfocus="this.form.className='focused';" onblur="this.form.className=''" />
25 - <div><%=_('Press <strong>Enter</strong> to send the search query.')%></div> 26 + <div><%=_('Press <strong>Enter</strong> to send the search query.').html_safe%></div>
26 <%= javascript_tag 'jQuery("#user form input").hint();' %> 27 <%= javascript_tag 'jQuery("#user form input").hint();' %>
27 </form> 28 </form>
28 </div><!-- end id="user" --> 29 </div><!-- end id="user" -->
app/views/layouts/application-ng.html.erb
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<%= html_language %>" lang="<%= html_language %>" class="<%= h html_tag_classes %>"> 2 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<%= html_language %>" lang="<%= html_language %>" class="<%= h html_tag_classes %>">
3 <head> 3 <head>
4 - <title><%= h page_title %></title> 4 + <title><%= h page_title.html_safe %></title>
5 <%= yield(:feeds) %> 5 <%= yield(:feeds) %>
6 <!--<meta http-equiv="refresh" content="1"/>--> 6 <!--<meta http-equiv="refresh" content="1"/>-->
7 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 7 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
@@ -20,24 +20,33 @@ @@ -20,24 +20,33 @@
20 <%# Add custom tags/styles/etc via content_for %> 20 <%# Add custom tags/styles/etc via content_for %>
21 <%= yield :head %> 21 <%= yield :head %>
22 <%= 22 <%=
23 - @plugins.dispatch(:head_ending).map do |content|  
24 - if content.respond_to?(:call) then instance_exec(&content).to_s.html_safe else content.to_s.html_safe end  
25 - end.join("\n") 23 + str = (@plugins.dispatch(:head_ending).map do |content|
  24 + if content.respond_to?(:call) then
  25 + instance_exec(&content).to_s
  26 + else
  27 + content.to_s
  28 + end
  29 + end)
  30 + safe_join(str, "\n")
26 %> 31 %>
27 32
28 <script type="text/javascript"> 33 <script type="text/javascript">
29 - DEFAULT_LOADING_MESSAGE = <%="'#{ _('loading...') }'" %>;  
30 - noosfero.profile = <%= (@profile.identifier if @profile).to_json %> 34 + DEFAULT_LOADING_MESSAGE = <%="'#{ _('loading...') }'".html_safe %>;
  35 + noosfero.profile = <%= (@profile.identifier if @profile).to_json.html_safe %>
31 </script> 36 </script>
32 37
33 </head> 38 </head>
34 <body class="<%= h body_classes %>"> 39 <body class="<%= h body_classes %>">
35 <a href="#content" id="link-go-content"><span><%= _("Go to the content") %></span></a> 40 <a href="#content" id="link-go-content"><span><%= _("Go to the content") %></span></a>
36 -  
37 <%= 41 <%=
38 - @plugins.dispatch(:body_beginning).map do |content|  
39 - if content.respond_to?(:call) then instance_exec(&content).to_s.html_safe else content.to_s.html_safe end  
40 - end.join("\n") 42 + str = (@plugins.dispatch(:body_beginning).map do |content|
  43 + if content.respond_to?(:call) then
  44 + instance_exec(&content).to_s
  45 + else
  46 + content.to_s
  47 + end
  48 + end)
  49 + safe_join(str, "\n")
41 %> 50 %>
42 <div id="global-header"> 51 <div id="global-header">
43 <%= global_header %> 52 <%= global_header %>
@@ -75,9 +84,14 @@ @@ -75,9 +84,14 @@
75 <%= noosfero_layout_features %> 84 <%= noosfero_layout_features %>
76 <%= addthis_javascript %> 85 <%= addthis_javascript %>
77 <%= 86 <%=
78 - @plugins.dispatch(:body_ending).map do |content|  
79 - if content.respond_to?(:call) then instance_exec(&content).html_safe else content.html_safe end  
80 - end.join("\n") 87 + str = (@plugins.dispatch(:body_ending).map do |content|
  88 + if content.respond_to?(:call) then
  89 + instance_exec(&content)
  90 + else
  91 + content
  92 + end
  93 + end)
  94 + safe_join(str, "\n")
81 %> 95 %>
82 96
83 </body> 97 </body>
app/views/mailconf/index.html.erb
@@ -16,7 +16,7 @@ @@ -16,7 +16,7 @@
16 <% if profile.user.enable_email %> 16 <% if profile.user.enable_email %>
17 <h2><%= ('E-mail address') %></h2> 17 <h2><%= ('E-mail address') %></h2>
18 <ul> 18 <ul>
19 - <%= profile.email_addresses.map{|i| content_tag('li', i)}.join("\n") %> 19 + <%= safe_join(profile.email_addresses.map{|i| content_tag('li', i)}, "\n") %>
20 </ul> 20 </ul>
21 <h2><%= _('Configuration') %></h2> 21 <h2><%= _('Configuration') %></h2>
22 <ul> 22 <ul>
@@ -31,7 +31,7 @@ @@ -31,7 +31,7 @@
31 <% else %> 31 <% else %>
32 32
33 <h2><%= _("Enable e-Mail account below:") %></h2> 33 <h2><%= _("Enable e-Mail account below:") %></h2>
34 - <ul><%= profile.email_addresses.map{|i| content_tag('li', i)}.join("\n") %></ul> 34 + <ul><%= safe_join(profile.email_addresses.map{|i| content_tag('li', i)}, "\n") %></ul>
35 <blockquote><%= _("You'll be able to access a webmail from your user menu.") %></blockquote> 35 <blockquote><%= _("You'll be able to access a webmail from your user menu.") %></blockquote>
36 <% button_bar do %> 36 <% button_bar do %>
37 <%= button(:ok, _('Enable e-Mail'), { :action => 'enable' }, :method => 'post') %> 37 <%= button(:ok, _('Enable e-Mail'), { :action => 'enable' }, :method => 'post') %>
app/views/mailing/sender/notification.html.erb
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
5 </head> 5 </head>
6 <body style="margin: 0"> 6 <body style="margin: 0">
7 - <%= word_wrap(@message) %> 7 + <%= raw word_wrap(@message) %>
8 <p> 8 <p>
9 --<br/> 9 --<br/>
10 <%= @signature_message %><br/> 10 <%= @signature_message %><br/>
app/views/manage_products/show.html.erb
@@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
14 </div> 14 </div>
15 <div id='product-extra-content'> 15 <div id='product-extra-content'>
16 <% extra_content = @plugins.dispatch(:product_info_extras, @product).collect { |content| instance_exec(&content) } %> 16 <% extra_content = @plugins.dispatch(:product_info_extras, @product).collect { |content| instance_exec(&content) } %>
17 - <%= extra_content.join("\n") %> 17 + <%= safe_join(extra_content, "\n") %>
18 </div> 18 </div>
19 <div id='product-info'> 19 <div id='product-info'>
20 <%= render :partial => 'manage_products/display_info' %> 20 <%= render :partial => 'manage_products/display_info' %>
app/views/memberships/new_community.html.erb
@@ -34,13 +34,13 @@ @@ -34,13 +34,13 @@
34 <div style='margin-bottom: 0.5em' id='community-join-before'> 34 <div style='margin-bottom: 0.5em' id='community-join-before'>
35 <%= radio_button 'community', 'closed', 'true', :style => 'float: left' %> 35 <%= radio_button 'community', 'closed', 'true', :style => 'float: left' %>
36 <div style='margin-left: 30px'> 36 <div style='margin-left: 30px'>
37 - <%= _('<strong>Before</strong> joining this group (a moderator has to accept the member in pending request before member can access the intranet and/or the website).') %> 37 + <%= _('<strong>Before</strong> joining this group (a moderator has to accept the member in pending request before member can access the intranet and/or the website).').html_safe %>
38 </div> 38 </div>
39 </div> 39 </div>
40 <div id='community-join-after'> 40 <div id='community-join-after'>
41 <%= radio_button 'community', 'closed', 'false', :style => 'float: left' %> 41 <%= radio_button 'community', 'closed', 'false', :style => 'float: left' %>
42 <div style='margin-left: 30px'> 42 <div style='margin-left: 30px'>
43 - <%= _('<strong>After</strong> joining this group (a moderator can always desactivate access for users later).') %> 43 + <%= _('<strong>After</strong> joining this group (a moderator can always desactivate access for users later).').html_safe %>
44 </div> 44 </div>
45 </div> 45 </div>
46 46
app/views/pending_task_notifier/notification.text.erb
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 2
3 <%= _("You have %d pending task(s).") % @tasks.size %> 3 <%= _("You have %d pending task(s).") % @tasks.size %>
4 4
5 -<%= @tasks.map{|i| " * #{i.description}"}.join("\n") %> 5 +<%= safe_join(@tasks.map{|i| " * #{i.description}"}, "\n") %>
6 6
7 <%= _("Click in address below to process task(s):") %> 7 <%= _("Click in address below to process task(s):") %>
8 8
@@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@
11 <% pending_tasks = @person.pending_tasks_for_organization(organization) %> 11 <% pending_tasks = @person.pending_tasks_for_organization(organization) %>
12 <%= _("%s has %d pending task(s).") % [organization.name, pending_tasks.size] %> 12 <%= _("%s has %d pending task(s).") % [organization.name, pending_tasks.size] %>
13 13
14 -<%= pending_tasks.map{|i| " * #{i.information}"}.join("\n") %> 14 +<%= safe_join(pending_tasks.map{|i| " * #{i.information}"}, "\n") %>
15 15
16 <%= _("Click in address below to process task(s):") %> 16 <%= _("Click in address below to process task(s):") %>
17 17
app/views/profile/content_tagged.html.erb
@@ -20,6 +20,6 @@ @@ -20,6 +20,6 @@
20 <%= pagination_links @tagged, :param_name => 'npage' %> 20 <%= pagination_links @tagged, :param_name => 'npage' %>
21 21
22 <div> 22 <div>
23 - <%= link_to _('See content tagged with "%s" in the entire site') % escaped_tag, :controller => 'search', :action => 'tag', :tag => @tag %> 23 + <%= link_to (_('See content tagged with "%s" in the entire site') % escaped_tag).html_safe, :controller => 'search', :action => 'tag', :tag => @tag %>
24 </div> 24 </div>
25 <% end %> 25 <% end %>
app/views/profile/index.html.erb
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 <% else %> 5 <% else %>
6 <% unless profile.description.blank? %> 6 <% unless profile.description.blank? %>
7 <div class='public-profile-description'> 7 <div class='public-profile-description'>
8 - <%= profile.description %> 8 + <%= raw profile.description %>
9 </div> 9 </div>
10 <% end %> 10 <% end %>
11 <div id='public-profile-search'> 11 <div id='public-profile-search'>
app/views/profile_editor/_moderation.html.erb
@@ -34,13 +34,13 @@ @@ -34,13 +34,13 @@
34 <div style='margin-bottom: 0.5em'> 34 <div style='margin-bottom: 0.5em'>
35 <%= radio_button 'profile_data', 'closed', 'true', :style => 'float: left' %> 35 <%= radio_button 'profile_data', 'closed', 'true', :style => 'float: left' %>
36 <div style='margin-left: 30px'> 36 <div style='margin-left: 30px'>
37 - <%= _('<strong>Before</strong> joining this group (a moderator has to accept the member in pending request before member can access the intranet and/or the website).') %> 37 + <%= _('<strong>Before</strong> joining this group (a moderator has to accept the member in pending request before member can access the intranet and/or the website).').html_safe %>
38 </div> 38 </div>
39 </div> 39 </div>
40 <div> 40 <div>
41 <%= radio_button 'profile_data', 'closed', 'false', :style => 'float: left' %> 41 <%= radio_button 'profile_data', 'closed', 'false', :style => 'float: left' %>
42 <div style='margin-left: 30px'> 42 <div style='margin-left: 30px'>
43 - <%= _('<strong>After</strong> joining this group (a moderator can always desactivate access for users later).') %> 43 + <%= _('<strong>After</strong> joining this group (a moderator can always desactivate access for users later).').html_safe %>
44 </div> 44 </div>
45 </div> 45 </div>
46 <br> 46 <br>
@@ -52,13 +52,13 @@ @@ -52,13 +52,13 @@
52 <div style='margin-bottom: 0.5em'> 52 <div style='margin-bottom: 0.5em'>
53 <%= radio_button 'profile_data', 'moderated_articles', 'true', :style => 'float: left' %> 53 <%= radio_button 'profile_data', 'moderated_articles', 'true', :style => 'float: left' %>
54 <div style='margin-left: 30px'> 54 <div style='margin-left: 30px'>
55 - <%= _('<strong>Before</strong> being published in this group (a moderator has to accept the article in pending request before the article be listed as a article of this group).') %> 55 + <%= _('<strong>Before</strong> being published in this group (a moderator has to accept the article in pending request before the article be listed as a article of this group).').html_safe %>
56 </div> 56 </div>
57 </div> 57 </div>
58 <div> 58 <div>
59 <%= radio_button 'profile_data', 'moderated_articles', 'false', :style => 'float: left' %> 59 <%= radio_button 'profile_data', 'moderated_articles', 'false', :style => 'float: left' %>
60 <div style='margin-left: 30px'> 60 <div style='margin-left: 30px'>
61 - <%= _('<strong>After</strong> being published in this group (a moderator can always remove publicated articles later).') %> 61 + <%= _('<strong>After</strong> being published in this group (a moderator can always remove publicated articles later).').html_safe %>
62 </div> 62 </div>
63 </div> 63 </div>
64 64
app/views/profile_editor/_organization.html.erb
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 4
5 <%= required f.text_field(:name) %> 5 <%= required f.text_field(:name) %>
6 6
7 - <%= @plugins.dispatch(:profile_info_extra_contents).collect { |content| instance_exec(&content) }.join("") %> 7 + <%= safe_join(@plugins.dispatch(:profile_info_extra_contents).collect { |content| instance_exec(&content) }, "") %>
8 8
9 <% if @environment.enabled?('enable_organization_url_change') %> 9 <% if @environment.enabled?('enable_organization_url_change') %>
10 <script type="text/javascript"> 10 <script type="text/javascript">
@@ -41,7 +41,7 @@ @@ -41,7 +41,7 @@
41 <div id="profile-identifier-formitem"> 41 <div id="profile-identifier-formitem">
42 <%= required labelled_form_field( _('Address'), 42 <%= required labelled_form_field( _('Address'),
43 content_tag('code', 43 content_tag('code',
44 - url_for(profile.url).gsub(/#{profile.identifier}$/, '') + 44 + url_for(profile.url).gsub(/#{profile.identifier}$/, '').html_safe +
45 text_field(:profile_data, :identifier, :onchange => "warn_value_change()", :size => 25) 45 text_field(:profile_data, :identifier, :onchange => "warn_value_change()", :size => 25)
46 ) + 46 ) +
47 content_tag('div', 47 content_tag('div',
app/views/profile_editor/_pending_tasks.html.erb
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 <div class='pending-tasks'> 4 <div class='pending-tasks'>
5 <h2><%= _('You have pending requests') %></h2> 5 <h2><%= _('You have pending requests') %></h2>
6 <ul> 6 <ul>
7 - <%= @pending_tasks.take(10).map {|task| content_tag('li', task_information(task))}.join %> 7 + <%= safe_join(@pending_tasks.map {|task| content_tag('li', task_information(task))}) %>
8 </ul> 8 </ul>
9 <%= button(:todo, _('Process requests'), :controller => 'tasks', :action => 'index') %> 9 <%= button(:todo, _('Process requests'), :controller => 'tasks', :action => 'index') %>
10 </div> 10 </div>
app/views/profile_editor/_person.html.erb
@@ -16,7 +16,7 @@ @@ -16,7 +16,7 @@
16 </div> 16 </div>
17 </div> 17 </div>
18 18
19 - <%= @plugins.dispatch(:profile_info_extra_contents).collect { |content| instance_exec(&content) }.join("") %> 19 + <%= safe_join(@plugins.dispatch(:profile_info_extra_contents).collect { |content| instance_exec(&content) }, "") %>
20 20
21 <div class="formfieldline"> 21 <div class="formfieldline">
22 <%= label_tag("private_token", _("Private Token")) %> 22 <%= label_tag("private_token", _("Private Token")) %>
app/views/profile_editor/edit.html.erb
@@ -26,20 +26,20 @@ @@ -26,20 +26,20 @@
26 26
27 <% if profile.person? %> 27 <% if profile.person? %>
28 <div> 28 <div>
29 - <%= labelled_radio_button _('Public &mdash; show my contents to all internet users'), 'profile_data[public_profile]', true, @profile.public_profile? %> 29 + <%= labelled_radio_button _('Public &mdash; show my contents to all internet users').html_safe, 'profile_data[public_profile]', true, @profile.public_profile? %>
30 </div> 30 </div>
31 <div> 31 <div>
32 - <%= labelled_radio_button _('Private &mdash; show my contents only to friends'), 'profile_data[public_profile]', false, !@profile.public_profile? %> 32 + <%= labelled_radio_button _('Private &mdash; show my contents only to friends').html_safe, 'profile_data[public_profile]', false, !@profile.public_profile? %>
33 </div> 33 </div>
34 <% else %> 34 <% else %>
35 <div> 35 <div>
36 - <%= labelled_check_box _("Secret &mdash; hide the community and all its contents for non members and other people can't join this community unless they are invited to."), 'profile_data[secret]', true, profile.secret, :class => "profile-secret-box" %> 36 + <%= labelled_check_box _("Secret &mdash; hide the community and all its contents for non members and other people can't join this community unless they are invited to.").html_safe, 'profile_data[secret]', true, profile.secret, :class => "profile-secret-box" %>
37 </div> 37 </div>
38 <div> 38 <div>
39 - <%= labelled_radio_button _('Public &mdash; show content of this group to all internet users'), 'profile_data[public_profile]', true, @profile.public_profile?, :class => "public-community-button" %> 39 + <%= labelled_radio_button _('Public &mdash; show content of this group to all internet users').html_safe, 'profile_data[public_profile]', true, @profile.public_profile?, :class => "public-community-button" %>
40 </div> 40 </div>
41 <div> 41 <div>
42 - <%= labelled_radio_button _('Private &mdash; show content of this group only to members'), 'profile_data[public_profile]', false, !@profile.public_profile?, :class => "private-community-button" %> 42 + <%= labelled_radio_button _('Private &mdash; show content of this group only to members').html_safe, 'profile_data[public_profile]', false, !@profile.public_profile?, :class => "private-community-button" %>
43 </div> 43 </div>
44 <% end %> 44 <% end %>
45 45
@@ -60,9 +60,9 @@ @@ -60,9 +60,9 @@
60 )%> 60 )%>
61 61
62 <%= 62 <%=
63 - @plugins.dispatch(:profile_editor_extras).map do |content| 63 + safe_join(@plugins.dispatch(:profile_editor_extras).map do |content|
64 content.kind_of?(Proc) ? self.instance_exec(&content) : content 64 content.kind_of?(Proc) ? self.instance_exec(&content) : content
65 - end.join("\n") 65 + end, "\n")
66 %> 66 %>
67 67
68 <%= select_categories(:profile_data, _('Select the categories of your interest'), 2) %> 68 <%= select_categories(:profile_data, _('Select the categories of your interest'), 2) %>
app/views/profile_members/_members_filter.erb
@@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
7 7
8 <p><%= _('Roles:') %> </p> 8 <p><%= _('Roles:') %> </p>
9 <% @data[:roles].each do |r| %> 9 <% @data[:roles].each do |r| %>
10 - <%= labelled_check_box(r.name, 'filters[roles][]', r.id, @filters[:roles].include?(r.id.to_s), :add_hidden => false) %><br/> 10 + <%= raw labelled_check_box(r.name, 'filters[roles][]', r.id, @filters[:roles].include?(r.id.to_s), :add_hidden => false) %><br/>
11 <% end %> 11 <% end %>
12 <p> 12 <p>
13 <%= submit_button(:search, _('Search')) %> 13 <%= submit_button(:search, _('Search')) %>
app/views/profile_roles/_form.html.erb
@@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
9 <% permissions.each do |key| %> 9 <% permissions.each do |key| %>
10 <div class="permissions <%= key.downcase %>"> 10 <div class="permissions <%= key.downcase %>">
11 <h4><%= _('%s Permissions:' % key) %></h4> 11 <h4><%= _('%s Permissions:' % key) %></h4>
12 - <% ActiveRecord::Base::PERMISSIONS[key].keys.each do |p| %> 12 + <% ApplicationRecord::PERMISSIONS[key].keys.each do |p| %>
13 <%= check_box_tag("role[permissions][]", p, role.has_permission?(p), { :id => p }) %> 13 <%= check_box_tag("role[permissions][]", p, role.has_permission?(p), { :id => p }) %>
14 <%= content_tag(:label, permission_name(p), { :for => p }) %><br/> 14 <%= content_tag(:label, permission_name(p), { :for => p }) %><br/>
15 <% end %> 15 <% end %>
app/views/role/_form.html.erb
@@ -9,7 +9,7 @@ @@ -9,7 +9,7 @@
9 <% permissions.each do |key| %> 9 <% permissions.each do |key| %>
10 <div class="permissions <%= key.downcase %>"> 10 <div class="permissions <%= key.downcase %>">
11 <h4><%= _('%s Permissions:' % key) %></h4> 11 <h4><%= _('%s Permissions:' % key) %></h4>
12 - <% ActiveRecord::Base::PERMISSIONS[key].keys.each do |p| %> 12 + <% ApplicationRecord::PERMISSIONS[key].keys.each do |p| %>
13 <%= check_box_tag("role[permissions][]", p, role.has_permission?(p), { :id => p }) %> 13 <%= check_box_tag("role[permissions][]", p, role.has_permission?(p), { :id => p }) %>
14 <%= content_tag(:label, permission_name(p), { :for => p }) %><br/> 14 <%= content_tag(:label, permission_name(p), { :for => p }) %><br/>
15 <% end %> 15 <% end %>
app/views/search/_article_last_change.html.erb
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 2
3 <div class="search-article-author-changes"> 3 <div class="search-article-author-changes">
4 <% if article.last_changed_by and article.last_changed_by != article.profile %> 4 <% if article.last_changed_by and article.last_changed_by != article.profile %>
5 - <span><%= _('Updated by %{name} at %{date}') % {:name => link_to(article.last_changed_by.name, article.last_changed_by.url), 5 + <span><%= _('Updated by %{name} at %{date}').html_safe % {:name => link_to(article.last_changed_by.name, article.last_changed_by.url),
6 :date => show_date(article.updated_at) } %></span> 6 :date => show_date(article.updated_at) } %></span>
7 <% else %> 7 <% else %>
8 <span><%= _('Last update: %s.') % show_date(article.updated_at) %></span> 8 <span><%= _('Last update: %s.') % show_date(article.updated_at) %></span>
app/views/search/_full_product.html.erb
1 <% extra_content = @plugins.dispatch(:asset_product_extras, product).collect { |content| instance_exec(&content) } %> 1 <% extra_content = @plugins.dispatch(:asset_product_extras, product).collect { |content| instance_exec(&content) } %>
2 -<% extra_properties = @plugins.dispatch(:asset_product_properties, product)%> 2 +<% extra_properties = @plugins.dispatch(:asset_product_properties, product) %>
3 3
4 <li class="search-product-item <%= 'highlighted' if product.highlighted? %>"> 4 <li class="search-product-item <%= 'highlighted' if product.highlighted? %>">
5 5
@@ -77,9 +77,9 @@ @@ -77,9 +77,9 @@
77 77
78 <div style="clear: both"></div> 78 <div style="clear: both"></div>
79 79
80 - <%= extra_content.join('\n') %> 80 + <%= safe_join(extra_content, '\n') %>
81 <% extra_properties.each do |property| %> 81 <% extra_properties.each do |property| %>
82 - <div><%= property[:name] + ': ' + instance_exec(&property[:content]) %></div> 82 + <div><%= ''.html_safe + property[:name] + ': ' + instance_exec(&property[:content]) %></div>
83 <% end %> 83 <% end %>
84 84
85 </li> 85 </li>
app/views/search/tag.html.erb
1 <h2> 1 <h2>
2 - <%= _('Tagged with "%s"') % content_tag('code', @tag) %> 2 + <%= _('Tagged with "%s"').html_safe % content_tag('code', @tag) %>
3 </h2> 3 </h2>
4 4
5 <% button_bar do %> 5 <% button_bar do %>
app/views/shared/_list_groups.html.erb
@@ -6,9 +6,9 @@ @@ -6,9 +6,9 @@
6 </div> 6 </div>
7 <span class='profile-details'> 7 <span class='profile-details'>
8 <strong><%= group.name %></strong><br/> 8 <strong><%= group.name %></strong><br/>
9 - <%= _('Role: %s') % rolename_for(profile, group) + '<br/>' if profile.role_assignments.find_by(resource_id: group.id) %> 9 + <%= raw _('Role: %s') % rolename_for(profile, group) + '<br/>' if profile.role_assignments.find_by(resource_id: group.id) %>
10 <%= _('Type: %s') % _(group.class.identification) %> <br/> 10 <%= _('Type: %s') % _(group.class.identification) %> <br/>
11 - <%= _('Description: %s') % group.description + '<br/>' if group.community? %> 11 + <%= raw _('Description: %s') % group.description + '<br/>' if group.community? %>
12 <%= _('Members: %s') % group.members_count.to_s %> <br/> 12 <%= _('Members: %s') % group.members_count.to_s %> <br/>
13 <%= _('Created at: %s') % show_date(group.created_at) unless group.enterprise? %> <br/> 13 <%= _('Created at: %s') % show_date(group.created_at) unless group.enterprise? %> <br/>
14 <% button_bar do %> 14 <% button_bar do %>
app/views/tasks/_add_member_accept_details.html.erb
1 <%= content = _("Roles:")+"<br />" 1 <%= content = _("Roles:")+"<br />"
2 roles = Profile::Roles.organization_member_roles(task.target.environment.id) + profile.custom_roles 2 roles = Profile::Roles.organization_member_roles(task.target.environment.id) + profile.custom_roles
3 roles.each do |role| 3 roles.each do |role|
4 - content += labelled_check_box(role.name, "tasks[#{task.id}][task][roles][]", role.id, false)+"<br />" 4 + content += labelled_check_box(role.name, "tasks[#{task.id}][task][roles][]", role.id, false) + "<br />".html_safe
5 end 5 end
6 -content_tag('p', content, :class => 'member-classify-suggestion') 6 +content_tag('p', content.html_safe, :class => 'member-classify-suggestion').html_safe
7 %> 7 %>
app/views/tasks/_task_icon.html.erb
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 if icon_info[:type] == :profile_image 3 if icon_info[:type] == :profile_image
4 icon = profile_image(icon_info[:profile], :minor) 4 icon = profile_image(icon_info[:profile], :minor)
5 elsif icon_info[:type] == :defined_image 5 elsif icon_info[:type] == :defined_image
6 - icon = "<img src='#{icon_info[:src]}' alt='#{icon_info[:name]}' />" 6 + icon = "<img src='#{icon_info[:src]}' alt='#{icon_info[:name]}' />".html_safe
7 end 7 end
8 8
9 if icon_info[:url] 9 if icon_info[:url]
app/views/tasks/list_requested.html.erb
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 <ul> 3 <ul>
4 <% @tasks.each do |task| %> 4 <% @tasks.each do |task| %>
5 <li> 5 <li>
6 - <strong><%= task.respond_to?(:title) ? link_to( task.title, :action => 'ticket_details', :id => task.id) : task.information %></strong><br/> 6 + <strong><%= task.respond_to?(:title) ? link_to( task.title, :action => 'ticket_details', :id => task.id).html_safe : task.information %></strong><br/>
7 <small> 7 <small>
8 <%= _('Created:') + ' ' + show_date(task.created_at) %> 8 <%= _('Created:') + ' ' + show_date(task.created_at) %>
9 &nbsp; &#151; &nbsp; 9 &nbsp; &#151; &nbsp;
app/views/tasks/processed.html.erb
@@ -6,23 +6,25 @@ @@ -6,23 +6,25 @@
6 <div class="task-processed-filter"> 6 <div class="task-processed-filter">
7 <% 7 <%
8 type_collection = [[nil, _('All')]] + @task_types 8 type_collection = [[nil, _('All')]] + @task_types
  9 + type_collection.map!{|first,last| [last,first]}
9 %> 10 %>
10 <%= form_tag '#', :method => 'get' do %> 11 <%= form_tag '#', :method => 'get' do %>
11 <%= field_set_tag _('Filter'), :class => 'filter_fields' do %> 12 <%= field_set_tag _('Filter'), :class => 'filter_fields' do %>
12 <div> 13 <div>
13 - <%= labelled_select(_('Type of task')+': ', 'filter[type]', :first, :last, @filter[:type], type_collection, {:id => 'filter-type'}) %>  
14 - <%= labelled_select(_('Status:'), 'filter[status]', :last, :first, @filter[:status], [[_('Any'), nil], [_(Task::Status.names[Task::Status::CANCELLED]), 2], [_(Task::Status.names[Task::Status::FINISHED]), 3] ]) %> 14 + <%= labelled_form_field(_('Type of task')+': ', select_tag('filter[type]', options_for_select(type_collection, @filter[:type]), {:id => 'filter-type'})) %>
  15 + <%= labelled_form_field(_('Status')+': ', select_tag('filter[status]', options_for_select([[_('Any'), nil], [_(Task::Status.names[Task::Status::CANCELLED]), 2], [_(Task::Status.names[Task::Status::FINISHED]), 3] ], @filter[:status]))) %>
15 </div> 16 </div>
16 17
17 <div> 18 <div>
18 - <%= labelled_text_field(_('Text Filter:'), 'filter[text]', @filter[:text]) %> 19 + <%= labelled_form_field(_('Text Filter:'), text_field_tag('filter[text]', @filter[:text])) %>
19 </div> 20 </div>
20 21
21 <div> 22 <div>
22 - <%= labelled_text_field(_('Requestor:'), 'filter[requestor]', @filter[:requestor]) %>  
23 - <%= labelled_text_field(_('Closed by:'), 'filter[closed_by]', @filter[:closed_by]) %> 23 + <%= labelled_form_field(_('Requestor:'), text_field_tag('filter[requestor]', @filter[:requestor])) %>
  24 + <%= labelled_form_field(_('Closed by:'), text_field_tag('filter[closed_by]', @filter[:closed_by])) %>
24 </div> 25 </div>
25 - 26 + <%= labelled_form_field(_('Creation date'), date_range_field('filter[created_from]', 'filter[created_until]', @filter[:created_from], @filter[:created_until], { :change_month => true, :change_year => true, :date_format => 'yy-mm-dd' }, { :size => 14, :from_id => 'filter_created_from', :to_id => 'filter_created_until' })) %>
  27 + <%= labelled_form_field(_('Processed date'), date_range_field('filter[closed_from]', 'filter[closed_until]', @filter[:closed_from], @filter[:closed_until], { :change_month => true, :change_year => true, :date_format => 'yy-mm-dd' }, { :size => 14, :from_id => 'filter_closed_from', :to_id => 'filter_closed_until' })) %>
26 28
27 <div class="actions"> 29 <div class="actions">
28 <%= submit_button(:search, _('Search')) %> 30 <%= submit_button(:search, _('Search')) %>
@@ -28,22 +28,22 @@ test: @@ -28,22 +28,22 @@ test:
28 bundle exec rake test:api 28 bundle exec rake test:api
29 bundle exec rake test:functionals 29 bundle exec rake test:functionals
30 SLICE=1/4 bundle exec rake selenium 30 SLICE=1/4 bundle exec rake selenium
31 - SLICE=1/4 BUNDLE_OPTS=install bundle exec rake test:noosfero_plugins 31 + SLICE=1/4 NOOSFERO_BUNDLE_OPTS=install bundle exec rake test:noosfero_plugins
32 ;; 32 ;;
33 1) 33 1)
34 bundle exec rake test:integration 34 bundle exec rake test:integration
35 SLICE=2/4 bundle exec rake selenium 35 SLICE=2/4 bundle exec rake selenium
36 - SLICE=2/4 BUNDLE_OPTS=install bundle exec rake test:noosfero_plugins 36 + SLICE=2/4 NOOSFERO_BUNDLE_OPTS=install bundle exec rake test:noosfero_plugins
37 ;; 37 ;;
38 2) 38 2)
39 bundle exec rake test:units 39 bundle exec rake test:units
40 SLICE=3/4 bundle exec rake selenium 40 SLICE=3/4 bundle exec rake selenium
41 - SLICE=3/4 BUNDLE_OPTS=install bundle exec rake test:noosfero_plugins 41 + SLICE=3/4 NOOSFERO_BUNDLE_OPTS=install bundle exec rake test:noosfero_plugins
42 ;; 42 ;;
43 3) 43 3)
44 bundle exec rake cucumber 44 bundle exec rake cucumber
45 SLICE=4/4 bundle exec rake selenium 45 SLICE=4/4 bundle exec rake selenium
46 - SLICE=4/4 BUNDLE_OPTS=install bundle exec rake test:noosfero_plugins 46 + SLICE=4/4 NOOSFERO_BUNDLE_OPTS=install bundle exec rake test:noosfero_plugins
47 ;; 47 ;;
48 esac 48 esac
49 : 49 :
config/initializers/active_record_extensions.rb
@@ -14,4 +14,5 @@ module ActiveRecordExtension @@ -14,4 +14,5 @@ module ActiveRecordExtension
14 end 14 end
15 end 15 end
16 end 16 end
17 -ActiveRecord::Base.send(:include, ActiveRecordExtension) 17 +
  18 +ApplicationRecord.send :include, ActiveRecordExtension
config/initializers/html_safe.rb
@@ -1,10 +0,0 @@ @@ -1,10 +0,0 @@
1 -#From: https://github.com/coletivoEITA/noosfero-ecosol/blob/57908cde4fe65dfe22298a8a7f6db5dba1e7cc75/config/initializers/html_safe.rb  
2 -  
3 -# Disable Rails html autoescaping. This is due to noosfero using too much helpers/models to output html.  
4 -# It it would change too much code and make it hard to maintain.  
5 -# FIXME THIS IS SO WRONG  
6 -class Object  
7 - def html_safe?  
8 - true  
9 - end  
10 -end  
db/migrate/033_destroy_organization_and_person_infos.rb
1 class DestroyOrganizationAndPersonInfos < ActiveRecord::Migration 1 class DestroyOrganizationAndPersonInfos < ActiveRecord::Migration
2 def self.up 2 def self.up
3 Person.find_each do |i| 3 Person.find_each do |i|
4 - info = ActiveRecord::Base.connection.select_one("select * from person_infos where person_id = #{i.id}") 4 + info = ApplicationRecord.connection.select_one("select * from person_infos where person_id = #{i.id}")
5 i.name = info["name"] unless info["name"].nil? 5 i.name = info["name"] unless info["name"].nil?
6 i.address = info["address"] unless info["address"].nil? 6 i.address = info["address"] unless info["address"].nil?
7 [ "photo", "contact_information", "birth_date", "sex", "city", "state", "country" ].each do |field| 7 [ "photo", "contact_information", "birth_date", "sex", "city", "state", "country" ].each do |field|
@@ -12,7 +12,7 @@ class DestroyOrganizationAndPersonInfos &lt; ActiveRecord::Migration @@ -12,7 +12,7 @@ class DestroyOrganizationAndPersonInfos &lt; ActiveRecord::Migration
12 drop_table :person_infos 12 drop_table :person_infos
13 13
14 Organization.find_each do |i| 14 Organization.find_each do |i|
15 - info = ActiveRecord::Base.connection.select_one("select * from organization_infos where organization_id = #{i.id}") 15 + info = ApplicationRecord.connection.select_one("select * from organization_infos where organization_id = #{i.id}")
16 [ "contact_person", "contact_email", "acronym", "foundation_year", "legal_form", "economic_activity", "management_information", "validated" ].each do |field| 16 [ "contact_person", "contact_email", "acronym", "foundation_year", "legal_form", "economic_activity", "management_information", "validated" ].each do |field|
17 i.send("#{field}=", info[field]) 17 i.send("#{field}=", info[field])
18 end 18 end
db/migrate/059_add_birth_date_to_person.rb
@@ -29,7 +29,7 @@ class AddBirthDateToPerson &lt; ActiveRecord::Migration @@ -29,7 +29,7 @@ class AddBirthDateToPerson &lt; ActiveRecord::Migration
29 end 29 end
30 end 30 end
31 31
32 - class Person < ActiveRecord::Base 32 + class Person < ApplicationRecord
33 self.table_name = 'profiles' 33 self.table_name = 'profiles'
34 serialize :data, Hash 34 serialize :data, Hash
35 end 35 end
db/migrate/069_add_enviroment_id_to_role.rb
1 -class Role < ActiveRecord::Base; end  
2 -class RoleWithEnvironment < ActiveRecord::Base 1 +class Role < ApplicationRecord
  2 +class RoleWithEnvironment < ApplicationRecord
3 self.table_name = 'roles' 3 self.table_name = 'roles'
4 belongs_to :environment 4 belongs_to :environment
5 end 5 end
6 -class RoleAssignment < ActiveRecord::Base 6 +class RoleAssignment < ApplicationRecord
7 belongs_to :accessor, :polymorphic => true 7 belongs_to :accessor, :polymorphic => true
8 belongs_to :resource, :polymorphic => true 8 belongs_to :resource, :polymorphic => true
9 end 9 end
db/migrate/074_move_title_to_name_from_blogs.rb
@@ -2,7 +2,7 @@ class MoveTitleToNameFromBlogs &lt; ActiveRecord::Migration @@ -2,7 +2,7 @@ class MoveTitleToNameFromBlogs &lt; ActiveRecord::Migration
2 def self.up 2 def self.up
3 select_all("select id, setting from articles where type = 'Blog' and name != 'Blog'").each do |blog| 3 select_all("select id, setting from articles where type = 'Blog' and name != 'Blog'").each do |blog|
4 title = YAML.load(blog['setting'])[:title] 4 title = YAML.load(blog['setting'])[:title]
5 - assignments = ActiveRecord::Base.sanitize_sql_for_assignment(:name => title) 5 + assignments = ApplicationRecord.sanitize_sql_for_assignment(:name => title)
6 update("update articles set %s where id = %d" % [assignments, blog['id']] ) 6 update("update articles set %s where id = %d" % [assignments, blog['id']] )
7 end 7 end
8 end 8 end
db/migrate/20100921121528_add_is_image_to_articles.rb
@@ -3,7 +3,7 @@ class AddIsImageToArticles &lt; ActiveRecord::Migration @@ -3,7 +3,7 @@ class AddIsImageToArticles &lt; ActiveRecord::Migration
3 add_column :articles, :is_image, :boolean, :default => false 3 add_column :articles, :is_image, :boolean, :default => false
4 add_column :article_versions, :is_image, :boolean, :default => false 4 add_column :article_versions, :is_image, :boolean, :default => false
5 5
6 - execute ActiveRecord::Base.sanitize_sql(["update articles set is_image = ? where articles.content_type like 'image/%'", true]) 6 + execute ApplicationRecord.sanitize_sql(["update articles set is_image = ? where articles.content_type like 'image/%'", true])
7 end 7 end
8 8
9 def self.down 9 def self.down
db/migrate/20101129234429_convert_folders_to_galleries.rb
@@ -10,7 +10,7 @@ class ConvertFoldersToGalleries &lt; ActiveRecord::Migration @@ -10,7 +10,7 @@ class ConvertFoldersToGalleries &lt; ActiveRecord::Migration
10 select_all("select id, setting from articles where type = 'Gallery'").each do |folder| 10 select_all("select id, setting from articles where type = 'Gallery'").each do |folder|
11 settings = YAML.load(folder['setting'] || {}.to_yaml) 11 settings = YAML.load(folder['setting'] || {}.to_yaml)
12 settings[:view_as] = 'image_gallery' 12 settings[:view_as] = 'image_gallery'
13 - assignments = ActiveRecord::Base.sanitize_sql_for_assignment(:setting => settings.to_yaml) 13 + assignments = ApplicationRecord.sanitize_sql_for_assignment(:setting => settings.to_yaml)
14 update("update articles set %s, type = 'Folder' where id = %d" % [assignments, folder['id']]) 14 update("update articles set %s, type = 'Folder' where id = %d" % [assignments, folder['id']])
15 end 15 end
16 end 16 end
db/migrate/20101202205446_remove_published_articles.rb
@@ -3,7 +3,7 @@ class RemovePublishedArticles &lt; ActiveRecord::Migration @@ -3,7 +3,7 @@ class RemovePublishedArticles &lt; ActiveRecord::Migration
3 select_all("SELECT * from articles WHERE type = 'PublishedArticle'").each do |published| 3 select_all("SELECT * from articles WHERE type = 'PublishedArticle'").each do |published|
4 reference = select_one('select * from articles where id = %d' % published['reference_article_id']) 4 reference = select_one('select * from articles where id = %d' % published['reference_article_id'])
5 if reference 5 if reference
6 - execute(ActiveRecord::Base.sanitize_sql(["UPDATE articles SET type = ?, abstract = ?, body = ? WHERE articles.id = ?", reference['type'], reference['abstract'], reference['body'], published['id']])) 6 + execute(ApplicationRecord.sanitize_sql(["UPDATE articles SET type = ?, abstract = ?, body = ? WHERE articles.id = ?", reference['type'], reference['abstract'], reference['body'], published['id']]))
7 else 7 else
8 execute("DELETE from articles where articles.id = #{published['id']}") 8 execute("DELETE from articles where articles.id = #{published['id']}")
9 end 9 end
db/migrate/20101205034144_add_language_and_translation_of_id_to_article.rb
@@ -11,7 +11,7 @@ class AddLanguageAndTranslationOfIdToArticle &lt; ActiveRecord::Migration @@ -11,7 +11,7 @@ class AddLanguageAndTranslationOfIdToArticle &lt; ActiveRecord::Migration
11 select_all("select id, setting from articles where type = 'Blog'").each do |blog| 11 select_all("select id, setting from articles where type = 'Blog'").each do |blog|
12 settings = YAML.load(blog['setting'] || {}.to_yaml) 12 settings = YAML.load(blog['setting'] || {}.to_yaml)
13 settings[:display_posts_in_current_language] = true 13 settings[:display_posts_in_current_language] = true
14 - assignments = ActiveRecord::Base.sanitize_sql_for_assignment(:setting => settings.to_yaml) 14 + assignments = ApplicationRecord.sanitize_sql_for_assignment(:setting => settings.to_yaml)
15 update("update articles set %s where id = %d" % [assignments, blog['id']]) 15 update("update articles set %s where id = %d" % [assignments, blog['id']])
16 end 16 end
17 17
db/migrate/20110203160153_rename_images_path_on_tracked_actions.rb
@@ -15,7 +15,7 @@ class RenameImagesPathOnTrackedActions &lt; ActiveRecord::Migration @@ -15,7 +15,7 @@ class RenameImagesPathOnTrackedActions &lt; ActiveRecord::Migration
15 end 15 end
16 params[param_name] = paths 16 params[param_name] = paths
17 17
18 - execute(ActiveRecord::Base.sanitize_sql(["UPDATE action_tracker SET params = ? WHERE id = ?", params.to_yaml, tracker['id']])) 18 + execute(ApplicationRecord.sanitize_sql(["UPDATE action_tracker SET params = ? WHERE id = ?", params.to_yaml, tracker['id']]))
19 end 19 end
20 end 20 end
21 21
db/migrate/20110215153624_move_data_serialized_hash_to_setting_field_for_articles.rb
@@ -12,9 +12,9 @@ class MoveDataSerializedHashToSettingFieldForArticles &lt; ActiveRecord::Migration @@ -12,9 +12,9 @@ class MoveDataSerializedHashToSettingFieldForArticles &lt; ActiveRecord::Migration
12 end 12 end
13 if body.kind_of?(Hash) 13 if body.kind_of?(Hash)
14 settings = article.setting.merge(body) 14 settings = article.setting.merge(body)
15 - body = ActiveRecord::Base.sanitize_sql_for_assignment(:body => settings[:description]) 15 + body = ApplicationRecord.sanitize_sql_for_assignment(:body => settings[:description])
16 update("UPDATE articles set %s WHERE id = %d" % [body, article.id]) 16 update("UPDATE articles set %s WHERE id = %d" % [body, article.id])
17 - setting = ActiveRecord::Base.sanitize_sql_for_assignment(:setting => settings.to_yaml) 17 + setting = ApplicationRecord.sanitize_sql_for_assignment(:setting => settings.to_yaml)
18 update("UPDATE articles set %s WHERE id = %d" % [setting, article.id]) 18 update("UPDATE articles set %s WHERE id = %d" % [setting, article.id])
19 end 19 end
20 end 20 end
db/migrate/20110302214607_move_data_serialized_hash_to_setting_field_for_events.rb
@@ -11,9 +11,9 @@ class MoveDataSerializedHashToSettingFieldForEvents &lt; ActiveRecord::Migration @@ -11,9 +11,9 @@ class MoveDataSerializedHashToSettingFieldForEvents &lt; ActiveRecord::Migration
11 end 11 end
12 if body.kind_of?(Hash) 12 if body.kind_of?(Hash)
13 settings = article.setting.merge(body) 13 settings = article.setting.merge(body)
14 - body = ActiveRecord::Base.sanitize_sql_for_assignment(:body => settings[:description]) 14 + body = ApplicationRecord.sanitize_sql_for_assignment(:body => settings[:description])
15 update("UPDATE articles set %s WHERE id = %d" % [body, article.id]) 15 update("UPDATE articles set %s WHERE id = %d" % [body, article.id])
16 - setting = ActiveRecord::Base.sanitize_sql_for_assignment(:setting => settings.to_yaml) 16 + setting = ApplicationRecord.sanitize_sql_for_assignment(:setting => settings.to_yaml)
17 update("UPDATE articles set %s WHERE id = %d" % [setting, article.id]) 17 update("UPDATE articles set %s WHERE id = %d" % [setting, article.id])
18 end 18 end
19 end 19 end
db/migrate/20110706171330_fix_misunderstood_script_filename.rb
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 # from the migration fall on a loop and breaks the migration. Both them are 2 # from the migration fall on a loop and breaks the migration. Both them are
3 # related to alias_method_chain, probably there is a problem with this kind of 3 # related to alias_method_chain, probably there is a problem with this kind of
4 # alias on the migration level. 4 # alias on the migration level.
5 -class Article < ActiveRecord::Base 5 +class Article < ApplicationRecord
6 def sanitize_tag_list 6 def sanitize_tag_list
7 end 7 end
8 end 8 end
db/migrate/20110824192153_add_activated_at_to_users.rb
@@ -2,7 +2,7 @@ class AddActivatedAtToUsers &lt; ActiveRecord::Migration @@ -2,7 +2,7 @@ class AddActivatedAtToUsers &lt; ActiveRecord::Migration
2 def self.up 2 def self.up
3 add_column :users, :activation_code, :string, :limit => 40 3 add_column :users, :activation_code, :string, :limit => 40
4 add_column :users, :activated_at, :datetime 4 add_column :users, :activated_at, :datetime
5 - if ActiveRecord::Base.connection.adapter_name == 'SQLite' 5 + if ApplicationRecord.connection.adapter_name == 'SQLite'
6 execute "update users set activated_at = datetime();" 6 execute "update users set activated_at = datetime();"
7 else 7 else
8 execute "update users set activated_at = now();" 8 execute "update users set activated_at = now();"
db/migrate/20140724134601_fix_yaml_encoding.rb
1 class FixYamlEncoding < ActiveRecord::Migration 1 class FixYamlEncoding < ActiveRecord::Migration
2 def self.up 2 def self.up
3 - ActiveRecord::Base.transaction do 3 + ApplicationRecord.transaction do
4 fix_encoding(Environment, 'settings') 4 fix_encoding(Environment, 'settings')
5 fix_encoding(Profile, 'data') 5 fix_encoding(Profile, 'data')
6 fix_encoding(Product, 'data') 6 fix_encoding(Product, 'data')
db/migrate/20150216213259_create_profile_activity.rb
1 class CreateProfileActivity < ActiveRecord::Migration 1 class CreateProfileActivity < ActiveRecord::Migration
2 def up 2 def up
3 - ActiveRecord::Base.transaction do 3 + ApplicationRecord.transaction do
4 create_table :profile_activities do |t| 4 create_table :profile_activities do |t|
5 t.integer :profile_id 5 t.integer :profile_id
6 t.integer :activity_id 6 t.integer :activity_id
lib/activities_counter_cache_job.rb
1 class ActivitiesCounterCacheJob 1 class ActivitiesCounterCacheJob
2 2
3 def perform 3 def perform
4 - person_activities_counts = ActiveRecord::Base.connection.execute("SELECT profiles.id, count(action_tracker.id) as count FROM profiles LEFT OUTER JOIN action_tracker ON profiles.id = action_tracker.user_id WHERE (action_tracker.created_at >= #{ActiveRecord::Base.connection.quote(ActionTracker::Record::RECENT_DELAY.days.ago.to_s(:db))}) AND ( (profiles.type = 'Person' ) ) GROUP BY profiles.id;")  
5 - organization_activities_counts = ActiveRecord::Base.connection.execute("SELECT profiles.id, count(action_tracker.id) as count FROM profiles LEFT OUTER JOIN action_tracker ON profiles.id = action_tracker.target_id WHERE (action_tracker.created_at >= #{ActiveRecord::Base.connection.quote(ActionTracker::Record::RECENT_DELAY.days.ago.to_s(:db))}) AND ( (profiles.type = 'Community' OR profiles.type = 'Enterprise' OR profiles.type = 'Organization' ) ) GROUP BY profiles.id;") 4 + person_activities_counts = ApplicationRecord.connection.execute("SELECT profiles.id, count(action_tracker.id) as count FROM profiles LEFT OUTER JOIN action_tracker ON profiles.id = action_tracker.user_id WHERE (action_tracker.created_at >= #{ApplicationRecord.connection.quote(ActionTracker::Record::RECENT_DELAY.days.ago.to_s(:db))}) AND ( (profiles.type = 'Person' ) ) GROUP BY profiles.id;")
  5 + organization_activities_counts = ApplicationRecord.connection.execute("SELECT profiles.id, count(action_tracker.id) as count FROM profiles LEFT OUTER JOIN action_tracker ON profiles.id = action_tracker.target_id WHERE (action_tracker.created_at >= #{ApplicationRecord.connection.quote(ActionTracker::Record::RECENT_DELAY.days.ago.to_s(:db))}) AND ( (profiles.type = 'Community' OR profiles.type = 'Enterprise' OR profiles.type = 'Organization' ) ) GROUP BY profiles.id;")
6 activities_counts = person_activities_counts.entries + organization_activities_counts.entries 6 activities_counts = person_activities_counts.entries + organization_activities_counts.entries
7 activities_counts.each do |count| 7 activities_counts.each do |count|
8 - update_sql = ActiveRecord::Base.__send__(:sanitize_sql, ["UPDATE profiles SET activities_count=? WHERE profiles.id=?;", count['count'].to_i, count['id'] ], '')  
9 - ActiveRecord::Base.connection.execute(update_sql) 8 + update_sql = ApplicationRecord.__send__(:sanitize_sql, ["UPDATE profiles SET activities_count=? WHERE profiles.id=?;", count['count'].to_i, count['id'] ], '')
  9 + ApplicationRecord.connection.execute(update_sql)
10 end 10 end
11 Delayed::Job.enqueue(ActivitiesCounterCacheJob.new, {:priority => -3, :run_at => 1.day.from_now}) 11 Delayed::Job.enqueue(ActivitiesCounterCacheJob.new, {:priority => -3, :run_at => 1.day.from_now})
12 end 12 end
lib/acts_as_customizable.rb
@@ -122,4 +122,4 @@ module Customizable @@ -122,4 +122,4 @@ module Customizable
122 end 122 end
123 end 123 end
124 124
125 -ActiveRecord::Base.send(:include, Customizable) 125 +ApplicationRecord.send :include, Customizable
lib/acts_as_filesystem.rb
@@ -33,7 +33,7 @@ module ActsAsFileSystem @@ -33,7 +33,7 @@ module ActsAsFileSystem
33 module ClassMethods 33 module ClassMethods
34 34
35 def build_ancestry(parent_id = nil, ancestry = '') 35 def build_ancestry(parent_id = nil, ancestry = '')
36 - ActiveRecord::Base.transaction do 36 + ApplicationRecord.transaction do
37 self.base_class.where(parent_id: parent_id).each do |node| 37 self.base_class.where(parent_id: parent_id).each do |node|
38 node.update_column :ancestry, ancestry 38 node.update_column :ancestry, ancestry
39 39
@@ -263,5 +263,5 @@ module ActsAsFileSystem @@ -263,5 +263,5 @@ module ActsAsFileSystem
263 end 263 end
264 end 264 end
265 265
266 -ActiveRecord::Base.extend ActsAsFileSystem::ActsMethods 266 +ApplicationRecord.extend ActsAsFileSystem::ActsMethods
267 267
lib/acts_as_having_boxes.rb
@@ -35,4 +35,4 @@ module ActsAsHavingBoxes @@ -35,4 +35,4 @@ module ActsAsHavingBoxes
35 35
36 end 36 end
37 37
38 -ActiveRecord::Base.extend(ActsAsHavingBoxes::ClassMethods) 38 +ApplicationRecord.extend ActsAsHavingBoxes::ClassMethods
lib/acts_as_having_image.rb
@@ -23,4 +23,5 @@ module ActsAsHavingImage @@ -23,4 +23,5 @@ module ActsAsHavingImage
23 23
24 end 24 end
25 25
26 -ActiveRecord::Base.extend(ActsAsHavingImage::ClassMethods) 26 +ApplicationRecord.extend ActsAsHavingImage::ClassMethods
  27 +
lib/acts_as_having_posts.rb
@@ -47,4 +47,5 @@ module ActsAsHavingPosts @@ -47,4 +47,5 @@ module ActsAsHavingPosts
47 47
48 end 48 end
49 49
50 -ActiveRecord::Base.extend(ActsAsHavingPosts::ClassMethods) 50 +ApplicationRecord.extend ActsAsHavingPosts::ClassMethods
  51 +
lib/acts_as_having_settings.rb
@@ -87,4 +87,5 @@ module ActsAsHavingSettings @@ -87,4 +87,5 @@ module ActsAsHavingSettings
87 87
88 end 88 end
89 89
90 -ActiveRecord::Base.send(:extend, ActsAsHavingSettings::ClassMethods) 90 +ApplicationRecord.extend ActsAsHavingSettings::ClassMethods
  91 +
lib/code_numbering.rb
@@ -55,4 +55,4 @@ module CodeNumbering @@ -55,4 +55,4 @@ module CodeNumbering
55 end 55 end
56 end 56 end
57 57
58 -ActiveRecord::Base.extend CodeNumbering::ClassMethods 58 +ApplicationRecord.extend CodeNumbering::ClassMethods
lib/delayed_attachment_fu.rb
@@ -52,4 +52,5 @@ module DelayedAttachmentFu @@ -52,4 +52,5 @@ module DelayedAttachmentFu
52 end 52 end
53 end 53 end
54 54
55 -ActiveRecord::Base.send(:extend, DelayedAttachmentFu::ClassMethods) 55 +ApplicationRecord.extend DelayedAttachmentFu::ClassMethods
  56 +
lib/noosfero/core_ext.rb
1 require 'noosfero/core_ext/string' 1 require 'noosfero/core_ext/string'
2 require 'noosfero/core_ext/integer' 2 require 'noosfero/core_ext/integer'
3 -require 'noosfero/core_ext/active_record' 3 +require 'noosfero/core_ext/active_record/calculations'
4 require 'noosfero/core_ext/active_record/reflection' 4 require 'noosfero/core_ext/active_record/reflection'
5 5
lib/noosfero/core_ext/active_record.rb
@@ -1,74 +0,0 @@ @@ -1,74 +0,0 @@
1 -require 'active_record'  
2 -  
3 -class ActiveRecord::Base  
4 -  
5 - def self.postgresql?  
6 - ActiveRecord::Base.connection.adapter_name == 'PostgreSQL'  
7 - end  
8 -  
9 - # an ActionView instance for rendering views on models  
10 - def self.action_view  
11 - @action_view ||= begin  
12 - view_paths = ::ActionController::Base.view_paths  
13 - action_view = ::ActionView::Base.new view_paths  
14 - # for using Noosfero helpers inside render calls  
15 - action_view.extend ::ApplicationHelper  
16 - action_view  
17 - end  
18 - end  
19 -  
20 - # default value needed for the above ActionView  
21 - def to_partial_path  
22 - self.class.name.underscore  
23 - end  
24 -  
25 - alias :meta_cache_key :cache_key  
26 - def cache_key  
27 - key = [Noosfero::VERSION, meta_cache_key]  
28 - key.unshift(ActiveRecord::Base.connection.schema_search_path) if ActiveRecord::Base.postgresql?  
29 - key.join('/')  
30 - end  
31 -  
32 - def self.like_search(query, options={})  
33 - if defined?(self::SEARCHABLE_FIELDS) || options[:fields].present?  
34 - fields_per_table = {}  
35 - fields_per_table[table_name] = (options[:fields].present? ? options[:fields] : self::SEARCHABLE_FIELDS.keys.map(&:to_s)) & column_names  
36 -  
37 - if options[:joins].present?  
38 - join_asset = options[:joins].to_s.classify.constantize  
39 - if defined?(join_asset::SEARCHABLE_FIELDS) || options[:fields].present?  
40 - fields_per_table[join_asset.table_name] = (options[:fields].present? ? options[:fields] : join_asset::SEARCHABLE_FIELDS.keys.map(&:to_s)) & join_asset.column_names  
41 - end  
42 - end  
43 -  
44 - query = query.downcase.strip  
45 - fields_per_table.delete_if { |table,fields| fields.blank? }  
46 - conditions = fields_per_table.map do |table,fields|  
47 - fields.map do |field|  
48 - "lower(#{table}.#{field}) LIKE '%#{query}%'"  
49 - end.join(' OR ')  
50 - end.join(' OR ')  
51 -  
52 - if options[:joins].present?  
53 - joins(options[:joins]).where(conditions)  
54 - else  
55 - where(conditions)  
56 - end  
57 -  
58 - else  
59 - raise "No searchable fields defined for #{self.name}"  
60 - end  
61 - end  
62 -  
63 -end  
64 -  
65 -ActiveRecord::Calculations.class_eval do  
66 - def count_with_distinct column_name=self.primary_key  
67 - if column_name  
68 - distinct.count_without_distinct column_name  
69 - else  
70 - count_without_distinct  
71 - end  
72 - end  
73 - alias_method_chain :count, :distinct  
74 -end  
lib/noosfero/core_ext/active_record/calculations.rb 0 → 100644
@@ -0,0 +1,10 @@ @@ -0,0 +1,10 @@
  1 +ActiveRecord::Calculations.class_eval do
  2 + def count_with_distinct column_name=self.primary_key
  3 + if column_name
  4 + distinct.count_without_distinct column_name
  5 + else
  6 + count_without_distinct
  7 + end
  8 + end
  9 + alias_method_chain :count, :distinct
  10 +end
lib/noosfero/multi_tenancy.rb
@@ -12,12 +12,12 @@ module Noosfero @@ -12,12 +12,12 @@ module Noosfero
12 def self.db_by_host=(host) 12 def self.db_by_host=(host)
13 if host != @db_by_host 13 if host != @db_by_host
14 @db_by_host = host 14 @db_by_host = host
15 - ActiveRecord::Base.connection.schema_search_path = self.mapping[host] 15 + ApplicationRecord.connection.schema_search_path = self.mapping[host]
16 end 16 end
17 end 17 end
18 18
19 def self.setup!(host) 19 def self.setup!(host)
20 - if Noosfero::MultiTenancy.on? and ActiveRecord::Base.postgresql? 20 + if Noosfero::MultiTenancy.on? and ApplicationRecord.postgresql?
21 Noosfero::MultiTenancy.db_by_host = host 21 Noosfero::MultiTenancy.db_by_host = host
22 end 22 end
23 end 23 end
lib/noosfero/plugin.rb
@@ -661,7 +661,7 @@ class Noosfero::Plugin @@ -661,7 +661,7 @@ class Noosfero::Plugin
661 end 661 end
662 662
663 # -> Perform extra transactions related to profile in profile editor 663 # -> Perform extra transactions related to profile in profile editor
664 - # returns = true in success or raise and exception if it could not update the data 664 + # returns = true in success or raise an exception if it could not update the data
665 def profile_editor_transaction_extras 665 def profile_editor_transaction_extras
666 nil 666 nil
667 end 667 end
lib/noosfero/unicorn.rb
@@ -7,11 +7,11 @@ GC.respond_to?(:copy_on_write_friendly=) and @@ -7,11 +7,11 @@ GC.respond_to?(:copy_on_write_friendly=) and
7 GC.copy_on_write_friendly = true 7 GC.copy_on_write_friendly = true
8 8
9 before_fork do |server, worker| 9 before_fork do |server, worker|
10 - ActiveRecord::Base.connection.disconnect! if defined?(ActiveRecord::Base) 10 + ApplicationRecord.connection.disconnect! if defined?(ApplicationRecord)
11 end 11 end
12 12
13 after_fork do |server, worker| 13 after_fork do |server, worker|
14 - ActiveRecord::Base.establish_connection if defined?(ActiveRecord::Base) 14 + ApplicationRecord.establish_connection if defined?(ApplicationRecord)
15 end 15 end
16 16
17 # load local configuration file, if it exists 17 # load local configuration file, if it exists
lib/postgresql_attachment_fu.rb
@@ -9,11 +9,12 @@ module PostgresqlAttachmentFu @@ -9,11 +9,12 @@ module PostgresqlAttachmentFu
9 module InstanceMethods 9 module InstanceMethods
10 def full_filename(thumbnail = nil) 10 def full_filename(thumbnail = nil)
11 file_system_path = (thumbnail ? thumbnail_class : self).attachment_options[:path_prefix].to_s 11 file_system_path = (thumbnail ? thumbnail_class : self).attachment_options[:path_prefix].to_s
12 - file_system_path = File.join(file_system_path, ActiveRecord::Base.connection.schema_search_path) if ActiveRecord::Base.postgresql? and Noosfero::MultiTenancy.on? 12 + file_system_path = File.join(file_system_path, ApplicationRecord.connection.schema_search_path) if ApplicationRecord.postgresql? and Noosfero::MultiTenancy.on?
13 Rails.root.join(file_system_path, *partitioned_path(thumbnail_name_for(thumbnail))).to_s 13 Rails.root.join(file_system_path, *partitioned_path(thumbnail_name_for(thumbnail))).to_s
14 end 14 end
15 end 15 end
16 16
17 end 17 end
18 18
19 -ActiveRecord::Base.send(:extend, PostgresqlAttachmentFu::ClassMethods) 19 +ApplicationRecord.extend PostgresqlAttachmentFu::ClassMethods
  20 +
lib/split_datetime.rb
@@ -69,4 +69,5 @@ module SplitDatetime @@ -69,4 +69,5 @@ module SplitDatetime
69 end 69 end
70 70
71 Class.extend SplitDatetime::SplitMethods 71 Class.extend SplitDatetime::SplitMethods
72 -ActiveRecord::Base.extend SplitDatetime::SplitMethods 72 +ApplicationRecord.extend SplitDatetime::SplitMethods
  73 +
lib/sqlite_extension.rb
1 -if ActiveRecord::Base.connection.adapter_name.downcase == 'sqlite' 1 +if ApplicationRecord.connection.adapter_name.downcase == 'sqlite'
2 2
3 - database = ActiveRecord::Base.connection.raw_connection 3 + database = ApplicationRecord.connection.raw_connection
4 4
5 database.create_function('pow', 2, 1) do |func, base, exponent| 5 database.create_function('pow', 2, 1) do |func, base, exponent|
6 func.set_result(base.to_f ** exponent.to_f) 6 func.set_result(base.to_f ** exponent.to_f)
7 end 7 end
8 - 8 +
9 database.create_function('sqrt', 1, 1) do |func, value| 9 database.create_function('sqrt', 1, 1) do |func, value|
10 func.set_result(Math.sqrt(value)) 10 func.set_result(Math.sqrt(value))
11 end 11 end
@@ -18,8 +18,8 @@ if ActiveRecord::Base.connection.adapter_name.downcase == &#39;sqlite&#39; @@ -18,8 +18,8 @@ if ActiveRecord::Base.connection.adapter_name.downcase == &#39;sqlite&#39;
18 func.set_result( 18 func.set_result(
19 radius.to_f * Math.acos( 19 radius.to_f * Math.acos(
20 [1, 20 [1,
21 - Math.cos(lat1.to_f) * Math.cos(long1.to_f) * Math.cos(lat2.to_f) * Math.cos(long2.to_f) +  
22 - Math.cos(lat1.to_f) * Math.sin(long1.to_f) * Math.cos(lat2.to_f) * Math.sin(long2.to_f) + 21 + Math.cos(lat1.to_f) * Math.cos(long1.to_f) * Math.cos(lat2.to_f) * Math.cos(long2.to_f) +
  22 + Math.cos(lat1.to_f) * Math.sin(long1.to_f) * Math.cos(lat2.to_f) * Math.sin(long2.to_f) +
23 Math.sin(lat1.to_f) * Math.sin(lat2.to_f) 23 Math.sin(lat1.to_f) * Math.sin(lat2.to_f)
24 ].min 24 ].min
25 ) 25 )
lib/tasks/backup.rake
@@ -115,7 +115,7 @@ end @@ -115,7 +115,7 @@ end
115 115
116 desc 'Removes emails from database' 116 desc 'Removes emails from database'
117 task 'restore:remove_emails' => :environment do 117 task 'restore:remove_emails' => :environment do
118 - connection = ActiveRecord::Base.connection 118 + connection = ApplicationRecord.connection
119 [ 119 [
120 "UPDATE users SET email = concat('user', id, '@localhost.localdomain')", 120 "UPDATE users SET email = concat('user', id, '@localhost.localdomain')",
121 "UPDATE environments SET contact_email = concat('environment', id, '@localhost.localdomain')", 121 "UPDATE environments SET contact_email = concat('environment', id, '@localhost.localdomain')",
lib/tasks/multitenancy.rake
1 namespace :multitenancy do 1 namespace :multitenancy do
2 2
3 task :create => :environment do 3 task :create => :environment do
4 - db_envs = ActiveRecord::Base.configurations.keys.select{ |k| k.match(/_development$|_production$|_test$/) } 4 + db_envs = ApplicationRecord.configurations.keys.select{ |k| k.match(/_development$|_production$|_test$/) }
5 cd Rails.root.join('config', 'environments'), :verbose => true 5 cd Rails.root.join('config', 'environments'), :verbose => true
6 file_envs = Dir.glob "{*_development.rb,*_production.rb,*_test.rb}" 6 file_envs = Dir.glob "{*_development.rb,*_production.rb,*_test.rb}"
7 (db_envs.map{ |e| e + '.rb' } - file_envs).each { |env| ln_s env.split('_').last, env } 7 (db_envs.map{ |e| e + '.rb' } - file_envs).each { |env| ln_s env.split('_').last, env }
8 end 8 end
9 9
10 task :remove => :environment do 10 task :remove => :environment do
11 - db_envs = ActiveRecord::Base.configurations.keys.select{ |k| k.match(/_development$|_production$|_test$/) } 11 + db_envs = ApplicationRecord.configurations.keys.select{ |k| k.match(/_development$|_production$|_test$/) }
12 cd Rails.root.join('config', 'environments'), :verbose => true 12 cd Rails.root.join('config', 'environments'), :verbose => true
13 file_envs = Dir.glob "{*_development.rb,*_production.rb,*_test.rb}" 13 file_envs = Dir.glob "{*_development.rb,*_production.rb,*_test.rb}"
14 (file_envs - db_envs.map{ |e| e + '.rb' }).each { |env| safe_unlink env } 14 (file_envs - db_envs.map{ |e| e + '.rb' }).each { |env| safe_unlink env }
@@ -19,7 +19,7 @@ end @@ -19,7 +19,7 @@ end
19 namespace :db do 19 namespace :db do
20 20
21 task :migrate_other_environments => :environment do 21 task :migrate_other_environments => :environment do
22 - envs = ActiveRecord::Base.configurations.keys.select{ |k| k.match(/_#{Rails.env}$/) } 22 + envs = ApplicationRecord.configurations.keys.select{ |k| k.match(/_#{Rails.env}$/) }
23 envs.each do |e| 23 envs.each do |e|
24 puts "*** Migrating #{e}" if Rake.application.options.trace 24 puts "*** Migrating #{e}" if Rake.application.options.trace
25 system "rake db:migrate RAILS_ENV=#{e} SCHEMA=/dev/null" 25 system "rake db:migrate RAILS_ENV=#{e} SCHEMA=/dev/null"
lib/tasks/plugins_tests.rake
@@ -9,7 +9,7 @@ $broken_plugins = %w[ @@ -9,7 +9,7 @@ $broken_plugins = %w[
9 @all_plugins = Dir.glob('plugins/*').map { |f| File.basename(f) } - ['template'] 9 @all_plugins = Dir.glob('plugins/*').map { |f| File.basename(f) } - ['template']
10 @all_plugins.sort! 10 @all_plugins.sort!
11 11
12 -@all_tasks = [:units, :functionals, :integration, :cucumber, :selenium] 12 +@all_tasks = [:units, :api, :functionals, :integration, :cucumber, :selenium]
13 13
14 def enabled_plugins 14 def enabled_plugins
15 Dir.glob('{baseplugins,config/plugins}/*').map { |f| File.basename(f) } - ['README'] 15 Dir.glob('{baseplugins,config/plugins}/*').map { |f| File.basename(f) } - ['README']
@@ -25,7 +25,7 @@ def enable_plugins(plugins) @@ -25,7 +25,7 @@ def enable_plugins(plugins)
25 plugins = Array(plugins) 25 plugins = Array(plugins)
26 command = ['./script/noosfero-plugins', '-q', 'enable', *plugins] 26 command = ['./script/noosfero-plugins', '-q', 'enable', *plugins]
27 puts plugins.join(' ') 27 puts plugins.join(' ')
28 - system *command 28 + Bundler.clean_system *command
29 end 29 end
30 30
31 def disable_plugins(plugins = '*') 31 def disable_plugins(plugins = '*')
@@ -87,6 +87,8 @@ def task2folder(task) @@ -87,6 +87,8 @@ def task2folder(task)
87 result = case task.to_sym 87 result = case task.to_sym
88 when :units 88 when :units
89 :unit 89 :unit
  90 + when :api
  91 + :api
90 when :functionals 92 when :functionals
91 :functional 93 :functional
92 when :integration 94 when :integration
lib/upload_sanitizer.rb
@@ -10,4 +10,4 @@ module UploadSanitizer @@ -10,4 +10,4 @@ module UploadSanitizer
10 end 10 end
11 end 11 end
12 12
13 -ActiveRecord::Base.send(:include, UploadSanitizer) 13 +ApplicationRecord.send :include, UploadSanitizer
plugins/analytics/models/analytics_plugin/page_view.rb
1 -class AnalyticsPlugin::PageView < ActiveRecord::Base 1 +class AnalyticsPlugin::PageView < ApplicationRecord
2 2
3 serialize :data 3 serialize :data
4 4
plugins/analytics/models/analytics_plugin/visit.rb
1 -class AnalyticsPlugin::Visit < ActiveRecord::Base 1 +class AnalyticsPlugin::Visit < ApplicationRecord
2 2
3 attr_accessible *self.column_names 3 attr_accessible *self.column_names
4 attr_accessible :profile 4 attr_accessible :profile
plugins/breadcrumbs/lib/breadcrumbs_plugin/content_breadcrumbs_block.rb
@@ -49,7 +49,7 @@ class BreadcrumbsPlugin::ContentBreadcrumbsBlock &lt; Block @@ -49,7 +49,7 @@ class BreadcrumbsPlugin::ContentBreadcrumbsBlock &lt; Block
49 49
50 def content(args={}) 50 def content(args={})
51 block = self 51 block = self
52 - proc do 52 + ret = (proc do
53 trail = block.trail(@page, @profile, params) 53 trail = block.trail(@page, @profile, params)
54 if !trail.empty? 54 if !trail.empty?
55 separator = content_tag('span', ' > ', :class => 'separator') 55 separator = content_tag('span', ' > ', :class => 'separator')
@@ -63,11 +63,12 @@ class BreadcrumbsPlugin::ContentBreadcrumbsBlock &lt; Block @@ -63,11 +63,12 @@ class BreadcrumbsPlugin::ContentBreadcrumbsBlock &lt; Block
63 breadcrumb << content_tag('div', section_name, :class => 'section-name') 63 breadcrumb << content_tag('div', section_name, :class => 'section-name')
64 end 64 end
65 65
66 - breadcrumb 66 + breadcrumb.html_safe
67 else 67 else
68 '' 68 ''
69 end 69 end
70 - end 70 + end)
  71 + ret
71 end 72 end
72 73
73 def cacheable? 74 def cacheable?
plugins/comment_classification/lib/comment_classification_plugin/comment_label_user.rb
1 -class CommentClassificationPlugin::CommentLabelUser < ActiveRecord::Base 1 +class CommentClassificationPlugin::CommentLabelUser < ApplicationRecord
2 self.table_name = :comment_classification_plugin_comment_label_user 2 self.table_name = :comment_classification_plugin_comment_label_user
3 3
4 belongs_to :profile 4 belongs_to :profile
plugins/comment_classification/lib/comment_classification_plugin/comment_status_user.rb
1 -class CommentClassificationPlugin::CommentStatusUser < ActiveRecord::Base 1 +class CommentClassificationPlugin::CommentStatusUser < ApplicationRecord
2 self.table_name = :comment_classification_plugin_comment_status_user 2 self.table_name = :comment_classification_plugin_comment_status_user
3 3
4 belongs_to :profile 4 belongs_to :profile
plugins/comment_classification/lib/comment_classification_plugin/label.rb
1 -class CommentClassificationPlugin::Label < ActiveRecord::Base 1 +class CommentClassificationPlugin::Label < ApplicationRecord
2 2
3 belongs_to :owner, :polymorphic => true 3 belongs_to :owner, :polymorphic => true
4 4
plugins/comment_classification/lib/comment_classification_plugin/status.rb
1 -class CommentClassificationPlugin::Status < ActiveRecord::Base 1 +class CommentClassificationPlugin::Status < ApplicationRecord
2 2
3 belongs_to :owner, :polymorphic => true 3 belongs_to :owner, :polymorphic => true
4 4
plugins/community_block/views/blocks/community.html.erb
@@ -23,7 +23,7 @@ @@ -23,7 +23,7 @@
23 <%= link_to( 23 <%= link_to(
24 content_tag('span','',:class => 'community-block-button icon-arrow'), 24 content_tag('span','',:class => 'community-block-button icon-arrow'),
25 '#', 25 '#',
26 - :onclick => "toggleSubmenu(this,'',#{CGI::escapeHTML(links.to_json)}); return false;", 26 + :onclick => "toggleSubmenu(this,'',#{CGI::escapeHTML(links.to_json)}); return false;".html_safe,
27 :class => 'simplemenu-trigger') %> 27 :class => 'simplemenu-trigger') %>
28 28
29 <% end %> 29 <% end %>
plugins/context_content/lib/context_content_plugin/context_content_block.rb
@@ -86,15 +86,16 @@ class ContextContentPlugin::ContextContentBlock &lt; Block @@ -86,15 +86,16 @@ class ContextContentPlugin::ContextContentBlock &lt; Block
86 86
87 def content(args={}) 87 def content(args={})
88 block = self 88 block = self
89 - proc do 89 + ret = proc do
90 contents = block.contents(@page) 90 contents = block.contents(@page)
91 parent_title = block.parent_title(contents) 91 parent_title = block.parent_title(contents)
92 - if !contents.blank? 92 + if contents.present?
93 render(:file => 'blocks/context_content', :locals => {:block => block, :contents => contents, :parent_title => parent_title}) 93 render(:file => 'blocks/context_content', :locals => {:block => block, :contents => contents, :parent_title => parent_title})
94 else 94 else
95 '' 95 ''
96 end 96 end
97 end 97 end
  98 + ret
98 end 99 end
99 100
100 def cacheable? 101 def cacheable?
plugins/custom_forms/db/migrate/20130823151900_associate_fields_to_alternatives.rb
1 class AssociateFieldsToAlternatives < ActiveRecord::Migration 1 class AssociateFieldsToAlternatives < ActiveRecord::Migration
2 - class CustomFormsPlugin::Field < ActiveRecord::Base 2 + class CustomFormsPlugin::Field < ApplicationRecord
3 self.table_name = :custom_forms_plugin_fields 3 self.table_name = :custom_forms_plugin_fields
4 has_many :alternatives, :class_name => 'CustomFormsPlugin::Alternative' 4 has_many :alternatives, :class_name => 'CustomFormsPlugin::Alternative'
5 serialize :choices, Hash 5 serialize :choices, Hash
plugins/custom_forms/lib/custom_forms_plugin/alternative.rb
1 -class CustomFormsPlugin::Alternative < ActiveRecord::Base 1 +class CustomFormsPlugin::Alternative < ApplicationRecord
2 self.table_name = :custom_forms_plugin_alternatives 2 self.table_name = :custom_forms_plugin_alternatives
3 3
4 validates_presence_of :label 4 validates_presence_of :label
plugins/custom_forms/lib/custom_forms_plugin/answer.rb
1 -class CustomFormsPlugin::Answer < ActiveRecord::Base 1 +class CustomFormsPlugin::Answer < ApplicationRecord
2 self.table_name = :custom_forms_plugin_answers 2 self.table_name = :custom_forms_plugin_answers
3 belongs_to :field, :class_name => 'CustomFormsPlugin::Field' 3 belongs_to :field, :class_name => 'CustomFormsPlugin::Field'
4 belongs_to :submission, :class_name => 'CustomFormsPlugin::Submission' 4 belongs_to :submission, :class_name => 'CustomFormsPlugin::Submission'
plugins/custom_forms/lib/custom_forms_plugin/field.rb
1 -class CustomFormsPlugin::Field < ActiveRecord::Base 1 +class CustomFormsPlugin::Field < ApplicationRecord
2 self.table_name = :custom_forms_plugin_fields 2 self.table_name = :custom_forms_plugin_fields
3 3
4 validates_presence_of :name 4 validates_presence_of :name
plugins/custom_forms/lib/custom_forms_plugin/form.rb
1 -class CustomFormsPlugin::Form < ActiveRecord::Base 1 +class CustomFormsPlugin::Form < ApplicationRecord
2 2
3 belongs_to :profile 3 belongs_to :profile
4 4
plugins/custom_forms/lib/custom_forms_plugin/submission.rb
1 -class CustomFormsPlugin::Submission < ActiveRecord::Base 1 +class CustomFormsPlugin::Submission < ApplicationRecord
2 2
3 belongs_to :form, :class_name => 'CustomFormsPlugin::Form' 3 belongs_to :form, :class_name => 'CustomFormsPlugin::Form'
4 belongs_to :profile 4 belongs_to :profile
plugins/custom_forms/po/ru/custom_forms.po
@@ -7,21 +7,21 @@ msgid &quot;&quot; @@ -7,21 +7,21 @@ msgid &quot;&quot;
7 msgstr "" 7 msgstr ""
8 "Project-Id-Version: 1.3~rc2-1-ga15645d\n" 8 "Project-Id-Version: 1.3~rc2-1-ga15645d\n"
9 "POT-Creation-Date: 2015-10-30 16:35-0300\n" 9 "POT-Creation-Date: 2015-10-30 16:35-0300\n"
10 -"PO-Revision-Date: 2015-03-09 09:51+0200\n"  
11 -"Last-Translator: Michal Čihař <michal@cihar.com>\n" 10 +"PO-Revision-Date: 2016-04-22 22:31+0000\n"
  11 +"Last-Translator: Iryna Pruitt <jdpruitt2807@prodigy.net>\n"
12 "Language-Team: Russian <https://hosted.weblate.org/projects/noosfero/plugin-" 12 "Language-Team: Russian <https://hosted.weblate.org/projects/noosfero/plugin-"
13 "custom-forms/ru/>\n" 13 "custom-forms/ru/>\n"
14 "Language: ru\n" 14 "Language: ru\n"
15 "MIME-Version: 1.0\n" 15 "MIME-Version: 1.0\n"
16 "Content-Type: text/plain; charset=UTF-8\n" 16 "Content-Type: text/plain; charset=UTF-8\n"
17 "Content-Transfer-Encoding: 8bit\n" 17 "Content-Transfer-Encoding: 8bit\n"
18 -"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"  
19 -"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"  
20 -"X-Generator: Weblate 2.3-dev\n" 18 +"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<="
  19 +"4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
  20 +"X-Generator: Weblate 2.6-dev\n"
21 21
22 #: plugins/custom_forms/lib/custom_forms_plugin/form.rb:67 22 #: plugins/custom_forms/lib/custom_forms_plugin/form.rb:67
23 msgid "Invalid string format of access." 23 msgid "Invalid string format of access."
24 -msgstr "" 24 +msgstr "Недействительный формат строки доступа."
25 25
26 #: plugins/custom_forms/lib/custom_forms_plugin/form.rb:71 26 #: plugins/custom_forms/lib/custom_forms_plugin/form.rb:71
27 #: plugins/custom_forms/lib/custom_forms_plugin/form.rb:76 27 #: plugins/custom_forms/lib/custom_forms_plugin/form.rb:76
@@ -31,11 +31,11 @@ msgstr &quot;Со следующими файлами возникли проблем @@ -31,11 +31,11 @@ msgstr &quot;Со следующими файлами возникли проблем
31 31
32 #: plugins/custom_forms/lib/custom_forms_plugin/form.rb:81 32 #: plugins/custom_forms/lib/custom_forms_plugin/form.rb:81
33 msgid "Invalid type format of access." 33 msgid "Invalid type format of access."
34 -msgstr "" 34 +msgstr "Недействительный тип формата доступа."
35 35
36 #: plugins/custom_forms/lib/custom_forms_plugin/form.rb:87 36 #: plugins/custom_forms/lib/custom_forms_plugin/form.rb:87
37 msgid "The time range selected is invalid." 37 msgid "The time range selected is invalid."
38 -msgstr "" 38 +msgstr "Диапазон времени выбран неверно."
39 39
40 #: plugins/custom_forms/lib/custom_forms_plugin/membership_survey.rb:20 40 #: plugins/custom_forms/lib/custom_forms_plugin/membership_survey.rb:20
41 #, fuzzy 41 #, fuzzy
@@ -76,11 +76,11 @@ msgstr &quot;Пользовательский заголовок&quot; @@ -76,11 +76,11 @@ msgstr &quot;Пользовательский заголовок&quot;
76 76
77 #: plugins/custom_forms/lib/custom_forms_plugin/helper.rb:24 77 #: plugins/custom_forms/lib/custom_forms_plugin/helper.rb:24
78 msgid "Always" 78 msgid "Always"
79 -msgstr "" 79 +msgstr "Всегда"
80 80
81 #: plugins/custom_forms/lib/custom_forms_plugin/helper.rb:28 81 #: plugins/custom_forms/lib/custom_forms_plugin/helper.rb:28
82 msgid "Until %s" 82 msgid "Until %s"
83 -msgstr "" 83 +msgstr "До %"
84 84
85 #: plugins/custom_forms/lib/custom_forms_plugin/helper.rb:30 85 #: plugins/custom_forms/lib/custom_forms_plugin/helper.rb:30
86 #, fuzzy 86 #, fuzzy
@@ -94,16 +94,15 @@ msgstr &quot;Выбрать...&quot; @@ -94,16 +94,15 @@ msgstr &quot;Выбрать...&quot;
94 94
95 #: plugins/custom_forms/lib/custom_forms_plugin/helper.rb:61 95 #: plugins/custom_forms/lib/custom_forms_plugin/helper.rb:61
96 msgid "Text field" 96 msgid "Text field"
97 -msgstr "" 97 +msgstr "Поле текста"
98 98
99 #: plugins/custom_forms/lib/custom_forms_plugin/helper.rb:62 99 #: plugins/custom_forms/lib/custom_forms_plugin/helper.rb:62
100 -#, fuzzy  
101 msgid "Select field" 100 msgid "Select field"
102 -msgstr "Выбрать папки" 101 +msgstr "Выбрать поле"
103 102
104 #: plugins/custom_forms/lib/custom_forms_plugin/helper.rb:102 103 #: plugins/custom_forms/lib/custom_forms_plugin/helper.rb:102
105 msgid "Hold down Ctrl to select options" 104 msgid "Hold down Ctrl to select options"
106 -msgstr "" 105 +msgstr "Держать нажатой клавишу Ctrl для выбора опций"
107 106
108 #: plugins/custom_forms/lib/custom_forms_plugin/admission_survey.rb:9 107 #: plugins/custom_forms/lib/custom_forms_plugin/admission_survey.rb:9
109 #, fuzzy 108 #, fuzzy
@@ -111,9 +110,8 @@ msgid &quot;Admission survey&quot; @@ -111,9 +110,8 @@ msgid &quot;Admission survey&quot;
111 msgstr "Участники: %s" 110 msgstr "Участники: %s"
112 111
113 #: plugins/custom_forms/lib/custom_forms_plugin/admission_survey.rb:13 112 #: plugins/custom_forms/lib/custom_forms_plugin/admission_survey.rb:13
114 -#, fuzzy  
115 msgid "%{requestor} wants you to fill in some information before joining." 113 msgid "%{requestor} wants you to fill in some information before joining."
116 -msgstr "%s хочет быть вашим другом" 114 +msgstr "%s хочет чтоб вы внесли информацию, прежде чем присоединиться."
117 115
118 #: plugins/custom_forms/lib/custom_forms_plugin/admission_survey.rb:17 116 #: plugins/custom_forms/lib/custom_forms_plugin/admission_survey.rb:17
119 #, fuzzy 117 #, fuzzy
plugins/custom_forms/views/custom_forms_plugin_profile/show.html.erb
@@ -6,9 +6,9 @@ @@ -6,9 +6,9 @@
6 <% if @submission.id.nil? %> 6 <% if @submission.id.nil? %>
7 <% if @form.expired? %> 7 <% if @form.expired? %>
8 <% if @form.will_open? %> 8 <% if @form.will_open? %>
9 - <h2><%= _('Sorry, you can\'t fill this form yet') %></h2> 9 + <h2><%= _('Sorry, you can\'t fill this form yet').html_safe %></h2>
10 <% else %> 10 <% else %>
11 - <h2><%= _('Sorry, you can\'t fill this form anymore') %></h2> 11 + <h2><%= _('Sorry, you can\'t fill this form anymore').html_safe %></h2>
12 <% end %> 12 <% end %>
13 <% end %> 13 <% end %>
14 14
plugins/delivery/db/migrate/20130719132252_create_delivery_plugin_tables.rb
1 class CreateDeliveryPluginTables < ActiveRecord::Migration 1 class CreateDeliveryPluginTables < ActiveRecord::Migration
2 def self.up 2 def self.up
3 # check if distribution plugin already moved tables 3 # check if distribution plugin already moved tables
4 - return if ActiveRecord::Base.connection.table_exists? :delivery_plugin_methods 4 + return if ApplicationRecord.connection.table_exists? :delivery_plugin_methods
5 5
6 create_table :delivery_plugin_methods do |t| 6 create_table :delivery_plugin_methods do |t|
7 t.integer :profile_id 7 t.integer :profile_id
plugins/delivery/models/delivery_plugin/method.rb
1 -class DeliveryPlugin::Method < ActiveRecord::Base 1 +class DeliveryPlugin::Method < ApplicationRecord
2 2
3 Types = ['pickup', 'deliver'] 3 Types = ['pickup', 'deliver']
4 4
plugins/delivery/models/delivery_plugin/option.rb
1 -class DeliveryPlugin::Option < ActiveRecord::Base 1 +class DeliveryPlugin::Option < ApplicationRecord
2 2
3 belongs_to :delivery_method, :class_name => 'DeliveryPlugin::Method' 3 belongs_to :delivery_method, :class_name => 'DeliveryPlugin::Method'
4 belongs_to :owner, :polymorphic => true 4 belongs_to :owner, :polymorphic => true
plugins/display_content/lib/display_content_block.rb
@@ -177,9 +177,9 @@ class DisplayContentBlock &lt; Block @@ -177,9 +177,9 @@ class DisplayContentBlock &lt; Block
177 177
178 content_sections += read_more_section if !read_more_section.blank? 178 content_sections += read_more_section if !read_more_section.blank?
179 #raise sections.inspect 179 #raise sections.inspect
180 - content_tag('li', content_sections) 180 + content_tag('li', content_sections.html_safe)
181 end 181 end
182 - }.join(" ")) 182 + }.join(" ").html_safe)
183 end 183 end
184 end 184 end
185 185
plugins/driven_signup/models/driven_signup_plugin/auth.rb
1 -class DrivenSignupPlugin::Auth < ActiveRecord::Base 1 +class DrivenSignupPlugin::Auth < ApplicationRecord
2 2
3 attr_accessible :name, :token 3 attr_accessible :name, :token
4 4
plugins/environment_notification/lib/environment_notifications_user.rb
1 -class EnvironmentNotificationsUser < ActiveRecord::Base 1 +class EnvironmentNotificationsUser < ApplicationRecord
2 self.table_name = "environment_notifications_users" 2 self.table_name = "environment_notifications_users"
3 3
4 belongs_to :user 4 belongs_to :user
plugins/environment_notification/models/environment_notification_plugin/environment_notification.rb
1 -class EnvironmentNotificationPlugin::EnvironmentNotification < ActiveRecord::Base 1 +class EnvironmentNotificationPlugin::EnvironmentNotification < ApplicationRecord
2 2
3 self.table_name = "environment_notifications" 3 self.table_name = "environment_notifications"
4 4
plugins/event/views/event_plugin/event_block_item.html.erb
@@ -3,11 +3,11 @@ @@ -3,11 +3,11 @@
3 ev_days_tag = '' 3 ev_days_tag = ''
4 if event.duration > 1 4 if event.duration > 1
5 ev_days_tag = content_tag('time', 5 ev_days_tag = content_tag('time',
6 - n_('Duration: 1 day', 'Duration: %s days', event.duration) % "<b>#{event.duration}</b>", 6 + n_('Duration: 1 day', 'Duration: %s days', event.duration).html_safe % "<b>#{event.duration}</b>".html_safe,
7 :itemprop => 'endDate', 7 :itemprop => 'endDate',
8 :datetime => show_date(event.end_date) + 'T00:00', 8 :datetime => show_date(event.end_date) + 'T00:00',
9 :class => 'duration', 9 :class => 'duration',
10 - :title => show_date(event.start_date) + ' &mdash; ' + time_left_str 10 + :title => (show_date(event.start_date) + ' &mdash; ' + time_left_str).html_safe
11 ) 11 )
12 end 12 end
13 13
@@ -16,7 +16,7 @@ @@ -16,7 +16,7 @@
16 img_class = img.blank? ? 'no-img' : 'has-img' 16 img_class = img.blank? ? 'no-img' : 'has-img'
17 %> 17 %>
18 <%= 18 <%=
19 - link_to([ 19 + link_to(safe_join([
20 content_tag('time', 20 content_tag('time',
21 block.date_to_html(event.start_date), 21 block.date_to_html(event.start_date),
22 :itemprop => 'startDate', 22 :itemprop => 'startDate',
@@ -33,7 +33,7 @@ @@ -33,7 +33,7 @@
33 :itemtype => 'http://schema.org/Place', 33 :itemtype => 'http://schema.org/Place',
34 :itemprop => :location), 34 :itemprop => :location),
35 content_tag('span', time_left_str, :class => 'days-left ' + time_class) 35 content_tag('span', time_left_str, :class => 'days-left ' + time_class)
36 - ].join("\n"), 36 + ], "\n"),
37 (event.link.blank? ? event.url : event.link), 37 (event.link.blank? ? event.url : event.link),
38 :class => 'ev-days-' + event.duration.to_s, 38 :class => 'ev-days-' + event.duration.to_s,
39 :itemprop => :url 39 :itemprop => :url
plugins/fb_app/models/fb_app_plugin/page_tab.rb
1 -class FbAppPlugin::PageTab < ActiveRecord::Base 1 +class FbAppPlugin::PageTab < ApplicationRecord
2 2
3 # FIXME: rename table to match model 3 # FIXME: rename table to match model
4 self.table_name = :fb_app_plugin_page_tab_configs 4 self.table_name = :fb_app_plugin_page_tab_configs
plugins/foo/lib/foo_plugin/bar.rb
1 -class FooPlugin::Bar < ActiveRecord::Base 1 +class FooPlugin::Bar < ApplicationRecord
2 2
3 end 3 end
plugins/lattes_curriculum/lib/academic_info.rb
1 -class AcademicInfo < ActiveRecord::Base 1 +class AcademicInfo < ApplicationRecord
2 2
3 belongs_to :person 3 belongs_to :person
4 4
plugins/mark_comment_as_read/lib/mark_comment_as_read_plugin/read_comments.rb
1 -class MarkCommentAsReadPlugin::ReadComments < ActiveRecord::Base 1 +class MarkCommentAsReadPlugin::ReadComments < ApplicationRecord
2 self.table_name = 'mark_comment_as_read_plugin' 2 self.table_name = 'mark_comment_as_read_plugin'
3 belongs_to :comment 3 belongs_to :comment
4 belongs_to :person 4 belongs_to :person
plugins/metadata/lib/metadata_plugin/base.rb
@@ -55,7 +55,7 @@ class MetadataPlugin::Base &lt; Noosfero::Plugin @@ -55,7 +55,7 @@ class MetadataPlugin::Base &lt; Noosfero::Plugin
55 end 55 end
56 end 56 end
57 end 57 end
58 - r.join 58 + safe_join(r)
59 end 59 end
60 end 60 end
61 61
@@ -71,6 +71,6 @@ end @@ -71,6 +71,6 @@ end
71 71
72 ActiveSupport.run_load_hooks :metadata_plugin, MetadataPlugin 72 ActiveSupport.run_load_hooks :metadata_plugin, MetadataPlugin
73 ActiveSupport.on_load :active_record do 73 ActiveSupport.on_load :active_record do
74 - ActiveRecord::Base.extend MetadataPlugin::Specs::ClassMethods 74 + ApplicationRecord.extend MetadataPlugin::Specs::ClassMethods
75 end 75 end
76 76
plugins/newsletter/lib/newsletter_plugin/newsletter.rb
1 require 'csv' 1 require 'csv'
2 2
3 -class NewsletterPlugin::Newsletter < ActiveRecord::Base 3 +class NewsletterPlugin::Newsletter < ApplicationRecord
4 4
5 belongs_to :environment 5 belongs_to :environment
6 belongs_to :person 6 belongs_to :person
@@ -110,11 +110,11 @@ class NewsletterPlugin::Newsletter &lt; ActiveRecord::Base @@ -110,11 +110,11 @@ class NewsletterPlugin::Newsletter &lt; ActiveRecord::Base
110 include DatesHelper 110 include DatesHelper
111 111
112 def message_to_public_link 112 def message_to_public_link
113 - content_tag(:p, _("If you can't view this email, %s.") % link_to(_('click here'), '{mailing_url}'), :id => 'newsletter-public-link') 113 + content_tag(:p, (_("If you can't view this email, %s.") % link_to(_('click here'), '{mailing_url}')).html_safe, :id => 'newsletter-public-link').html_safe
114 end 114 end
115 115
116 def message_to_unsubscribe 116 def message_to_unsubscribe
117 - content_tag(:div, _("This is an automatically generated email, please do not reply. If you do not wish to receive future newsletter emails, %s.") % link_to(_("cancel your subscription here"), self.unsubscribe_url, :style => CSS['public-link']), :style => CSS['newsletter-unsubscribe'], :id => 'newsletter-unsubscribe') 117 + content_tag(:div, _("This is an automatically generated email, please do not reply. If you do not wish to receive future newsletter emails, %s.").html_safe % link_to(_("cancel your subscription here"), self.unsubscribe_url, :style => CSS['public-link']), :style => CSS['newsletter-unsubscribe'], :id => 'newsletter-unsubscribe').html_safe
118 end 118 end
119 119
120 def read_more(link_address) 120 def read_more(link_address)
@@ -130,13 +130,13 @@ class NewsletterPlugin::Newsletter &lt; ActiveRecord::Base @@ -130,13 +130,13 @@ class NewsletterPlugin::Newsletter &lt; ActiveRecord::Base
130 end 130 end
131 131
132 def body(data = {}) 132 def body(data = {})
133 - content_tag(:div, content_tag(:div, message_to_public_link, :style => CSS['newsletter-public-link'])+content_tag(:table,(self.image.nil? ? '' : content_tag(:tr, content_tag(:th, tag(:img, :src => "#{self.environment.top_url}#{self.image.public_filename}", :style => CSS['header-image']),:colspan => 2),:style => CSS['newsletter-header']))+self.posts(data).map do |post| 133 + content_tag(:div, content_tag(:div, message_to_public_link, :style => CSS['newsletter-public-link']).html_safe+content_tag(:table,(self.image.nil? ? '' : content_tag(:tr, content_tag(:th, tag(:img, :src => "#{self.environment.top_url}#{self.image.public_filename}", :style => CSS['header-image']),:colspan => 2),:style => CSS['newsletter-header'])).html_safe+self.posts(data).map do |post|
134 if post.image 134 if post.image
135 post_with_image(post) 135 post_with_image(post)
136 else 136 else
137 post_without_image(post) 137 post_without_image(post)
138 end 138 end
139 - end.join()+content_tag(:tr, content_tag(:td, self.footer, :colspan => 2)),:style => CSS['breakingnews'])+content_tag(:div,message_to_unsubscribe, :style => CSS['newsletter-unsubscribe']),:style => CSS['breakingnews-wrap']) 139 + end.join().html_safe+content_tag(:tr, content_tag(:td, self.footer, :colspan => 2)),:style => CSS['breakingnews']).html_safe+content_tag(:div,message_to_unsubscribe, :style => CSS['newsletter-unsubscribe']),:style => CSS['breakingnews-wrap']).html_safe
140 end 140 end
141 141
142 def default_subject 142 def default_subject
plugins/oauth_client/models/oauth_client_plugin/auth.rb
1 -class OauthClientPlugin::Auth < ActiveRecord::Base 1 +class OauthClientPlugin::Auth < ApplicationRecord
2 2
3 attr_accessible :profile, :provider, :enabled, 3 attr_accessible :profile, :provider, :enabled,
4 :access_token, :expires_in, :oauth_data 4 :access_token, :expires_in, :oauth_data
plugins/oauth_client/models/oauth_client_plugin/provider.rb
1 -class OauthClientPlugin::Provider < ActiveRecord::Base 1 +class OauthClientPlugin::Provider < ApplicationRecord
2 2
3 belongs_to :environment 3 belongs_to :environment
4 4
plugins/open_graph/models/open_graph_plugin/track.rb
1 -class OpenGraphPlugin::Track < ActiveRecord::Base 1 +class OpenGraphPlugin::Track < ApplicationRecord
2 2
3 class_attribute :context 3 class_attribute :context
4 self.context = :open_graph 4 self.context = :open_graph
plugins/orders/db/migrate/20130719132245_create_orders_plugin_tables.rb
1 class CreateOrdersPluginTables < ActiveRecord::Migration 1 class CreateOrdersPluginTables < ActiveRecord::Migration
2 def self.up 2 def self.up
3 # check if distribution plugin already moved tables 3 # check if distribution plugin already moved tables
4 - return if ActiveRecord::Base.connection.table_exists? :orders_plugin_orders 4 + return if ApplicationRecord.connection.table_exists? :orders_plugin_orders
5 5
6 create_table :orders_plugin_orders do |t| 6 create_table :orders_plugin_orders do |t|
7 t.integer :profile_id 7 t.integer :profile_id
plugins/orders/lib/code_numbering.rb
@@ -55,4 +55,4 @@ module CodeNumbering @@ -55,4 +55,4 @@ module CodeNumbering
55 end 55 end
56 end 56 end
57 57
58 -ActiveRecord::Base.extend CodeNumbering::ClassMethods 58 +ApplicationRecord.extend CodeNumbering::ClassMethods
plugins/orders/lib/serialized_synced_data.rb
@@ -56,7 +56,7 @@ module SerializedSyncedData @@ -56,7 +56,7 @@ module SerializedSyncedData
56 source = self.send field 56 source = self.send field
57 if block_given? 57 if block_given?
58 data = SerializedSyncedData.prepare_data instance_exec(source, &block) 58 data = SerializedSyncedData.prepare_data instance_exec(source, &block)
59 - elsif source.is_a? ActiveRecord::Base 59 + elsif source.is_a? ApplicationRecord
60 data = SerializedSyncedData.prepare_data source.attributes 60 data = SerializedSyncedData.prepare_data source.attributes
61 elsif source.is_a? Array 61 elsif source.is_a? Array
62 data = source.map{ |source| SerializedSyncedData.prepare_data source.attributes } 62 data = source.map{ |source| SerializedSyncedData.prepare_data source.attributes }
plugins/orders/models/orders_plugin/item.rb
1 -class OrdersPlugin::Item < ActiveRecord::Base 1 +class OrdersPlugin::Item < ApplicationRecord
2 2
3 attr_accessible :order, :sale, :purchase, 3 attr_accessible :order, :sale, :purchase,
4 :product, :product_id, 4 :product, :product_id,
plugins/orders/models/orders_plugin/order.rb
1 -class OrdersPlugin::Order < ActiveRecord::Base 1 +class OrdersPlugin::Order < ApplicationRecord
2 2
3 # if abstract_class is true then it will trigger https://github.com/rails/rails/issues/20871 3 # if abstract_class is true then it will trigger https://github.com/rails/rails/issues/20871
4 #self.abstract_class = true 4 #self.abstract_class = true
plugins/orders_cycle/db/migrate/20130909175738_create_orders_cycle_plugin_tables.rb
@@ -2,7 +2,7 @@ class CreateOrdersCyclePluginTables &lt; ActiveRecord::Migration @@ -2,7 +2,7 @@ class CreateOrdersCyclePluginTables &lt; ActiveRecord::Migration
2 2
3 def change 3 def change
4 # check if distribution plugin already moved the table 4 # check if distribution plugin already moved the table
5 - return if ActiveRecord::Base.connection.table_exists? :orders_cycle_plugin_cycles 5 + return if ApplicationRecord.connection.table_exists? :orders_cycle_plugin_cycles
6 6
7 create_table :orders_cycle_plugin_cycle_orders do |t| 7 create_table :orders_cycle_plugin_cycle_orders do |t|
8 t.integer :cycle_id 8 t.integer :cycle_id
plugins/orders_cycle/models/orders_cycle_plugin/cycle.rb
1 -class OrdersCyclePlugin::Cycle < ActiveRecord::Base 1 +class OrdersCyclePlugin::Cycle < ApplicationRecord
2 2
3 attr_accessible :profile, :status, :name, :description, :opening_message 3 attr_accessible :profile, :status, :name, :description, :opening_message
4 4
@@ -233,7 +233,7 @@ class OrdersCyclePlugin::Cycle &lt; ActiveRecord::Base @@ -233,7 +233,7 @@ class OrdersCyclePlugin::Cycle &lt; ActiveRecord::Base
233 233
234 def add_products 234 def add_products
235 return if self.products.count > 0 235 return if self.products.count > 0
236 - ActiveRecord::Base.transaction do 236 + ApplicationRecord.transaction do
237 self.profile.products.supplied.unarchived.available.find_each batch_size: 20 do |product| 237 self.profile.products.supplied.unarchived.available.find_each batch_size: 20 do |product|
238 self.add_product product 238 self.add_product product
239 end 239 end
plugins/orders_cycle/models/orders_cycle_plugin/cycle_order.rb
1 -class OrdersCyclePlugin::CycleOrder < ActiveRecord::Base 1 +class OrdersCyclePlugin::CycleOrder < ApplicationRecord
2 2
3 belongs_to :cycle, class_name: 'OrdersCyclePlugin::Cycle' 3 belongs_to :cycle, class_name: 'OrdersCyclePlugin::Cycle'
4 belongs_to :sale, class_name: 'OrdersCyclePlugin::Sale', foreign_key: :sale_id, dependent: :destroy 4 belongs_to :sale, class_name: 'OrdersCyclePlugin::Sale', foreign_key: :sale_id, dependent: :destroy
plugins/orders_cycle/models/orders_cycle_plugin/cycle_product.rb
1 -class OrdersCyclePlugin::CycleProduct < ActiveRecord::Base 1 +class OrdersCyclePlugin::CycleProduct < ApplicationRecord
2 2
3 self.table_name = :orders_cycle_plugin_cycle_products 3 self.table_name = :orders_cycle_plugin_cycle_products
4 4
plugins/orders_cycle/models/orders_cycle_plugin/sale.rb
@@ -34,7 +34,7 @@ class OrdersCyclePlugin::Sale &lt; OrdersPlugin::Sale @@ -34,7 +34,7 @@ class OrdersCyclePlugin::Sale &lt; OrdersPlugin::Sale
34 end 34 end
35 35
36 def add_purchases_items 36 def add_purchases_items
37 - ActiveRecord::Base.transaction do 37 + ApplicationRecord.transaction do
38 self.items.each do |item| 38 self.items.each do |item|
39 next unless supplier_product = item.product.supplier_product 39 next unless supplier_product = item.product.supplier_product
40 next unless supplier = supplier_product.profile 40 next unless supplier = supplier_product.profile
@@ -54,7 +54,7 @@ class OrdersCyclePlugin::Sale &lt; OrdersPlugin::Sale @@ -54,7 +54,7 @@ class OrdersCyclePlugin::Sale &lt; OrdersPlugin::Sale
54 end 54 end
55 55
56 def remove_purchases_items 56 def remove_purchases_items
57 - ActiveRecord::Base.transaction do 57 + ApplicationRecord.transaction do
58 self.items.each do |item| 58 self.items.each do |item|
59 next unless supplier_product = item.product.supplier_product 59 next unless supplier_product = item.product.supplier_product
60 next unless purchase = supplier_product.orders_cycles_purchases.for_cycle(self.cycle).first 60 next unless purchase = supplier_product.orders_cycles_purchases.for_cycle(self.cycle).first
plugins/organization_ratings/lib/organization_rating.rb
1 -class OrganizationRating < ActiveRecord::Base 1 +class OrganizationRating < ApplicationRecord
2 belongs_to :person 2 belongs_to :person
3 belongs_to :organization 3 belongs_to :organization
4 belongs_to :comment 4 belongs_to :comment
plugins/organization_ratings/lib/organization_ratings_config.rb
1 -class OrganizationRatingsConfig < ActiveRecord::Base 1 +class OrganizationRatingsConfig < ApplicationRecord
2 2
3 belongs_to :environment 3 belongs_to :environment
4 4
plugins/pg_search/lib/ext/active_record.rb
@@ -1,17 +0,0 @@ @@ -1,17 +0,0 @@
1 -require_dependency 'active_record'  
2 -  
3 -class ActiveRecord::Base  
4 - def self.pg_search_plugin_search(query)  
5 - filtered_query = query.gsub(/[\|\(\)\\\/\s\[\]'"*%&!:]/,' ').split.map{|w| w += ":*"}.join('|')  
6 - if defined?(self::SEARCHABLE_FIELDS)  
7 - where("to_tsvector('simple', #{pg_search_plugin_fields}) @@ to_tsquery('#{filtered_query}')").  
8 - order("ts_rank(to_tsvector('simple', #{pg_search_plugin_fields}), to_tsquery('#{filtered_query}')) DESC")  
9 - else  
10 - raise "No searchable fields defined for #{self.name}"  
11 - end  
12 - end  
13 -  
14 - def self.pg_search_plugin_fields  
15 - self::SEARCHABLE_FIELDS.keys.map(&:to_s).sort.map {|f| "coalesce(#{table_name}.#{f}, '')"}.join(" || ' ' || ")  
16 - end  
17 -end  
plugins/pg_search/lib/ext/application_record.rb 0 → 100644
@@ -0,0 +1,19 @@ @@ -0,0 +1,19 @@
  1 +require_dependency 'application_record'
  2 +
  3 +class ApplicationRecord
  4 +
  5 + def self.pg_search_plugin_search(query)
  6 + filtered_query = query.gsub(/[\|\(\)\\\/\s\[\]'"*%&!:]/,' ').split.map{|w| w += ":*"}.join('|')
  7 + if defined?(self::SEARCHABLE_FIELDS)
  8 + where("to_tsvector('simple', #{pg_search_plugin_fields}) @@ to_tsquery('#{filtered_query}')").
  9 + order("ts_rank(to_tsvector('simple', #{pg_search_plugin_fields}), to_tsquery('#{filtered_query}')) DESC")
  10 + else
  11 + raise "No searchable fields defined for #{self.name}"
  12 + end
  13 + end
  14 +
  15 + def self.pg_search_plugin_fields
  16 + self::SEARCHABLE_FIELDS.keys.map(&:to_s).sort.map {|f| "coalesce(#{table_name}.#{f}, '')"}.join(" || ' ' || ")
  17 + end
  18 +
  19 +end
plugins/profile_members_headlines/views/blocks/headlines.html.erb
@@ -15,7 +15,7 @@ @@ -15,7 +15,7 @@
15 <%= show_date(headline.published_at) %> 15 <%= show_date(headline.published_at) %>
16 </div> 16 </div>
17 <div class='tags'> 17 <div class='tags'>
18 - <%= headline.tags.map { |t| link_to(t, :controller => 'profile', :profile => member.identifier, :action => 'tags', :id => t.name ) }.join("\n") %> 18 + <%= safe_join(headline.tags.map { |t| link_to(t, :controller => 'profile', :profile => member.identifier, :action => 'tags', :id => t.name ) }, "\n") %>
19 </div> 19 </div>
20 </div> 20 </div>
21 </div> 21 </div>
plugins/push_notification/lib/device_token.rb
1 -class PushNotificationPlugin::DeviceToken < ActiveRecord::Base 1 +class PushNotificationPlugin::DeviceToken < ApplicationRecord
2 belongs_to :user 2 belongs_to :user
3 attr_accessible :token, :device_name, :user 3 attr_accessible :token, :device_name, :user
4 4
plugins/push_notification/lib/notification_settings.rb
1 -class PushNotificationPlugin::NotificationSettings < ActiveRecord::Base 1 +class PushNotificationPlugin::NotificationSettings < ApplicationRecord
2 2
3 NOTIFICATIONS= { 3 NOTIFICATIONS= {
4 "add_friend" => 0x1, 4 "add_friend" => 0x1,
plugins/push_notification/lib/notification_subscription.rb
1 -class PushNotificationPlugin::NotificationSubscription < ActiveRecord::Base 1 +class PushNotificationPlugin::NotificationSubscription < ApplicationRecord
  2 +
2 belongs_to :environment 3 belongs_to :environment
3 attr_accessible :subscribers, :notification, :environment 4 attr_accessible :subscribers, :notification, :environment
4 5
plugins/push_notification/test/api/api_test.rb 0 → 100644
@@ -0,0 +1,178 @@ @@ -0,0 +1,178 @@
  1 +require_relative '../../../../test/api/test_helper'
  2 +
  3 +class PushNotificationApiTest < ActiveSupport::TestCase
  4 +
  5 + def setup
  6 + login_api
  7 + environment = Environment.default
  8 + environment.enable_plugin(PushNotificationPlugin)
  9 + end
  10 +
  11 + should 'list all my device tokens' do
  12 + logged_user = @user
  13 + token1 = PushNotificationPlugin::DeviceToken.create!(:token => "firsttoken", device_name: "my device", :user => logged_user)
  14 + token2 = PushNotificationPlugin::DeviceToken.create!(:token => "secondtoken", device_name: "my device", :user => logged_user)
  15 +
  16 + get "/api/v1/push_notification_plugin/device_tokens?#{params.to_query}"
  17 + json = JSON.parse(last_response.body)
  18 + assert_equivalent [token1.token, token2.token], json
  19 + end
  20 +
  21 + should 'not list other people device tokens' do
  22 + user = User.create!(:login => 'outro', :email => 'outro@example.com', :password => 'outro', :password_confirmation => 'outro', :environment => Environment.default)
  23 + user.activate
  24 + PushNotificationPlugin::DeviceToken.create!(:token => "firsttoken", device_name: "my device", :user => user)
  25 + get "/api/v1/push_notification_plugin/device_tokens?#{params.merge(:target_id => user.id).to_query}"
  26 + assert_equal 401, last_response.status
  27 + end
  28 +
  29 + should 'admin see other user\'s device tokens' do
  30 + logged_user = @user
  31 + Environment.default.add_admin(logged_user.person)
  32 + logged_user.reload
  33 +
  34 + user = User.create!(:login => 'outro', :email => 'outro@example.com', :password => 'outro', :password_confirmation => 'outro', :environment => Environment.default)
  35 + user.activate
  36 +
  37 + token1 = PushNotificationPlugin::DeviceToken.create!(:token => "firsttoken", device_name: "my device", :user => user)
  38 +
  39 + get "/api/v1/push_notification_plugin/device_tokens?#{params.merge(:target_id => user.id).to_query}"
  40 + json = JSON.parse(last_response.body)
  41 + assert_equivalent [token1.token], json
  42 + end
  43 +
  44 +#------------------------------------------------------------------------------------------------------
  45 +
  46 + should 'add my device token' do
  47 + params.merge!(:device_name => "my_device", :token => "token1")
  48 + post "/api/v1/push_notification_plugin/device_tokens?#{params.to_query}"
  49 + json = JSON.parse(last_response.body)
  50 + assert_equivalent ["token1"], json["user"]["device_tokens"]
  51 + end
  52 +
  53 + should 'not add device tokens for other people' do
  54 + user = User.create!(:login => 'outro', :email => 'outro@example.com', :password => 'outro', :password_confirmation => 'outro', :environment => Environment.default)
  55 + user.activate
  56 + params.merge!(:device_name => "my_device", :token => "tokenX", :target_id => user.id)
  57 + post "/api/v1/push_notification_plugin/device_tokens?#{params.to_query}"
  58 + assert_equal 401, last_response.status
  59 + end
  60 +
  61 + should 'admin add device tokens for other users' do
  62 + logged_user = @user
  63 + Environment.default.add_admin(logged_user.person)
  64 + logged_user.reload
  65 +
  66 + user = User.create!(:login => 'outro', :email => 'outro@example.com', :password => 'outro', :password_confirmation => 'outro', :environment => Environment.default)
  67 + user.activate
  68 +
  69 + params.merge!(:device_name => "my_device", :token=> "tokenY", :target_id => user.id)
  70 + post "/api/v1/push_notification_plugin/device_tokens?#{params.to_query}"
  71 +
  72 + json = JSON.parse(last_response.body)
  73 + assert_equivalent ["tokenY"], json["user"]["device_tokens"]
  74 + end
  75 +
  76 +#------------------------------------------------------------------------------------------------------
  77 +
  78 + should 'delete my device tokens' do
  79 + logged_user = @user
  80 + PushNotificationPlugin::DeviceToken.create!(:token => "firsttoken", device_name: "my device", :user => logged_user)
  81 + PushNotificationPlugin::DeviceToken.create!(:token => "secondtoken", device_name: "my device", :user => logged_user)
  82 +
  83 + params.merge!(:token => "secondtoken")
  84 + delete "/api/v1/push_notification_plugin/device_tokens?#{params.to_query}"
  85 + json = JSON.parse(last_response.body)
  86 + assert_equivalent ["firsttoken"], json["user"]["device_tokens"]
  87 + end
  88 +
  89 + should 'not delete device tokens for other people' do
  90 + user = User.create!(:login => 'outro', :email => 'outro@example.com', :password => 'outro', :password_confirmation => 'outro', :environment => Environment.default)
  91 + user.activate
  92 +
  93 + PushNotificationPlugin::DeviceToken.create!(:token => "secondtoken", device_name: "my device", :user => user)
  94 + user.reload
  95 +
  96 + params.merge!(:token => "secondtoken", :target_id => user.id)
  97 + delete "/api/v1/push_notification_plugin/device_tokens?#{params.to_query}"
  98 + assert_equal 401, last_response.status
  99 + assert_equivalent user.device_token_list, ["secondtoken"]
  100 + end
  101 +
  102 + should 'admin delete device tokens for other users' do
  103 + logged_user = @user
  104 + Environment.default.add_admin(logged_user.person)
  105 + logged_user.reload
  106 +
  107 + user = User.create!(:login => 'outro', :email => 'outro@example.com', :password => 'outro', :password_confirmation => 'outro', :environment => Environment.default)
  108 + user.activate
  109 +
  110 + PushNotificationPlugin::DeviceToken.create!(:token => "firsttoken", device_name: "my device", :user => user)
  111 + PushNotificationPlugin::DeviceToken.create!(:token => "secondtoken", device_name: "my device", :user => user)
  112 + user.reload
  113 +
  114 + params.merge!(:token=> "secondtoken", :target_id => user.id)
  115 + delete "/api/v1/push_notification_plugin/device_tokens?#{params.to_query}"
  116 +
  117 + json = JSON.parse(last_response.body)
  118 + assert_equivalent ["firsttoken"], json["user"]["device_tokens"]
  119 + end
  120 +
  121 +#--------------------------------------------------------------------------------------------------------------------------------------------
  122 +
  123 + should 'list all notifications disabled by default for new users' do
  124 + get "/api/v1/push_notification_plugin/notification_settings?#{params.to_query}"
  125 + json = JSON.parse(last_response.body)
  126 + json["user"]["notification_settings"].each_pair do |notification, status|
  127 + refute status
  128 + end
  129 + end
  130 +
  131 + should 'list device tokens notification options' do
  132 + logged_user = @user
  133 + logged_user.notification_settings.activate_notification "new_comment"
  134 + logged_user.save!
  135 +
  136 + get "/api/v1/push_notification_plugin/notification_settings?#{params.to_query}"
  137 + json = JSON.parse(last_response.body)
  138 + assert_equal true, json["user"]["notification_settings"]["new_comment"]
  139 + assert_equal false, json["user"]["notification_settings"]["add_friend"]
  140 + end
  141 +
  142 + should 'get possible notifications' do
  143 + get "/api/v1/push_notification_plugin/possible_notifications?#{params.to_query}"
  144 + json = JSON.parse(last_response.body)
  145 + assert_equivalent PushNotificationPlugin::NotificationSettings::NOTIFICATIONS.keys, json["possible_notifications"]
  146 + end
  147 +
  148 + should 'change device tokens notification options' do
  149 + logged_user = @user
  150 + params.merge!("new_comment"=> "true")
  151 +
  152 + post "/api/v1/push_notification_plugin/notification_settings?#{params.to_query}"
  153 + logged_user.reload
  154 + json = JSON.parse(last_response.body)
  155 + assert_equal true, json["user"]["notification_settings"]["new_comment"]
  156 + assert_equal true, logged_user.notification_settings.hash_flags["new_comment"]
  157 + end
  158 +
  159 + should 'get active notifications list' do
  160 + logged_user = @user
  161 + logged_user.notification_settings.activate_notification "new_comment"
  162 + logged_user.save!
  163 +
  164 + get "/api/v1/push_notification_plugin/active_notifications?#{params.to_query}"
  165 + json = JSON.parse(last_response.body)
  166 + assert_equivalent ["new_comment"], json
  167 + end
  168 +
  169 + should 'get inactive notifications list' do
  170 + logged_user = @user
  171 + logged_user.notification_settings.activate_notification "new_comment"
  172 + logged_user.save
  173 +
  174 + get "/api/v1/push_notification_plugin/inactive_notifications?#{params.to_query}"
  175 + json = JSON.parse(last_response.body)
  176 + assert_equivalent (PushNotificationPlugin::NotificationSettings::NOTIFICATIONS.keys-["new_comment"]), json
  177 + end
  178 +end
plugins/push_notification/test/unit/api_test.rb
@@ -1,178 +0,0 @@ @@ -1,178 +0,0 @@
1 -require_relative '../../../../test/unit/api/test_helper'  
2 -  
3 -class PushNotificationApiTest < ActiveSupport::TestCase  
4 -  
5 - def setup  
6 - login_api  
7 - environment = Environment.default  
8 - environment.enable_plugin(PushNotificationPlugin)  
9 - end  
10 -  
11 - should 'list all my device tokens' do  
12 - logged_user = @user  
13 - token1 = PushNotificationPlugin::DeviceToken.create!(:token => "firsttoken", device_name: "my device", :user => logged_user)  
14 - token2 = PushNotificationPlugin::DeviceToken.create!(:token => "secondtoken", device_name: "my device", :user => logged_user)  
15 -  
16 - get "/api/v1/push_notification_plugin/device_tokens?#{params.to_query}"  
17 - json = JSON.parse(last_response.body)  
18 - assert_equivalent [token1.token, token2.token], json  
19 - end  
20 -  
21 - should 'not list other people device tokens' do  
22 - user = User.create!(:login => 'outro', :email => 'outro@example.com', :password => 'outro', :password_confirmation => 'outro', :environment => Environment.default)  
23 - user.activate  
24 - PushNotificationPlugin::DeviceToken.create!(:token => "firsttoken", device_name: "my device", :user => user)  
25 - get "/api/v1/push_notification_plugin/device_tokens?#{params.merge(:target_id => user.id).to_query}"  
26 - assert_equal 401, last_response.status  
27 - end  
28 -  
29 - should 'admin see other user\'s device tokens' do  
30 - logged_user = @user  
31 - Environment.default.add_admin(logged_user.person)  
32 - logged_user.reload  
33 -  
34 - user = User.create!(:login => 'outro', :email => 'outro@example.com', :password => 'outro', :password_confirmation => 'outro', :environment => Environment.default)  
35 - user.activate  
36 -  
37 - token1 = PushNotificationPlugin::DeviceToken.create!(:token => "firsttoken", device_name: "my device", :user => user)  
38 -  
39 - get "/api/v1/push_notification_plugin/device_tokens?#{params.merge(:target_id => user.id).to_query}"  
40 - json = JSON.parse(last_response.body)  
41 - assert_equivalent [token1.token], json  
42 - end  
43 -  
44 -#------------------------------------------------------------------------------------------------------  
45 -  
46 - should 'add my device token' do  
47 - params.merge!(:device_name => "my_device", :token => "token1")  
48 - post "/api/v1/push_notification_plugin/device_tokens?#{params.to_query}"  
49 - json = JSON.parse(last_response.body)  
50 - assert_equivalent ["token1"], json["user"]["device_tokens"]  
51 - end  
52 -  
53 - should 'not add device tokens for other people' do  
54 - user = User.create!(:login => 'outro', :email => 'outro@example.com', :password => 'outro', :password_confirmation => 'outro', :environment => Environment.default)  
55 - user.activate  
56 - params.merge!(:device_name => "my_device", :token => "tokenX", :target_id => user.id)  
57 - post "/api/v1/push_notification_plugin/device_tokens?#{params.to_query}"  
58 - assert_equal 401, last_response.status  
59 - end  
60 -  
61 - should 'admin add device tokens for other users' do  
62 - logged_user = @user  
63 - Environment.default.add_admin(logged_user.person)  
64 - logged_user.reload  
65 -  
66 - user = User.create!(:login => 'outro', :email => 'outro@example.com', :password => 'outro', :password_confirmation => 'outro', :environment => Environment.default)  
67 - user.activate  
68 -  
69 - params.merge!(:device_name => "my_device", :token=> "tokenY", :target_id => user.id)  
70 - post "/api/v1/push_notification_plugin/device_tokens?#{params.to_query}"  
71 -  
72 - json = JSON.parse(last_response.body)  
73 - assert_equivalent ["tokenY"], json["user"]["device_tokens"]  
74 - end  
75 -  
76 -#------------------------------------------------------------------------------------------------------  
77 -  
78 - should 'delete my device tokens' do  
79 - logged_user = @user  
80 - PushNotificationPlugin::DeviceToken.create!(:token => "firsttoken", device_name: "my device", :user => logged_user)  
81 - PushNotificationPlugin::DeviceToken.create!(:token => "secondtoken", device_name: "my device", :user => logged_user)  
82 -  
83 - params.merge!(:token => "secondtoken")  
84 - delete "/api/v1/push_notification_plugin/device_tokens?#{params.to_query}"  
85 - json = JSON.parse(last_response.body)  
86 - assert_equivalent ["firsttoken"], json["user"]["device_tokens"]  
87 - end  
88 -  
89 - should 'not delete device tokens for other people' do  
90 - user = User.create!(:login => 'outro', :email => 'outro@example.com', :password => 'outro', :password_confirmation => 'outro', :environment => Environment.default)  
91 - user.activate  
92 -  
93 - PushNotificationPlugin::DeviceToken.create!(:token => "secondtoken", device_name: "my device", :user => user)  
94 - user.reload  
95 -  
96 - params.merge!(:token => "secondtoken", :target_id => user.id)  
97 - delete "/api/v1/push_notification_plugin/device_tokens?#{params.to_query}"  
98 - assert_equal 401, last_response.status  
99 - assert_equivalent user.device_token_list, ["secondtoken"]  
100 - end  
101 -  
102 - should 'admin delete device tokens for other users' do  
103 - logged_user = @user  
104 - Environment.default.add_admin(logged_user.person)  
105 - logged_user.reload  
106 -  
107 - user = User.create!(:login => 'outro', :email => 'outro@example.com', :password => 'outro', :password_confirmation => 'outro', :environment => Environment.default)  
108 - user.activate  
109 -  
110 - PushNotificationPlugin::DeviceToken.create!(:token => "firsttoken", device_name: "my device", :user => user)  
111 - PushNotificationPlugin::DeviceToken.create!(:token => "secondtoken", device_name: "my device", :user => user)  
112 - user.reload  
113 -  
114 - params.merge!(:token=> "secondtoken", :target_id => user.id)  
115 - delete "/api/v1/push_notification_plugin/device_tokens?#{params.to_query}"  
116 -  
117 - json = JSON.parse(last_response.body)  
118 - assert_equivalent ["firsttoken"], json["user"]["device_tokens"]  
119 - end  
120 -  
121 -#--------------------------------------------------------------------------------------------------------------------------------------------  
122 -  
123 - should 'list all notifications disabled by default for new users' do  
124 - get "/api/v1/push_notification_plugin/notification_settings?#{params.to_query}"  
125 - json = JSON.parse(last_response.body)  
126 - json["user"]["notification_settings"].each_pair do |notification, status|  
127 - refute status  
128 - end  
129 - end  
130 -  
131 - should 'list device tokens notification options' do  
132 - logged_user = @user  
133 - logged_user.notification_settings.activate_notification "new_comment"  
134 - logged_user.save!  
135 -  
136 - get "/api/v1/push_notification_plugin/notification_settings?#{params.to_query}"  
137 - json = JSON.parse(last_response.body)  
138 - assert_equal true, json["user"]["notification_settings"]["new_comment"]  
139 - assert_equal false, json["user"]["notification_settings"]["add_friend"]  
140 - end  
141 -  
142 - should 'get possible notifications' do  
143 - get "/api/v1/push_notification_plugin/possible_notifications?#{params.to_query}"  
144 - json = JSON.parse(last_response.body)  
145 - assert_equivalent PushNotificationPlugin::NotificationSettings::NOTIFICATIONS.keys, json["possible_notifications"]  
146 - end  
147 -  
148 - should 'change device tokens notification options' do  
149 - logged_user = @user  
150 - params.merge!("new_comment"=> "true")  
151 -  
152 - post "/api/v1/push_notification_plugin/notification_settings?#{params.to_query}"  
153 - logged_user.reload  
154 - json = JSON.parse(last_response.body)  
155 - assert_equal true, json["user"]["notification_settings"]["new_comment"]  
156 - assert_equal true, logged_user.notification_settings.hash_flags["new_comment"]  
157 - end  
158 -  
159 - should 'get active notifications list' do  
160 - logged_user = @user  
161 - logged_user.notification_settings.activate_notification "new_comment"  
162 - logged_user.save!  
163 -  
164 - get "/api/v1/push_notification_plugin/active_notifications?#{params.to_query}"  
165 - json = JSON.parse(last_response.body)  
166 - assert_equivalent ["new_comment"], json  
167 - end  
168 -  
169 - should 'get inactive notifications list' do  
170 - logged_user = @user  
171 - logged_user.notification_settings.activate_notification "new_comment"  
172 - logged_user.save  
173 -  
174 - get "/api/v1/push_notification_plugin/inactive_notifications?#{params.to_query}"  
175 - json = JSON.parse(last_response.body)  
176 - assert_equivalent (PushNotificationPlugin::NotificationSettings::NOTIFICATIONS.keys-["new_comment"]), json  
177 - end  
178 -end  
plugins/relevant_content/lib/relevant_content_plugin/relevant_content_block.rb
@@ -83,7 +83,7 @@ class RelevantContentPlugin::RelevantContentBlock &lt; Block @@ -83,7 +83,7 @@ class RelevantContentPlugin::RelevantContentBlock &lt; Block
83 end 83 end
84 end 84 end
85 end 85 end
86 - return content 86 + return content.html_safe
87 end 87 end
88 88
89 def timeout 89 def timeout
plugins/require_auth_to_comment/lib/require_auth_to_comment_plugin.rb
@@ -17,7 +17,7 @@ class RequireAuthToCommentPlugin &lt; Noosfero::Plugin @@ -17,7 +17,7 @@ class RequireAuthToCommentPlugin &lt; Noosfero::Plugin
17 end 17 end
18 18
19 def profile_editor_extras 19 def profile_editor_extras
20 - expanded_template('profile-editor-extras.html.erb') 20 + expanded_template('profile-editor-extras.html.erb').html_safe
21 end 21 end
22 22
23 def stylesheet? 23 def stylesheet?
plugins/shopping_cart/db/migrate/20131226125124_move_shopping_cart_purchase_order_to_orders_plugin_order.rb
1 OrdersPlugin.send :remove_const, :Item if defined? OrdersPlugin::Item 1 OrdersPlugin.send :remove_const, :Item if defined? OrdersPlugin::Item
2 OrdersPlugin.send :remove_const, :Order if defined? OrdersPlugin::Order 2 OrdersPlugin.send :remove_const, :Order if defined? OrdersPlugin::Order
3 3
4 -class ShoppingCartPlugin::PurchaseOrder < ActiveRecord::Base 4 +class ShoppingCartPlugin::PurchaseOrder < ApplicationRecord
5 acts_as_having_settings field: :data 5 acts_as_having_settings field: :data
6 6
7 module Status 7 module Status
@@ -16,10 +16,10 @@ class Profile @@ -16,10 +16,10 @@ class Profile
16 has_many :orders, class_name: 'OrdersPlugin::Order' 16 has_many :orders, class_name: 'OrdersPlugin::Order'
17 end 17 end
18 18
19 -class OrdersPlugin::Item < ActiveRecord::Base 19 +class OrdersPlugin::Item < ApplicationRecord
20 belongs_to :order, class_name: 'OrdersPlugin::Order' 20 belongs_to :order, class_name: 'OrdersPlugin::Order'
21 end 21 end
22 -class OrdersPlugin::Order < ActiveRecord::Base 22 +class OrdersPlugin::Order < ApplicationRecord
23 has_many :items, class_name: 'OrdersPlugin::Item', foreign_key: :order_id 23 has_many :items, class_name: 'OrdersPlugin::Item', foreign_key: :order_id
24 24
25 extend CodeNumbering::ClassMethods 25 extend CodeNumbering::ClassMethods
plugins/shopping_cart/po/ru/shopping_cart.po
@@ -7,17 +7,17 @@ msgid &quot;&quot; @@ -7,17 +7,17 @@ msgid &quot;&quot;
7 msgstr "" 7 msgstr ""
8 "Project-Id-Version: 1.3~rc2-1-ga15645d\n" 8 "Project-Id-Version: 1.3~rc2-1-ga15645d\n"
9 "POT-Creation-Date: 2015-10-30 16:34-0300\n" 9 "POT-Creation-Date: 2015-10-30 16:34-0300\n"
10 -"PO-Revision-Date: 2015-02-23 11:36+0200\n"  
11 -"Last-Translator: Michal Čihař <michal@cihar.com>\n" 10 +"PO-Revision-Date: 2016-04-21 01:21+0000\n"
  11 +"Last-Translator: Iryna Pruitt <jdpruitt2807@prodigy.net>\n"
12 "Language-Team: Russian <https://hosted.weblate.org/projects/noosfero/plugin-" 12 "Language-Team: Russian <https://hosted.weblate.org/projects/noosfero/plugin-"
13 "shopping-cart/ru/>\n" 13 "shopping-cart/ru/>\n"
14 "Language: ru\n" 14 "Language: ru\n"
15 "MIME-Version: 1.0\n" 15 "MIME-Version: 1.0\n"
16 "Content-Type: text/plain; charset=UTF-8\n" 16 "Content-Type: text/plain; charset=UTF-8\n"
17 "Content-Transfer-Encoding: 8bit\n" 17 "Content-Transfer-Encoding: 8bit\n"
18 -"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"  
19 -"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"  
20 -"X-Generator: Weblate 2.3-dev\n" 18 +"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<="
  19 +"4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
  20 +"X-Generator: Weblate 2.6-dev\n"
21 21
22 #: plugins/shopping_cart/lib/shopping_cart_plugin.rb:10 22 #: plugins/shopping_cart/lib/shopping_cart_plugin.rb:10
23 #, fuzzy 23 #, fuzzy
@@ -30,9 +30,8 @@ msgid &quot;Shopping basket&quot; @@ -30,9 +30,8 @@ msgid &quot;Shopping basket&quot;
30 msgstr "Учебный статус" 30 msgstr "Учебный статус"
31 31
32 #: plugins/shopping_cart/lib/shopping_cart_plugin/cart_helper.rb:11 32 #: plugins/shopping_cart/lib/shopping_cart_plugin/cart_helper.rb:11
33 -#, fuzzy  
34 msgid "Add to basket" 33 msgid "Add to basket"
35 -msgstr "Добавить контакт" 34 +msgstr "Добавить в корзину"
36 35
37 #: plugins/shopping_cart/lib/shopping_cart_plugin/mailer.rb:20 36 #: plugins/shopping_cart/lib/shopping_cart_plugin/mailer.rb:20
38 #, fuzzy 37 #, fuzzy
@@ -48,20 +47,19 @@ msgid &quot;&quot; @@ -48,20 +47,19 @@ msgid &quot;&quot;
48 "Your order has been sent successfully! You will receive a confirmation e-" 47 "Your order has been sent successfully! You will receive a confirmation e-"
49 "mail shortly." 48 "mail shortly."
50 msgstr "" 49 msgstr ""
  50 +"Ваш заказ был успешно отправлен! Вы получите подтверждение через минуту."
51 51
52 #: plugins/shopping_cart/controllers/shopping_cart_plugin_controller.rb:158 52 #: plugins/shopping_cart/controllers/shopping_cart_plugin_controller.rb:158
53 -#, fuzzy  
54 msgid "Basket displayed." 53 msgid "Basket displayed."
55 -msgstr "Не отображать" 54 +msgstr "Изображение корзины"
56 55
57 #: plugins/shopping_cart/controllers/shopping_cart_plugin_controller.rb:177 56 #: plugins/shopping_cart/controllers/shopping_cart_plugin_controller.rb:177
58 msgid "Basket hidden." 57 msgid "Basket hidden."
59 -msgstr "" 58 +msgstr "Спрятать корзину"
60 59
61 #: plugins/shopping_cart/controllers/shopping_cart_plugin_controller.rb:200 60 #: plugins/shopping_cart/controllers/shopping_cart_plugin_controller.rb:200
62 -#, fuzzy  
63 msgid "Delivery option updated." 61 msgid "Delivery option updated."
64 -msgstr "Уничтожить профиль" 62 +msgstr "Способы отправки обновлены."
65 63
66 #: plugins/shopping_cart/controllers/shopping_cart_plugin_controller.rb:218 64 #: plugins/shopping_cart/controllers/shopping_cart_plugin_controller.rb:218
67 msgid "" 65 msgid ""
@@ -70,9 +68,8 @@ msgid &quot;&quot; @@ -70,9 +68,8 @@ msgid &quot;&quot;
70 msgstr "" 68 msgstr ""
71 69
72 #: plugins/shopping_cart/controllers/shopping_cart_plugin_controller.rb:232 70 #: plugins/shopping_cart/controllers/shopping_cart_plugin_controller.rb:232
73 -#, fuzzy  
74 msgid "There is no basket." 71 msgid "There is no basket."
75 -msgstr "Нет категорий" 72 +msgstr "Нет корзины."
76 73
77 #: plugins/shopping_cart/controllers/shopping_cart_plugin_controller.rb:248 74 #: plugins/shopping_cart/controllers/shopping_cart_plugin_controller.rb:248
78 #, fuzzy 75 #, fuzzy
@@ -86,7 +83,7 @@ msgstr &quot;Компания не может быть активирована&quot; @@ -86,7 +83,7 @@ msgstr &quot;Компания не может быть активирована&quot;
86 83
87 #: plugins/shopping_cart/controllers/shopping_cart_plugin_controller.rb:276 84 #: plugins/shopping_cart/controllers/shopping_cart_plugin_controller.rb:276
88 msgid "Invalid quantity." 85 msgid "Invalid quantity."
89 -msgstr "" 86 +msgstr "Недействительное количество."
90 87
91 #: plugins/shopping_cart/controllers/shopping_cart_plugin_controller.rb:364 88 #: plugins/shopping_cart/controllers/shopping_cart_plugin_controller.rb:364
92 #, fuzzy 89 #, fuzzy
@@ -94,14 +91,12 @@ msgid &quot;Undefined product&quot; @@ -94,14 +91,12 @@ msgid &quot;Undefined product&quot;
94 msgstr "Продукт без категории" 91 msgstr "Продукт без категории"
95 92
96 #: plugins/shopping_cart/controllers/shopping_cart_plugin_controller.rb:366 93 #: plugins/shopping_cart/controllers/shopping_cart_plugin_controller.rb:366
97 -#, fuzzy  
98 msgid "Wrong product id" 94 msgid "Wrong product id"
99 -msgstr "Нет продукта" 95 +msgstr "Неправильная категория товара"
100 96
101 #: plugins/shopping_cart/views/shopping_cart_plugin_myprofile/edit.html.erb:1 97 #: plugins/shopping_cart/views/shopping_cart_plugin_myprofile/edit.html.erb:1
102 -#, fuzzy  
103 msgid "Basket options" 98 msgid "Basket options"
104 -msgstr "Еще опции" 99 +msgstr "Опции корзины"
105 100
106 #: plugins/shopping_cart/views/shopping_cart_plugin_myprofile/edit.html.erb:7 101 #: plugins/shopping_cart/views/shopping_cart_plugin_myprofile/edit.html.erb:7
107 #, fuzzy 102 #, fuzzy
@@ -109,86 +104,75 @@ msgid &quot;Enable shopping basket&quot; @@ -109,86 +104,75 @@ msgid &quot;Enable shopping basket&quot;
109 msgstr "Учебный статус" 104 msgstr "Учебный статус"
110 105
111 #: plugins/shopping_cart/views/shopping_cart_plugin_myprofile/edit.html.erb:13 106 #: plugins/shopping_cart/views/shopping_cart_plugin_myprofile/edit.html.erb:13
112 -#, fuzzy  
113 msgid "Deliveries or pickups" 107 msgid "Deliveries or pickups"
114 -msgstr "Уничтожить профиль" 108 +msgstr "Доставка или получение на месте"
115 109
116 #: plugins/shopping_cart/views/public/_cart.html.erb:6 110 #: plugins/shopping_cart/views/public/_cart.html.erb:6
117 #: plugins/shopping_cart/views/public/_cart.html.erb:19 111 #: plugins/shopping_cart/views/public/_cart.html.erb:19
118 #: plugins/shopping_cart/views/shopping_cart_plugin/buy.html.erb:3 112 #: plugins/shopping_cart/views/shopping_cart_plugin/buy.html.erb:3
119 -#, fuzzy  
120 msgid "Shopping checkout" 113 msgid "Shopping checkout"
121 -msgstr "Учебный статус" 114 +msgstr "Оформление и оплата заказа"
122 115
123 #: plugins/shopping_cart/views/public/_cart.html.erb:8 116 #: plugins/shopping_cart/views/public/_cart.html.erb:8
124 -#, fuzzy  
125 msgid "Basket is empty" 117 msgid "Basket is empty"
126 -msgstr "Не отображать" 118 +msgstr "Корзина пуста"
127 119
128 #: plugins/shopping_cart/views/public/_cart.html.erb:14 120 #: plugins/shopping_cart/views/public/_cart.html.erb:14
129 msgid "Basket" 121 msgid "Basket"
130 -msgstr "" 122 +msgstr "Корзина"
131 123
132 #: plugins/shopping_cart/views/public/_cart.html.erb:16 124 #: plugins/shopping_cart/views/public/_cart.html.erb:16
133 -#, fuzzy  
134 msgid "Clean basket" 125 msgid "Clean basket"
135 -msgstr "Открыть чат" 126 +msgstr "Чистая корзина"
136 127
137 #: plugins/shopping_cart/views/public/_cart.html.erb:20 128 #: plugins/shopping_cart/views/public/_cart.html.erb:20
138 #: plugins/shopping_cart/views/shopping_cart_plugin/_items.html.erb:42 129 #: plugins/shopping_cart/views/shopping_cart_plugin/_items.html.erb:42
139 -#, fuzzy  
140 msgid "Total:" 130 msgid "Total:"
141 -msgstr "Получатель:" 131 +msgstr "Всего:"
142 132
143 #: plugins/shopping_cart/views/public/_cart.html.erb:23 133 #: plugins/shopping_cart/views/public/_cart.html.erb:23
144 -#, fuzzy  
145 msgid "Show basket" 134 msgid "Show basket"
146 -msgstr "Учебный статус" 135 +msgstr "Показать корзину"
147 136
148 #: plugins/shopping_cart/views/public/_cart.html.erb:24 137 #: plugins/shopping_cart/views/public/_cart.html.erb:24
149 -#, fuzzy  
150 msgid "Hide basket" 138 msgid "Hide basket"
151 -msgstr "Спрятать" 139 +msgstr "Спрятать корзину"
152 140
153 #: plugins/shopping_cart/views/public/_cart.html.erb:44 141 #: plugins/shopping_cart/views/public/_cart.html.erb:44
154 msgid "Ups... I had a problem to load the basket list." 142 msgid "Ups... I had a problem to load the basket list."
155 -msgstr "" 143 +msgstr "Ой... Проблема с загрузкой списка корзины."
156 144
157 #: plugins/shopping_cart/views/public/_cart.html.erb:46 145 #: plugins/shopping_cart/views/public/_cart.html.erb:46
158 -#, fuzzy  
159 msgid "Did you want to reload this page?" 146 msgid "Did you want to reload this page?"
160 -msgstr "Хотите присоединиться к группе?" 147 +msgstr "Хотите перезагрузить эту страницу?"
161 148
162 #: plugins/shopping_cart/views/public/_cart.html.erb:49 149 #: plugins/shopping_cart/views/public/_cart.html.erb:49
163 msgid "Sorry, you can't have more then 100 kinds of items on this basket." 150 msgid "Sorry, you can't have more then 100 kinds of items on this basket."
164 -msgstr "" 151 +msgstr "Извините, но в корзине не может быть более 100 товаров."
165 152
166 #: plugins/shopping_cart/views/public/_cart.html.erb:51 153 #: plugins/shopping_cart/views/public/_cart.html.erb:51
167 msgid "Oops, you must wait your last request to finish first!" 154 msgid "Oops, you must wait your last request to finish first!"
168 msgstr "" 155 msgstr ""
169 156
170 #: plugins/shopping_cart/views/public/_cart.html.erb:52 157 #: plugins/shopping_cart/views/public/_cart.html.erb:52
171 -#, fuzzy  
172 msgid "Are you sure you want to remove this item?" 158 msgid "Are you sure you want to remove this item?"
173 -msgstr "Вы уверены что хотите удалить этот элемент?" 159 +msgstr "Вы уверены, что хотите удалить этот товар?"
174 160
175 #: plugins/shopping_cart/views/public/_cart.html.erb:53 161 #: plugins/shopping_cart/views/public/_cart.html.erb:53
176 -#, fuzzy  
177 msgid "Are you sure you want to clean your basket?" 162 msgid "Are you sure you want to clean your basket?"
178 -msgstr "Вы уверены что хотите выйти?" 163 +msgstr "Вы уверены, что хотите удалить все из корзины?"
179 164
180 #: plugins/shopping_cart/views/public/_cart.html.erb:54 165 #: plugins/shopping_cart/views/public/_cart.html.erb:54
181 msgid "repeat order" 166 msgid "repeat order"
182 -msgstr "" 167 +msgstr "Повторить заказ"
183 168
184 #: plugins/shopping_cart/views/shopping_cart_plugin/_items.html.erb:7 169 #: plugins/shopping_cart/views/shopping_cart_plugin/_items.html.erb:7
185 -#, fuzzy  
186 msgid "Item name" 170 msgid "Item name"
187 -msgstr "Имя файла" 171 +msgstr "Название товара"
188 172
189 #: plugins/shopping_cart/views/shopping_cart_plugin/_items.html.erb:13 173 #: plugins/shopping_cart/views/shopping_cart_plugin/_items.html.erb:13
190 msgid "Price" 174 msgid "Price"
191 -msgstr "" 175 +msgstr "Цена"
192 176
193 #: plugins/shopping_cart/views/shopping_cart_plugin/mailer/customer_notification.html.erb:7 177 #: plugins/shopping_cart/views/shopping_cart_plugin/mailer/customer_notification.html.erb:7
194 #: plugins/shopping_cart/views/shopping_cart_plugin/mailer/supplier_notification.html.erb:7 178 #: plugins/shopping_cart/views/shopping_cart_plugin/mailer/supplier_notification.html.erb:7
@@ -207,45 +191,40 @@ msgid &quot;&quot; @@ -207,45 +191,40 @@ msgid &quot;&quot;
207 msgstr "" 191 msgstr ""
208 192
209 #: plugins/shopping_cart/views/shopping_cart_plugin/mailer/customer_notification.html.erb:12 193 #: plugins/shopping_cart/views/shopping_cart_plugin/mailer/customer_notification.html.erb:12
210 -#, fuzzy  
211 msgid "If you have any doubts about your order, write to us at: %s." 194 msgid "If you have any doubts about your order, write to us at: %s."
212 -msgstr "У вас еще нет контактов" 195 +msgstr "Если у вас есть какие-либо сомнения в вашем заказе, свяжитесь с нами:%."
213 196
214 #: plugins/shopping_cart/views/shopping_cart_plugin/mailer/customer_notification.html.erb:13 197 #: plugins/shopping_cart/views/shopping_cart_plugin/mailer/customer_notification.html.erb:13
215 msgid "Review below the informations of your order:" 198 msgid "Review below the informations of your order:"
216 -msgstr "" 199 +msgstr "Проверьте ваш заказ:"
217 200
218 #: plugins/shopping_cart/views/shopping_cart_plugin/mailer/customer_notification.html.erb:19 201 #: plugins/shopping_cart/views/shopping_cart_plugin/mailer/customer_notification.html.erb:19
219 #: plugins/shopping_cart/views/shopping_cart_plugin/mailer/supplier_notification.html.erb:17 202 #: plugins/shopping_cart/views/shopping_cart_plugin/mailer/supplier_notification.html.erb:17
220 -#, fuzzy  
221 msgid "Phone number" 203 msgid "Phone number"
222 -msgstr "один участник" 204 +msgstr "Номер телефона"
223 205
224 #: plugins/shopping_cart/views/shopping_cart_plugin/mailer/customer_notification.html.erb:22 206 #: plugins/shopping_cart/views/shopping_cart_plugin/mailer/customer_notification.html.erb:22
225 #: plugins/shopping_cart/views/shopping_cart_plugin/buy.html.erb:22 207 #: plugins/shopping_cart/views/shopping_cart_plugin/buy.html.erb:22
226 msgid "Payment's method" 208 msgid "Payment's method"
227 -msgstr "" 209 +msgstr "Метод оплаты"
228 210
229 #: plugins/shopping_cart/views/shopping_cart_plugin/mailer/customer_notification.html.erb:24 211 #: plugins/shopping_cart/views/shopping_cart_plugin/mailer/customer_notification.html.erb:24
230 #: plugins/shopping_cart/views/shopping_cart_plugin/mailer/supplier_notification.html.erb:22 212 #: plugins/shopping_cart/views/shopping_cart_plugin/mailer/supplier_notification.html.erb:22
231 #: plugins/shopping_cart/views/shopping_cart_plugin/buy.html.erb:26 213 #: plugins/shopping_cart/views/shopping_cart_plugin/buy.html.erb:26
232 -#, fuzzy  
233 msgid "shopping_cart|Change" 214 msgid "shopping_cart|Change"
234 -msgstr "Учебный статус" 215 +msgstr "Покупательская корзина|Изменения"
235 216
236 #: plugins/shopping_cart/views/shopping_cart_plugin/mailer/customer_notification.html.erb:28 217 #: plugins/shopping_cart/views/shopping_cart_plugin/mailer/customer_notification.html.erb:28
237 -#, fuzzy  
238 msgid "Delivery or pickup" 218 msgid "Delivery or pickup"
239 -msgstr "Уничтожить профиль" 219 +msgstr "Доставка или получение на месте"
240 220
241 #: plugins/shopping_cart/views/shopping_cart_plugin/mailer/customer_notification.html.erb:63 221 #: plugins/shopping_cart/views/shopping_cart_plugin/mailer/customer_notification.html.erb:63
242 msgid "Here are the products you bought:" 222 msgid "Here are the products you bought:"
243 -msgstr "" 223 +msgstr "Вот купленный вами товар:"
244 224
245 #: plugins/shopping_cart/views/shopping_cart_plugin/mailer/customer_notification.html.erb:67 225 #: plugins/shopping_cart/views/shopping_cart_plugin/mailer/customer_notification.html.erb:67
246 -#, fuzzy  
247 msgid "Thanks for buying with us!" 226 msgid "Thanks for buying with us!"
248 -msgstr "Спасибо за регистрацию!" 227 +msgstr "Спасибо за вашу покупку!"
249 228
250 #: plugins/shopping_cart/views/shopping_cart_plugin/mailer/customer_notification.html.erb:70 229 #: plugins/shopping_cart/views/shopping_cart_plugin/mailer/customer_notification.html.erb:70
251 #: plugins/shopping_cart/views/shopping_cart_plugin/mailer/supplier_notification.html.erb:61 230 #: plugins/shopping_cart/views/shopping_cart_plugin/mailer/supplier_notification.html.erb:61
@@ -259,28 +238,29 @@ msgstr &quot;Это републикация \&quot;%s\&quot;, от %s.&quot; @@ -259,28 +238,29 @@ msgstr &quot;Это републикация \&quot;%s\&quot;, от %s.&quot;
259 238
260 #: plugins/shopping_cart/views/shopping_cart_plugin/mailer/supplier_notification.html.erb:11 239 #: plugins/shopping_cart/views/shopping_cart_plugin/mailer/supplier_notification.html.erb:11
261 msgid "Below follows the customer informations:" 240 msgid "Below follows the customer informations:"
262 -msgstr "" 241 +msgstr "Ниже изображена информация покупателя:"
263 242
264 #: plugins/shopping_cart/views/shopping_cart_plugin/mailer/supplier_notification.html.erb:20 243 #: plugins/shopping_cart/views/shopping_cart_plugin/mailer/supplier_notification.html.erb:20
265 #: plugins/shopping_cart/views/shopping_cart_plugin/buy.html.erb:25 244 #: plugins/shopping_cart/views/shopping_cart_plugin/buy.html.erb:25
266 msgid "Payment" 245 msgid "Payment"
267 -msgstr "" 246 +msgstr "Оплата"
268 247
269 #: plugins/shopping_cart/views/shopping_cart_plugin/mailer/supplier_notification.html.erb:55 248 #: plugins/shopping_cart/views/shopping_cart_plugin/mailer/supplier_notification.html.erb:55
270 msgid "And here are the items bought by this customer:" 249 msgid "And here are the items bought by this customer:"
271 -msgstr "" 250 +msgstr "Вот товары, купленные этим покупателем:"
272 251
273 #: plugins/shopping_cart/views/shopping_cart_plugin/mailer/supplier_notification.html.erb:59 252 #: plugins/shopping_cart/views/shopping_cart_plugin/mailer/supplier_notification.html.erb:59
274 msgid "If there are any problems with this email contact the admin of %s." 253 msgid "If there are any problems with this email contact the admin of %s."
275 msgstr "" 254 msgstr ""
  255 +"Если есть проблемы с этим электронным сообщением, свяжитесь с администрацией."
276 256
277 #: plugins/shopping_cart/views/shopping_cart_plugin/buy.html.erb:4 257 #: plugins/shopping_cart/views/shopping_cart_plugin/buy.html.erb:4
278 msgid "haven't finished yet: back to shopping" 258 msgid "haven't finished yet: back to shopping"
279 -msgstr "" 259 +msgstr "еще не закончил: назад к покупкам"
280 260
281 #: plugins/shopping_cart/views/shopping_cart_plugin/buy.html.erb:12 261 #: plugins/shopping_cart/views/shopping_cart_plugin/buy.html.erb:12
282 msgid "Personal identification" 262 msgid "Personal identification"
283 -msgstr "" 263 +msgstr "Личная идентификация"
284 264
285 #: plugins/shopping_cart/views/shopping_cart_plugin/buy.html.erb:15 265 #: plugins/shopping_cart/views/shopping_cart_plugin/buy.html.erb:15
286 msgid "Name" 266 msgid "Name"
@@ -293,16 +273,15 @@ msgstr &quot;E-Mail&quot; @@ -293,16 +273,15 @@ msgstr &quot;E-Mail&quot;
293 273
294 #: plugins/shopping_cart/views/shopping_cart_plugin/buy.html.erb:17 274 #: plugins/shopping_cart/views/shopping_cart_plugin/buy.html.erb:17
295 msgid "Contact phone" 275 msgid "Contact phone"
296 -msgstr "" 276 +msgstr "Контактный телефон"
297 277
298 #: plugins/shopping_cart/views/shopping_cart_plugin/buy.html.erb:32 278 #: plugins/shopping_cart/views/shopping_cart_plugin/buy.html.erb:32
299 -#, fuzzy  
300 msgid "Delivery or pickup method" 279 msgid "Delivery or pickup method"
301 -msgstr "Уничтожить профиль" 280 +msgstr "Доставка или получение на месте"
302 281
303 #: plugins/shopping_cart/views/shopping_cart_plugin/buy.html.erb:40 282 #: plugins/shopping_cart/views/shopping_cart_plugin/buy.html.erb:40
304 msgid "Your Order" 283 msgid "Your Order"
305 -msgstr "" 284 +msgstr "Ваш заказ"
306 285
307 #: plugins/shopping_cart/views/shopping_cart_plugin/buy.html.erb:47 286 #: plugins/shopping_cart/views/shopping_cart_plugin/buy.html.erb:47
308 #, fuzzy 287 #, fuzzy
plugins/site_tour/views/tour_actions.html.erb
@@ -6,11 +6,11 @@ @@ -6,11 +6,11 @@
6 <script> 6 <script>
7 jQuery( document ).ready(function( $ ) { 7 jQuery( document ).ready(function( $ ) {
8 <% actions.each_with_index do |action, index| %> 8 <% actions.each_with_index do |action, index| %>
9 - <%= "siteTourPlugin.add('#{j action[:group_name]}', '#{j action[:selector]}', '#{j parse_tour_description(action[:description])}', #{index + 1});" %> 9 + <%= raw "siteTourPlugin.add('#{j action[:group_name]}', '#{j action[:selector]}', '#{j parse_tour_description(action[:description])}', #{index + 1});" %>
10 <% end %> 10 <% end %>
11 11
12 <% (group_triggers||[]).each do |group| %> 12 <% (group_triggers||[]).each do |group| %>
13 - <%= "siteTourPlugin.addGroupTrigger('#{j group[:group_name]}', '#{j group[:selector]}', '#{j group[:event]}');" %> 13 + <%= "siteTourPlugin.addGroupTrigger('#{j group[:group_name]}', '#{j group[:selector]}', '#{j group[:event]}');".html_safe %>
14 <% end %> 14 <% end %>
15 15
16 siteTourPlugin.setOption('nextLabel', '<%= _('Next') %>'); 16 siteTourPlugin.setOption('nextLabel', '<%= _('Next') %>');
plugins/sniffer/db/migrate/20131212124106_drop_sniffer_profile_table.rb
1 SnifferPlugin.send :remove_const, :Opportunity if defined? SnifferPlugin::Opportunity 1 SnifferPlugin.send :remove_const, :Opportunity if defined? SnifferPlugin::Opportunity
2 2
3 -class SnifferPlugin::Profile < ActiveRecord::Base 3 +class SnifferPlugin::Profile < ApplicationRecord
4 belongs_to :profile 4 belongs_to :profile
5 end 5 end
6 -class SnifferPlugin::Opportunity < ActiveRecord::Base 6 +class SnifferPlugin::Opportunity < ApplicationRecord
7 belongs_to :sniffer_profile, class_name: 'SnifferPlugin::Profile', foreign_key: :profile_id 7 belongs_to :sniffer_profile, class_name: 'SnifferPlugin::Profile', foreign_key: :profile_id
8 end 8 end
9 9
plugins/sniffer/models/sniffer_plugin/opportunity.rb
1 -class SnifferPlugin::Opportunity < ActiveRecord::Base 1 +class SnifferPlugin::Opportunity < ApplicationRecord
2 2
3 self.table_name = :sniffer_plugin_opportunities 3 self.table_name = :sniffer_plugin_opportunities
4 4
plugins/sniffer/views/sniffer_plugin_myprofile/search.html.erb
@@ -46,8 +46,8 @@ @@ -46,8 +46,8 @@
46 var currentProfile = <%= filter_visible_attr_profile(profile).to_json %>; 46 var currentProfile = <%= filter_visible_attr_profile(profile).to_json %>;
47 sniffer.search.map.load({ 47 sniffer.search.map.load({
48 "zoom": <%= GoogleMaps.initial_zoom.to_json %>, 48 "zoom": <%= GoogleMaps.initial_zoom.to_json %>,
49 - "balloonUrl": <%= url_for(:controller => :sniffer_plugin_myprofile, :action => :map_balloon, :id => "_id_", :escape => false).to_json %>,  
50 - "myBalloonUrl": <%= url_for(:controller => :sniffer_plugin_myprofile, :action => :my_map_balloon, :escape => false).to_json %>, 49 + "balloonUrl": <%= raw url_for(:controller => :sniffer_plugin_myprofile, :action => :map_balloon, :id => "_id_", :escape => false).to_json %>,
  50 + "myBalloonUrl": <%= raw url_for(:controller => :sniffer_plugin_myprofile, :action => :my_map_balloon, :escape => false).to_json %>,
51 "profiles": <%= 51 "profiles": <%=
52 @profiles_data.map do |id, profile_data| 52 @profiles_data.map do |id, profile_data|
53 data = filter_visible_attr_profile(profile_data[:profile]) 53 data = filter_visible_attr_profile(profile_data[:profile])
@@ -55,7 +55,7 @@ @@ -55,7 +55,7 @@
55 data[:suppliersProducts] = filter_visible_attr_suppliers_products(profile_data[:suppliers_products]) 55 data[:suppliersProducts] = filter_visible_attr_suppliers_products(profile_data[:suppliers_products])
56 data[:icon] = profile_data[:profile][:icon] 56 data[:icon] = profile_data[:profile][:icon]
57 data 57 data
58 - end.to_json 58 + end.to_json.html_safe
59 %> 59 %>
60 }); 60 });
61 </script> 61 </script>
plugins/solr/lib/acts_as_faceted.rb
@@ -191,32 +191,5 @@ module ActsAsFaceted @@ -191,32 +191,5 @@ module ActsAsFaceted
191 191
192 end 192 end
193 193
194 -ActiveRecord::Base.extend ActsAsFaceted::ActsMethods  
195 -  
196 -# from https://github.com/rubyworks/facets/blob/master/lib/core/facets/enumerable/graph.rb  
197 -module Enumerable  
198 - def graph(&yld)  
199 - if yld  
200 - h = {}  
201 - each do |*kv|  
202 - r = yld[*kv]  
203 - case r  
204 - when Hash  
205 - nk, nv = *r.to_a[0]  
206 - when Range  
207 - nk, nv = r.first, r.last  
208 - else  
209 - nk, nv = *r  
210 - end  
211 - h[nk] = nv  
212 - end  
213 - h  
214 - else  
215 - Enumerator.new(self,:graph)  
216 - end  
217 - end  
218 -  
219 - # Alias for #graph, which stands for "map hash".  
220 - alias_method :mash, :graph  
221 -end 194 +ApplicationRecord.extend ActsAsFaceted::ActsMethods
222 195
plugins/solr/lib/acts_as_searchable.rb
@@ -35,7 +35,7 @@ module ActsAsSearchable @@ -35,7 +35,7 @@ module ActsAsSearchable
35 module FindByContents 35 module FindByContents
36 36
37 def schema_name 37 def schema_name
38 - (Noosfero::MultiTenancy.on? and ActiveRecord::Base.postgresql?) ? ActiveRecord::Base.connection.schema_search_path : '' 38 + (Noosfero::MultiTenancy.on? and ApplicationRecord.postgresql?) ? ApplicationRecord.connection.schema_search_path : ''
39 end 39 end
40 40
41 def find_by_contents(query, pg_options = {}, options = {}, db_options = {}) 41 def find_by_contents(query, pg_options = {}, options = {}, db_options = {})
@@ -84,4 +84,5 @@ module ActsAsSearchable @@ -84,4 +84,5 @@ module ActsAsSearchable
84 end 84 end
85 end 85 end
86 86
87 -ActiveRecord::Base.send(:extend, ActsAsSearchable::ClassMethods) 87 +ApplicationRecord.extend ActsAsSearchable::ClassMethods
  88 +
plugins/solr/test/unit/acts_as_faceted_test.rb
@@ -2,11 +2,11 @@ require_relative &#39;../test_helper&#39; @@ -2,11 +2,11 @@ require_relative &#39;../test_helper&#39;
2 require "#{File.dirname(__FILE__)}/../../lib/acts_as_faceted" 2 require "#{File.dirname(__FILE__)}/../../lib/acts_as_faceted"
3 3
4 4
5 -class TestModel < ActiveRecord::Base 5 +class TestModel < ApplicationRecord
6 def self.f_type_proc(klass) 6 def self.f_type_proc(klass)
7 - klass.constantize 7 + klass.constantize
8 h = { 8 h = {
9 - 'UploadedFile' => "Uploaded File", 9 + 'UploadedFile' => "Uploaded File",
10 'TextArticle' => "Text", 10 'TextArticle' => "Text",
11 'Folder' => "Folder", 11 'Folder' => "Folder",
12 'Event' => "Event", 12 'Event' => "Event",
@@ -92,7 +92,7 @@ class ActsAsFacetedTest &lt; ActiveSupport::TestCase @@ -92,7 +92,7 @@ class ActsAsFacetedTest &lt; ActiveSupport::TestCase
92 assert_equivalent [["[* TO NOW-1YEARS/DAY]", "Older than one year", 10], ["[NOW-1YEARS TO NOW/DAY]", "Last year", 19]], r 92 assert_equivalent [["[* TO NOW-1YEARS/DAY]", "Older than one year", 10], ["[NOW-1YEARS TO NOW/DAY]", "Last year", 19]], r
93 end 93 end
94 94
95 - should 'return facet hash in map_facets_for' do 95 + should 'return facet hash in map_facets_for' do
96 r = TestModel.map_facets_for(Environment.default) 96 r = TestModel.map_facets_for(Environment.default)
97 assert r.count, 2 97 assert r.count, 2
98 98
@@ -147,7 +147,7 @@ class ActsAsFacetedTest &lt; ActiveSupport::TestCase @@ -147,7 +147,7 @@ class ActsAsFacetedTest &lt; ActiveSupport::TestCase
147 facets = TestModel.map_facets_for(Environment.default) 147 facets = TestModel.map_facets_for(Environment.default)
148 facet = facets.select{ |f| f[:id] == 'f_type' }.first 148 facet = facets.select{ |f| f[:id] == 'f_type' }.first
149 facet_data = TestModel.map_facet_results facet, @facet_params, @facets, @all_facets, {} 149 facet_data = TestModel.map_facet_results facet, @facet_params, @facets, @all_facets, {}
150 - sorted = TestModel.facet_result_sort(facet, facet_data, :alphabetically) 150 + sorted = TestModel.facet_result_sort(facet, facet_data, :alphabetically)
151 assert_equal sorted, 151 assert_equal sorted,
152 [["Folder", "Folder", 3], ["Gallery", "Gallery", 1], ["TextArticle", 'Text', 15], ["UploadedFile", "Uploaded File", 6]] 152 [["Folder", "Folder", 3], ["Gallery", "Gallery", 1], ["TextArticle", 'Text', 15], ["UploadedFile", "Uploaded File", 6]]
153 end 153 end
@@ -156,7 +156,7 @@ class ActsAsFacetedTest &lt; ActiveSupport::TestCase @@ -156,7 +156,7 @@ class ActsAsFacetedTest &lt; ActiveSupport::TestCase
156 facets = TestModel.map_facets_for(Environment.default) 156 facets = TestModel.map_facets_for(Environment.default)
157 facet = facets.select{ |f| f[:id] == 'f_type' }.first 157 facet = facets.select{ |f| f[:id] == 'f_type' }.first
158 facet_data = TestModel.map_facet_results facet, @facet_params, @facets, @all_facets, {} 158 facet_data = TestModel.map_facet_results facet, @facet_params, @facets, @all_facets, {}
159 - sorted = TestModel.facet_result_sort(facet, facet_data, :count) 159 + sorted = TestModel.facet_result_sort(facet, facet_data, :count)
160 assert_equal sorted, 160 assert_equal sorted,
161 [["TextArticle", "Text", 15], ["UploadedFile", "Uploaded File", 6], ["Folder", "Folder", 3], ["Gallery", "Gallery", 1]] 161 [["TextArticle", "Text", 15], ["UploadedFile", "Uploaded File", 6], ["Folder", "Folder", 3], ["Gallery", "Gallery", 1]]
162 end 162 end
plugins/solr/test/unit/acts_as_searchable_test.rb
@@ -23,7 +23,7 @@ class ActsAsSearchableTest &lt; ActiveSupport::TestCase @@ -23,7 +23,7 @@ class ActsAsSearchableTest &lt; ActiveSupport::TestCase
23 should 'not be searchable when disabled' do 23 should 'not be searchable when disabled' do
24 # suppress warning about already initialized constant 24 # suppress warning about already initialized constant
25 silent { ActsAsSearchable::ClassMethods::ACTS_AS_SEARCHABLE_ENABLED = false } 25 silent { ActsAsSearchable::ClassMethods::ACTS_AS_SEARCHABLE_ENABLED = false }
26 - 26 +
27 @test_model.expects(:acts_as_solr).never 27 @test_model.expects(:acts_as_solr).never
28 @test_model.acts_as_searchable 28 @test_model.acts_as_searchable
29 end 29 end
plugins/solr/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/dynamic_attribute.rb
1 -class DynamicAttribute < ActiveRecord::Base 1 +class DynamicAttribute < ApplicationRecord
2 belongs_to :dynamicable, :polymorphic => true 2 belongs_to :dynamicable, :polymorphic => true
3 end 3 end
plugins/spaminator/lib/spaminator_plugin/report.rb
1 -class SpaminatorPlugin::Report < ActiveRecord::Base 1 +class SpaminatorPlugin::Report < ApplicationRecord
2 2
3 serialize :failed, Hash 3 serialize :failed, Hash
4 4
plugins/stoa/lib/stoa_plugin/usp_aluno_turma_grad.rb
1 -class StoaPlugin::UspAlunoTurmaGrad < ActiveRecord::Base 1 +class StoaPlugin::UspAlunoTurmaGrad < ApplicationRecord
2 2
3 establish_connection(:stoa) 3 establish_connection(:stoa)
4 4
plugins/stoa/lib/stoa_plugin/usp_user.rb
1 -class StoaPlugin::UspUser < ActiveRecord::Base 1 +class StoaPlugin::UspUser < ApplicationRecord
2 2
3 establish_connection(:stoa) 3 establish_connection(:stoa)
4 self.table_name = 'pessoa' 4 self.table_name = 'pessoa'
plugins/stoa/test/functional/account_controller_test.rb
@@ -6,7 +6,7 @@ class AccountControllerTest &lt; ActionController::TestCase @@ -6,7 +6,7 @@ class AccountControllerTest &lt; ActionController::TestCase
6 SALT=YAML::load(File.open(StoaPlugin.root_path + 'config.yml'))['salt'] 6 SALT=YAML::load(File.open(StoaPlugin.root_path + 'config.yml'))['salt']
7 7
8 @db = Tempfile.new('stoa-test') 8 @db = Tempfile.new('stoa-test')
9 - configs = ActiveRecord::Base.configurations['stoa'] = {:adapter => 'sqlite3', :database => @db.path} 9 + ActiveRecord::Base.configurations['stoa'] = {:adapter => 'sqlite3', :database => @db.path}
10 ActiveRecord::Base.establish_connection(:stoa) 10 ActiveRecord::Base.establish_connection(:stoa)
11 ActiveRecord::Schema.verbose = false 11 ActiveRecord::Schema.verbose = false
12 ActiveRecord::Schema.create_table "pessoa" do |t| 12 ActiveRecord::Schema.create_table "pessoa" do |t|
plugins/stoa/test/functional/profile_editor_controller_test.rb
@@ -13,7 +13,7 @@ class StoaPluginProfileEditorControllerTest &lt; ActionController::TestCase @@ -13,7 +13,7 @@ class StoaPluginProfileEditorControllerTest &lt; ActionController::TestCase
13 login_as(@person.identifier) 13 login_as(@person.identifier)
14 Environment.default.enable_plugin(StoaPlugin.name) 14 Environment.default.enable_plugin(StoaPlugin.name)
15 db = Tempfile.new('stoa-test') 15 db = Tempfile.new('stoa-test')
16 - ActiveRecord::Base.configurations['stoa'] = {:adapter => 'sqlite3', :database => db.path} 16 + ApplicationRecord.configurations['stoa'] = {:adapter => 'sqlite3', :database => db.path}
17 end 17 end
18 18
19 attr_accessor :person 19 attr_accessor :person
plugins/stoa/test/functional/stoa_plugin_controller_test.rb
@@ -9,7 +9,7 @@ class StoaPluginControllerTest &lt; ActionController::TestCase @@ -9,7 +9,7 @@ class StoaPluginControllerTest &lt; ActionController::TestCase
9 @controller = StoaPluginController.new 9 @controller = StoaPluginController.new
10 @request = ActionController::TestRequest.new 10 @request = ActionController::TestRequest.new
11 @response = ActionController::TestResponse.new 11 @response = ActionController::TestResponse.new
12 - ActiveRecord::Base.configurations['stoa'] = {:adapter => 'sqlite3', :database => ':memory:', :verbosity => 'quiet'} 12 + ApplicationRecord.configurations['stoa'] = {:adapter => 'sqlite3', :database => ':memory:', :verbosity => 'quiet'}
13 env = Environment.default 13 env = Environment.default
14 env.enable_plugin(StoaPlugin.name) 14 env.enable_plugin(StoaPlugin.name)
15 env.enable('skip_new_user_email_confirmation') 15 env.enable('skip_new_user_email_confirmation')
plugins/stoa/test/unit/usp_user_test.rb
@@ -5,7 +5,7 @@ class StoaPlugin::UspUserTest &lt; ActiveSupport::TestCase @@ -5,7 +5,7 @@ class StoaPlugin::UspUserTest &lt; ActiveSupport::TestCase
5 SALT=YAML::load(File.open(StoaPlugin.root_path + 'config.yml'))['salt'] 5 SALT=YAML::load(File.open(StoaPlugin.root_path + 'config.yml'))['salt']
6 6
7 @db = Tempfile.new('stoa-test') 7 @db = Tempfile.new('stoa-test')
8 - configs = ActiveRecord::Base.configurations['stoa'] = {:adapter => 'sqlite3', :database => @db.path} 8 + ActiveRecord::Base.configurations['stoa'] = {:adapter => 'sqlite3', :database => @db.path}
9 ActiveRecord::Base.establish_connection(:stoa) 9 ActiveRecord::Base.establish_connection(:stoa)
10 ActiveRecord::Schema.verbose = false 10 ActiveRecord::Schema.verbose = false
11 ActiveRecord::Schema.create_table "pessoa" do |t| 11 ActiveRecord::Schema.create_table "pessoa" do |t|
@@ -14,6 +14,7 @@ class StoaPlugin::UspUserTest &lt; ActiveSupport::TestCase @@ -14,6 +14,7 @@ class StoaPlugin::UspUserTest &lt; ActiveSupport::TestCase
14 t.date "dtanas" 14 t.date "dtanas"
15 end 15 end
16 ActiveRecord::Base.establish_connection(:test) 16 ActiveRecord::Base.establish_connection(:test)
  17 + StoaPlugin::UspUser.reset_column_information
17 18
18 def setup 19 def setup
19 StoaPlugin::UspUser.create({:codpes => 123456, :cpf => Digest::MD5.hexdigest(SALT+'12345678'), :birth_date => '1970-01-30'}, :without_protection => true) 20 StoaPlugin::UspUser.create({:codpes => 123456, :cpf => Digest::MD5.hexdigest(SALT+'12345678'), :birth_date => '1970-01-30'}, :without_protection => true)
plugins/sub_organizations/lib/sub_organizations_plugin/approve_paternity_relation.rb
1 -class SubOrganizationsPlugin::ApprovePaternityRelation < ActiveRecord::Base 1 +class SubOrganizationsPlugin::ApprovePaternityRelation < ApplicationRecord
2 2
3 belongs_to :task 3 belongs_to :task
4 belongs_to :parent, :polymorphic => true 4 belongs_to :parent, :polymorphic => true
plugins/sub_organizations/lib/sub_organizations_plugin/relation.rb
1 -class SubOrganizationsPlugin::Relation < ActiveRecord::Base 1 +class SubOrganizationsPlugin::Relation < ApplicationRecord
2 2
3 belongs_to :parent, :polymorphic => true 3 belongs_to :parent, :polymorphic => true
4 belongs_to :child, :polymorphic => true 4 belongs_to :child, :polymorphic => true
plugins/suppliers/db/migrate/20130704000000_create_suppliers_plugin_tables.rb
1 class CreateSuppliersPluginTables < ActiveRecord::Migration 1 class CreateSuppliersPluginTables < ActiveRecord::Migration
2 def self.up 2 def self.up
3 # check if distribution plugin already moved the table 3 # check if distribution plugin already moved the table
4 - return if ActiveRecord::Base.connection.table_exists? :suppliers_plugin_suppliers 4 + return if ApplicationRecord.connection.table_exists? :suppliers_plugin_suppliers
5 5
6 create_table :suppliers_plugin_suppliers do |t| 6 create_table :suppliers_plugin_suppliers do |t|
7 t.integer :profile_id 7 t.integer :profile_id
plugins/suppliers/db/migrate/20130704202336_create_suppliers_plugin_source_product.rb
1 class CreateSuppliersPluginSourceProduct < ActiveRecord::Migration 1 class CreateSuppliersPluginSourceProduct < ActiveRecord::Migration
2 def self.up 2 def self.up
3 # check if distribution plugin already moved the table 3 # check if distribution plugin already moved the table
4 - return if ActiveRecord::Base.connection.table_exists? "suppliers_plugin_source_products" 4 + return if ApplicationRecord.connection.table_exists? "suppliers_plugin_source_products"
5 5
6 create_table :suppliers_plugin_source_products do |t| 6 create_table :suppliers_plugin_source_products do |t|
7 t.integer "from_product_id" 7 t.integer "from_product_id"
plugins/suppliers/db/migrate/20130902115916_add_active_to_suppliers_plugin_supplier.rb
1 -class SuppliersPlugin::Supplier < ActiveRecord::Base 1 +class SuppliersPlugin::Supplier < ApplicationRecord
2 end 2 end
3 3
4 class AddActiveToSuppliersPluginSupplier < ActiveRecord::Migration 4 class AddActiveToSuppliersPluginSupplier < ActiveRecord::Migration
plugins/suppliers/lib/default_delegate.rb
@@ -126,4 +126,4 @@ module DefaultDelegate @@ -126,4 +126,4 @@ module DefaultDelegate
126 126
127 end 127 end
128 128
129 -ActiveRecord::Base.extend DefaultDelegate::ClassMethods 129 +ApplicationRecord.extend DefaultDelegate::ClassMethods
plugins/suppliers/models/suppliers_plugin/source_product.rb
1 -class SuppliersPlugin::SourceProduct < ActiveRecord::Base 1 +class SuppliersPlugin::SourceProduct < ApplicationRecord
2 2
3 attr_accessible :from_product, :to_product, :quantity 3 attr_accessible :from_product, :to_product, :quantity
4 4
plugins/suppliers/models/suppliers_plugin/supplier.rb
1 -class SuppliersPlugin::Supplier < ActiveRecord::Base 1 +class SuppliersPlugin::Supplier < ApplicationRecord
2 2
3 attr_accessor :distribute_products_on_create, :dont_destroy_dummy, :identifier_from_name 3 attr_accessor :distribute_products_on_create, :dont_destroy_dummy, :identifier_from_name
4 4
plugins/tolerance_time/lib/tolerance_time_plugin/publication.rb
1 -class ToleranceTimePlugin::Publication < ActiveRecord::Base 1 +class ToleranceTimePlugin::Publication < ApplicationRecord
2 2
3 belongs_to :target, :polymorphic => true 3 belongs_to :target, :polymorphic => true
4 validates_presence_of :target_id, :target_type 4 validates_presence_of :target_id, :target_type
plugins/tolerance_time/lib/tolerance_time_plugin/tolerance.rb
1 -class ToleranceTimePlugin::Tolerance < ActiveRecord::Base 1 +class ToleranceTimePlugin::Tolerance < ApplicationRecord
2 2
3 belongs_to :profile 3 belongs_to :profile
4 validates_presence_of :profile_id 4 validates_presence_of :profile_id
plugins/volunteers/models/volunteers_plugin/assignment.rb
1 -class VolunteersPlugin::Assignment < ActiveRecord::Base 1 +class VolunteersPlugin::Assignment < ApplicationRecord
2 2
3 attr_accessible :profile_id 3 attr_accessible :profile_id
4 4
plugins/volunteers/models/volunteers_plugin/period.rb
1 -class VolunteersPlugin::Period < ActiveRecord::Base 1 +class VolunteersPlugin::Period < ApplicationRecord
2 2
3 attr_accessible :name 3 attr_accessible :name
4 attr_accessible :start, :end 4 attr_accessible :start, :end
po/ru/noosfero.po
@@ -7,17 +7,17 @@ msgid &quot;&quot; @@ -7,17 +7,17 @@ msgid &quot;&quot;
7 msgstr "" 7 msgstr ""
8 "Project-Id-Version: 1.3~rc2-8-g01ea9f7\n" 8 "Project-Id-Version: 1.3~rc2-8-g01ea9f7\n"
9 "POT-Creation-Date: 2015-11-04 12:36-0300\n" 9 "POT-Creation-Date: 2015-11-04 12:36-0300\n"
10 -"PO-Revision-Date: 2014-12-12 14:23+0200\n"  
11 -"Last-Translator: Michal Čihař <michal@cihar.com>\n"  
12 -"Language-Team: Russian <https://hosted.weblate.org/projects/noosfero/"  
13 -"noosfero/ru/>\n" 10 +"PO-Revision-Date: 2016-04-21 01:15+0000\n"
  11 +"Last-Translator: Iryna Pruitt <jdpruitt2807@prodigy.net>\n"
  12 +"Language-Team: Russian "
  13 +"<https://hosted.weblate.org/projects/noosfero/noosfero/ru/>\n"
14 "Language: ru\n" 14 "Language: ru\n"
15 "MIME-Version: 1.0\n" 15 "MIME-Version: 1.0\n"
16 "Content-Type: text/plain; charset=UTF-8\n" 16 "Content-Type: text/plain; charset=UTF-8\n"
17 "Content-Transfer-Encoding: 8bit\n" 17 "Content-Transfer-Encoding: 8bit\n"
18 -"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"  
19 -"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"  
20 -"X-Generator: Weblate 2.2-dev\n" 18 +"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<="
  19 +"4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
  20 +"X-Generator: Weblate 2.6-dev\n"
21 21
22 #: app/models/approve_comment.rb:17 22 #: app/models/approve_comment.rb:17
23 #, fuzzy 23 #, fuzzy
@@ -9948,7 +9948,7 @@ msgstr &quot;Список продуктов и услуг&quot; @@ -9948,7 +9948,7 @@ msgstr &quot;Список продуктов и услуг&quot;
9948 9948
9949 #: app/views/manage_products/index.html.erb:6 9949 #: app/views/manage_products/index.html.erb:6
9950 msgid "Price" 9950 msgid "Price"
9951 -msgstr "цена" 9951 +msgstr "Цена"
9952 9952
9953 #: app/views/manage_products/index.html.erb:11 9953 #: app/views/manage_products/index.html.erb:11
9954 msgid "(no product registered yet)" 9954 msgid "(no product registered yet)"
public/designs/themes/base/footer.html.erb
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 <%= link_to _('Manual'), '/doc', id: "link-to-doc", class: 'icon-help' %> 3 <%= link_to _('Manual'), '/doc', id: "link-to-doc", class: 'icon-help' %>
4 </div><!-- end id="footer-links" --> 4 </div><!-- end id="footer-links" -->
5 <div id="copyright"> 5 <div id="copyright">
6 - <p><%= _('This social network uses <a href="http://noosfero.org/">Noosfero</a>, developed by %s and licensed under the <a href="http://www.gnu.org/licenses/agpl.html">GNU Affero General Public License</a> version 3 or any later version.') % link_to('Colivre', 'http://colivre.coop.br/') %></p> 6 + <p><%= (_('This social network uses <a href="http://noosfero.org/">Noosfero</a>, developed by %s and licensed under the <a href="http://www.gnu.org/licenses/agpl.html">GNU Affero General Public License</a> version 3 or any later version.') % link_to('Colivre', 'http://colivre.coop.br/')).html_safe %></p>
7 </div><!-- end id="copyright" --> 7 </div><!-- end id="copyright" -->
8 <%= language_chooser(environment) %> 8 <%= language_chooser(environment) %>
9 </div> 9 </div>
public/designs/themes/profile-base/footer.html.erb
1 <div id="footer-content"> 1 <div id="footer-content">
2 - <p><%= _('This site uses <a href="http://noosfero.org/">Noosfero</a>, developed by %s and licensed under the <a href="http://www.gnu.org/licenses/agpl.html">GNU Affero General Public License</a> version 3 or any later version.') % link_to('Colivre', 'http://colivre.coop.br/') %></p> 2 + <p><%= _('This site uses <a href="http://noosfero.org/">Noosfero</a>, developed by %s and licensed under the <a href="http://www.gnu.org/licenses/agpl.html">GNU Affero General Public License</a> version 3 or any later version.') % link_to('Colivre', 'http://colivre.coop.br/').html_safe %></p>
3 </div> 3 </div>
public/stylesheets/tasks.scss
@@ -82,3 +82,47 @@ div.pending-tasks { @@ -82,3 +82,47 @@ div.pending-tasks {
82 .task_responsible { 82 .task_responsible {
83 text-align: right; 83 text-align: right;
84 } 84 }
  85 +
  86 +.task-processed li {
  87 + background-color: rgb(240, 240, 240);
  88 + border-radius: 8px;
  89 + margin: 10px 0;
  90 + list-style-type: none;
  91 + padding: 12px;
  92 +}
  93 +
  94 +.task-processed .task.status-3 {
  95 + background-color: rgb(205, 252, 218);
  96 +}
  97 +
  98 +.task-processed .task.status-2 {
  99 + background-color: rgb(255, 203, 203);
  100 +}
  101 +
  102 +.task-processed ul {
  103 + padding: 0;
  104 +}
  105 +
  106 +.task-processed .task-list .task .title {
  107 + border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  108 + font-weight: bold;
  109 + color: rgb(44, 44, 44);
  110 +}
  111 +
  112 +.task-processed .task .status {
  113 + float: right;
  114 + color: rgb(156, 156, 156);
  115 + font-weight: bold;
  116 +}
  117 +
  118 +.task-processed .task .dates {
  119 + font-size: 11px;
  120 +}
  121 +
  122 +.task-processed .task .closed-by {
  123 + font-size: 11px;
  124 +}
  125 +
  126 +.task-processed .task .label {
  127 + font-weight: bold
  128 +}
script/noosfero-plugins
@@ -79,7 +79,7 @@ run(){ @@ -79,7 +79,7 @@ run(){
79 79
80 _install(){ 80 _install(){
81 # export so that recursive enables for dependencies inherit this option too 81 # export so that recursive enables for dependencies inherit this option too
82 - export BUNDLE_OPTS='install' 82 + export NOOSFERO_BUNDLE_OPTS='install'
83 _enable "$1" 83 _enable "$1"
84 } 84 }
85 85
@@ -119,8 +119,8 @@ _enable(){ @@ -119,8 +119,8 @@ _enable(){
119 if [ -e $source/Gemfile ]; then 119 if [ -e $source/Gemfile ]; then
120 gemfile=$(mktemp --tmpdir=.) 120 gemfile=$(mktemp --tmpdir=.)
121 cat $NOOSFERO_DIR/Gemfile $source/Gemfile > $gemfile 121 cat $NOOSFERO_DIR/Gemfile $source/Gemfile > $gemfile
122 - if [ -z "$BUNDLE_OPTS" ]; then BUNDLE_OPTS="--local"; fi  
123 - if ! RUBYOPT='' BUNDLE_GEMFILE="$gemfile" bundle $BUNDLE_OPTS --quiet; then 122 + if [ -z "$NOOSFERO_BUNDLE_OPTS" ]; then NOOSFERO_BUNDLE_OPTS="--local"; fi
  123 + if ! RUBYOPT='' BUNDLE_GEMFILE="$gemfile" bundle $NOOSFERO_BUNDLE_OPTS --quiet; then
124 dependencies_ok=false 124 dependencies_ok=false
125 else 125 else
126 mv "$gemfile".lock Gemfile.lock 126 mv "$gemfile".lock Gemfile.lock
test/functional/account_controller_test.rb
@@ -689,7 +689,7 @@ class AccountControllerTest &lt; ActionController::TestCase @@ -689,7 +689,7 @@ class AccountControllerTest &lt; ActionController::TestCase
689 should 'merge user data with extra stuff from plugins' do 689 should 'merge user data with extra stuff from plugins' do
690 class Plugin1 < Noosfero::Plugin 690 class Plugin1 < Noosfero::Plugin
691 def user_data_extras 691 def user_data_extras
692 - {:foo => 'bar'} 692 + {:foo => 'bar'.html_safe }
693 end 693 end
694 end 694 end
695 695
@@ -787,12 +787,12 @@ class AccountControllerTest &lt; ActionController::TestCase @@ -787,12 +787,12 @@ class AccountControllerTest &lt; ActionController::TestCase
787 should 'add extra content on signup forms from plugins' do 787 should 'add extra content on signup forms from plugins' do
788 class Plugin1 < Noosfero::Plugin 788 class Plugin1 < Noosfero::Plugin
789 def signup_extra_contents 789 def signup_extra_contents
790 - proc {"<strong>Plugin1 text</strong>"} 790 + proc {"<strong>Plugin1 text</strong>".html_safe}
791 end 791 end
792 end 792 end
793 class Plugin2 < Noosfero::Plugin 793 class Plugin2 < Noosfero::Plugin
794 def signup_extra_contents 794 def signup_extra_contents
795 - proc {"<strong>Plugin2 text</strong>"} 795 + proc {"<strong>Plugin2 text</strong>".html_safe}
796 end 796 end
797 end 797 end
798 Noosfero::Plugin.stubs(:all).returns([Plugin1.name, Plugin2.name]) 798 Noosfero::Plugin.stubs(:all).returns([Plugin1.name, Plugin2.name])
@@ -909,12 +909,12 @@ class AccountControllerTest &lt; ActionController::TestCase @@ -909,12 +909,12 @@ class AccountControllerTest &lt; ActionController::TestCase
909 should 'add extra content on login form from plugins' do 909 should 'add extra content on login form from plugins' do
910 class Plugin1 < Noosfero::Plugin 910 class Plugin1 < Noosfero::Plugin
911 def login_extra_contents 911 def login_extra_contents
912 - proc {"<strong>Plugin1 text</strong>"} 912 + proc {"<strong>Plugin1 text</strong>".html_safe}
913 end 913 end
914 end 914 end
915 class Plugin2 < Noosfero::Plugin 915 class Plugin2 < Noosfero::Plugin
916 def login_extra_contents 916 def login_extra_contents
917 - proc {"<strong>Plugin2 text</strong>"} 917 + proc {"<strong>Plugin2 text</strong>".html_safe}
918 end 918 end
919 end 919 end
920 Noosfero::Plugin.stubs(:all).returns([Plugin1.name, Plugin2.name]) 920 Noosfero::Plugin.stubs(:all).returns([Plugin1.name, Plugin2.name])
test/functional/application_controller_test.rb
@@ -375,7 +375,7 @@ class ApplicationControllerTest &lt; ActionController::TestCase @@ -375,7 +375,7 @@ class ApplicationControllerTest &lt; ActionController::TestCase
375 should 'include javascripts supplied by plugins' do 375 should 'include javascripts supplied by plugins' do
376 class Plugin1 < Noosfero::Plugin 376 class Plugin1 < Noosfero::Plugin
377 def js_files 377 def js_files
378 - ['js1.js'] 378 + ['js1.js'.html_safe]
379 end 379 end
380 end 380 end
381 381
@@ -384,7 +384,7 @@ class ApplicationControllerTest &lt; ActionController::TestCase @@ -384,7 +384,7 @@ class ApplicationControllerTest &lt; ActionController::TestCase
384 384
385 class Plugin2 < Noosfero::Plugin 385 class Plugin2 < Noosfero::Plugin
386 def js_files 386 def js_files
387 - ['js2.js', 'js3.js'] 387 + ['js2.js'.html_safe, 'js3.js'.html_safe]
388 end 388 end
389 end 389 end
390 390
@@ -409,12 +409,12 @@ class ApplicationControllerTest &lt; ActionController::TestCase @@ -409,12 +409,12 @@ class ApplicationControllerTest &lt; ActionController::TestCase
409 should 'include content in the beginning of body supplied by plugins regardless it is a block or html code' do 409 should 'include content in the beginning of body supplied by plugins regardless it is a block or html code' do
410 class TestBodyBeginning1Plugin < Noosfero::Plugin 410 class TestBodyBeginning1Plugin < Noosfero::Plugin
411 def body_beginning 411 def body_beginning
412 - lambda {"<span id='plugin1'>This is [[plugin1]] speaking!</span>"} 412 + lambda {"<span id='plugin1'>This is [[plugin1]] speaking!</span>".html_safe}
413 end 413 end
414 end 414 end
415 class TestBodyBeginning2Plugin < Noosfero::Plugin 415 class TestBodyBeginning2Plugin < Noosfero::Plugin
416 def body_beginning 416 def body_beginning
417 - "<span id='plugin2'>This is Plugin2 speaking!</span>" 417 + "<span id='plugin2'>This is Plugin2 speaking!</span>".html_safe
418 end 418 end
419 end 419 end
420 420
@@ -432,12 +432,12 @@ class ApplicationControllerTest &lt; ActionController::TestCase @@ -432,12 +432,12 @@ class ApplicationControllerTest &lt; ActionController::TestCase
432 432
433 class TestHeadEnding1Plugin < Noosfero::Plugin 433 class TestHeadEnding1Plugin < Noosfero::Plugin
434 def head_ending 434 def head_ending
435 - lambda {"<script>alert('This is [[plugin1]] speaking!')</script>"} 435 + lambda {"<script>alert('This is [[plugin1]] speaking!')</script>".html_safe}
436 end 436 end
437 end 437 end
438 class TestHeadEnding2Plugin < Noosfero::Plugin 438 class TestHeadEnding2Plugin < Noosfero::Plugin
439 def head_ending 439 def head_ending
440 - "<style>This is Plugin2 speaking!</style>" 440 + "<style>This is Plugin2 speaking!</style>".html_safe
441 end 441 end
442 end 442 end
443 443
test/functional/catalog_controller_test.rb
@@ -71,13 +71,13 @@ class CatalogControllerTest &lt; ActionController::TestCase @@ -71,13 +71,13 @@ class CatalogControllerTest &lt; ActionController::TestCase
71 should 'include extra content supplied by plugins on catalog item extras' do 71 should 'include extra content supplied by plugins on catalog item extras' do
72 class Plugin1 < Noosfero::Plugin 72 class Plugin1 < Noosfero::Plugin
73 def catalog_item_extras(product) 73 def catalog_item_extras(product)
74 - proc {"<span id='plugin1'>This is Plugin1 speaking!</span>"} 74 + proc {"<span id='plugin1'>This is Plugin1 speaking!</span>".html_safe}
75 end 75 end
76 end 76 end
77 77
78 class Plugin2 < Noosfero::Plugin 78 class Plugin2 < Noosfero::Plugin
79 def catalog_item_extras(product) 79 def catalog_item_extras(product)
80 - proc {"<span id='plugin2'>This is Plugin2 speaking!</span>"} 80 + proc {"<span id='plugin2'>This is Plugin2 speaking!</span>".html_safe}
81 end 81 end
82 end 82 end
83 Noosfero::Plugin.stubs(:all).returns([Plugin1.name, Plugin2.name]) 83 Noosfero::Plugin.stubs(:all).returns([Plugin1.name, Plugin2.name])
test/functional/enterprise_registration_controller_test.rb
@@ -191,13 +191,13 @@ class EnterpriseRegistrationControllerTest &lt; ActionController::TestCase @@ -191,13 +191,13 @@ class EnterpriseRegistrationControllerTest &lt; ActionController::TestCase
191 should 'include hidden fields supplied by plugins on enterprise registration' do 191 should 'include hidden fields supplied by plugins on enterprise registration' do
192 class Plugin1 < Noosfero::Plugin 192 class Plugin1 < Noosfero::Plugin
193 def enterprise_registration_hidden_fields 193 def enterprise_registration_hidden_fields
194 - {'plugin1' => 'Plugin 1'} 194 + {'plugin1' => 'Plugin 1'.html_safe}
195 end 195 end
196 end 196 end
197 197
198 class Plugin2 < Noosfero::Plugin 198 class Plugin2 < Noosfero::Plugin
199 def enterprise_registration_hidden_fields 199 def enterprise_registration_hidden_fields
200 - {'plugin2' => 'Plugin 2'} 200 + {'plugin2' => 'Plugin 2'.html_safe}
201 end 201 end
202 end 202 end
203 Noosfero::Plugin.stubs(:all).returns([Plugin1.name, Plugin2.name]) 203 Noosfero::Plugin.stubs(:all).returns([Plugin1.name, Plugin2.name])
test/functional/events_controller_test.rb
@@ -13,7 +13,7 @@ class EventsControllerTest &lt; ActionController::TestCase @@ -13,7 +13,7 @@ class EventsControllerTest &lt; ActionController::TestCase
13 13
14 get :events, :profile => profile.identifier 14 get :events, :profile => profile.identifier
15 15
16 - today = DateTime.now.strftime("%B %d, %Y") 16 + today = DateTime.now.strftime("%B %d, %Y").html_safe
17 assert_tag :tag => 'div', :attributes => {:id => "agenda-items"}, 17 assert_tag :tag => 'div', :attributes => {:id => "agenda-items"},
18 :descendant => {:tag => 'h3', :content => "Events for #{today}"}, 18 :descendant => {:tag => 'h3', :content => "Events for #{today}"},
19 :descendant => {:tag => 'tr', :content => "Joao Birthday"}, 19 :descendant => {:tag => 'tr', :content => "Joao Birthday"},
test/functional/friends_controller_test.rb
@@ -43,7 +43,7 @@ class FriendsControllerTest &lt; ActionController::TestCase @@ -43,7 +43,7 @@ class FriendsControllerTest &lt; ActionController::TestCase
43 43
44 should 'display find people button' do 44 should 'display find people button' do
45 get :index, :profile => 'testuser' 45 get :index, :profile => 'testuser'
46 - assert_tag :tag => 'a', :content => 'Find people', :attributes => { :href => '/search/assets?asset=people' } 46 + assert_tag :tag => 'a', :content => 'Find people', :attributes => { :href => '/search/assets?asset=people'.html_safe }
47 end 47 end
48 48
49 should 'not display invite friends button if any plugin tells not to' do 49 should 'not display invite friends button if any plugin tells not to' do
test/functional/home_controller_test.rb
@@ -88,12 +88,12 @@ class HomeControllerTest &lt; ActionController::TestCase @@ -88,12 +88,12 @@ class HomeControllerTest &lt; ActionController::TestCase
88 should 'provide a link to make the user authentication' do 88 should 'provide a link to make the user authentication' do
89 class Plugin1 < Noosfero::Plugin 89 class Plugin1 < Noosfero::Plugin
90 def alternative_authentication_link 90 def alternative_authentication_link
91 - proc {"<a href='plugin1'>Plugin1 link</a>"} 91 + proc {"<a href='plugin1'>Plugin1 link</a>".html_safe}
92 end 92 end
93 end 93 end
94 class Plugin2 < Noosfero::Plugin 94 class Plugin2 < Noosfero::Plugin
95 def alternative_authentication_link 95 def alternative_authentication_link
96 - proc {"<a href='plugin2'>Plugin2 link</a>"} 96 + proc {"<a href='plugin2'>Plugin2 link</a>".html_safe}
97 end 97 end
98 end 98 end
99 Noosfero::Plugin.stubs(:all).returns([Plugin1.name, Plugin2.name]) 99 Noosfero::Plugin.stubs(:all).returns([Plugin1.name, Plugin2.name])
@@ -168,7 +168,7 @@ class HomeControllerTest &lt; ActionController::TestCase @@ -168,7 +168,7 @@ class HomeControllerTest &lt; ActionController::TestCase
168 should 'plugins add class to the <html>' do 168 should 'plugins add class to the <html>' do
169 class Plugin1 < Noosfero::Plugin 169 class Plugin1 < Noosfero::Plugin
170 def html_tag_classes 170 def html_tag_classes
171 - lambda { ['t1', 't2'] } 171 + lambda { ['t1'.html_safe, 't2'.html_safe] }
172 end 172 end
173 end 173 end
174 174
test/functional/manage_products_controller_test.rb
@@ -429,12 +429,12 @@ class ManageProductsControllerTest &lt; ActionController::TestCase @@ -429,12 +429,12 @@ class ManageProductsControllerTest &lt; ActionController::TestCase
429 should 'include extra content supplied by plugins on products info extras' do 429 should 'include extra content supplied by plugins on products info extras' do
430 class TestProductInfoExtras1Plugin < Noosfero::Plugin 430 class TestProductInfoExtras1Plugin < Noosfero::Plugin
431 def product_info_extras(p) 431 def product_info_extras(p)
432 - proc {"<span id='plugin1'>This is Plugin1 speaking!</span>"} 432 + proc {"<span id='plugin1'>This is Plugin1 speaking!</span>".html_safe}
433 end 433 end
434 end 434 end
435 class TestProductInfoExtras2Plugin < Noosfero::Plugin 435 class TestProductInfoExtras2Plugin < Noosfero::Plugin
436 def product_info_extras(p) 436 def product_info_extras(p)
437 - proc { "<span id='plugin2'>This is Plugin2 speaking!</span>" } 437 + proc { "<span id='plugin2'>This is Plugin2 speaking!</span>".html_safe }
438 end 438 end
439 end 439 end
440 440
test/functional/profile_controller_test.rb
@@ -125,7 +125,7 @@ class ProfileControllerTest &lt; ActionController::TestCase @@ -125,7 +125,7 @@ class ProfileControllerTest &lt; ActionController::TestCase
125 @profile.articles.create!(:name => 'testarticle', :tag_list => 'tag1') 125 @profile.articles.create!(:name => 'testarticle', :tag_list => 'tag1')
126 get :content_tagged, :profile => @profile.identifier, :id => 'tag1' 126 get :content_tagged, :profile => @profile.identifier, :id => 'tag1'
127 127
128 - assert_tag :tag => 'a', :attributes => { :href => '/tag/tag1' }, :content => 'See content tagged with "tag1" in the entire site' 128 + assert_tag :tag => 'a', :attributes => { :href => '/tag/tag1' }, :content => 'See content tagged with "tag1" in the entire site'.html_safe
129 end 129 end
130 130
131 should 'show a link to own control panel' do 131 should 'show a link to own control panel' do
@@ -512,7 +512,7 @@ class ProfileControllerTest &lt; ActionController::TestCase @@ -512,7 +512,7 @@ class ProfileControllerTest &lt; ActionController::TestCase
512 should 'show description of orgarnization' do 512 should 'show description of orgarnization' do
513 login_as(@profile.identifier) 513 login_as(@profile.identifier)
514 ent = fast_create(Enterprise) 514 ent = fast_create(Enterprise)
515 - ent.description = 'Enterprise\'s description' 515 + ent.description = "<span>Enterprise's description</span>"
516 ent.save 516 ent.save
517 get :index, :profile => ent.identifier 517 get :index, :profile => ent.identifier
518 assert_tag :tag => 'div', :attributes => { :class => 'public-profile-description' }, :content => /Enterprise\'s description/ 518 assert_tag :tag => 'div', :attributes => { :class => 'public-profile-description' }, :content => /Enterprise\'s description/
@@ -1236,13 +1236,13 @@ class ProfileControllerTest &lt; ActionController::TestCase @@ -1236,13 +1236,13 @@ class ProfileControllerTest &lt; ActionController::TestCase
1236 should 'display plugins tabs' do 1236 should 'display plugins tabs' do
1237 class Plugin1 < Noosfero::Plugin 1237 class Plugin1 < Noosfero::Plugin
1238 def profile_tabs 1238 def profile_tabs
1239 - {:title => 'Plugin1 tab', :id => 'plugin1_tab', :content => proc { 'Content from plugin1.' }} 1239 + {:title => 'Plugin1 tab', :id => 'plugin1_tab', :content => proc { 'Content from plugin1.'.html_safe }}
1240 end 1240 end
1241 end 1241 end
1242 1242
1243 class Plugin2 < Noosfero::Plugin 1243 class Plugin2 < Noosfero::Plugin
1244 def profile_tabs 1244 def profile_tabs
1245 - {:title => 'Plugin2 tab', :id => 'plugin2_tab', :content => proc { 'Content from plugin2.' }} 1245 + {:title => 'Plugin2 tab', :id => 'plugin2_tab', :content => proc { 'Content from plugin2.'.html_safe }}
1246 end 1246 end
1247 end 1247 end
1248 Noosfero::Plugin.stubs(:all).returns([Plugin1.to_s, Plugin2.to_s]) 1248 Noosfero::Plugin.stubs(:all).returns([Plugin1.to_s, Plugin2.to_s])
test/functional/profile_editor_controller_test.rb
@@ -1002,7 +1002,7 @@ class ProfileEditorControllerTest &lt; ActionController::TestCase @@ -1002,7 +1002,7 @@ class ProfileEditorControllerTest &lt; ActionController::TestCase
1002 should 'add extra content provided by plugins on edit' do 1002 should 'add extra content provided by plugins on edit' do
1003 class TestProfileEditPlugin < Noosfero::Plugin 1003 class TestProfileEditPlugin < Noosfero::Plugin
1004 def profile_editor_extras 1004 def profile_editor_extras
1005 - "<input id='field_added_by_plugin' value='value_of_field_added_by_plugin'/>" 1005 + "<input id='field_added_by_plugin' value='value_of_field_added_by_plugin'/>".html_safe
1006 end 1006 end
1007 end 1007 end
1008 Noosfero::Plugin.stubs(:all).returns([TestProfileEditPlugin.to_s]) 1008 Noosfero::Plugin.stubs(:all).returns([TestProfileEditPlugin.to_s])
@@ -1018,7 +1018,7 @@ class ProfileEditorControllerTest &lt; ActionController::TestCase @@ -1018,7 +1018,7 @@ class ProfileEditorControllerTest &lt; ActionController::TestCase
1018 class TestProfileEditPlugin < Noosfero::Plugin 1018 class TestProfileEditPlugin < Noosfero::Plugin
1019 def profile_editor_extras 1019 def profile_editor_extras
1020 lambda do 1020 lambda do
1021 - render :text => "<input id='field_added_by_plugin' value='value_of_field_added_by_plugin'/>" 1021 + (render :text => "<input id='field_added_by_plugin' value='value_of_field_added_by_plugin'/>".html_safe).html_safe
1022 end 1022 end
1023 end 1023 end
1024 end 1024 end
@@ -1043,12 +1043,12 @@ class ProfileEditorControllerTest &lt; ActionController::TestCase @@ -1043,12 +1043,12 @@ class ProfileEditorControllerTest &lt; ActionController::TestCase
1043 should 'add extra content on person info from plugins' do 1043 should 'add extra content on person info from plugins' do
1044 class Plugin1 < Noosfero::Plugin 1044 class Plugin1 < Noosfero::Plugin
1045 def profile_info_extra_contents 1045 def profile_info_extra_contents
1046 - proc {"<strong>Plugin1 text</strong>"} 1046 + proc {"<strong>Plugin1 text</strong>".html_safe}
1047 end 1047 end
1048 end 1048 end
1049 class Plugin2 < Noosfero::Plugin 1049 class Plugin2 < Noosfero::Plugin
1050 def profile_info_extra_contents 1050 def profile_info_extra_contents
1051 - proc {"<strong>Plugin2 text</strong>"} 1051 + proc {"<strong>Plugin2 text</strong>".html_safe}
1052 end 1052 end
1053 end 1053 end
1054 Noosfero::Plugin.stubs(:all).returns([Plugin1.to_s, Plugin2.to_s]) 1054 Noosfero::Plugin.stubs(:all).returns([Plugin1.to_s, Plugin2.to_s])
@@ -1065,12 +1065,12 @@ class ProfileEditorControllerTest &lt; ActionController::TestCase @@ -1065,12 +1065,12 @@ class ProfileEditorControllerTest &lt; ActionController::TestCase
1065 should 'add extra content on organization info from plugins' do 1065 should 'add extra content on organization info from plugins' do
1066 class Plugin1 < Noosfero::Plugin 1066 class Plugin1 < Noosfero::Plugin
1067 def profile_info_extra_contents 1067 def profile_info_extra_contents
1068 - proc {"<strong>Plugin1 text</strong>"} 1068 + proc {"<strong>Plugin1 text</strong>".html_safe}
1069 end 1069 end
1070 end 1070 end
1071 class Plugin2 < Noosfero::Plugin 1071 class Plugin2 < Noosfero::Plugin
1072 def profile_info_extra_contents 1072 def profile_info_extra_contents
1073 - proc {"<strong>Plugin2 text</strong>"} 1073 + proc {"<strong>Plugin2 text</strong>".html_safe}
1074 end 1074 end
1075 end 1075 end
1076 Noosfero::Plugin.stubs(:all).returns([Plugin1.to_s, Plugin2.to_s]) 1076 Noosfero::Plugin.stubs(:all).returns([Plugin1.to_s, Plugin2.to_s])
test/functional/role_controller_test.rb
@@ -80,7 +80,7 @@ class RoleControllerTest &lt; ActionController::TestCase @@ -80,7 +80,7 @@ class RoleControllerTest &lt; ActionController::TestCase
80 role = Role.create!(:name => 'environment_role', :key => 'environment_role', :environment => Environment.default) 80 role = Role.create!(:name => 'environment_role', :key => 'environment_role', :environment => Environment.default)
81 get :edit, :id => role.id 81 get :edit, :id => role.id
82 ['Environment', 'Profile'].each do |key| 82 ['Environment', 'Profile'].each do |key|
83 - ActiveRecord::Base::PERMISSIONS[key].each do |permission, value| 83 + ApplicationRecord::PERMISSIONS[key].each do |permission, value|
84 assert_select ".permissions.#{key.downcase} input##{permission}" 84 assert_select ".permissions.#{key.downcase} input##{permission}"
85 end 85 end
86 end 86 end
@@ -89,7 +89,7 @@ class RoleControllerTest &lt; ActionController::TestCase @@ -89,7 +89,7 @@ class RoleControllerTest &lt; ActionController::TestCase
89 should 'display permissions only for profile when editing a profile role' do 89 should 'display permissions only for profile when editing a profile role' do
90 role = Role.create!(:name => 'profile_role', :key => 'profile_role', :environment => Environment.default) 90 role = Role.create!(:name => 'profile_role', :key => 'profile_role', :environment => Environment.default)
91 get :edit, :id => role.id 91 get :edit, :id => role.id
92 - ActiveRecord::Base::PERMISSIONS['Profile'].each do |permission, value| 92 + ApplicationRecord::PERMISSIONS['Profile'].each do |permission, value|
93 assert_select "input##{permission}" 93 assert_select "input##{permission}"
94 end 94 end
95 assert_select ".permissions.environment", false 95 assert_select ".permissions.environment", false
test/functional/search_controller_test.rb
@@ -150,13 +150,13 @@ class SearchControllerTest &lt; ActionController::TestCase @@ -150,13 +150,13 @@ class SearchControllerTest &lt; ActionController::TestCase
150 should 'include extra content supplied by plugins on product asset' do 150 should 'include extra content supplied by plugins on product asset' do
151 class Plugin1 < Noosfero::Plugin 151 class Plugin1 < Noosfero::Plugin
152 def asset_product_extras(product) 152 def asset_product_extras(product)
153 - proc {"<span id='plugin1'>This is Plugin1 speaking!</span>"} 153 + proc {"<span id='plugin1'>This is Plugin1 speaking!</span>".html_safe}
154 end 154 end
155 end 155 end
156 156
157 class Plugin2 < Noosfero::Plugin 157 class Plugin2 < Noosfero::Plugin
158 def asset_product_extras(product) 158 def asset_product_extras(product)
159 - proc {"<span id='plugin2'>This is Plugin2 speaking!</span>"} 159 + proc {"<span id='plugin2'>This is Plugin2 speaking!</span>".html_safe}
160 end 160 end
161 end 161 end
162 Noosfero::Plugin.stubs(:all).returns([Plugin1.to_s, Plugin2.to_s]) 162 Noosfero::Plugin.stubs(:all).returns([Plugin1.to_s, Plugin2.to_s])
test/functional/tasks_controller_test.rb
@@ -75,6 +75,7 @@ class TasksControllerTest &lt; ActionController::TestCase @@ -75,6 +75,7 @@ class TasksControllerTest &lt; ActionController::TestCase
75 75
76 assert_response :success 76 assert_response :success
77 assert_template 'processed' 77 assert_template 'processed'
  78 + assert !assigns(:tasks).nil?
78 assert_kind_of ActiveRecord::Relation, assigns(:tasks) 79 assert_kind_of ActiveRecord::Relation, assigns(:tasks)
79 end 80 end
80 81
@@ -761,32 +762,6 @@ class TasksControllerTest &lt; ActionController::TestCase @@ -761,32 +762,6 @@ class TasksControllerTest &lt; ActionController::TestCase
761 assert_not_includes task_one.tags_from(nil), 'test' 762 assert_not_includes task_one.tags_from(nil), 'test'
762 end 763 end
763 764
764 - should 'filter processed tasks by all filters' do  
765 - requestor = fast_create(Person)  
766 - closed_by = fast_create(Person)  
767 - class AnotherTask < Task; end  
768 -  
769 - created_date = DateTime.now  
770 - processed_date = DateTime.now  
771 -  
772 - task_params = {:status => Task::Status::FINISHED, :requestor => requestor, :target => profile, :created_at => created_date, :end_date => processed_date, :closed_by => closed_by, :data => {:field => 'some data field'}}  
773 -  
774 - task = create(AnotherTask, task_params)  
775 - create(Task, task_params)  
776 - create(AnotherTask, task_params.clone.merge(:status => Task::Status::CANCELLED))  
777 - create(AnotherTask, task_params.clone.merge(:created_at => created_date - 1.day))  
778 - create(AnotherTask, task_params.clone.merge(:created_at => created_date + 1.day))  
779 - create(AnotherTask, task_params.clone.merge(:end_date => processed_date - 1.day))  
780 - create(AnotherTask, task_params.clone.merge(:end_date => processed_date + 1.day))  
781 - create(AnotherTask, task_params.clone.merge(:requestor => fast_create(Person, :name => 'another-requestor')))  
782 - create(AnotherTask, task_params.clone.merge(:closed_by => fast_create(Person, :name => 'another-closer')))  
783 - create(AnotherTask, task_params.clone.merge(:data => {:field => 'other data field'}))  
784 -  
785 - get :processed, :filter => {:type => AnotherTask, :status => Task::Status::FINISHED, :created_from => created_date, :created_until => created_date, :closed_from => processed_date, :closed_until => processed_date, :requestor => requestor.name, :closed_by => closed_by.name, :text => 'some data field'}  
786 - assert_response :success  
787 - assert_equal [task], assigns(:tasks)  
788 - end  
789 -  
790 should 'list custom field details in moderation user tasks when moderation_tasks is true' do 765 should 'list custom field details in moderation user tasks when moderation_tasks is true' do
791 person_custom_field = CustomField.create(:name => "great_field", :format=>"string", :default_value => "value for person", :customized_type=>"Person", :active => true, :environment => Environment.default, :moderation_task => true, :required => true) 766 person_custom_field = CustomField.create(:name => "great_field", :format=>"string", :default_value => "value for person", :customized_type=>"Person", :active => true, :environment => Environment.default, :moderation_task => true, :required => true)
792 p1 = create_user("great_person").person 767 p1 = create_user("great_person").person
@@ -847,4 +822,30 @@ class TasksControllerTest &lt; ActionController::TestCase @@ -847,4 +822,30 @@ class TasksControllerTest &lt; ActionController::TestCase
847 assert_equal [email_template], assigns(:rejection_email_templates) 822 assert_equal [email_template], assigns(:rejection_email_templates)
848 end 823 end
849 824
  825 + should 'filter processed tasks by all filters' do
  826 + requestor = fast_create(Person)
  827 + closed_by = fast_create(Person)
  828 + class AnotherTask < Task; end
  829 +
  830 + created_date = DateTime.now
  831 + processed_date = DateTime.now
  832 +
  833 + task_params = {:status => Task::Status::FINISHED, :requestor => requestor, :target => profile, :created_at => created_date, :end_date => processed_date, :closed_by => closed_by, :data => {:field => 'some data field'}}
  834 +
  835 + task = create(AnotherTask, task_params)
  836 + create(Task, task_params)
  837 + create(AnotherTask, task_params.clone.merge(:status => Task::Status::CANCELLED))
  838 + create(AnotherTask, task_params.clone.merge(:created_at => created_date - 1.day))
  839 + create(AnotherTask, task_params.clone.merge(:created_at => created_date + 1.day))
  840 + create(AnotherTask, task_params.clone.merge(:end_date => processed_date - 1.day))
  841 + create(AnotherTask, task_params.clone.merge(:end_date => processed_date + 1.day))
  842 + create(AnotherTask, task_params.clone.merge(:requestor => fast_create(Person, :name => 'another-requestor')))
  843 + create(AnotherTask, task_params.clone.merge(:closed_by => fast_create(Person, :name => 'another-closer')))
  844 + create(AnotherTask, task_params.clone.merge(:data => {:field => "other data field"}))
  845 +
  846 + get :processed, :filter => {:type => AnotherTask, :status => Task::Status::FINISHED, :created_from => created_date, :created_until => created_date, :closed_from => processed_date, :closed_until => processed_date, :requestor => requestor.name, :closed_by => closed_by.name, :text => "some data field"}
  847 + assert_response :success
  848 + assert_equal [task], assigns(:tasks)
  849 + end
  850 +
850 end 851 end
test/integration/multi_tenancy_test.rb
@@ -29,12 +29,12 @@ class MultiTenancyTest &lt; ActionDispatch::IntegrationTest @@ -29,12 +29,12 @@ class MultiTenancyTest &lt; ActionDispatch::IntegrationTest
29 user = create_user 29 user = create_user
30 session_obj = create(Session, user_id: user.id, session_id: 'some_id', data: {}) 30 session_obj = create(Session, user_id: user.id, session_id: 'some_id', data: {})
31 person_identifier = user.person.identifier 31 person_identifier = user.person.identifier
32 - 32 +
33 Noosfero::MultiTenancy.setup!('schema1.com') 33 Noosfero::MultiTenancy.setup!('schema1.com')
34 host! 'schema2.com' 34 host! 'schema2.com'
35 cookies[:_noosfero_session] = session_obj.session_id 35 cookies[:_noosfero_session] = session_obj.session_id
36 assert_nothing_raised { get "/myprofile/#{person_identifier}" } 36 assert_nothing_raised { get "/myprofile/#{person_identifier}" }
37 - assert_equal 'public', ActiveRecord::Base.connection.schema_search_path 37 + assert_equal 'public', ApplicationRecord.connection.schema_search_path
38 end 38 end
39 39
40 end 40 end
test/mocks/test/environment.rb
1 require File.expand_path(File.dirname(__FILE__) + "/../../../app/models/environment") 1 require File.expand_path(File.dirname(__FILE__) + "/../../../app/models/environment")
2 2
3 -class Environment < ActiveRecord::Base 3 +class Environment < ApplicationRecord
4 def self.available_features 4 def self.available_features
5 { 5 {
6 'feature1' => 'Enable Feature 1', 6 'feature1' => 'Enable Feature 1',
test/mocks/test/test_controller.rb
@@ -22,7 +22,7 @@ class TestController &lt; ApplicationController @@ -22,7 +22,7 @@ class TestController &lt; ApplicationController
22 end 22 end
23 23
24 def help_textile_with_string 24 def help_textile_with_string
25 - render :inline => '<%= help_textile "*my_bold_help_message*" %>' 25 + render :inline => '<%= help_textile "*my_bold_help_message*".html_safe %>'
26 end 26 end
27 27
28 def help_textile_with_block 28 def help_textile_with_block
test/support/factories.rb
@@ -5,9 +5,9 @@ module Noosfero::Factory @@ -5,9 +5,9 @@ module Noosfero::Factory
5 attrs[:slug] = attrs[:name].to_slug if attrs[:name].present? && attrs[:slug].blank? && defaults[:slug].present? 5 attrs[:slug] = attrs[:name].to_slug if attrs[:name].present? && attrs[:slug].blank? && defaults[:slug].present?
6 data = defaults_for(name.to_s.gsub('::','')).merge(attrs) 6 data = defaults_for(name.to_s.gsub('::','')).merge(attrs)
7 klass = name.to_s.camelize.constantize 7 klass = name.to_s.camelize.constantize
8 - if klass.superclass != ActiveRecord::Base  
9 - data[:type] = klass.to_s  
10 - end 8 +
  9 + data[:type] = klass.to_s if klass.column_names.include? 'type'
  10 +
11 if options[:timestamps] 11 if options[:timestamps]
12 fast_insert_with_timestamps(klass, data) 12 fast_insert_with_timestamps(klass, data)
13 else 13 else
@@ -129,7 +129,7 @@ module Noosfero::Factory @@ -129,7 +129,7 @@ module Noosfero::Factory
129 129
130 def fast_insert(klass, data) 130 def fast_insert(klass, data)
131 names = data.keys 131 names = data.keys
132 - values = names.map {|k| ActiveRecord::Base.send(:sanitize_sql_array, ['?', data[k]]) } 132 + values = names.map {|k| ApplicationRecord.send(:sanitize_sql_array, ['?', data[k]]) }
133 sql = 'insert into %s(%s) values (%s)' % [klass.table_name, names.join(','), values.join(',')] 133 sql = 'insert into %s(%s) values (%s)' % [klass.table_name, names.join(','), values.join(',')]
134 klass.connection.execute(sql) 134 klass.connection.execute(sql)
135 klass.order(:id).last 135 klass.order(:id).last
test/test_helper.rb
@@ -187,14 +187,14 @@ class ActiveSupport::TestCase @@ -187,14 +187,14 @@ class ActiveSupport::TestCase
187 end 187 end
188 188
189 def uses_postgresql(schema_name = 'test_schema') 189 def uses_postgresql(schema_name = 'test_schema')
190 - adapter = ActiveRecord::Base.connection.class 190 + adapter = ApplicationRecord.connection.class
191 adapter.any_instance.stubs(:adapter_name).returns('PostgreSQL') 191 adapter.any_instance.stubs(:adapter_name).returns('PostgreSQL')
192 adapter.any_instance.stubs(:schema_search_path).returns(schema_name) 192 adapter.any_instance.stubs(:schema_search_path).returns(schema_name)
193 Noosfero::MultiTenancy.stubs(:on?).returns(true) 193 Noosfero::MultiTenancy.stubs(:on?).returns(true)
194 end 194 end
195 195
196 def uses_sqlite 196 def uses_sqlite
197 - adapter = ActiveRecord::Base.connection.class 197 + adapter = ApplicationRecord.connection.class
198 adapter.any_instance.stubs(:adapter_name).returns('SQLite') 198 adapter.any_instance.stubs(:adapter_name).returns('SQLite')
199 Noosfero::MultiTenancy.stubs(:on?).returns(false) 199 Noosfero::MultiTenancy.stubs(:on?).returns(false)
200 end 200 end
test/unit/blog_helper_test.rb
@@ -43,7 +43,8 @@ class BlogHelperTest &lt; ActionView::TestCase @@ -43,7 +43,8 @@ class BlogHelperTest &lt; ActionView::TestCase
43 "<#{tag}#{options.map{|k,v| " #{k}=\"#{[v].flatten.join(' ')}\""}.join}>#{content}</#{tag}>" 43 "<#{tag}#{options.map{|k,v| " #{k}=\"#{[v].flatten.join(' ')}\""}.join}>#{content}</#{tag}>"
44 end 44 end
45 45
46 - html = Nokogiri::HTML list_posts(blog.posts) 46 + html = Nokogiri::HTML list_posts(blog.posts).html_safe
  47 +
47 assert_select html, "div#post-#{newer_post.id}.blog-post.position-1.first.odd-post" + 48 assert_select html, "div#post-#{newer_post.id}.blog-post.position-1.first.odd-post" +
48 " > div.odd-post-inner.blog-post-inner > .title", 'Last post' 49 " > div.odd-post-inner.blog-post-inner > .title", 'Last post'
49 assert_select html, "div#post-#{hidden_post.id}.blog-post.position-2.not-published.even-post" + 50 assert_select html, "div#post-#{hidden_post.id}.blog-post.position-2.not-published.even-post" +
test/unit/geo_ref_test.rb
@@ -22,7 +22,7 @@ class GeoRefTest &lt; ActiveSupport::TestCase @@ -22,7 +22,7 @@ class GeoRefTest &lt; ActiveSupport::TestCase
22 @acme = Enterprise.create! environment: env, identifier: 'acme', name: 'ACME', 22 @acme = Enterprise.create! environment: env, identifier: 'acme', name: 'ACME',
23 city: 'Salvador', state: 'Bahia', country: 'BR', lat: -12.9, lng: -38.5 23 city: 'Salvador', state: 'Bahia', country: 'BR', lat: -12.9, lng: -38.5
24 def sql_dist_to(ll) 24 def sql_dist_to(ll)
25 - ActiveRecord::Base.connection.execute( 25 + ApplicationRecord.connection.execute(
26 "SELECT #{Noosfero::GeoRef.sql_dist ll[0], ll[1]} as dist" + 26 "SELECT #{Noosfero::GeoRef.sql_dist ll[0], ll[1]} as dist" +
27 " FROM profiles WHERE id = #{@acme.id};" 27 " FROM profiles WHERE id = #{@acme.id};"
28 ).first['dist'].to_f.round 28 ).first['dist'].to_f.round
test/unit/multi_tenancy.rb
@@ -36,7 +36,7 @@ class MultiTenancyTest &lt; ActiveSupport::TestCase @@ -36,7 +36,7 @@ class MultiTenancyTest &lt; ActiveSupport::TestCase
36 36
37 def test_set_schema_by_host 37 def test_set_schema_by_host
38 Noosfero::MultiTenancy.expects(:mapping).returns({ 'host' => 'schema' }) 38 Noosfero::MultiTenancy.expects(:mapping).returns({ 'host' => 'schema' })
39 - adapter = ActiveRecord::Base.connection.class 39 + adapter = ApplicationRecord.connection.class
40 adapter.any_instance.expects(:schema_search_path=).with('schema').returns(true) 40 adapter.any_instance.expects(:schema_search_path=).with('schema').returns(true)
41 assert Noosfero::MultiTenancy.db_by_host = 'host' 41 assert Noosfero::MultiTenancy.db_by_host = 'host'
42 end 42 end
test/unit/plugin_manager_test.rb
@@ -43,13 +43,13 @@ class PluginManagerTest &lt; ActiveSupport::TestCase @@ -43,13 +43,13 @@ class PluginManagerTest &lt; ActiveSupport::TestCase
43 43
44 class Plugin1 < Noosfero::Plugin 44 class Plugin1 < Noosfero::Plugin
45 def random_event 45 def random_event
46 - 'Plugin 1 action.' 46 + 'Plugin 1 action.'.html_safe
47 end 47 end
48 end 48 end
49 49
50 class Plugin2 < Noosfero::Plugin 50 class Plugin2 < Noosfero::Plugin
51 def random_event 51 def random_event
52 - 'Plugin 2 action.' 52 + 'Plugin 2 action.'.html_safe
53 end 53 end
54 end 54 end
55 Noosfero::Plugin.stubs(:all).returns(['PluginManagerTest::Plugin1', 'PluginManagerTest::Plugin2']) 55 Noosfero::Plugin.stubs(:all).returns(['PluginManagerTest::Plugin1', 'PluginManagerTest::Plugin2'])
@@ -70,19 +70,19 @@ class PluginManagerTest &lt; ActiveSupport::TestCase @@ -70,19 +70,19 @@ class PluginManagerTest &lt; ActiveSupport::TestCase
70 70
71 class Plugin1 < Noosfero::Plugin 71 class Plugin1 < Noosfero::Plugin
72 def random_event 72 def random_event
73 - 'Plugin 1 action.' 73 + 'Plugin 1 action.'.html_safe
74 end 74 end
75 end 75 end
76 76
77 class Plugin2 < Noosfero::Plugin 77 class Plugin2 < Noosfero::Plugin
78 def random_event 78 def random_event
79 - 'Plugin 2 action.' 79 + 'Plugin 2 action.'.html_safe
80 end 80 end
81 end 81 end
82 82
83 class Plugin3 < Noosfero::Plugin 83 class Plugin3 < Noosfero::Plugin
84 def random_event 84 def random_event
85 - 'Plugin 3 action.' 85 + 'Plugin 3 action.'.html_safe
86 end 86 end
87 end 87 end
88 Noosfero::Plugin.stubs(:all).returns(['PluginManagerTest::Plugin1', 'PluginManagerTest::Plugin2', 'PluginManagerTest::Plugin3']) 88 Noosfero::Plugin.stubs(:all).returns(['PluginManagerTest::Plugin1', 'PluginManagerTest::Plugin2', 'PluginManagerTest::Plugin3'])
test/unit/recent_documents_block_test.rb
@@ -2,6 +2,8 @@ require_relative &quot;../test_helper&quot; @@ -2,6 +2,8 @@ require_relative &quot;../test_helper&quot;
2 2
3 class RecentDocumentsBlockTest < ActiveSupport::TestCase 3 class RecentDocumentsBlockTest < ActiveSupport::TestCase
4 4
  5 + include ActionView::Helpers::OutputSafetyHelper
  6 +
5 def setup 7 def setup
6 @articles = [] 8 @articles = []
7 @profile = create_user('testinguser').person 9 @profile = create_user('testinguser').person
test/unit/sqlite_extension_test.rb
@@ -1,34 +0,0 @@ @@ -1,34 +0,0 @@
1 -require_relative "../test_helper"  
2 -  
3 -# if this test is run without SQLite (e.g. with mysql or postgres), the tests  
4 -# will just pass. The idea is to test our local extensions to SQLite.  
5 -class SQliteExtensionTest < ActiveSupport::TestCase  
6 -  
7 - if ActiveRecord::Base.connection.adapter_name =~ /^sqlite$/i  
8 -  
9 - should 'have power function' do  
10 - assert_in_delta 8.0, ActiveRecord::Base.connection.execute('select pow(2.0, 3.0) as result').first['result'], 0.0001  
11 - end  
12 -  
13 - should 'have radians function' do  
14 - assert_in_delta Math::PI/2, ActiveRecord::Base.connection.execute('select radians(90) as rad').first['rad'], 0.0001  
15 - end  
16 -  
17 - should 'have square root function' do  
18 - assert_in_delta 1.4142, ActiveRecord::Base.connection.execute('select sqrt(2) as sqrt').first['sqrt'], 0.0001  
19 - end  
20 -  
21 - should 'have a distance function' do  
22 - args = [32.918593, -96.958444, 32.951613, -96.958444].map{|l|l * Math::PI/180}  
23 - assert_in_delta 2.28402, ActiveRecord::Base.connection.execute("select spheric_distance(#{args.inspect[1..-2]}, 3963.19) as dist").first['dist'], 0.0001  
24 - end  
25 -  
26 - else  
27 -  
28 - should 'just pass (not using SQLite)' do  
29 - assert true  
30 - end  
31 -  
32 - end  
33 -  
34 -end