Commit bc7502ae145817797bfffd9ccf3f1943a904b221

Authored by Victor Costa
2 parents 24ead125 df0c5164
Exists in staging and in 1 other branch production

Merge branch 'master' into staging

app/controllers/application_controller.rb
... ... @@ -18,6 +18,13 @@ class ApplicationController < ActionController::Base
18 18 end
19 19 before_filter :redirect_to_current_user
20 20  
  21 + before_filter :set_session_theme
  22 + def set_session_theme
  23 + if params[:theme]
  24 + session[:theme] = environment.theme_ids.include?(params[:theme]) ? params[:theme] : nil
  25 + end
  26 + end
  27 +
21 28 def require_login_for_environment
22 29 login_required
23 30 end
... ...
app/controllers/my_profile/profile_themes_controller.rb
... ... @@ -63,12 +63,12 @@ class ProfileThemesController < ThemesController
63 63 end
64 64  
65 65 def start_test
66   - session[:theme] = params[:id]
  66 + session[:user_theme] = params[:id]
67 67 redirect_to :controller => 'content_viewer', :profile => profile.identifier, :action => 'view_page'
68 68 end
69 69  
70 70 def stop_test
71   - session[:theme] = nil
  71 + session[:user_theme] = nil
72 72 redirect_to :action => 'index'
73 73 end
74 74  
... ...
app/helpers/application_helper.rb
... ... @@ -346,7 +346,7 @@ module ApplicationHelper
346 346 end
347 347  
348 348 def is_testing_theme
349   - !controller.session[:theme].nil?
  349 + !controller.session[:user_theme].nil?
350 350 end
351 351  
352 352 def theme_owner
... ... @@ -595,8 +595,8 @@ module ApplicationHelper
595 595 end
596 596  
597 597 if block
598   - field_html ||= ''
599   - field_html += capture(&block)
  598 + field_html ||= ''.html_safe
  599 + field_html = [field_html, capture(&block)].safe_join
600 600 end
601 601  
602 602 if controller.action_name == 'signup' || controller.action_name == 'new_community' || (controller.controller_name == "enterprise_registration" && controller.action_name == 'index') || (controller.controller_name == 'home' && controller.action_name == 'index' && user.nil?)
... ... @@ -605,7 +605,9 @@ module ApplicationHelper
605 605 end
606 606 else
607 607 if profile.active_fields.include?(name)
608   - result = content_tag('div', field_html + profile_field_privacy_selector(profile, name), :class => 'field-with-privacy-selector')
  608 + result = content_tag :div, class: 'field-with-privacy-selector' do
  609 + [field_html, profile_field_privacy_selector(profile, name)].safe_join
  610 + end
609 611 end
610 612 end
611 613  
... ... @@ -613,10 +615,6 @@ module ApplicationHelper
613 615 result = required(result)
614 616 end
615 617  
616   - if block
617   - concat(result)
618   - end
619   -
620 618 result
621 619 end
622 620  
... ... @@ -983,6 +981,7 @@ module ApplicationHelper
983 981 values = {}
984 982 values.merge!(task.information[:variables]) if task.information[:variables]
985 983 values.merge!({:requestor => link_to(task.requestor.name, task.requestor.url)}) if task.requestor
  984 + values.merge!({:target => link_to(task.target.name, task.target.url)}) if (task.target && task.target.respond_to?(:url))
986 985 values.merge!({:subject => content_tag('span', task.subject, :class=>'task_target')}) if task.subject
987 986 values.merge!({:linked_subject => link_to(content_tag('span', task.linked_subject[:text], :class => 'task_target'), task.linked_subject[:url])}) if task.linked_subject
988 987 (task.information[:message] % values).html_safe
... ...
app/helpers/theme_loader_helper.rb
... ... @@ -2,8 +2,8 @@ module ThemeLoaderHelper
2 2 def current_theme
3 3 @current_theme ||=
4 4 begin
5   - if session[:theme]
6   - session[:theme]
  5 + if session[:user_theme]
  6 + session[:user_theme]
7 7 else
8 8 # utility for developers: set the theme to 'random' in development mode and
9 9 # you will get a different theme every request. This is interesting for
... ... @@ -11,8 +11,8 @@ module ThemeLoaderHelper
11 11 if Rails.env.development? && environment.theme == 'random'
12 12 @random_theme ||= Dir.glob('public/designs/themes/*').map { |f| File.basename(f) }.rand
13 13 @random_theme
14   - elsif Rails.env.development? && respond_to?(:params) && params[:theme] && File.exists?(Rails.root.join('public/designs/themes', params[:theme]))
15   - params[:theme]
  14 + elsif Rails.env.development? && respond_to?(:params) && params[:user_theme] && File.exists?(Rails.root.join('public/designs/themes', params[:user_theme]))
  15 + params[:user_theme]
16 16 else
17 17 if profile && !profile.theme.nil?
18 18 profile.theme
... ... @@ -34,8 +34,10 @@ module ThemeLoaderHelper
34 34 end
35 35  
36 36 def theme_path
37   - if session[:theme]
  37 + if session[:user_theme]
38 38 '/user_themes/' + current_theme
  39 + elsif session[:theme]
  40 + '/designs/themes/' + session[:theme]
39 41 else
40 42 '/designs/themes/' + current_theme
41 43 end
... ...
app/models/add_member.rb
... ... @@ -37,6 +37,10 @@ class AddMember < Task
37 37 true
38 38 end
39 39  
  40 + def reject_details
  41 + true
  42 + end
  43 +
40 44 def footer
41 45 true
42 46 end
... ... @@ -72,8 +76,9 @@ class AddMember < Task
72 76 end
73 77  
74 78 def task_cancelled_message
75   - _("Your request to enter community \"%{target} with the profile \"%{requestor}\" was not accepted. Please contact any profile admin from %{url} for more information.") %
76   - {:target => self.target.name, :url => self.target.url,
77   - :requestor => self.requestor.name}
  79 + _("Your request to enter community \"%{target}\" with the profile \"%{requestor}\" was not accepted. Please contact any profile admin from %{target} for more information. The following explanation was given: \n\n\"%{explanation}\"") %
  80 + {:target => self.target.name,
  81 + :requestor => self.requestor.name,
  82 + :explanation => self.reject_explanation}
78 83 end
79 84 end
... ...
app/models/environment.rb
... ... @@ -750,6 +750,10 @@ class Environment < ApplicationRecord
750 750 end
751 751 end
752 752  
  753 + def theme_ids
  754 + settings[:themes] || []
  755 + end
  756 +
753 757 def themes=(values)
754 758 settings[:themes] = values
755 759 end
... ...
app/models/person_notifier.rb
... ... @@ -82,7 +82,7 @@ class PersonNotifier
82 82 helper ActionTrackerHelper
83 83  
84 84 def session
85   - {:theme => nil}
  85 + {:user_theme => nil}
86 86 end
87 87  
88 88 def content_summary(person, notifications, tasks)
... ...
plugins/analytics/views/analytics_plugin/_body_ending.html.slim
1 1 javascript:
2   - analytics.timeOnPage.baseUrl = #{url_for(controller: 'analytics_plugin/time_on_page').to_json}
  2 + analytics.timeOnPage.baseUrl = #{url_for(profile: profile.identifier, controller: 'analytics_plugin/time_on_page').to_json}
3 3 analytics.timeOnPage.updateInterval = #{AnalyticsPlugin::TimeOnPageUpdateIntervalMs.to_json}
4 4 analytics.requestId = #{request.env['action_dispatch.request_id'].to_json}
5 5 analytics.init()
... ...
plugins/metadata/lib/metadata_plugin/base.rb
1   -
2 1 class MetadataPlugin::Base < Noosfero::Plugin
3 2  
4 3 def self.plugin_name
... ... @@ -71,6 +70,6 @@ end
71 70  
72 71 ActiveSupport.run_load_hooks :metadata_plugin, MetadataPlugin
73 72 ActiveSupport.on_load :active_record do
74   - ApplicationRecord.extend MetadataPlugin::Specs::ClassMethods
  73 + ActiveRecord::Base.extend MetadataPlugin::Specs::ClassMethods
75 74 end
76 75  
... ...
plugins/products/test/unit/profile_test.rb
... ... @@ -22,9 +22,8 @@ class ProfileTest &lt; ActiveSupport::TestCase
22 22 end
23 23  
24 24 should 'collect the highlighted products with image' do
25   - env = Environment.default
26 25 e1 = fast_create(Enterprise)
27   - p1 = create(Product, name: 'test_prod1', product_category_id: @product_category.id, enterprise: e1)
  26 + create(Product, name: 'test_prod1', product_category_id: @product_category.id, enterprise: e1)
28 27 products = []
29 28 3.times {|n|
30 29 products.push(create(Product, name: "product #{n}", profile_id: e1.id,
... ... @@ -36,7 +35,8 @@ class ProfileTest &lt; ActiveSupport::TestCase
36 35 create(Product, name: "product 5", profile_id: e1.id, product_category_id: @product_category.id, image_builder: {
37 36 uploaded_data: fixture_file_upload('/files/rails.png', 'image/png')
38 37 })
39   - assert_equal products, e1.highlighted_products_with_image
  38 +
  39 + assert_equivalent products, e1.highlighted_products_with_image
40 40 end
41 41  
42 42 should 'have many inputs through products' do
... ...
plugins/products/views/profile_editor/_products_profile_info_contents.html.slim 0 → 100644
... ... @@ -0,0 +1,3 @@
  1 +- if profile.enterprise?
  2 + h2= _('Products/Services catalog')
  3 + = labelled_form_field(_('Number of products/services displayed per page on catalog'), text_field(:profile_data, :products_per_catalog_page, size: 3))
... ...
plugins/products/views/profile_editor/products_profile_info_contents.html.slim
... ... @@ -1,3 +0,0 @@
1   -- if profile.enterprise?
2   - h2= _('Products/Services catalog')
3   - = labelled_form_field(_('Number of products/services displayed per page on catalog'), text_field(:profile_data, :products_per_catalog_page, size: 3))
plugins/responsive/lib/ext/application_helper.rb
... ... @@ -5,7 +5,7 @@ module ApplicationHelper
5 5 protected
6 6  
7 7 module ResponsiveMethods
8   - FORM_CONTROL_CLASS = "form-control"
  8 + FORM_CONTROL_CLASS = 'form-control'
9 9  
10 10 def button(type, label, url, html_options = {})
11 11 return super unless theme_responsive?
... ... @@ -13,15 +13,14 @@ module ApplicationHelper
13 13 option = html_options.delete(:option) || 'default'
14 14 size = html_options.delete(:size) || 'xs'
15 15 the_class = "with-text btn btn-#{size} btn-#{option} icon-#{type}"
16   - if html_options.has_key?(:class)
17   - the_class << ' ' << html_options[:class]
18   - end
19   - #button_without_text type, label, url, html_options.merge(:class => the_class)
  16 + the_class << ' ' << html_options[:class] if html_options.has_key?(:class)
  17 +
  18 + #button_without_text type, label, url, html_options.merge(class: the_class)
20 19 the_title = html_options[:title] || label
21 20 if html_options[:disabled]
22   - content_tag('a', content_tag('span', label), html_options.merge(class: the_class, title: the_title))
  21 + content_tag(:a, content_tag(:span, label), html_options.merge(class: the_class, title: the_title))
23 22 else
24   - link_to(content_tag('span', label), url, html_options.merge(class: the_class, title: the_title))
  23 + link_to(content_tag(:span, label), url, html_options.merge(class: the_class, title: the_title))
25 24 end
26 25 end
27 26  
... ... @@ -36,7 +35,7 @@ module ApplicationHelper
36 35 end
37 36 the_title = html_options[:title] || label
38 37 if html_options[:disabled]
39   - content_tag('a', '', html_options.merge(class: the_class, title: the_title))
  38 + content_tag(:a, '', html_options.merge(class: the_class, title: the_title))
40 39 else
41 40 link_to('', url, html_options.merge(class: the_class, title: the_title))
42 41 end
... ... @@ -91,7 +90,7 @@ module ApplicationHelper
91 90 if html_options.has_key?(:class)
92 91 the_class << ' ' << html_options[:class]
93 92 end
94   - content_tag('div', '', html_options.merge(class: the_class))
  93 + content_tag(:div, '', html_options.merge(class: the_class))
95 94 end
96 95  
97 96 def icon_button(type, text, url, html_options = {})
... ... @@ -104,16 +103,21 @@ module ApplicationHelper
104 103 the_class << ' ' << html_options[:class]
105 104 end
106 105  
107   - link_to(content_tag('span', text), url, html_options.merge(class: the_class, title: text))
  106 + link_to(content_tag(:span, text), url, html_options.merge(class: the_class, title: text))
108 107 end
109 108  
110   - def button_bar(options = {}, &block)
  109 + def button_bar options = {}, &block
111 110 return super unless theme_responsive?
112 111  
113   - options[:class].nil? ?
114   - options[:class]='button-bar' :
115   - options[:class]+=' button-bar'
116   - concat(content_tag('div', capture(&block).to_s + tag('br', style: 'clear: left;'), options))
  112 + options[:class] ||= ''
  113 + options[:class] << 'button-bar'
  114 +
  115 + content_tag :div, options do
  116 + [
  117 + capture(&block).to_s,
  118 + tag('br', style: 'clear: left;'),
  119 + ].safe_join
  120 + end
117 121 end
118 122  
119 123 def expirable_button(content, action, text, url, html_options = {})
... ... @@ -128,143 +132,93 @@ module ApplicationHelper
128 132 def search_contents_menu
129 133 return super unless theme_responsive?
130 134  
131   - host = environment.default_hostname
132   -
133   - output = '<li class="dropdown">'
134   - output += link_to(_('Contents'), '#', :class=>"dropdown-toggle icon-menu-articles", title: _('Contents'), :'data-toggle'=>"dropdown", :'data-hover'=>"dropdown")
135   - output += '<ul class="dropdown-menu" role="menu">'
136   -
137   - output += '<li>' + link_to(_('All contents'), {host: host, controller: "search", action: 'contents', category_path: ''}) + '</li>'
138   -
  135 + host = environment.default_hostname
139 136 links = [
140   - {s_('contents|More recent') => {:href => url_for({host: host, :controller => 'search', :action => 'contents', :filter => 'more_recent'})}},
141   - {s_('contents|More viewed') => {:href => url_for({host: host, :controller => 'search', :action => 'contents', :filter => 'more_popular'})}},
142   - {s_('contents|Most commented') => {:href => url_for({host: host, :controller => 'search', :action => 'contents', :filter => 'more_comments'})}}
  137 + [_('All contents'), {host: host, controller: :search, action: :contents, category_path: ''}],
  138 + [s_('contents|More recent'), {host: host, controller: :search, action: :contents, filter: 'more_recent'}],
  139 + [s_('contents|More viewed'), {host: host, controller: :search, action: :contents, filter: 'more_popular'}],
  140 + [s_('contents|Most commented'), {host: host, controller: :search, action: :contents, filter: 'more_comments'}],
143 141 ]
144 142 if logged_in?
145   - links.push(_('New content') => modal_options({href: url_for({controller: 'cms', action: 'new', profile: current_user.login, cms: true})}))
  143 + links.push [_('New content'), '', modal_options({href: url_for({controller: 'cms', action: 'new', profile: current_user.login, cms: true})})]
146 144 end
147 145  
148   - links.each do |link|
149   - link.each do |name, options|
150   - output += content_tag(:li,content_tag(:a,name,options))
151   - end
  146 + content_tag :li, class: 'dropdown' do
  147 + [
  148 + link_to('#', class: 'dropdown-toggle icon-menu-articles', title: _('Contents'), data: {toggle: 'dropdown', hover: 'dropdown'}) do
  149 + content_tag :span, _('Contents')
  150 + end,
  151 + content_tag(:ul, class: 'dropdown-menu', role: 'menu') do
  152 + links.map do |(name, url)|
  153 + content_tag :li do
  154 + link_to name, url
  155 + end
  156 + end.safe_join
  157 + end,
  158 + ].safe_join
152 159 end
153   -
154   - output += '</ul>'
155   - output += '</li>'
156   - output
157 160 end
158 161  
159 162 def search_people_menu
160 163 return super unless theme_responsive?
161 164  
162   - host = environment.default_hostname
163   -
164   - output = '<li class="dropdown">'
165   - output += link_to(_('People'), '#', :class=>"dropdown-toggle icon-menu-people", title: _('People'), :'data-toggle'=>"dropdown", :'data-hover'=>"dropdown")
166   - output += '<ul class="dropdown-menu" role="menu">'
167   -
168   - output += '<li>' + link_to(_('All people'), {host: host, controller: "search", action: 'people', category_path: ''}) + '</li>'
169   -
  165 + host = environment.default_hostname
170 166 links = [
171   - {s_('people|More recent') => {:href => url_for({host: host, :controller => 'search', :action => 'people', :filter => 'more_recent'})}},
172   - {s_('people|More active') => {:href => url_for({host: host, :controller => 'search', :action => 'people', :filter => 'more_active'})}},
173   - {s_('people|More popular') => {:href => url_for({host: host, :controller => 'search', :action => 'people', :filter => 'more_popular'})}}
  167 + [_('All people'), {host: host, controller: :search, action: :people, category_path: ''}],
  168 + [s_('people|More recent'), {host: host, controller: :search, action: :people, filter: 'more_recent'}],
  169 + [s_('people|More active'), {host: host, controller: :search, action: :people, filter: 'more_active'}],
  170 + [s_('people|More popular'), {host: host, controller: :search, action: :people, filter: 'more_popular'}],
174 171 ]
175 172 if logged_in?
176   - links.push(_('My friends') => {href: url_for({profile: current_user.login, controller: 'friends'})})
177   - links.push(_('Invite friends') => {href: url_for({profile: current_user.login, controller: 'invite', action: 'friends'})})
  173 + links.push [_('My friends'), {profile: current_user.login, controller: 'friends'}]
  174 + links.push [_('Invite friends'), {profile: current_user.login, controller: 'invite', action: 'friends'}]
178 175 end
179 176  
180   - links.each do |link|
181   - link.each do |name, url|
182   - output += '<li><a href="'+url[:href]+'">' + name + '</a></li>'
183   - end
  177 + content_tag :li, class: 'dropdown' do
  178 + [
  179 + link_to('#', class: "dropdown-toggle icon-menu-people", title: _('People'), data: {toggle: 'dropdown', hover: 'dropdown'}) do
  180 + content_tag :span, _('People')
  181 + end,
  182 + content_tag(:ul, class: 'dropdown-menu', role: 'menu') do
  183 + links.map do |params|
  184 + content_tag :li do
  185 + link_to *params
  186 + end
  187 + end.safe_join
  188 + end
  189 + ].safe_join
184 190 end
185   -
186   - output += '</ul>'
187   - output += '</li>'
188   - output
189 191 end
190 192  
191 193 def search_communities_menu
192 194 return super unless theme_responsive?
193 195  
194   - host = environment.default_hostname
195   -
196   - output = '<li class="dropdown">'
197   - output += link_to(_('Communities'), '#', :class=>"dropdown-toggle icon-menu-community", title: _('Communities'), :'data-toggle'=>"dropdown", :'data-hover'=>"dropdown")
198   - output += '<ul class="dropdown-menu" role="menu">'
199   -
200   - output += '<li>' + link_to(_('All communities'), {host: host, controller: "search", action: 'communities', category_path: ''}) + '</li>'
201   -
  196 + host = environment.default_hostname
202 197 links = [
203   - {s_('communities|More recent') => {:href => url_for({host: host, :controller => 'search', :action => 'communities', :filter => 'more_recent'})}},
204   - {s_('communities|More active') => {:href => url_for({host: host, :controller => 'search', :action => 'communities', :filter => 'more_active'})}},
205   - {s_('communities|More popular') => {:href => url_for({host: host, :controller => 'search', :action => 'communities', :filter => 'more_popular'})}}
  198 + [_('All communities'), {host: host, controller: :search, action: :communities, category_path: ''}],
  199 + [s_('communities|More recent'), {host: host, controller: :search, action: :communities, filter: 'more_recent'}],
  200 + [s_('communities|More active'), {host: host, controller: :search, action: :communities, filter: 'more_active'}],
  201 + [s_('communities|More popular'), {host: host, controller: :search, action: :communities, filter: 'more_popular'}],
206 202 ]
207 203 if logged_in?
208   - links.push(_('My communities') => {href: url_for({profile: current_user.login, controller: 'memberships'})})
209   - links.push(_('New community') => {href: url_for({profile: current_user.login, controller: 'memberships', action: 'new_community'})})
  204 + links.push [_('My communities'), {profile: current_user.login, controller: 'memberships'}]
  205 + links.push [_('New community'), {profile: current_user.login, controller: 'memberships', action: 'new_community'}]
210 206 end
211 207  
212   - links.each do |link|
213   - link.each do |name, url|
214   - output += '<li><a href="'+url[:href]+'">' + name + '</a></li>'
215   - end
216   - end
217   -
218   - output += '</ul>'
219   - output += '</li>'
220   - output
221   - end
222   -
223   - def usermenu_logged_in
224   - return super unless theme_responsive?
225   -
226   - output = '<li class="dropdown">'
227   -
228   - pending_tasks_count = ''
229   - count = user ? Task.to(user).pending.count : -1
230   - if count > 0
231   - pending_tasks_count = "<span class=\"badge\" onclick=\"document.location='#{url_for(user.tasks_url)}'\" title=\"#{_("Manage your pending tasks")}\">" + count.to_s + '</span>'
  208 + content_tag :li, class: 'dropdown' do
  209 + [
  210 + link_to('#', class: 'dropdown-toggle icon-menu-community', title: _('Communities'), data: {toggle: 'dropdown', hover: 'dropdown'}) do
  211 + content_tag :span, _('Communities')
  212 + end,
  213 + content_tag(:ul, class: 'dropdown-menu', role: 'menu') do
  214 + links.map do |params|
  215 + content_tag :li do
  216 + link_to *params
  217 + end
  218 + end.safe_join
  219 + end
  220 + ].safe_join
232 221 end
233   -
234   - output += link_to("<img class=\"menu-user-gravatar\" src=\"#{user.profile_custom_icon(gravatar_default)}\"><strong>#{user.identifier}</strong> #{pending_tasks_count}", '#', id: "homepage-link", title: _('Go to your homepage'), :class=>"dropdown-toggle", :'data-toggle'=>"dropdown", :'data-target'=>"", :'data-hover'=>"dropdown")
235   -
236   -
237   - output += '<ul class="dropdown-menu" role="menu">'
238   - output += '<li>' + link_to('<span class="icon-person">'+_('Profile')+'</span>', user.public_profile_url, id: "homepage-link", title: _('Go to your homepage')) + '</li>'
239   -
240   - output += '<li class="divider"></li>'
241   -
242   - #TODO
243   - #render_environment_features(:usermenu) +
244   -
245   - #admin_link
246   - admin_link_str = admin_link
247   - output += admin_link_str.present? ? '<li>' + admin_link_str + '</li>' : ''
248   -
249   - #control_panel link
250   - output += '<li>' + 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")) + '</li>'
251   -
252   - output += chat_user_status_menu('icon-menu-offline', _('Offline'))
253   -
254   - #manage_enterprises
255   - manage_enterprises_str = manage_enterprises
256   - output += manage_enterprises_str.present? ? '<li>' + manage_enterprises_str + '</li>' : ''
257   -
258   - #manage_communities
259   - manage_communities_str = manage_communities
260   - output += manage_communities_str.present? ? '<li>' + manage_communities_str + '</li>' : ''
261   -
262   - output += '<li class="divider"></li>'
263   -
264   - output += '<li>' + link_to('<i class="icon-menu-logout"></i><strong>' + _('Logout') + '</strong>', { controller: 'account', action: 'logout'} , id: "logout", title: _("Leave the system")) + '</li>'
265   -
266   - output += '</ul>'
267   - output
268 222 end
269 223  
270 224 def manage_link(list, kind, title)
... ... @@ -274,17 +228,22 @@ module ApplicationHelper
274 228 link_to_all = nil
275 229 if list.count > 5
276 230 list = list.first(5)
277   - link_to_all = link_to(content_tag('strong', _('See all')), :controller => 'memberships', :profile => user.identifier)
  231 + link_to_all = link_to(content_tag(:strong, _('See all')), controller: 'memberships', profile: user.identifier)
278 232 end
279 233 link = list.map do |element|
280   - link_to(content_tag('strong', element.short_name(25)), element.admin_url, :class => "icon-menu-"+element.class.identification.underscore, :title => _('Manage %s') % element.short_name)
  234 + link_to(content_tag(:strong, element.short_name(25)), element.admin_url, class: "icon-menu-"+element.class.identification.underscore, title: _('Manage %s') % element.short_name)
281 235 end
282 236 if link_to_all
283 237 link << link_to_all
284 238 end
285   - content_tag('li', nil, class: 'divider') +
286   - content_tag('li', title, class: 'dropdown-header') +
287   - link.map{ |l| content_tag 'li', l }.join
  239 +
  240 + [
  241 + content_tag(:li, nil, class: 'divider'),
  242 + content_tag(:li, title, class: 'dropdown-header'),
  243 + link.map do |l|
  244 + content_tag :li, l
  245 + end.safe_join
  246 + ].safe_join
288 247 end
289 248 end
290 249  
... ... @@ -301,15 +260,24 @@ module ApplicationHelper
301 260 unless html_options[:style].present? and html_options[:style] =~ /display *: *none/
302 261 menu_content << '<br/>' unless first
303 262 first = false
304   - menu_content << content_tag(:a,link_label,html_options)
  263 + menu_content << content_tag(:a, link_label,html_options)
305 264 end
306 265 end
307 266 end
308 267 end
309 268  
310 269 option = html_options.delete(:option) || 'default'
311   - size = html_options.delete(:size) || 'xs'
312   - "<button class='btn btn-#{size} btn-#{option} btn-popover-menu icon-parent-folder' data-toggle='popover' data-html='true' data-placement='top' data-trigger='focus' data-content=\""+CGI::escapeHTML(menu_content)+'" data-title="'+menu_title+'"></button>'
  270 + size = html_options.delete(:size) || 'xs'
  271 + button_tag '',
  272 + class: "btn btn-#{size} btn-#{option} btn-popover-menu icon-parent-folder",
  273 + data: {
  274 + html: 'true',
  275 + toggle: 'popover',
  276 + placement: 'top',
  277 + trigger: 'focus',
  278 + content: menu_content,
  279 + title: menu_title,
  280 + }
313 281 end
314 282  
315 283  
... ... @@ -406,12 +374,7 @@ module ApplicationHelper
406 374 end
407 375  
408 376 include ResponsiveChecks
409   - if RUBY_VERSION >= '2.0.0'
410   - prepend ResponsiveMethods
411   - else
412   - extend ActiveSupport::Concern
413   - included { include ResponsiveMethods }
414   - end
  377 + prepend ResponsiveMethods
415 378  
416 379 # TODO: apply theme_responsive? condition
417 380 class NoosferoFormBuilder
... ... @@ -440,13 +403,16 @@ module ApplicationHelper
440 403  
441 404 if options[:horizontal]
442 405 label_html = content_tag :label, gettext(text), class: 'control-label col-sm-3 col-md-2 col-lg-2', for: field_id
443   - result = content_tag :div, label_html + content_tag('div',field_html, class: 'col-sm-9 col-md-6 col-lg-6'), class: 'form-group'
  406 + content = [
  407 + label_html,
  408 + content_tag(:div, field_html.html_safe, class: 'col-sm-9 col-md-6 col-lg-6'),
  409 + ].safe_join
  410 + content_tag :div, content, class: 'form-group'
444 411 else
445 412 label_html = content_tag :label, gettext(text), class: 'control-label', for: field_id
446   - result = content_tag :div, label_html + field_html, class: 'form-group'
  413 + content = [label_html, field_html.html_safe].safe_join
  414 + content_tag :div, content, class: 'form-group'
447 415 end
448   -
449   - result
450 416 end
451 417 end
452 418  
... ...
plugins/responsive/lib/ext/boxes_helper.rb
... ... @@ -62,12 +62,7 @@ module BoxesHelper
62 62 end
63 63  
64 64 include ResponsiveChecks
65   - if RUBY_VERSION >= '2.0.0'
66   - prepend ResponsiveMethods
67   - else
68   - extend ActiveSupport::Concern
69   - included { include ResponsiveMethods }
70   - end
  65 + prepend ResponsiveMethods
71 66  
72 67 end
73 68  
... ...
plugins/responsive/lib/ext/chat_helper.rb
... ... @@ -23,12 +23,7 @@ module ChatHelper
23 23 end
24 24  
25 25 include ResponsiveChecks
26   - if RUBY_VERSION >= '2.0.0'
27   - prepend ResponsiveMethods
28   - else
29   - extend ActiveSupport::Concern
30   - included { include ResponsiveMethods }
31   - end
  26 + prepend ResponsiveMethods
32 27  
33 28 end
34 29  
... ...
plugins/responsive/lib/ext/forms_helper.rb
... ... @@ -11,8 +11,15 @@ module FormsHelper
11 11 return super unless theme_responsive?
12 12  
13 13 options[:id] ||= 'radio-' + FormsHelper.next_id_number
14   - content_tag( 'label', radio_button_tag( name, value, checked, options ) + ' ' +
15   - human_name, for: options[:id], class: 'radio-inline' )
  14 + content_tag :div, class:'radio-inline' do
  15 + content_tag :label, for: options[:id] do
  16 + [
  17 + radio_button_tag(name, value, checked, options),
  18 + ' ',
  19 + human_name,
  20 + ].safe_join
  21 + end
  22 + end
16 23 end
17 24  
18 25 # add -inline class
... ... @@ -20,8 +27,18 @@ module FormsHelper
20 27 return super unless theme_responsive?
21 28  
22 29 options[:id] ||= 'checkbox-' + FormsHelper.next_id_number
23   - hidden_field_tag(name, '0') +
24   - content_tag( 'label', check_box_tag( name, value, checked, options ) + ' ' + human_name, for: options[:id], class: 'checkbox-inline')
  30 + [
  31 + hidden_field_tag(name, '0'),
  32 + content_tag(:div, class:'checkbox-inline') do
  33 + content_tag :label, for: options[:id] do
  34 + [
  35 + check_box_tag(name, value, checked, options),
  36 + ' ',
  37 + human_name,
  38 + ].safe_join
  39 + end
  40 + end
  41 + ].safe_join
25 42 end
26 43  
27 44 def submit_button(type, label, html_options = {})
... ... @@ -43,42 +60,34 @@ module FormsHelper
43 60 html_options.delete(:cancel)
44 61 bt_submit = button_tag(label, html_options.merge(class: the_class))
45 62  
46   - bt_submit + bt_cancel
  63 + [bt_submit + bt_cancel].safe_join
47 64 end
48 65  
49   - %w[select select_tag text_field_tag number_field_tag password_field_tag].each do |method|
50   - define_method method do |*args, &block|
51   - #return super(*args, &block) unless theme_responsive?
  66 + bt_submit + bt_cancel
  67 + end
52 68  
53   - options = args.extract_options!
54   - if options['class']
55   - options['class'] = "#{options['class']} form-control"
56   - else
57   - options[:class] = "#{options[:class]} form-control"
58   - end
59   - super(*(args << options), &block)
  69 + %w[
  70 + select_tag
  71 + text_field_tag text_area_tag
  72 + number_field_tag password_field_tag url_field_tag email_field_tag
  73 + month_field_tag date_field_tag
  74 + ].each do |method|
  75 + define_method method do |name, value=nil, options={}, &block|
  76 + responsive_add_field_class! options
  77 + super(name, value, options, &block).html_safe
60 78 end
61 79 end
62 80 %w[select_month select_year].each do |method|
63 81 define_method method do |date, options={}, html_options={}|
64   - if html_options['class']
65   - html_options['class'] = "#{html_options['class']} form-control"
66   - else
67   - html_options[:class] = "#{html_options[:class]} form-control"
68   - end
69   - super date, options, html_options
  82 + responsive_add_field_class! html_options
  83 + super(date, options, html_options).html_safe
70 84 end
71 85 end
72 86  
73 87 end
74 88  
75 89 include ResponsiveChecks
76   - if RUBY_VERSION >= '2.0.0'
77   - prepend ResponsiveMethods
78   - else
79   - extend ActiveSupport::Concern
80   - included { include ResponsiveMethods }
81   - end
  90 + prepend ResponsiveMethods
82 91  
83 92 end
84 93  
... ...
plugins/responsive/lib/ext/input_helper.rb
... ... @@ -4,16 +4,15 @@ module InputHelper
4 4 protected
5 5  
6 6 def input_group_addon addon, options = {}, &block
7   - content_tag :div,
8   - content_tag(:span, addon, class: 'input-group-addon') + yield,
9   - class: 'input-group'
  7 + content_tag :div, class: 'input-group' do
  8 + [
  9 + content_tag(:span, addon, class: 'input-group-addon'),
  10 + capture(&block),
  11 + ].safe_join
  12 + end
10 13 end
11 14  
12 15 end
13 16  
14   -module ApplicationHelper
15   -
16   - include InputHelper
17   -
18   -end
  17 +ApplicationHelper.include InputHelper
19 18  
... ...
plugins/responsive/lib/responsive_plugin.rb
... ... @@ -13,7 +13,7 @@ class ResponsivePlugin &lt; Noosfero::Plugin
13 13 end
14 14  
15 15 def head_ending
16   - '<meta name="viewport" content="width=device-width, initial-scale=1">'
  16 + '<meta name="viewport" content="width=device-width, initial-scale=1">'.html_safe
17 17 end
18 18  
19 19 def body_ending
... ...
plugins/responsive/views/layouts/_menu_responsive.html.erb
... ... @@ -1,71 +0,0 @@
1   -<div>
2   -<nav id="top-bar" class="navbar navbar-default" role="navigation">
3   - <div class="container">
4   - <!-- Brand and toggle get grouped for better mobile display -->
5   - <div class="navbar-header">
6   - <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-user-collapse">
7   - <span class="sr-only"><%= _('User menu') %></span>
8   - <span class="fa fa-user navbar-toggle-icon"></span>
9   - </button>
10   - <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-search-collapse">
11   - <span class="sr-only"><%= _('Search') %></span>
12   - <span class="fa fa-search navbar-toggle-icon"></span>
13   - </button>
14   - <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-navigation-collapse">
15   - <span class="sr-only"><%= _('Navigation') %></span>
16   - <span class="icon-bar"></span>
17   - <span class="icon-bar"></span>
18   - <span class="icon-bar"></span>
19   - </button>
20   -
21   - </div>
22   -
23   - <!-- Collect the nav links, forms, and other content for toggling -->
24   - <div class="collapse navbar-collapse" id="navbar-navigation-collapse">
25   - <ul class="nav navbar-nav menu-navigation">
26   - <%= theme_extra_navigation %>
27   - <li class="dropdown" id="search-dropdown-menu">
28   - <a href="#" class="dropdown-toggle icon-search" data-hover="dropdown" data-toggle="dropdown" title="<%= _('Search') %>"><span><%= _('Search') %></span></a>
29   - <ul class="dropdown-menu" role="menu">
30   - <li>
31   - <form action="/search" id="top-search" method="get" role="search">
32   - <div class="form-group col-lg-12 col-md-12 col-sm-12">
33   - <input name="query" title="<%=_('Search...')%>" placeholder="<%=_('Search...')%>" type="text" class="form-control input-sm"/>
34   - </div>
35   - </form>
36   - </li>
37   - </ul>
38   - </li>
39   - </ul>
40   - </div>
41   - <div class="collapse navbar-collapse" id="navbar-search-collapse">
42   - <form action="/search" id="top-search" class="navbar-form navbar-left" method="get" role="search">
43   - <div class="form-group">
44   - <input name="query" title="<%=_('Search...')%>" placeholder="<%=_('Search...')%>" type="text" class="form-control"/>
45   - </div>
46   - </form>
47   - </div>
48   - <div class="collapse navbar-collapse" id="navbar-user-collapse">
49   - <ul class="nav navbar-nav pull-right">
50   - <% if user.present? %>
51   - <%= usermenu_logged_in %>
52   - <% else %>
53   - <li>
54   - <%= modal_inline_link_to('<i class="icon-menu-login"></i><strong>' + _('Login') + '</strong>', login_url, '#inlineLoginBox', :id => 'link_login') %>
55   - <%= @plugins.dispatch(:alternative_authentication_link).collect { |content| instance_exec(&content) }.join("") #TODO review this
56   - %>
57   - </li>
58   - <% unless @plugins.dispatch(:allow_user_registration).include?(false) %>
59   - <li>
60   - <%= link_to('<strong>' + _('Sign up') + '</strong>', :controller => 'account', :action => 'signup')%>
61   - </li>
62   - <% end %>
63   - <% end %>
64   - </ul>
65   - </div><!-- /.navbar-collapse -->
66   - </div><!-- /.container-fluid -->
67   -</nav>
68   -</div>
69   -<div id='inlineLoginBox' style='display: none;'>
70   - <%= render :file => 'account/login', :locals => { :is_thickbox => true } %>
71   -</div>
plugins/responsive/views/layouts/_menu_responsive.html.slim 0 → 100644
... ... @@ -0,0 +1,54 @@
  1 +div
  2 + nav#top-bar.navbar.navbar-default.navbar-static-top role="navigation"
  3 + .container
  4 + /! Brand and toggle get grouped for better mobile display
  5 + .navbar-header
  6 + button.navbar-toggle data-target="#navbar-user-collapse" data-toggle="collapse" type="button"
  7 + span.sr-only= _('User menu')
  8 + span.fa.fa-user.navbar-toggle-icon
  9 +
  10 + button.navbar-toggle data-target="#navbar-search-collapse" data-toggle="collapse" type="button"
  11 + span.sr-only= _('Search')
  12 + span.fa.fa-search.navbar-toggle-icon
  13 +
  14 + button.navbar-toggle data-target="#navbar-navigation-collapse" data-toggle="collapse" type="button"
  15 + span.sr-only= _('Navigation')
  16 + span.icon-bar
  17 + span.icon-bar
  18 + span.icon-bar
  19 + a.navbar-brand href="#{environment.top_url}"
  20 + = theme_site_title
  21 + span#navbar-brand-site-title
  22 + = h @environment.name
  23 +
  24 + /! Collect the nav links, forms, and other content for toggling
  25 + #navbar-navigation-collapse.collapse.navbar-collapse
  26 + ul.nav.navbar-nav.menu-navigation
  27 + = theme_extra_navigation
  28 + li#search-dropdown-menu.dropdown
  29 + a.dropdown-toggle.icon-search data-hover="dropdown" data-toggle="dropdown" href="#" title="#{_('Search')}"
  30 + span= _('Search')
  31 + ul.dropdown-menu role="menu"
  32 + li
  33 + form#top-search action="/search" method="get" role="search"
  34 + .form-group.col-lg-12.col-md-12.col-sm-12
  35 + input.form-control.input-sm name="query" placeholder="#{_('Search...')}" title="#{_('Search...')}" type="text" /
  36 +
  37 + #navbar-search-collapse.collapse.navbar-collapse
  38 + form#top-search.navbar-form.navbar-left action="/search" method="get" role="search"
  39 + .form-group
  40 + input.form-control name="query" placeholder="#{_('Search...')}" title="#{_('Search...')}" type="text" /
  41 +
  42 + #navbar-user-collapse.collapse.navbar-collapse
  43 + ul.nav.navbar-nav.pull-right
  44 + - if user.present?
  45 + = render 'layouts/usermenu_logged_in'
  46 + - else
  47 + li
  48 + = modal_inline_link_to "<i class='icon-menu-login'></i><strong>#{_('Login')}</strong>".html_safe, login_url, '#inlineLoginBox', id: 'link_login'
  49 + = @plugins.dispatch(:alternative_authentication_link).collect{ |content| instance_exec(&content) }.safe_join
  50 + - unless @plugins.dispatch(:allow_user_registration).include? false
  51 + li= link_to content_tag(:strong, _('Sign up')), controller: :account, action: :signup
  52 +
  53 +#inlineLoginBox style="display: none;"
  54 + = render file: 'account/login', locals: {is_thickbox: true}
... ...
plugins/responsive/views/layouts/_usermenu_logged_in.html.slim 0 → 100644
... ... @@ -0,0 +1,39 @@
  1 +- pending_tasks_count = Task.to(user).pending.count if user
  2 +
  3 +li.dropdown
  4 + = link_to '#', id: "homepage-link", title: _('Go to your homepage'), class: 'dropdown-toggle', data: {toggle: 'dropdown', hover: 'dropdown'}
  5 + = image_tag user.profile_custom_icon(gravatar_default), class: 'menu-user-gravatar'
  6 + = content_tag :strong, user.identifier
  7 + - if pending_tasks_count
  8 + span class='badge' onclick="document.location='#{url_for(user.tasks_url)}'" title="#{_("Manage your pending tasks")}"
  9 + count
  10 +
  11 + ul class='dropdown-menu' role='menu'
  12 + li
  13 + = link_to user.public_profile_url, id: "homepage-link", title: _('Go to your homepage')
  14 + span class='icon-person' = _('Profile')
  15 + li.divider
  16 +
  17 + /TODO
  18 + /= render_environment_features(:usermenu)
  19 +
  20 + li = admin_link
  21 +
  22 + li
  23 + = link_to user.admin_url, class: 'ctrl-panel', title: _("Configure your personal account and content")
  24 + i class='icon-menu-ctrl-panel'
  25 + strong = _('Control panel')
  26 +
  27 + - if environment.enabled? 'xmpp_chat'
  28 + = responsive_chat_user_status_menu 'icon-menu-offline', _('Offline')
  29 +
  30 + li = manage_enterprises
  31 + li = manage_communities
  32 +
  33 + li.divider
  34 +
  35 + li
  36 + = link_to({controller: 'account', action: 'logout'}, id: "logout", title: _("Leave the system"))
  37 + i class='icon-menu-logout'
  38 + strong = _('Logout')
  39 +
... ...
plugins/responsive/views/layouts/application-responsive.html.erb
1 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 2 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<%= html_language %>" lang="<%= html_language %>" class="<%= h html_tag_classes %>">
3 3 <head>
4   - <title><%= h page_title %></title>
  4 + <title><%= h page_title.html_safe %></title>
5 5 <%= yield(:feeds) %>
6 6 <!--<meta http-equiv="refresh" content="1"/>-->
7 7 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
... ... @@ -22,7 +22,7 @@
22 22 <%=
23 23 @plugins.dispatch(:head_ending).map do |content|
24 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")
  25 + end.safe_join
26 26 %>
27 27  
28 28 <script type="text/javascript">
... ... @@ -68,7 +68,7 @@
68 68 <%=
69 69 @plugins.dispatch(:body_ending).map do |content|
70 70 if content.respond_to?(:call) then instance_exec(&content).html_safe else content.html_safe end
71   - end.join("\n")
  71 + end.safe_join
72 72 %>
73 73 </body>
74 74 </html>
... ...
test/functional/application_controller_test.rb
... ... @@ -224,7 +224,7 @@ class ApplicationControllerTest &lt; ActionController::TestCase
224 224 end
225 225  
226 226 should 'display theme test panel when testing theme' do
227   - @request.session[:theme] = 'my-test-theme'
  227 + @request.session[:user_theme] = 'my-test-theme'
228 228 theme = mock
229 229 profile = mock
230 230 theme.expects(:owner).returns(profile).at_least_once
... ... @@ -576,4 +576,36 @@ class ApplicationControllerTest &lt; ActionController::TestCase
576 576 assert_redirected_to :controller => 'test', :action => 'index', :profile => profile.identifier
577 577 end
578 578  
  579 + should 'set session theme if a params theme is passed as parameter' do
  580 + current_theme = 'my-test-theme'
  581 + environment = Environment.default
  582 + Theme.stubs(:system_themes).returns([Theme.new(current_theme)])
  583 + environment.themes = [current_theme]
  584 + environment.save!
  585 + assert_nil @request.session[:theme]
  586 + get :index, :theme => current_theme
  587 + assert_equal current_theme, @request.session[:theme]
  588 + end
  589 +
  590 + should 'set session theme only in environment available themes' do
  591 + environment = Environment.default
  592 + assert_nil @request.session[:theme]
  593 + environment.stubs(:theme_ids).returns(['another_theme'])
  594 + get :index, :theme => 'my-test-theme'
  595 + assert_nil @request.session[:theme]
  596 + end
  597 +
  598 + should 'unset session theme if not environment available themes is defined' do
  599 + environment = Environment.default
  600 + current_theme = 'my-test-theme'
  601 + Theme.stubs(:system_themes).returns([Theme.new(current_theme)])
  602 + environment.themes = [current_theme]
  603 + environment.save!
  604 + get :index, :theme => current_theme
  605 + assert_equal current_theme, @request.session[:theme]
  606 +
  607 + get :index, :theme => 'another_theme'
  608 + assert_nil @request.session[:theme]
  609 + end
  610 +
579 611 end
... ...
test/functional/profile_themes_controller_test.rb
... ... @@ -231,7 +231,7 @@ class ProfileThemesControllerTest &lt; ActionController::TestCase
231 231 theme = Theme.create('theme-under-test', :owner => profile)
232 232 post :start_test, :profile => 'testinguser', :id => 'theme-under-test'
233 233  
234   - assert_equal 'theme-under-test', session[:theme]
  234 + assert_equal 'theme-under-test', session[:user_theme]
235 235 assert_redirected_to :controller => 'content_viewer', :profile => 'testinguser', :action => 'view_page'
236 236 end
237 237  
... ... @@ -239,7 +239,7 @@ class ProfileThemesControllerTest &lt; ActionController::TestCase
239 239 theme = Theme.create('theme-under-test', :owner => profile)
240 240 post :stop_test, :profile => 'testinguser', :id => 'theme-under-test'
241 241  
242   - assert_nil session[:theme]
  242 + assert_nil session[:user_theme]
243 243 assert_redirected_to :action => 'index'
244 244 end
245 245  
... ...
test/unit/add_member_test.rb
... ... @@ -149,4 +149,11 @@ class AddMemberTest &lt; ActiveSupport::TestCase
149 149  
150 150 assert_no_match(/\(#{task.requestor.email}\)/, task.target_notification_description)
151 151 end
  152 +
  153 + should 'have cancel notification message with explanation' do
  154 + explanation_message = 'some explanation'
  155 + task = AddMember.new(:person => person, :organization => community,
  156 + :reject_explanation => explanation_message)
  157 + assert_match(/#{explanation_message}/, task.task_cancelled_message)
  158 + end
152 159 end
... ...
test/unit/application_helper_test.rb
... ... @@ -466,7 +466,7 @@ class ApplicationHelperTest &lt; ActionView::TestCase
466 466 should 'use theme passed via param when in development mode' do
467 467 stubs(:environment).returns(build(Environment, :theme => 'environment-theme'))
468 468 Rails.env.stubs(:development?).returns(true)
469   - self.stubs(:params).returns({:theme => 'skyblue'})
  469 + self.stubs(:params).returns({:user_theme => 'skyblue'})
470 470 assert_equal 'skyblue', current_theme
471 471 end
472 472  
... ...
test/unit/content_viewer_helper_test.rb
... ... @@ -101,14 +101,14 @@ class ContentViewerHelperTest &lt; ActionView::TestCase
101 101 end
102 102  
103 103 should 'theme provides addthis custom icon' do
104   - stubs(:session).returns({:theme => 'base'})
  104 + stubs(:session).returns({:user_theme => 'base'})
105 105 File.expects(:exists?).with(anything).returns(true)
106 106 Environment.any_instance.stubs(:default_hostname).returns('noosfero.org')
107 107 assert_match 'addthis.gif', addthis_image_tag
108 108 end
109 109  
110 110 should 'use default addthis icon if theme has no addthis.gif image' do
111   - stubs(:session).returns({:theme => 'base'})
  111 + stubs(:session).returns({:user_theme => 'base'})
112 112 File.expects(:exists?).with(anything).returns(false)
113 113 Environment.any_instance.stubs(:default_hostname).returns('noosfero.org')
114 114 assert_match 'bt-bookmark.gif', addthis_image_tag
... ...
test/unit/environment_test.rb
... ... @@ -457,6 +457,22 @@ class EnvironmentTest &lt; ActiveSupport::TestCase
457 457 assert_equal ['new-theme', 'other-theme'], Environment.default.themes.map(&:id)
458 458 end
459 459  
  460 + should 'return the theme ids' do
  461 + env = Environment.default
  462 + t1 = 'theme_1'
  463 + t2 = 'theme_2'
  464 + Theme.stubs(:system_themes).returns([Theme.new(t1), Theme.new(t2)])
  465 + env.themes = [t1, t2]
  466 + env.save!
  467 + assert_equivalent [t1, t2], Environment.default.theme_ids
  468 + end
  469 + should 'theme_ids be an empty array if there is no settings themes defined' do
  470 + env = Environment.default
  471 + env.settings[:themes] = nil
  472 + env.save!
  473 + assert Environment.default.theme_ids.empty?
  474 + end
  475 +
460 476 should 'create templates' do
461 477 e = create(Environment, :name => 'test_env')
462 478 e.reload
... ...
test/unit/theme_loader_helper_test.rb
... ... @@ -20,7 +20,7 @@ class ThemeLoaderHelperTest &lt; ActionView::TestCase
20 20 end
21 21  
22 22 should 'override theme with testing theme from session' do
23   - stubs(:session).returns(:theme => 'theme-under-test')
  23 + stubs(:session).returns(:user_theme => 'theme-under-test')
24 24 assert_equal 'theme-under-test', current_theme
25 25 end
26 26  
... ... @@ -30,7 +30,17 @@ class ThemeLoaderHelperTest &lt; ActionView::TestCase
30 30 end
31 31  
32 32 should 'point to user theme path when testing theme' do
33   - stubs(:session).returns({:theme => 'theme-under-test'})
  33 + stubs(:session).returns({:user_theme => 'theme-under-test'})
34 34 assert_equal '/user_themes/theme-under-test', theme_path
35 35 end
36   -end
37 36 \ No newline at end of file
  37 +
  38 + should 'point to session theme is defined' do
  39 + session = mock
  40 + stubs(:session).returns(session)
  41 + my_session_theme = 'session_theme'
  42 + session.stubs(:[]).with(:user_theme).returns(nil)
  43 + session.stubs(:[]).with(:theme).returns(my_session_theme)
  44 + assert_equal '/designs/themes/' + my_session_theme, theme_path
  45 + end
  46 +
  47 +end
... ...