Commit 541e9495bd26d2ca5f81827fe665ca987545c638
Exists in
web_steps_improvements
and in
8 other branches
Merge branch 'master' into serpro_api
Showing
179 changed files
with
1649 additions
and
1093 deletions
Show diff stats
.travis.yml
@@ -24,6 +24,9 @@ addons: | @@ -24,6 +24,9 @@ addons: | ||
24 | - libreadline-dev | 24 | - libreadline-dev |
25 | - libsqlite3-dev | 25 | - libsqlite3-dev |
26 | - libxslt1-dev | 26 | - libxslt1-dev |
27 | + artifacts: | ||
28 | + paths: | ||
29 | + - $(ls tmp/artifact* | tr "\n" ":") | ||
27 | 30 | ||
28 | # workaround for https://github.com/travis-ci/travis-ci/issues/4536 | 31 | # workaround for https://github.com/travis-ci/travis-ci/issues/4536 |
29 | before_install: | 32 | before_install: |
@@ -32,7 +35,7 @@ before_install: | @@ -32,7 +35,7 @@ before_install: | ||
32 | cache: bundler | 35 | cache: bundler |
33 | 36 | ||
34 | before_script: | 37 | before_script: |
35 | - - mkdir -p tmp/{pids,cache} log | 38 | + - mkdir -p tmp/{pids,cache} log cache |
36 | - script/noosfero-plugins disableall | 39 | - script/noosfero-plugins disableall |
37 | #- bundle exec rake makemo &>/dev/null | 40 | #- bundle exec rake makemo &>/dev/null |
38 | # database | 41 | # database |
@@ -0,0 +1,12 @@ | @@ -0,0 +1,12 @@ | ||
1 | +If you made any significant change to the code that you consider worth being | ||
2 | +reminded on the Release Notes, also include a correspondent entry here. If you | ||
3 | +are not sure in which release your code will be released, include it on the | ||
4 | +latest release and leave it to the commiter or RM responsible for it. | ||
5 | + | ||
6 | +v 1.5.0 (unreleased) | ||
7 | + - Allow groups to disable admin email notificationo | ||
8 | + - Add option to HighlightsBlock to open link in a new tab | ||
9 | + - Move blocks html generation from models to helpers | ||
10 | + | ||
11 | +v 1.4.0 | ||
12 | + - Migration from Rails 3 to Rails 4! |
app/controllers/my_profile/profile_members_controller.rb
@@ -2,8 +2,27 @@ class ProfileMembersController < MyProfileController | @@ -2,8 +2,27 @@ class ProfileMembersController < MyProfileController | ||
2 | protect 'manage_memberships', :profile | 2 | protect 'manage_memberships', :profile |
3 | 3 | ||
4 | def index | 4 | def index |
5 | - @members = profile.members_by_name | ||
6 | - @member_role = environment.roles.find_by_name('member') | 5 | + @filters = params[:filters] || {:roles => []} |
6 | + all_roles = Profile::Roles.organization_member_roles(environment.id) | Profile::Roles.organization_custom_roles(environment.id, profile.id) | ||
7 | + @filters[:roles] = all_roles unless @filters[:roles].present? | ||
8 | + @data = {} | ||
9 | + field = 'name' | ||
10 | + field = 'email' if @filters[:name] =~ /\@/ | ||
11 | + | ||
12 | + @data[:members] = profile.members_by(field,@filters[:name]).by_role(@filters[:roles]) | ||
13 | + session[:members_filtered] = @data[:members].map{|m|m.id} if request.post? | ||
14 | + @data[:roles] = all_roles | ||
15 | + | ||
16 | + end | ||
17 | + | ||
18 | + def send_mail | ||
19 | + session[:members_filtered] = params[:members_filtered].select{|value| value!="0"} | ||
20 | + if session[:members_filtered].present? | ||
21 | + redirect_to :controller => :profile, :action => :send_mail | ||
22 | + else | ||
23 | + session[:notice] = _("Select at least one member.") | ||
24 | + redirect_to :action => :index | ||
25 | + end | ||
7 | end | 26 | end |
8 | 27 | ||
9 | def update_roles | 28 | def update_roles |
@@ -156,4 +175,13 @@ class ProfileMembersController < MyProfileController | @@ -156,4 +175,13 @@ class ProfileMembersController < MyProfileController | ||
156 | end | 175 | end |
157 | end | 176 | end |
158 | 177 | ||
178 | + def search_members | ||
179 | + field = 'name' | ||
180 | + field = 'email' if params[:filter_name] =~ /\@/ | ||
181 | + | ||
182 | + result = profile.members_like field, params[:filter_name] | ||
183 | + result = result.select{|member| member.can_view_field?(current_person, "email") } if field=="email" | ||
184 | + render :json => result.map { |member| {:label => "#{member.name}#{member.can_view_field?(current_person, "email") ? " <#{member.email}>" : ""}", :value => member.name }} | ||
185 | + end | ||
186 | + | ||
159 | end | 187 | end |
app/controllers/public/content_viewer_controller.rb
@@ -239,8 +239,12 @@ class ContentViewerController < ApplicationController | @@ -239,8 +239,12 @@ class ContentViewerController < ApplicationController | ||
239 | 239 | ||
240 | def get_posts(year = nil, month = nil) | 240 | def get_posts(year = nil, month = nil) |
241 | if year && month | 241 | if year && month |
242 | - filter_date = DateTime.parse("#{year}-#{month}-01") | ||
243 | - return @page.posts.by_range(filter_date..filter_date.at_end_of_month) | 242 | + begin |
243 | + filter_date = DateTime.parse("#{year}-#{month}-01") | ||
244 | + return @page.posts.by_range(filter_date..filter_date.at_end_of_month) | ||
245 | + rescue ArgumentError | ||
246 | + return @page.posts | ||
247 | + end | ||
244 | else | 248 | else |
245 | return @page.posts | 249 | return @page.posts |
246 | end | 250 | end |
app/controllers/public/profile_controller.rb
@@ -370,6 +370,7 @@ class ProfileController < PublicController | @@ -370,6 +370,7 @@ class ProfileController < PublicController | ||
370 | 370 | ||
371 | def send_mail | 371 | def send_mail |
372 | @mailing = profile.mailings.build(params[:mailing]) | 372 | @mailing = profile.mailings.build(params[:mailing]) |
373 | + @mailing.data = session[:members_filtered] ? {:members_filtered => session[:members_filtered]} : {} | ||
373 | if request.post? | 374 | if request.post? |
374 | @mailing.locale = locale | 375 | @mailing.locale = locale |
375 | @mailing.person = user | 376 | @mailing.person = user |
app/helpers/application_helper.rb
@@ -48,6 +48,8 @@ module ApplicationHelper | @@ -48,6 +48,8 @@ module ApplicationHelper | ||
48 | 48 | ||
49 | include PluginsHelper | 49 | include PluginsHelper |
50 | 50 | ||
51 | + include ButtonsHelper | ||
52 | + | ||
51 | def locale | 53 | def locale |
52 | (@page && !@page.language.blank?) ? @page.language : FastGettext.locale | 54 | (@page && !@page.language.blank?) ? @page.language : FastGettext.locale |
53 | end | 55 | end |
@@ -148,14 +150,8 @@ module ApplicationHelper | @@ -148,14 +150,8 @@ module ApplicationHelper | ||
148 | link_to text, profile_path(:profile => profile) , options | 150 | link_to text, profile_path(:profile => profile) , options |
149 | end | 151 | end |
150 | 152 | ||
151 | - def link_to_homepage(text, profile = nil, options = {}) | ||
152 | - p = if profile | ||
153 | - Profile[profile] | ||
154 | - else | ||
155 | - user | ||
156 | - end | ||
157 | - | ||
158 | - link_to text, p.url, options | 153 | + def link_to_homepage(text, profile, options = {}) |
154 | + link_to text, profile.url, options | ||
159 | end | 155 | end |
160 | 156 | ||
161 | def link_if_permitted(link, permission = nil, target = nil) | 157 | def link_if_permitted(link, permission = nil, target = nil) |
@@ -215,52 +211,6 @@ module ApplicationHelper | @@ -215,52 +211,6 @@ module ApplicationHelper | ||
215 | result | 211 | result |
216 | end | 212 | end |
217 | 213 | ||
218 | - def button(type, label, url, html_options = {}) | ||
219 | - html_options ||= {} | ||
220 | - the_class = 'with-text' | ||
221 | - if html_options.has_key?(:class) | ||
222 | - the_class << ' ' << html_options[:class] | ||
223 | - end | ||
224 | - button_without_text type, label, url, html_options.merge(:class => the_class) | ||
225 | - end | ||
226 | - | ||
227 | - def button_without_text(type, label, url, html_options = {}) | ||
228 | - the_class = "button icon-#{type}" | ||
229 | - if html_options.has_key?(:class) | ||
230 | - the_class << ' ' << html_options[:class] | ||
231 | - end | ||
232 | - the_title = html_options[:title] || label | ||
233 | - if html_options[:disabled] | ||
234 | - content_tag('a', ' '+content_tag('span', label), html_options.merge(:class => the_class, :title => the_title)) | ||
235 | - else | ||
236 | - link_to(' '+content_tag('span', label), url, html_options.merge(:class => the_class, :title => the_title)) | ||
237 | - end | ||
238 | - end | ||
239 | - | ||
240 | - def button_to_function(type, label, js_code, html_options = {}, &block) | ||
241 | - html_options[:class] = "button with-text" unless html_options[:class] | ||
242 | - html_options[:class] << " icon-#{type}" | ||
243 | - link_to_function(label, js_code, html_options, &block) | ||
244 | - end | ||
245 | - | ||
246 | - def button_to_function_without_text(type, label, js_code, html_options = {}, &block) | ||
247 | - html_options[:class] = "" unless html_options[:class] | ||
248 | - html_options[:class] << " button icon-#{type}" | ||
249 | - link_to_function(content_tag('span', label), js_code, html_options, &block) | ||
250 | - end | ||
251 | - | ||
252 | - def button_to_remote(type, label, options, html_options = {}) | ||
253 | - html_options[:class] = "button with-text" unless html_options[:class] | ||
254 | - html_options[:class] << " icon-#{type}" | ||
255 | - link_to_remote(label, options, html_options) | ||
256 | - end | ||
257 | - | ||
258 | - def button_to_remote_without_text(type, label, options, html_options = {}) | ||
259 | - html_options[:class] = "" unless html_options[:class] | ||
260 | - html_options[:class] << " button icon-#{type}" | ||
261 | - link_to_remote(content_tag('span', label), options, html_options.merge(:title => label)) | ||
262 | - end | ||
263 | - | ||
264 | def icon(icon_name, html_options = {}) | 214 | def icon(icon_name, html_options = {}) |
265 | the_class = "button #{icon_name}" | 215 | the_class = "button #{icon_name}" |
266 | if html_options.has_key?(:class) | 216 | if html_options.has_key?(:class) |
@@ -940,13 +890,6 @@ module ApplicationHelper | @@ -940,13 +890,6 @@ module ApplicationHelper | ||
940 | content_for(:head) { stylesheet_link_tag(*args) } | 890 | content_for(:head) { stylesheet_link_tag(*args) } |
941 | end | 891 | end |
942 | 892 | ||
943 | - def article_to_html(article, options = {}) | ||
944 | - options.merge!(:page => params[:npage]) | ||
945 | - content = article.to_html(options) | ||
946 | - content = content.kind_of?(Proc) ? self.instance_exec(&content).html_safe : content.html_safe | ||
947 | - filter_html(content, article) | ||
948 | - end | ||
949 | - | ||
950 | # Please, use link_to by default! | 893 | # Please, use link_to by default! |
951 | # This method was created to work around to inexplicable | 894 | # This method was created to work around to inexplicable |
952 | # chain of problems when display_short_format was called | 895 | # chain of problems when display_short_format was called |
@@ -1049,10 +992,11 @@ module ApplicationHelper | @@ -1049,10 +992,11 @@ module ApplicationHelper | ||
1049 | end | 992 | end |
1050 | 993 | ||
1051 | def search_contents_menu | 994 | def search_contents_menu |
995 | + host = environment.default_hostname | ||
1052 | links = [ | 996 | links = [ |
1053 | - {s_('contents|More recent') => {:href => url_for({:controller => 'search', :action => 'contents', :filter => 'more_recent'})}}, | ||
1054 | - {s_('contents|More viewed') => {:href => url_for({:controller => 'search', :action => 'contents', :filter => 'more_popular'})}}, | ||
1055 | - {s_('contents|Most commented') => {:href => url_for({:controller => 'search', :action => 'contents', :filter => 'more_comments'})}} | 997 | + {s_('contents|More recent') => {href: url_for({host: host, controller: 'search', action: 'contents', filter: 'more_recent'})}}, |
998 | + {s_('contents|More viewed') => {href: url_for({host: host, controller: 'search', action: 'contents', filter: 'more_popular'})}}, | ||
999 | + {s_('contents|Most commented') => {href: url_for({host: host, controller: 'search', action: 'contents', filter: 'more_comments'})}} | ||
1056 | ] | 1000 | ] |
1057 | if logged_in? | 1001 | if logged_in? |
1058 | links.push(_('New content') => modal_options({:href => url_for({:controller => 'cms', :action => 'new', :profile => current_user.login, :cms => true})})) | 1002 | links.push(_('New content') => modal_options({:href => url_for({:controller => 'cms', :action => 'new', :profile => current_user.login, :cms => true})})) |
@@ -1064,10 +1008,11 @@ module ApplicationHelper | @@ -1064,10 +1008,11 @@ module ApplicationHelper | ||
1064 | alias :browse_contents_menu :search_contents_menu | 1008 | alias :browse_contents_menu :search_contents_menu |
1065 | 1009 | ||
1066 | def search_people_menu | 1010 | def search_people_menu |
1011 | + host = environment.default_hostname | ||
1067 | links = [ | 1012 | links = [ |
1068 | - {s_('people|More recent') => {:href => url_for({:controller => 'search', :action => 'people', :filter => 'more_recent'})}}, | ||
1069 | - {s_('people|More active') => {:href => url_for({:controller => 'search', :action => 'people', :filter => 'more_active'})}}, | ||
1070 | - {s_('people|More popular') => {:href => url_for({:controller => 'search', :action => 'people', :filter => 'more_popular'})}} | 1013 | + {s_('people|More recent') => {href: url_for({host: host, controller: 'search', action: 'people', filter: 'more_recent'})}}, |
1014 | + {s_('people|More active') => {href: url_for({host: host, controller: 'search', action: 'people', filter: 'more_active'})}}, | ||
1015 | + {s_('people|More popular') => {href: url_for({host: host, controller: 'search', action: 'people', filter: 'more_popular'})}} | ||
1071 | ] | 1016 | ] |
1072 | if logged_in? | 1017 | if logged_in? |
1073 | links.push(_('My friends') => {:href => url_for({:profile => current_user.login, :controller => 'friends'})}) | 1018 | links.push(_('My friends') => {:href => url_for({:profile => current_user.login, :controller => 'friends'})}) |
@@ -1080,10 +1025,11 @@ module ApplicationHelper | @@ -1080,10 +1025,11 @@ module ApplicationHelper | ||
1080 | alias :browse_people_menu :search_people_menu | 1025 | alias :browse_people_menu :search_people_menu |
1081 | 1026 | ||
1082 | def search_communities_menu | 1027 | def search_communities_menu |
1028 | + host = environment.default_hostname | ||
1083 | links = [ | 1029 | links = [ |
1084 | - {s_('communities|More recent') => {:href => url_for({:controller => 'search', :action => 'communities', :filter => 'more_recent'})}}, | ||
1085 | - {s_('communities|More active') => {:href => url_for({:controller => 'search', :action => 'communities', :filter => 'more_active'})}}, | ||
1086 | - {s_('communities|More popular') => {:href => url_for({:controller => 'search', :action => 'communities', :filter => 'more_popular'})}} | 1030 | + {s_('communities|More recent') => {href: url_for({host: host, controller: 'search', action: 'communities', filter: 'more_recent'})}}, |
1031 | + {s_('communities|More active') => {href: url_for({host: host, controller: 'search', action: 'communities', filter: 'more_active'})}}, | ||
1032 | + {s_('communities|More popular') => {href: url_for({host: host, controller: 'search', action: 'communities', filter: 'more_popular'})}} | ||
1087 | ] | 1033 | ] |
1088 | if logged_in? | 1034 | if logged_in? |
1089 | links.push(_('My communities') => {:href => url_for({:profile => current_user.login, :controller => 'memberships'})}) | 1035 | links.push(_('My communities') => {:href => url_for({:profile => current_user.login, :controller => 'memberships'})}) |
@@ -1368,16 +1314,6 @@ module ApplicationHelper | @@ -1368,16 +1314,6 @@ module ApplicationHelper | ||
1368 | @no_design_blocks = true | 1314 | @no_design_blocks = true |
1369 | end | 1315 | end |
1370 | 1316 | ||
1371 | - def filter_html(html, source) | ||
1372 | - if @plugins && source && source.has_macro? | ||
1373 | - html = convert_macro(html, source) unless @plugins.enabled_macros.blank? | ||
1374 | - #TODO This parse should be done through the macro infra, but since there | ||
1375 | - # are old things that do not support it we are keeping this hot spot. | ||
1376 | - html = @plugins.pipeline(:parse_content, html, source).first | ||
1377 | - end | ||
1378 | - html && html.html_safe | ||
1379 | - end | ||
1380 | - | ||
1381 | def convert_macro(html, source) | 1317 | def convert_macro(html, source) |
1382 | doc = Nokogiri::HTML.fragment html | 1318 | doc = Nokogiri::HTML.fragment html |
1383 | #TODO This way is more efficient but do not support macro inside of | 1319 | #TODO This way is more efficient but do not support macro inside of |
app/helpers/article_helper.rb
@@ -181,4 +181,21 @@ module ArticleHelper | @@ -181,4 +181,21 @@ module ArticleHelper | ||
181 | end | 181 | end |
182 | end | 182 | end |
183 | 183 | ||
184 | + def filter_html(html, source) | ||
185 | + if @plugins && source && source.has_macro? | ||
186 | + html = convert_macro(html, source) unless @plugins.enabled_macros.blank? | ||
187 | + #TODO This parse should be done through the macro infra, but since there | ||
188 | + # are old things that do not support it we are keeping this hot spot. | ||
189 | + html = @plugins.pipeline(:parse_content, html, source).first | ||
190 | + end | ||
191 | + html && html.html_safe | ||
192 | + end | ||
193 | + | ||
194 | + def article_to_html(article, options = {}) | ||
195 | + options.merge!(:page => params[:npage]) | ||
196 | + content = article.to_html(options) | ||
197 | + content = content.kind_of?(Proc) ? self.instance_exec(&content).html_safe : content.html_safe | ||
198 | + filter_html(content, article) | ||
199 | + end | ||
200 | + | ||
184 | end | 201 | end |
app/helpers/block_helper.rb
@@ -14,6 +14,7 @@ module BlockHelper | @@ -14,6 +14,7 @@ module BlockHelper | ||
14 | </td> | 14 | </td> |
15 | <td>#{text_field_tag 'block[images][][address]', image[:address], :class => 'highlight-address', :size => 20}</td> | 15 | <td>#{text_field_tag 'block[images][][address]', image[:address], :class => 'highlight-address', :size => 20}</td> |
16 | <td>#{text_field_tag 'block[images][][position]', image[:position], :class => 'highlight-position', :size => 1}</td> | 16 | <td>#{text_field_tag 'block[images][][position]', image[:position], :class => 'highlight-position', :size => 1}</td> |
17 | + <td>#{check_box_tag 'block[images][][new_window]', '1', image[:new_window], :class => 'highlight-new_window', :size => 1}</td> | ||
17 | </tr><tr class=\"image-title\" data-row-number='#{row_number}'> | 18 | </tr><tr class=\"image-title\" data-row-number='#{row_number}'> |
18 | <td colspan=\"3\"><label>#{ | 19 | <td colspan=\"3\"><label>#{ |
19 | content_tag('span', _('Title')) + | 20 | content_tag('span', _('Title')) + |
app/helpers/boxes_helper.rb
@@ -87,10 +87,38 @@ module BoxesHelper | @@ -87,10 +87,38 @@ module BoxesHelper | ||
87 | box_decorator == DontMoveBlocks | 87 | box_decorator == DontMoveBlocks |
88 | end | 88 | end |
89 | 89 | ||
90 | - def display_block_content(block, person, main_content = nil) | ||
91 | - content = block.main? ? wrap_main_content(main_content) : block.content({:person => person}) | 90 | + def render_block block, prefix = nil, klass = block.class |
91 | + template_name = klass.name.underscore.sub '_block', '' | ||
92 | + begin | ||
93 | + render template: "blocks/#{prefix}#{template_name}", locals: { block: block } | ||
94 | + rescue ActionView::MissingTemplate | ||
95 | + return if klass.superclass === Block | ||
96 | + render_block block, prefix, klass.superclass | ||
97 | + end | ||
98 | + end | ||
99 | + | ||
100 | + def render_block_content block | ||
101 | + # FIXME: this conditional should be removed after all | ||
102 | + # block footer from plugins methods get refactored into helpers and views. | ||
103 | + # They are a failsafe until all of them are done. | ||
104 | + return block.content if block.method(:content).owner != Block | ||
105 | + render_block block | ||
106 | + end | ||
107 | + | ||
108 | + def render_block_footer block | ||
109 | + return block.footer if block.method(:footer).owner != Block | ||
110 | + render_block block, 'footers/' | ||
111 | + end | ||
112 | + | ||
113 | + def display_block_content(block, main_content = nil) | ||
114 | + content = nil | ||
115 | + if block.main? | ||
116 | + content = wrap_main_content(main_content) | ||
117 | + else | ||
118 | + content = render_block_content block | ||
119 | + end | ||
92 | result = extract_block_content(content) | 120 | result = extract_block_content(content) |
93 | - footer_content = extract_block_content(block.footer) | 121 | + footer_content = extract_block_content(render_block_footer block) |
94 | unless footer_content.blank? | 122 | unless footer_content.blank? |
95 | footer_content = content_tag('div', footer_content, :class => 'block-footer-content' ) | 123 | footer_content = content_tag('div', footer_content, :class => 'block-footer-content' ) |
96 | end | 124 | end |
@@ -0,0 +1,47 @@ | @@ -0,0 +1,47 @@ | ||
1 | +module ButtonsHelper | ||
2 | + def button(type, label, url, html_options = {}) | ||
3 | + html_options ||= {} | ||
4 | + the_class = 'with-text' | ||
5 | + if html_options.has_key?(:class) | ||
6 | + the_class << ' ' << html_options[:class] | ||
7 | + end | ||
8 | + button_without_text type, label, url, html_options.merge(:class => the_class) | ||
9 | + end | ||
10 | + | ||
11 | + def button_without_text(type, label, url, html_options = {}) | ||
12 | + the_class = "button icon-#{type}" | ||
13 | + if html_options.has_key?(:class) | ||
14 | + the_class << ' ' << html_options[:class] | ||
15 | + end | ||
16 | + the_title = html_options[:title] || label | ||
17 | + if html_options[:disabled] | ||
18 | + content_tag('a', ' '+content_tag('span', label), html_options.merge(:class => the_class, :title => the_title)) | ||
19 | + else | ||
20 | + link_to(' '+content_tag('span', label), url, html_options.merge(:class => the_class, :title => the_title)) | ||
21 | + end | ||
22 | + end | ||
23 | + | ||
24 | + def button_to_function(type, label, js_code, html_options = {}, &block) | ||
25 | + html_options[:class] = "button with-text" unless html_options[:class] | ||
26 | + html_options[:class] << " icon-#{type}" | ||
27 | + link_to_function(label, js_code, html_options, &block) | ||
28 | + end | ||
29 | + | ||
30 | + def button_to_function_without_text(type, label, js_code, html_options = {}, &block) | ||
31 | + html_options[:class] = "" unless html_options[:class] | ||
32 | + html_options[:class] << " button icon-#{type}" | ||
33 | + link_to_function(content_tag('span', label), js_code, html_options, &block) | ||
34 | + end | ||
35 | + | ||
36 | + def button_to_remote(type, label, options, html_options = {}) | ||
37 | + html_options[:class] = "button with-text" unless html_options[:class] | ||
38 | + html_options[:class] << " icon-#{type}" | ||
39 | + link_to_remote(label, options, html_options) | ||
40 | + end | ||
41 | + | ||
42 | + def button_to_remote_without_text(type, label, options, html_options = {}) | ||
43 | + html_options[:class] = "" unless html_options[:class] | ||
44 | + html_options[:class] << " button icon-#{type}" | ||
45 | + link_to_remote(content_tag('span', label), options, html_options.merge(:title => label)) | ||
46 | + end | ||
47 | +end |
app/helpers/forms_helper.rb
@@ -7,9 +7,10 @@ module FormsHelper | @@ -7,9 +7,10 @@ module FormsHelper | ||
7 | 7 | ||
8 | def labelled_check_box( human_name, name, value = "1", checked = false, options = {} ) | 8 | def labelled_check_box( human_name, name, value = "1", checked = false, options = {} ) |
9 | options[:id] ||= 'checkbox-' + FormsHelper.next_id_number | 9 | options[:id] ||= 'checkbox-' + FormsHelper.next_id_number |
10 | - hidden_field_tag(name, '0') + | ||
11 | - check_box_tag( name, value, checked, options ) + | ||
12 | - content_tag( 'label', human_name, :for => options[:id] ) | 10 | + html = options[:add_hidden] == false ? "" : hidden_field_tag(name, '0') |
11 | + | ||
12 | + html += check_box_tag( name, value, checked, options ) + | ||
13 | + content_tag( 'label', human_name, :for => options[:id] ) | ||
13 | end | 14 | end |
14 | 15 | ||
15 | def labelled_text_field( human_name, name, value=nil, options={} ) | 16 | def labelled_text_field( human_name, name, value=nil, options={} ) |
app/mailers/mailing.rb
@@ -2,7 +2,10 @@ require_dependency 'mailing_job' | @@ -2,7 +2,10 @@ require_dependency 'mailing_job' | ||
2 | 2 | ||
3 | class Mailing < ActiveRecord::Base | 3 | class Mailing < ActiveRecord::Base |
4 | 4 | ||
5 | - attr_accessible :subject, :body | 5 | + acts_as_having_settings :field => :data |
6 | + | ||
7 | + attr_accessible :subject, :body, :data | ||
8 | + | ||
6 | validates_presence_of :source_id, :subject, :body | 9 | validates_presence_of :source_id, :subject, :body |
7 | belongs_to :source, :foreign_key => :source_id, :polymorphic => true | 10 | belongs_to :source, :foreign_key => :source_id, :polymorphic => true |
8 | belongs_to :person | 11 | belongs_to :person |
app/mailers/organization_mailing.rb
@@ -5,9 +5,17 @@ class OrganizationMailing < Mailing | @@ -5,9 +5,17 @@ class OrganizationMailing < Mailing | ||
5 | end | 5 | end |
6 | 6 | ||
7 | def recipients(offset=0, limit=100) | 7 | def recipients(offset=0, limit=100) |
8 | - source.members.order(:id).offset(offset).limit(limit) | ||
9 | - .joins("LEFT OUTER JOIN mailing_sents m ON (m.mailing_id = #{id} AND m.person_id = profiles.id)") | 8 | + result = source.members.order(:id).offset(offset).limit(limit) |
9 | + | ||
10 | + if data.present? and data.is_a?(Hash) and data[:members_filtered] | ||
11 | + result = result.where('profiles.id IN (?)', data[:members_filtered]) | ||
12 | + end | ||
13 | + | ||
14 | + if result.blank? | ||
15 | + result = result.joins("LEFT OUTER JOIN mailing_sents m ON (m.mailing_id = #{id} AND m.person_id = profiles.id)") | ||
10 | .where("m.person_id" => nil) | 16 | .where("m.person_id" => nil) |
17 | + end | ||
18 | + result | ||
11 | end | 19 | end |
12 | 20 | ||
13 | def each_recipient | 21 | def each_recipient |
app/models/article_block.rb
@@ -18,18 +18,6 @@ class ArticleBlock < Block | @@ -18,18 +18,6 @@ class ArticleBlock < Block | ||
18 | _('This block displays one of your articles. You can edit the block to select which one of your articles is going to be displayed in the block.') | 18 | _('This block displays one of your articles. You can edit the block to select which one of your articles is going to be displayed in the block.') |
19 | end | 19 | end |
20 | 20 | ||
21 | - def content(args={}) | ||
22 | - block = self | ||
23 | - proc do | ||
24 | - block_title(block.title) + | ||
25 | - (block.article ? article_to_html(FilePresenter.for(block.article), | ||
26 | - :gallery_view => false, | ||
27 | - :inside_block => block, # For Blogs and folders | ||
28 | - :format => block.visualization_format # For Articles and contents | ||
29 | - ).html_safe : _('Article not selected yet.')) | ||
30 | - end | ||
31 | - end | ||
32 | - | ||
33 | def article_id | 21 | def article_id |
34 | self.settings[:article_id] | 22 | self.settings[:article_id] |
35 | end | 23 | end |
app/models/blog.rb
@@ -93,4 +93,20 @@ class Blog < Folder | @@ -93,4 +93,20 @@ class Blog < Folder | ||
93 | posts.where("type != 'RssFeed'").order(:updated_at).limit(limit) | 93 | posts.where("type != 'RssFeed'").order(:updated_at).limit(limit) |
94 | end | 94 | end |
95 | 95 | ||
96 | + def total_number_of_posts(group_by, year = nil) | ||
97 | + case group_by | ||
98 | + when :by_year | ||
99 | + posts.published.native_translations | ||
100 | + .except(:order) | ||
101 | + .count(:all, :group => 'EXTRACT(YEAR FROM published_at)') | ||
102 | + .sort_by {|year, count| -year.to_i} | ||
103 | + when :by_month | ||
104 | + posts.published.native_translations | ||
105 | + .except(:order) | ||
106 | + .where('EXTRACT(YEAR FROM published_at)=?', year.to_i) | ||
107 | + .group('EXTRACT(MONTH FROM published_at)') | ||
108 | + .count | ||
109 | + .sort_by {|month, count| -month.to_i} | ||
110 | + end | ||
111 | + end | ||
96 | end | 112 | end |
app/models/blog_archives_block.rb
@@ -21,30 +21,6 @@ class BlogArchivesBlock < Block | @@ -21,30 +21,6 @@ class BlogArchivesBlock < Block | ||
21 | blog_id && owner.blogs.exists?(blog_id) ? owner.blogs.find(blog_id) : owner.blog | 21 | blog_id && owner.blogs.exists?(blog_id) ? owner.blogs.find(blog_id) : owner.blog |
22 | end | 22 | end |
23 | 23 | ||
24 | - def visible_posts(person) | ||
25 | - #FIXME Performance issues with display_to. Must convert it to a scope. | ||
26 | - # Checkout this page for further information: http://noosfero.org/Development/ActionItem2705 | ||
27 | - blog.posts.published.native_translations #.select {|post| post.display_to?(person)} | ||
28 | - end | ||
29 | - | ||
30 | - def content(args={}) | ||
31 | - owner_blog = self.blog | ||
32 | - return nil unless owner_blog | ||
33 | - results = '' | ||
34 | - posts = visible_posts(args[:person]) | ||
35 | - posts.except(:order).count(:all, :group => 'EXTRACT(YEAR FROM published_at)').sort_by {|year, count| -year.to_i}.each do |year, count| | ||
36 | - results << content_tag('li', content_tag('strong', "#{year.to_i} (#{count})")) | ||
37 | - results << "<ul class='#{year.to_i}-archive'>" | ||
38 | - posts.except(:order).where('EXTRACT(YEAR FROM published_at)=?', year.to_i).group('EXTRACT(MONTH FROM published_at)').count.sort_by {|month, count| -month.to_i}.each do |month, count| | ||
39 | - results << content_tag('li', link_to("#{month_name(month.to_i)} (#{count})", owner_blog.url.merge(year: year.to_i, month: month.to_i))) | ||
40 | - end | ||
41 | - results << "</ul>" | ||
42 | - end | ||
43 | - block_title(title) + | ||
44 | - content_tag('ul', results, :class => 'blog-archives') + | ||
45 | - content_tag('div', link_to(_('Subscribe RSS Feed'), owner_blog.feed.url), :class => 'subscribe-feed') | ||
46 | - end | ||
47 | - | ||
48 | def self.expire_on | 24 | def self.expire_on |
49 | { :profile => [:article], :environment => [:article] } | 25 | { :profile => [:article], :environment => [:article] } |
50 | end | 26 | end |
app/models/categories_block.rb
@@ -30,13 +30,6 @@ class CategoriesBlock < Block | @@ -30,13 +30,6 @@ class CategoriesBlock < Block | ||
30 | Category.top_level_for(self.owner).from_types(self.category_types) | 30 | Category.top_level_for(self.owner).from_types(self.category_types) |
31 | end | 31 | end |
32 | 32 | ||
33 | - def content(args={}) | ||
34 | - block = self | ||
35 | - proc do | ||
36 | - render :file => 'blocks/categories', :locals => { :block => block } | ||
37 | - end | ||
38 | - end | ||
39 | - | ||
40 | def self.expire_on | 33 | def self.expire_on |
41 | { :profile => [], :environment => [:category] } | 34 | { :profile => [], :environment => [:category] } |
42 | end | 35 | end |
app/models/communities_block.rb
@@ -27,15 +27,6 @@ class CommunitiesBlock < ProfileListBlock | @@ -27,15 +27,6 @@ class CommunitiesBlock < ProfileListBlock | ||
27 | owner.profile_suggestions.of_community.enabled.limit(3).includes(:suggestion) | 27 | owner.profile_suggestions.of_community.enabled.limit(3).includes(:suggestion) |
28 | end | 28 | end |
29 | 29 | ||
30 | - def footer | ||
31 | - owner = self.owner | ||
32 | - suggestions = self.suggestions | ||
33 | - return '' unless owner.kind_of?(Profile) || owner.kind_of?(Environment) | ||
34 | - proc do | ||
35 | - render :file => 'blocks/communities', :locals => { :owner => owner, :suggestions => suggestions } | ||
36 | - end | ||
37 | - end | ||
38 | - | ||
39 | def profiles | 30 | def profiles |
40 | owner.communities | 31 | owner.communities |
41 | end | 32 | end |
app/models/disabled_enterprise_message_block.rb
@@ -12,13 +12,6 @@ class DisabledEnterpriseMessageBlock < Block | @@ -12,13 +12,6 @@ class DisabledEnterpriseMessageBlock < Block | ||
12 | _('Message') | 12 | _('Message') |
13 | end | 13 | end |
14 | 14 | ||
15 | - def content(args={}) | ||
16 | - message = self.owner.environment.message_for_disabled_enterprise || '' | ||
17 | - lambda do |_| | ||
18 | - render :file => 'blocks/disabled_enterprise_message', :locals => {:message => message} | ||
19 | - end | ||
20 | - end | ||
21 | - | ||
22 | def editable?(user=nil) | 15 | def editable?(user=nil) |
23 | false | 16 | false |
24 | end | 17 | end |
app/models/enterprises_block.rb
@@ -12,22 +12,6 @@ class EnterprisesBlock < ProfileListBlock | @@ -12,22 +12,6 @@ class EnterprisesBlock < ProfileListBlock | ||
12 | _('Enterprises') | 12 | _('Enterprises') |
13 | end | 13 | end |
14 | 14 | ||
15 | - def footer | ||
16 | - owner = self.owner | ||
17 | - case owner | ||
18 | - when Profile | ||
19 | - proc do | ||
20 | - link_to s_('enterprises|View all'), :profile => owner.identifier, :controller => 'profile', :action => 'enterprises' | ||
21 | - end | ||
22 | - when Environment | ||
23 | - proc do | ||
24 | - link_to s_('enterprises|View all'), :controller => 'search', :action => 'assets', :asset => 'enterprises' | ||
25 | - end | ||
26 | - else | ||
27 | - '' | ||
28 | - end | ||
29 | - end | ||
30 | - | ||
31 | def profiles | 15 | def profiles |
32 | owner.enterprises | 16 | owner.enterprises |
33 | end | 17 | end |
app/models/fans_block.rb
@@ -12,14 +12,6 @@ class FansBlock < ProfileListBlock | @@ -12,14 +12,6 @@ class FansBlock < ProfileListBlock | ||
12 | _('This block presents the fans of an enterprise.') | 12 | _('This block presents the fans of an enterprise.') |
13 | end | 13 | end |
14 | 14 | ||
15 | - def footer | ||
16 | - profile = self.owner | ||
17 | - proc do | ||
18 | - link_to _('View all'), :profile => profile.identifier, :controller => | ||
19 | - 'profile', :action => 'fans' | ||
20 | - end | ||
21 | - end | ||
22 | - | ||
23 | def profiles | 15 | def profiles |
24 | owner.fans | 16 | owner.fans |
25 | end | 17 | end |
app/models/favorite_enterprises_block.rb
@@ -12,14 +12,6 @@ class FavoriteEnterprisesBlock < ProfileListBlock | @@ -12,14 +12,6 @@ class FavoriteEnterprisesBlock < ProfileListBlock | ||
12 | _('Favorite Enterprises') | 12 | _('Favorite Enterprises') |
13 | end | 13 | end |
14 | 14 | ||
15 | - def footer | ||
16 | - owner = self.owner | ||
17 | - return '' unless owner.kind_of?(Person) | ||
18 | - proc do | ||
19 | - link_to _('enterprises|View all'), {:profile => owner.identifier, :controller => 'profile', :action => 'favorite_enterprises'}, :class => 'view-all' | ||
20 | - end | ||
21 | - end | ||
22 | - | ||
23 | def profiles | 15 | def profiles |
24 | owner.favorite_enterprises | 16 | owner.favorite_enterprises |
25 | end | 17 | end |
app/models/featured_products_block.rb
@@ -32,11 +32,4 @@ class FeaturedProductsBlock < Block | @@ -32,11 +32,4 @@ class FeaturedProductsBlock < Block | ||
32 | self.owner.highlighted_products_with_image | 32 | self.owner.highlighted_products_with_image |
33 | end | 33 | end |
34 | 34 | ||
35 | - def content(args={}) | ||
36 | - block = self | ||
37 | - proc do | ||
38 | - render :file => 'blocks/featured_products', :locals => { :block => block } | ||
39 | - end | ||
40 | - end | ||
41 | - | ||
42 | end | 35 | end |
app/models/feed_reader_block.rb
@@ -52,24 +52,6 @@ class FeedReaderBlock < Block | @@ -52,24 +52,6 @@ class FeedReaderBlock < Block | ||
52 | self.feed_title.nil? ? _('Feed Reader') : self.feed_title | 52 | self.feed_title.nil? ? _('Feed Reader') : self.feed_title |
53 | end | 53 | end |
54 | 54 | ||
55 | - def formatted_feed_content | ||
56 | - if error_message.blank? | ||
57 | - "<ul>\n".html_safe + | ||
58 | - self.feed_items[0..(limit-1)].map{ |item| "<li><a href='#{item[:link]}'>#{item[:title]}</a></li>" }.join("\n").html_safe + | ||
59 | - "</ul>".html_safe | ||
60 | - else | ||
61 | - "<p>#{error_message}</p>".html_safe | ||
62 | - end | ||
63 | - end | ||
64 | - | ||
65 | - def footer | ||
66 | - if self.fetched_at.nil? or self.feed_items.empty? | ||
67 | - _('Feed content was not loaded yet') | ||
68 | - else | ||
69 | - _("Updated: %s") % show_date(self.fetched_at) | ||
70 | - end | ||
71 | - end | ||
72 | - | ||
73 | def add_item(title, link, date, content) | 55 | def add_item(title, link, date, content) |
74 | self.feed_items.unshift( {:title => title, :link => link}) | 56 | self.feed_items.unshift( {:title => title, :link => link}) |
75 | end | 57 | end |
@@ -85,8 +67,4 @@ class FeedReaderBlock < Block | @@ -85,8 +67,4 @@ class FeedReaderBlock < Block | ||
85 | self.save! | 67 | self.save! |
86 | end | 68 | end |
87 | 69 | ||
88 | - def content(args={}) | ||
89 | - block_title(title) + formatted_feed_content | ||
90 | - end | ||
91 | - | ||
92 | end | 70 | end |
app/models/highlights_block.rb
@@ -15,6 +15,8 @@ class HighlightsBlock < Block | @@ -15,6 +15,8 @@ class HighlightsBlock < Block | ||
15 | if !Noosfero.root.nil? and !i[:address].start_with?(Noosfero.root + '/') | 15 | if !Noosfero.root.nil? and !i[:address].start_with?(Noosfero.root + '/') |
16 | i[:address] = Noosfero.root + i[:address] | 16 | i[:address] = Noosfero.root + i[:address] |
17 | end | 17 | end |
18 | + i[:new_window] = i[:new_window] == '1' ? true : false | ||
19 | + | ||
18 | begin | 20 | begin |
19 | file = UploadedFile.find(i[:image_id]) | 21 | file = UploadedFile.find(i[:image_id]) |
20 | i[:image_src] = file.public_filename | 22 | i[:image_src] = file.public_filename |
@@ -41,13 +43,6 @@ class HighlightsBlock < Block | @@ -41,13 +43,6 @@ class HighlightsBlock < Block | ||
41 | end | 43 | end |
42 | end | 44 | end |
43 | 45 | ||
44 | - def content(args={}) | ||
45 | - block = self | ||
46 | - proc do | ||
47 | - render :file => 'blocks/highlights', :locals => { :block => block } | ||
48 | - end | ||
49 | - end | ||
50 | - | ||
51 | def folder_choices | 46 | def folder_choices |
52 | owner.image_galleries | 47 | owner.image_galleries |
53 | end | 48 | end |
app/models/link_list_block.rb
@@ -59,20 +59,6 @@ class LinkListBlock < Block | @@ -59,20 +59,6 @@ class LinkListBlock < Block | ||
59 | _('Link list') | 59 | _('Link list') |
60 | end | 60 | end |
61 | 61 | ||
62 | - def content(args={}) | ||
63 | - block_title(title) + | ||
64 | - content_tag('ul', | ||
65 | - links.select{|i| !i[:name].blank? and !i[:address].blank?}.map{|i| content_tag('li', link_html(i))}.join | ||
66 | - ) | ||
67 | - end | ||
68 | - | ||
69 | - def link_html(link) | ||
70 | - klass = 'icon-' + link[:icon] if link[:icon] | ||
71 | - sanitize_link( | ||
72 | - link_to(link[:name], expand_address(link[:address]), :target => link[:target], :class => klass, :title => link[:title]) | ||
73 | - ) | ||
74 | - end | ||
75 | - | ||
76 | def expand_address(address) | 62 | def expand_address(address) |
77 | add = if owner.respond_to?(:identifier) | 63 | add = if owner.respond_to?(:identifier) |
78 | address.gsub('{profile}', owner.identifier) | 64 | address.gsub('{profile}', owner.identifier) |
@@ -99,8 +85,6 @@ class LinkListBlock < Block | @@ -99,8 +85,6 @@ class LinkListBlock < Block | ||
99 | end | 85 | end |
100 | end | 86 | end |
101 | 87 | ||
102 | - private | ||
103 | - | ||
104 | def sanitize_link(text) | 88 | def sanitize_link(text) |
105 | sanitizer = HTML::WhiteListSanitizer.new | 89 | sanitizer = HTML::WhiteListSanitizer.new |
106 | sanitizer.sanitize(text) | 90 | sanitizer.sanitize(text) |
app/models/location_block.rb
@@ -13,12 +13,4 @@ class LocationBlock < Block | @@ -13,12 +13,4 @@ class LocationBlock < Block | ||
13 | _('Shows where the profile is on the material world.') | 13 | _('Shows where the profile is on the material world.') |
14 | end | 14 | end |
15 | 15 | ||
16 | - def content(args={}) | ||
17 | - block = self | ||
18 | - profile = self.owner | ||
19 | - proc do | ||
20 | - render :file => 'blocks/location', :locals => {:block => block, :profile => profile} | ||
21 | - end | ||
22 | - end | ||
23 | - | ||
24 | end | 16 | end |
app/models/login_block.rb
@@ -8,12 +8,6 @@ class LoginBlock < Block | @@ -8,12 +8,6 @@ class LoginBlock < Block | ||
8 | _('This block presents a login/logout block.') | 8 | _('This block presents a login/logout block.') |
9 | end | 9 | end |
10 | 10 | ||
11 | - def content(args={}) | ||
12 | - lambda do |context| | ||
13 | - render :file => 'blocks/login_block' | ||
14 | - end | ||
15 | - end | ||
16 | - | ||
17 | def cacheable? | 11 | def cacheable? |
18 | false | 12 | false |
19 | end | 13 | end |
app/models/main_block.rb
@@ -8,10 +8,6 @@ class MainBlock < Block | @@ -8,10 +8,6 @@ class MainBlock < Block | ||
8 | _('This block presents the main content of your pages.') | 8 | _('This block presents the main content of your pages.') |
9 | end | 9 | end |
10 | 10 | ||
11 | - def content(args={}) | ||
12 | - nil | ||
13 | - end | ||
14 | - | ||
15 | def main? | 11 | def main? |
16 | true | 12 | true |
17 | end | 13 | end |
app/models/my_network_block.rb
@@ -14,16 +14,6 @@ class MyNetworkBlock < Block | @@ -14,16 +14,6 @@ class MyNetworkBlock < Block | ||
14 | _('This block displays some info about your networking.') | 14 | _('This block displays some info about your networking.') |
15 | end | 15 | end |
16 | 16 | ||
17 | - def content(args={}) | ||
18 | - block = self | ||
19 | - proc do | ||
20 | - render :file => 'blocks/my_network', :locals => { | ||
21 | - :title => block.title, | ||
22 | - :owner => block.owner | ||
23 | - } | ||
24 | - end | ||
25 | - end | ||
26 | - | ||
27 | def cacheable? | 17 | def cacheable? |
28 | false | 18 | false |
29 | end | 19 | end |
app/models/person.rb
@@ -16,10 +16,13 @@ class Person < Profile | @@ -16,10 +16,13 @@ class Person < Profile | ||
16 | acts_as_trackable :after_add => Proc.new {|p,t| notify_activity(t)} | 16 | acts_as_trackable :after_add => Proc.new {|p,t| notify_activity(t)} |
17 | acts_as_accessor | 17 | acts_as_accessor |
18 | 18 | ||
19 | - scope :members_of, -> resources { | 19 | + scope :members_of, lambda { |resources, field = ''| |
20 | resources = Array(resources) | 20 | resources = Array(resources) |
21 | + joins = [:role_assignments] | ||
22 | + joins << :user if User.attribute_names.include? field | ||
23 | + | ||
21 | conditions = resources.map {|resource| "role_assignments.resource_type = '#{resource.class.base_class.name}' AND role_assignments.resource_id = #{resource.id || -1}"}.join(' OR ') | 24 | conditions = resources.map {|resource| "role_assignments.resource_type = '#{resource.class.base_class.name}' AND role_assignments.resource_id = #{resource.id || -1}"}.join(' OR ') |
22 | - distinct.select('profiles.*').joins(:role_assignments).where([conditions]) | 25 | + distinct.select('profiles.*').joins(joins).where([conditions]) |
23 | } | 26 | } |
24 | 27 | ||
25 | scope :not_members_of, -> resources { | 28 | scope :not_members_of, -> resources { |
@@ -48,8 +51,7 @@ class Person < Profile | @@ -48,8 +51,7 @@ class Person < Profile | ||
48 | ['( roles.key = ? AND role_assignments.accessor_type = ? AND role_assignments.accessor_id = ? ) OR ( | 51 | ['( roles.key = ? AND role_assignments.accessor_type = ? AND role_assignments.accessor_id = ? ) OR ( |
49 | ( ( friendships.person_id = ? ) OR (profiles.public_profile = ?)) AND (profiles.visible = ?) )', 'environment_administrator', Profile.name, person.id, person.id, true, true] | 52 | ( ( friendships.person_id = ? ) OR (profiles.public_profile = ?)) AND (profiles.visible = ?) )', 'environment_administrator', Profile.name, person.id, person.id, true, true] |
50 | ).uniq | 53 | ).uniq |
51 | - } | ||
52 | - | 54 | + } |
53 | 55 | ||
54 | def has_permission_with_admin?(permission, resource) | 56 | def has_permission_with_admin?(permission, resource) |
55 | return true if resource.blank? || resource.admins.include?(self) | 57 | return true if resource.blank? || resource.admins.include?(self) |
app/models/product_categories_block.rb
@@ -13,26 +13,6 @@ class ProductCategoriesBlock < Block | @@ -13,26 +13,6 @@ class ProductCategoriesBlock < Block | ||
13 | _('Helps to filter the products catalog.') | 13 | _('Helps to filter the products catalog.') |
14 | end | 14 | end |
15 | 15 | ||
16 | - def content(args={}) | ||
17 | - profile = owner | ||
18 | - proc do | ||
19 | - if @categories.nil? or @categories.length == 0 | ||
20 | - categories = ProductCategory.on_level(nil).order(:name) | ||
21 | - if @categories and @categories.length == 0 | ||
22 | - notice = _('There are no sub-categories for %s') % @category.name | ||
23 | - end | ||
24 | - else | ||
25 | - categories = @categories | ||
26 | - end | ||
27 | - render :file => 'blocks/product_categories', | ||
28 | - :locals => { | ||
29 | - :profile => profile, | ||
30 | - :categories => categories, | ||
31 | - :notice => notice | ||
32 | - } | ||
33 | - end | ||
34 | - end | ||
35 | - | ||
36 | DISPLAY_OPTIONS = DISPLAY_OPTIONS.merge('catalog_only' => _('Only on the catalog')) | 16 | DISPLAY_OPTIONS = DISPLAY_OPTIONS.merge('catalog_only' => _('Only on the catalog')) |
37 | 17 | ||
38 | def display | 18 | def display |
app/models/products_block.rb
@@ -19,26 +19,6 @@ class ProductsBlock < Block | @@ -19,26 +19,6 @@ class ProductsBlock < Block | ||
19 | _('This block presents a list of your products.') | 19 | _('This block presents a list of your products.') |
20 | end | 20 | end |
21 | 21 | ||
22 | - def content(args={}) | ||
23 | - block_title(title) + | ||
24 | - content_tag( | ||
25 | - 'ul', | ||
26 | - products.map {|product| | ||
27 | - content_tag('li', | ||
28 | - link_to( product.name, | ||
29 | - product.url, | ||
30 | - :style => 'background-image:url(%s)' % product.default_image('minor') | ||
31 | - ), | ||
32 | - :class => 'product' | ||
33 | - ) | ||
34 | - }.join | ||
35 | - ) | ||
36 | - end | ||
37 | - | ||
38 | - def footer | ||
39 | - link_to(_('View all products'), owner.public_profile_url.merge(:controller => 'catalog', :action => 'index')) | ||
40 | - end | ||
41 | - | ||
42 | settings_items :product_ids, type: Array | 22 | settings_items :product_ids, type: Array |
43 | def product_ids=(array) | 23 | def product_ids=(array) |
44 | self.settings[:product_ids] = array | 24 | self.settings[:product_ids] = array |
app/models/profile.rb
@@ -5,7 +5,7 @@ class Profile < ActiveRecord::Base | @@ -5,7 +5,7 @@ class Profile < ActiveRecord::Base | ||
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, |
8 | - :email_suggestions, :allow_members_to_invite, :invite_friends_only, :secret | 8 | + :email_suggestions, :allow_members_to_invite, :invite_friends_only, :secret, :profile_admin_mail_notification |
9 | 9 | ||
10 | # use for internationalizable human type names in search facets | 10 | # use for internationalizable human type names in search facets |
11 | # reimplement on subclasses | 11 | # reimplement on subclasses |
@@ -49,6 +49,9 @@ class Profile < ActiveRecord::Base | @@ -49,6 +49,9 @@ class Profile < ActiveRecord::Base | ||
49 | def self.organization_member_roles(env_id) | 49 | def self.organization_member_roles(env_id) |
50 | all_roles(env_id).select{ |r| r.key.match(/^profile_/) unless r.key.blank? || !r.profile_id.nil?} | 50 | all_roles(env_id).select{ |r| r.key.match(/^profile_/) unless r.key.blank? || !r.profile_id.nil?} |
51 | end | 51 | end |
52 | + def self.organization_custom_roles(env_id, profile_id) | ||
53 | + all_roles(env_id).where('profile_id = ?', profile_id) | ||
54 | + end | ||
52 | def self.all_roles(env_id) | 55 | def self.all_roles(env_id) |
53 | Role.where(environment_id: env_id) | 56 | Role.where(environment_id: env_id) |
54 | end | 57 | end |
@@ -155,15 +158,23 @@ class Profile < ActiveRecord::Base | @@ -155,15 +158,23 @@ class Profile < ActiveRecord::Base | ||
155 | 158 | ||
156 | include TimeScopes | 159 | include TimeScopes |
157 | 160 | ||
158 | - def members | 161 | + def members(by_field = '') |
159 | scopes = plugins.dispatch_scopes(:organization_members, self) | 162 | scopes = plugins.dispatch_scopes(:organization_members, self) |
160 | - scopes << Person.members_of(self) | 163 | + scopes << Person.members_of(self,by_field) |
161 | return scopes.first if scopes.size == 1 | 164 | return scopes.first if scopes.size == 1 |
162 | ScopeTool.union *scopes | 165 | ScopeTool.union *scopes |
163 | end | 166 | end |
164 | 167 | ||
165 | - def members_by_name | ||
166 | - members.order('profiles.name') | 168 | + def members_by(field,value = nil) |
169 | + if value and !value.blank? | ||
170 | + members_like(field,value).order('profiles.name') | ||
171 | + else | ||
172 | + members.order('profiles.name') | ||
173 | + end | ||
174 | + end | ||
175 | + | ||
176 | + def members_like(field,value) | ||
177 | + members(field).where("LOWER(#{field}) LIKE ?", "%#{value.downcase}%") if value | ||
167 | end | 178 | end |
168 | 179 | ||
169 | class << self | 180 | class << self |
@@ -234,6 +245,7 @@ class Profile < ActiveRecord::Base | @@ -234,6 +245,7 @@ class Profile < ActiveRecord::Base | ||
234 | settings_items :description | 245 | settings_items :description |
235 | settings_items :fields_privacy, :type => :hash, :default => {} | 246 | settings_items :fields_privacy, :type => :hash, :default => {} |
236 | settings_items :email_suggestions, :type => :boolean, :default => false | 247 | settings_items :email_suggestions, :type => :boolean, :default => false |
248 | + settings_items :profile_admin_mail_notification, :type => :boolean, :default => true | ||
237 | 249 | ||
238 | validates_length_of :description, :maximum => 550, :allow_nil => true | 250 | validates_length_of :description, :maximum => 550, :allow_nil => true |
239 | 251 | ||
@@ -1102,6 +1114,10 @@ private :generate_url, :url_options | @@ -1102,6 +1114,10 @@ private :generate_url, :url_options | ||
1102 | end | 1114 | end |
1103 | end | 1115 | end |
1104 | 1116 | ||
1117 | + def can_view_field? current_person, field | ||
1118 | + display_private_info_to?(current_person) || (public_fields.include?(field) && public?) | ||
1119 | + end | ||
1120 | + | ||
1105 | validates_inclusion_of :redirection_after_login, :in => Environment.login_redirection_options.keys, :allow_nil => true | 1121 | validates_inclusion_of :redirection_after_login, :in => Environment.login_redirection_options.keys, :allow_nil => true |
1106 | def preferred_login_redirection | 1122 | def preferred_login_redirection |
1107 | redirection_after_login.blank? ? environment.redirection_after_login : redirection_after_login | 1123 | redirection_after_login.blank? ? environment.redirection_after_login : redirection_after_login |
app/models/profile_image_block.rb
@@ -12,17 +12,6 @@ class ProfileImageBlock < Block | @@ -12,17 +12,6 @@ class ProfileImageBlock < Block | ||
12 | _('This block presents the profile image') | 12 | _('This block presents the profile image') |
13 | end | 13 | end |
14 | 14 | ||
15 | - def content(args={}) | ||
16 | - block = self | ||
17 | - s = show_name | ||
18 | - lambda do |object| | ||
19 | - render( | ||
20 | - :file => 'blocks/profile_image', | ||
21 | - :locals => { :block => block, :show_name => s } | ||
22 | - ) | ||
23 | - end | ||
24 | - end | ||
25 | - | ||
26 | def cacheable? | 15 | def cacheable? |
27 | false | 16 | false |
28 | end | 17 | end |
app/models/profile_info_block.rb
@@ -16,13 +16,6 @@ class ProfileInfoBlock < Block | @@ -16,13 +16,6 @@ class ProfileInfoBlock < Block | ||
16 | _('Basic information about <i>%{user}</i>: how long <i>%{user}</i> is part of <i>%{env}</i> and useful links.') % { :user => self.owner.name(), :env => self.owner.environment.name() } | 16 | _('Basic information about <i>%{user}</i>: how long <i>%{user}</i> is part of <i>%{env}</i> and useful links.') % { :user => self.owner.name(), :env => self.owner.environment.name() } |
17 | end | 17 | end |
18 | 18 | ||
19 | - def content(args={}) | ||
20 | - block = self | ||
21 | - lambda do |_| | ||
22 | - render :file => 'blocks/profile_info', :locals => { :block => block } | ||
23 | - end | ||
24 | - end | ||
25 | - | ||
26 | def cacheable? | 19 | def cacheable? |
27 | false | 20 | false |
28 | end | 21 | end |
app/models/profile_list_block.rb
@@ -40,26 +40,6 @@ result = public_profiles.all(:limit => get_limit, :order => 'profiles.updated_at | @@ -40,26 +40,6 @@ result = public_profiles.all(:limit => get_limit, :order => 'profiles.updated_at | ||
40 | _('Clicking on the people or groups will take you to their home page.') | 40 | _('Clicking on the people or groups will take you to their home page.') |
41 | end | 41 | end |
42 | 42 | ||
43 | - def content(args={}) | ||
44 | - profiles = self.profile_list | ||
45 | - title = self.view_title | ||
46 | - nl = "\n" | ||
47 | - proc do |context| | ||
48 | - count=0 | ||
49 | - list = profiles.map {|item| | ||
50 | - count+=1 | ||
51 | - send(:profile_image_link, item, :minor ) | ||
52 | - }.join("\n ") | ||
53 | - if list.empty? | ||
54 | - list = content_tag 'div', _('None'), :class => 'common-profile-list-block-none' | ||
55 | - else | ||
56 | - list = content_tag 'ul', nl +' '+ list + nl | ||
57 | - end | ||
58 | - block_title(title) + nl + | ||
59 | - content_tag('div', nl + list + nl + tag('br', :style => 'clear:both')) | ||
60 | - end | ||
61 | - end | ||
62 | - | ||
63 | def view_title | 43 | def view_title |
64 | title.gsub('{#}', profile_count.to_s) | 44 | title.gsub('{#}', profile_count.to_s) |
65 | end | 45 | end |
app/models/profile_search_block.rb
@@ -4,11 +4,4 @@ class ProfileSearchBlock < Block | @@ -4,11 +4,4 @@ class ProfileSearchBlock < Block | ||
4 | _('Display a form to search the profile') | 4 | _('Display a form to search the profile') |
5 | end | 5 | end |
6 | 6 | ||
7 | - def content(args={}) | ||
8 | - title = self.title | ||
9 | - lambda do |_| | ||
10 | - render :file => 'blocks/profile_search', :locals => { :title => title } | ||
11 | - end | ||
12 | - end | ||
13 | - | ||
14 | end | 7 | end |
app/models/raw_html_block.rb
@@ -12,10 +12,6 @@ class RawHTMLBlock < Block | @@ -12,10 +12,6 @@ class RawHTMLBlock < Block | ||
12 | 12 | ||
13 | attr_accessible :html | 13 | attr_accessible :html |
14 | 14 | ||
15 | - def content(args={}) | ||
16 | - (title.blank? ? '' : block_title(title)).html_safe + html.to_s.html_safe | ||
17 | - end | ||
18 | - | ||
19 | def has_macro? | 15 | def has_macro? |
20 | true | 16 | true |
21 | end | 17 | end |
app/models/recent_documents_block.rb
@@ -22,24 +22,6 @@ class RecentDocumentsBlock < Block | @@ -22,24 +22,6 @@ class RecentDocumentsBlock < Block | ||
22 | 22 | ||
23 | settings_items :limit, :type => :integer, :default => 5 | 23 | settings_items :limit, :type => :integer, :default => 5 |
24 | 24 | ||
25 | - def content(args={}) | ||
26 | - docs = self.docs | ||
27 | - title = self.title | ||
28 | - proc do | ||
29 | - block_title(title) + | ||
30 | - content_tag('ul', docs.map {|item| content_tag('li', link_to(h(item.title), item.url))}.join("\n")) | ||
31 | - end | ||
32 | - end | ||
33 | - | ||
34 | - def footer | ||
35 | - return nil unless self.owner.is_a?(Profile) | ||
36 | - | ||
37 | - profile = self.owner | ||
38 | - proc do | ||
39 | - link_to _('All content'), :profile => profile.identifier, :controller => 'profile', :action => 'sitemap' | ||
40 | - end | ||
41 | - end | ||
42 | - | ||
43 | def docs | 25 | def docs |
44 | self.limit.nil? ? owner.recent_documents(nil, {}, false) : owner.recent_documents(self.get_limit, {}, false) | 26 | self.limit.nil? ? owner.recent_documents(nil, {}, false) : owner.recent_documents(self.get_limit, {}, false) |
45 | end | 27 | end |
app/models/sellers_search_block.rb
@@ -22,10 +22,4 @@ class SellersSearchBlock < Block | @@ -22,10 +22,4 @@ class SellersSearchBlock < Block | ||
22 | _('This block presents a search engine for products.') | 22 | _('This block presents a search engine for products.') |
23 | end | 23 | end |
24 | 24 | ||
25 | - def content(args={}) | ||
26 | - title = self.title | ||
27 | - lambda do |object| | ||
28 | - render :file => 'search/_sellers_form', :locals => { :title => title } | ||
29 | - end | ||
30 | - end | ||
31 | end | 25 | end |
app/models/slideshow_block.rb
@@ -33,23 +33,6 @@ class SlideshowBlock < Block | @@ -33,23 +33,6 @@ class SlideshowBlock < Block | ||
33 | gallery.images.reject {|item| item.folder?} | 33 | gallery.images.reject {|item| item.folder?} |
34 | end | 34 | end |
35 | 35 | ||
36 | - def content(args={}) | ||
37 | - block = self | ||
38 | - if gallery | ||
39 | - images = block_images | ||
40 | - if shuffle | ||
41 | - images = images.shuffle | ||
42 | - end | ||
43 | - proc do | ||
44 | - render :file => 'blocks/slideshow', :locals => { :block => block, :images => images } | ||
45 | - end | ||
46 | - else | ||
47 | - proc do | ||
48 | - render :file => 'blocks/slideshow', :locals => { :block => block, :images => nil } | ||
49 | - end | ||
50 | - end | ||
51 | - end | ||
52 | - | ||
53 | def folder_choices | 36 | def folder_choices |
54 | owner.image_galleries | 37 | owner.image_galleries |
55 | end | 38 | end |
app/models/tags_block.rb
@@ -28,42 +28,6 @@ class TagsBlock < Block | @@ -28,42 +28,6 @@ class TagsBlock < Block | ||
28 | Try to add some tags to some articles and you'l see your tag cloud growing.") | 28 | Try to add some tags to some articles and you'l see your tag cloud growing.") |
29 | end | 29 | end |
30 | 30 | ||
31 | - def content(args={}) | ||
32 | - is_env = owner.class == Environment | ||
33 | - tags = is_env ? owner.tag_counts : owner.article_tags | ||
34 | - return '' if tags.empty? | ||
35 | - | ||
36 | - if limit | ||
37 | - tags_tmp = tags.sort_by{ |k,v| -v }[0..(limit-1)] | ||
38 | - tags = {} | ||
39 | - tags_tmp.map{ |k,v| tags[k] = v } | ||
40 | - end | ||
41 | - | ||
42 | - url = is_env ? {:host=>owner.default_hostname, :controller=>'search', :action => 'tag'} : | ||
43 | - owner.public_profile_url.merge(:controller => 'profile', :action => 'content_tagged') | ||
44 | - tagname_option = is_env ? :tag : :id | ||
45 | - | ||
46 | - block_title(title) + | ||
47 | - "\n<div class='tag_cloud'>\n".html_safe+ | ||
48 | - tag_cloud( tags, tagname_option, url, :max_size => 16, :min_size => 9 ) + | ||
49 | - "\n</div><!-- end class='tag_cloud' -->\n".html_safe | ||
50 | - end | ||
51 | - | ||
52 | - def footer | ||
53 | - if owner.class == Environment | ||
54 | - proc do | ||
55 | - link_to s_('tags|View all'), | ||
56 | - :controller => 'search', :action => 'tags' | ||
57 | - end | ||
58 | - else | ||
59 | - owner_id = owner.identifier | ||
60 | - proc do | ||
61 | - link_to s_('tags|View all'), | ||
62 | - :profile => owner_id, :controller => 'profile', :action => 'tags' | ||
63 | - end | ||
64 | - end | ||
65 | - end | ||
66 | - | ||
67 | def timeout | 31 | def timeout |
68 | 15.minutes | 32 | 15.minutes |
69 | end | 33 | end |
app/models/task.rb
@@ -67,7 +67,9 @@ class Task < ActiveRecord::Base | @@ -67,7 +67,9 @@ class Task < ActiveRecord::Base | ||
67 | begin | 67 | begin |
68 | target_msg = task.target_notification_message | 68 | target_msg = task.target_notification_message |
69 | if target_msg && task.target && !task.target.notification_emails.empty? | 69 | if target_msg && task.target && !task.target.notification_emails.empty? |
70 | - TaskMailer.target_notification(task, target_msg).deliver | 70 | + if target_profile_accepts_notification?(task) |
71 | + TaskMailer.target_notification(task, target_msg).deliver | ||
72 | + end | ||
71 | end | 73 | end |
72 | rescue NotImplementedError => ex | 74 | rescue NotImplementedError => ex |
73 | Rails.logger.info ex.to_s | 75 | Rails.logger.info ex.to_s |
@@ -75,6 +77,14 @@ class Task < ActiveRecord::Base | @@ -75,6 +77,14 @@ class Task < ActiveRecord::Base | ||
75 | end | 77 | end |
76 | end | 78 | end |
77 | 79 | ||
80 | + def target_profile_accepts_notification?(task) | ||
81 | + if task.target.kind_of? Organization | ||
82 | + return task.target.profile_admin_mail_notification | ||
83 | + else | ||
84 | + true | ||
85 | + end | ||
86 | + end | ||
87 | + | ||
78 | # this method finished the task. It calls #perform, which must be overriden | 88 | # this method finished the task. It calls #perform, which must be overriden |
79 | # by subclasses. At the end a message (as returned by #finish_message) is | 89 | # by subclasses. At the end a message (as returned by #finish_message) is |
80 | # sent to the requestor with #notify_requestor. | 90 | # sent to the requestor with #notify_requestor. |
app/views/account/index.html.erb
@@ -0,0 +1,12 @@ | @@ -0,0 +1,12 @@ | ||
1 | +<%= block_title(block.title) %> | ||
2 | +<% if block.article %> | ||
3 | + <%= | ||
4 | + h(article_to_html(FilePresenter.for(block.article), | ||
5 | + :gallery_view => false, | ||
6 | + :inside_block => block, # For Blogs and folders | ||
7 | + :format => block.visualization_format # For Articles and contents | ||
8 | + )) | ||
9 | + %> | ||
10 | +<% else %> | ||
11 | + <%= _('Article not selected yet.') %> | ||
12 | +<% end %> |
@@ -0,0 +1,16 @@ | @@ -0,0 +1,16 @@ | ||
1 | +<% if block.blog %> | ||
2 | + <%= block_title(block.title) %> | ||
3 | + | ||
4 | + <ul class='blog-archives'> | ||
5 | + <% block.blog.total_number_of_posts(:by_year).each do |year, count| %> | ||
6 | + <%= content_tag('li', content_tag('strong', "#{year.to_i} (#{count})")) %> | ||
7 | + <ul class='<%= year.to_i %>-archive'> | ||
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))) %> | ||
10 | + <% end %> | ||
11 | + </ul> | ||
12 | + <% end %> | ||
13 | + </ul> | ||
14 | + | ||
15 | + <%= content_tag('div', link_to(_('Subscribe RSS Feed'), block.blog.feed.url), :class => 'subscribe-feed') %> | ||
16 | +<% end %> |
app/views/blocks/communities.html.erb
@@ -1,17 +0,0 @@ | @@ -1,17 +0,0 @@ | ||
1 | -<% if owner.kind_of?(Profile) %> | ||
2 | - <%= link_to s_('communities|View all'), {:profile => owner.identifier, :controller => 'profile', :action => 'communities'}, :class => 'view-all' %> | ||
3 | -<% elsif owner.kind_of?(Environment) %> | ||
4 | - <%= link_to s_('communities|View all'), {:controller => 'search', :action => 'communities'}, :class => 'view-all' %> | ||
5 | -<% end %> | ||
6 | - | ||
7 | -<% if user && user == profile && suggestions && !suggestions.empty? %> | ||
8 | - <div class='suggestions-block common-profile-list-block'> | ||
9 | - <h4 class='block-subtitle'><%= _('Some suggestions for you') %></h4> | ||
10 | - <div class='profiles-suggestions'> | ||
11 | - <%= render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => suggestions, :collection => :communities_suggestions, :per_page => 3 } %> | ||
12 | - </div> | ||
13 | - <div class='more-suggestions'> | ||
14 | - <%= link_to _('See all suggestions'), profile.communities_suggestions_url %> | ||
15 | - </div> | ||
16 | - </div> | ||
17 | -<% end %> |
app/views/blocks/disabled_enterprise_message.html.erb
1 | +<% message = block.owner.environment.message_for_disabled_enterprise || '' %> | ||
2 | + | ||
1 | <div id='enterprise-disabled'> | 3 | <div id='enterprise-disabled'> |
2 | <%= message %> | 4 | <%= message %> |
3 | <% if profile.blocked? && user && user.is_admin?(profile.environment) %> | 5 | <% if profile.blocked? && user && user.is_admin?(profile.environment) %> |
@@ -0,0 +1,11 @@ | @@ -0,0 +1,11 @@ | ||
1 | +<%= block_title(block.title) %> | ||
2 | + | ||
3 | +<%= | ||
4 | + if block.error_message.blank? | ||
5 | + "<ul>\n".html_safe + | ||
6 | + block.feed_items[0..(block.limit-1)].map{ |item| "<li><a href='#{item[:link]}'>#{item[:title]}</a></li>" }.join("\n").html_safe + | ||
7 | + "</ul>".html_safe | ||
8 | + else | ||
9 | + "<p>#{block.error_message}</p>".html_safe | ||
10 | + end | ||
11 | +%> |
@@ -0,0 +1,19 @@ | @@ -0,0 +1,19 @@ | ||
1 | +<% if block.owner.kind_of?(Profile) || block.owner.kind_of?(Environment) %> | ||
2 | + <% if block.owner.kind_of?(Profile) %> | ||
3 | + <%= link_to s_('communities|View all'), {:profile => block.owner.identifier, :controller => 'profile', :action => 'communities'}, :class => 'view-all' %> | ||
4 | + <% elsif block.owner.kind_of?(Environment) %> | ||
5 | + <%= link_to s_('communities|View all'), {:controller => 'search', :action => 'communities'}, :class => 'view-all' %> | ||
6 | + <% end %> | ||
7 | + | ||
8 | + <% if user && user == profile && block.suggestions && !block.suggestions.empty? %> | ||
9 | + <div class='suggestions-block common-profile-list-block'> | ||
10 | + <h4 class='block-subtitle'><%= _('Some suggestions for you') %></h4> | ||
11 | + <div class='profiles-suggestions'> | ||
12 | + <%= render :partial => 'shared/profile_suggestions_list', :locals => { :suggestions => block.suggestions, :collection => :communities_suggestions, :per_page => 3 } %> | ||
13 | + </div> | ||
14 | + <div class='more-suggestions'> | ||
15 | + <%= link_to _('See all suggestions'), profile.communities_suggestions_url %> | ||
16 | + </div> | ||
17 | + </div> | ||
18 | + <% end %> | ||
19 | +<% end %> |
@@ -0,0 +1,5 @@ | @@ -0,0 +1,5 @@ | ||
1 | +<% if block.owner.is_a?(Profile) %> | ||
2 | + <%= link_to s_('enterprises|View all'), :profile => block.owner.identifier, :controller => 'profile', :action => 'enterprises' %> | ||
3 | +<% elsif block.owner.is_a?(Environment) %> | ||
4 | + <%= link_to s_('enterprises|View all'), :controller => 'search', :action => 'assets', :asset => 'enterprises' %> | ||
5 | +<% end %> |
@@ -0,0 +1 @@ | @@ -0,0 +1 @@ | ||
1 | +<%= link_to _('View all'), :profile => block.owner.identifier, :controller => 'profile', :action => 'fans' %> |
@@ -0,0 +1 @@ | @@ -0,0 +1 @@ | ||
1 | +<%= link_to(_('View all products'), block.owner.public_profile_url.merge(:controller => 'catalog', :action => 'index')) %> |
@@ -0,0 +1,5 @@ | @@ -0,0 +1,5 @@ | ||
1 | +<% if block.owner.is_a?(Environment) %> | ||
2 | + <%= link_to s_('tags|View all'), :controller => 'search', :action => 'tags' %> | ||
3 | +<% else %> | ||
4 | + <%= link_to s_('tags|View all'), :profile => block.owner.identifier, :controller => 'profile', :action => 'tags' %> | ||
5 | +<% end %> |
app/views/blocks/highlights.html.erb
@@ -3,7 +3,7 @@ | @@ -3,7 +3,7 @@ | ||
3 | <div class='highlights-border'> | 3 | <div class='highlights-border'> |
4 | <div class='highlights-container'> | 4 | <div class='highlights-container'> |
5 | <% block.featured_images.each do |img| %> | 5 | <% block.featured_images.each do |img| %> |
6 | - <a href="<%= img[:address] %>" title="<%= img[:title] %>" class="highlights-image-link"> | 6 | + <a href="<%= img[:address] %>" <%= 'target="_blank"' if img[:new_window] %> title="<%= img[:title] %>" class="highlights-image-link"> |
7 | <%= image_tag [Noosfero.root, img[:image_src]].join, alt: img[:title] %> | 7 | <%= image_tag [Noosfero.root, img[:image_src]].join, alt: img[:title] %> |
8 | <p class="highlights-label"><%= img[:title] %></p> | 8 | <p class="highlights-label"><%= img[:title] %></p> |
9 | </a> | 9 | </a> |
@@ -0,0 +1,14 @@ | @@ -0,0 +1,14 @@ | ||
1 | +<%= block_title(block.title) %> | ||
2 | + | ||
3 | +<%= block.links.empty? && block.title.empty? ? content_tag('em', _('Please, edit this block to add links')) : '' %> | ||
4 | + | ||
5 | +<ul> | ||
6 | + <% block.links.select{|i| !i[:name].blank? and !i[:address].blank?}.each do |link| %> | ||
7 | + <li> | ||
8 | + <%= block.sanitize_link(link_to(link[:name], block.expand_address(link[:address]), | ||
9 | + :target => link[:target], | ||
10 | + :class => (link[:icon] ? "icon-#{link[:icon]}" : ''), | ||
11 | + :title => link[:title])) %> | ||
12 | + </li> | ||
13 | + <% end %> | ||
14 | +</ul> |
app/views/blocks/location.html.erb
1 | -<% if profile.lat %> | 1 | +<% if block.owner.lat %> |
2 | <%= block_title block.title %> | 2 | <%= block_title block.title %> |
3 | <div class='the-localization-map'> | 3 | <div class='the-localization-map'> |
4 | - <img src="https://maps.google.com/maps/api/staticmap?center=<%=profile.lat%>,<%=profile.lng%>&zoom=<%=block.zoom%>&size=190x250&maptype=<%=block.map_type%>&markers=<%=profile.lat%>,<%=profile.lng%>&sensor=false"/> | 4 | + <img src="https://maps.google.com/maps/api/staticmap?center=<%=block.owner.lat%>,<%=block.owner.lng%>&zoom=<%=block.zoom%>&size=190x250&maptype=<%=block.map_type%>&markers=<%=block.owner.lat%>,<%=block.owner.lng%>&sensor=false"/> |
5 | </div> | 5 | </div> |
6 | <% else %> | 6 | <% else %> |
7 | <i><%= _('This profile has no geographical position registered.') %></i> | 7 | <i><%= _('This profile has no geographical position registered.') %></i> |
@@ -0,0 +1,16 @@ | @@ -0,0 +1,16 @@ | ||
1 | +<% if user.present? %> | ||
2 | + <div class="logged-user-info"> | ||
3 | + <h2><%= _('Logged in as %s') % user.identifier %></h2> | ||
4 | + <ul> | ||
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> | ||
7 | + </ul> | ||
8 | + <div class="user-actions"> | ||
9 | + <%= button(:'menu-logout', _('Logout'), :controller => 'account', :action => 'logout') %> | ||
10 | + </div> | ||
11 | + </div> | ||
12 | +<% else %> | ||
13 | + <div class='not-logged-user'> | ||
14 | + <%= render :file => 'account/login_block' %> | ||
15 | + </div> | ||
16 | +<% end%> |
app/views/blocks/login_block.html.erb
@@ -1,16 +0,0 @@ | @@ -1,16 +0,0 @@ | ||
1 | -<% if user.present? %> | ||
2 | - <div class="logged-user-info"> | ||
3 | - <h2><%= _('Logged in as %s') % user.identifier %></h2> | ||
4 | - <ul> | ||
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> | ||
7 | - </ul> | ||
8 | - <div class="user-actions"> | ||
9 | - <%= button(:'menu-logout', _('Logout'), :controller => 'account', :action => 'logout') %> | ||
10 | - </div> | ||
11 | - </div> | ||
12 | -<% else %> | ||
13 | - <div class='not-logged-user'> | ||
14 | - <%= render :file => 'account/login_block' %> | ||
15 | - </div> | ||
16 | -<% end%> |
app/views/blocks/my_network.html.erb
1 | -<%= block_title(title) %> | 1 | +<%= block_title(block.title) %> |
2 | 2 | ||
3 | <ul> | 3 | <ul> |
4 | - <li><%= link_to(_('Homepage'), owner.url, :class => 'url') %></li> | ||
5 | - <li><%= link_to(_('View profile'), owner.public_profile_url) %></li> | ||
6 | - <% if !user.nil? and owner.organization? and user.has_permission?('edit_profile', profile) %> | 4 | + <li><%= link_to(_('Homepage'), block.owner.url, :class => 'url') %></li> |
5 | + <li><%= link_to(_('View profile'), block.owner.public_profile_url) %></li> | ||
6 | + <% if !user.nil? and block.owner.organization? and user.has_permission?('edit_profile', profile) %> | ||
7 | <li><%= link_to _('Control panel'), :controller => 'profile_editor', :profile => profile.identifier %></li> | 7 | <li><%= link_to _('Control panel'), :controller => 'profile_editor', :profile => profile.identifier %></li> |
8 | <% end %> | 8 | <% end %> |
9 | </ul> | 9 | </ul> |
10 | 10 | ||
11 | <div class="my-network-actions"> | 11 | <div class="my-network-actions"> |
12 | - <%= render_profile_actions owner.class %> | 12 | + <%= render_profile_actions block.owner.class %> |
13 | </div> | 13 | </div> |
app/views/blocks/product_categories.html.erb
1 | -<%= link_to _('Catalog start'), profile.catalog_url, :class=>'catalog-home-link' %> | 1 | +<% |
2 | + if @categories.nil? or @categories.length == 0 | ||
3 | + categories = ProductCategory.on_level(nil).order(:name) | ||
4 | + else | ||
5 | + categories = @categories | ||
6 | + end | ||
7 | +%> | ||
8 | + | ||
9 | +<%= link_to _('Catalog start'), block.owner.catalog_url, :class=>'catalog-home-link' %> | ||
2 | <ul class="catalog-categories-list"> | 10 | <ul class="catalog-categories-list"> |
3 | <% categories.each do |category| %> | 11 | <% categories.each do |category| %> |
4 | <%= category_with_sub_list(category) %> | 12 | <%= category_with_sub_list(category) %> |
5 | <% end %> | 13 | <% end %> |
6 | </ul> | 14 | </ul> |
7 | -<% if notice %> | ||
8 | - <div class="catalog-categories-notice"><%= notice %></div> | 15 | +<% if @categories and @categories.length == 0 %> |
16 | + <div class="catalog-categories-notice"> | ||
17 | + <%= _('There are no sub-categories for %s') % @category.name %> | ||
18 | + </div> | ||
9 | <% end %> | 19 | <% end %> |
app/views/blocks/profile_image.html.erb
@@ -0,0 +1,17 @@ | @@ -0,0 +1,17 @@ | ||
1 | +<%= block_title(block.view_title) %> | ||
2 | + | ||
3 | +<% | ||
4 | + list = block.profile_list.map do |item| | ||
5 | + profile_image_link(item, :minor) | ||
6 | + end.join("\n ") | ||
7 | +%> | ||
8 | + | ||
9 | +<div> | ||
10 | + <% if list.empty? %> | ||
11 | + <div class='common-profile-list-block-none'><%= _('None') %></div> | ||
12 | + <% else %> | ||
13 | + <ul><%= list %></ul> | ||
14 | + <% end %> | ||
15 | +</div> | ||
16 | + | ||
17 | +<br style='clear:both'/> |
app/views/blocks/profile_search.html.erb
@@ -0,0 +1,24 @@ | @@ -0,0 +1,24 @@ | ||
1 | +<h3><%= block.title %></h3> | ||
2 | + | ||
3 | +<%= form_tag({:controller => 'search', :action => 'assets'}, {:method => 'get'}) do %> | ||
4 | + | ||
5 | + <div class="search-in-opt"><%= _('Search in:') %> | ||
6 | + <dir> | ||
7 | + <%= labelled_radio_button _('Enterprises'), 'asset', 'enterprises', true %><br /> | ||
8 | + <%= labelled_radio_button _('Products'), 'asset', 'products', false %> | ||
9 | + </dir> | ||
10 | + </div> | ||
11 | + | ||
12 | + <div class="formfield search-from-opt"> | ||
13 | + <%= select_city(true) %> | ||
14 | + </div> | ||
15 | + | ||
16 | + <div class="formfield search-distance-opt"> | ||
17 | + <%= labelled_select(_('Distance:'), 'radius', :first, :last, nil, [15, 30, 50, 100, 150, 200, 300, 400, 500, 1000].map{|n|[n, n.to_s + 'km']}) %> | ||
18 | + </div> | ||
19 | + | ||
20 | + <div class="button-bar"> | ||
21 | + <%= submit_button :search, _('Search') %> | ||
22 | + </div> | ||
23 | + | ||
24 | +<% end %> |
app/views/blocks/slideshow.html.erb
1 | +<% | ||
2 | + if block.gallery | ||
3 | + images = block.block_images | ||
4 | + if block.shuffle | ||
5 | + images = images.shuffle | ||
6 | + end | ||
7 | + end | ||
8 | +%> | ||
9 | + | ||
1 | <%= block_title(block.title) %> | 10 | <%= block_title(block.title) %> |
11 | + | ||
2 | <% if images %> | 12 | <% if images %> |
3 | <% description = images.any? { |img| !img.abstract.blank? } %> | 13 | <% description = images.any? { |img| !img.abstract.blank? } %> |
4 | <div class='slideshow-border<%= (description ? ' with-descriptions' : '')%>'> | 14 | <div class='slideshow-border<%= (description ? ' with-descriptions' : '')%>'> |
@@ -0,0 +1,25 @@ | @@ -0,0 +1,25 @@ | ||
1 | +<%= block_title(block.title) %> | ||
2 | + | ||
3 | +<% | ||
4 | + is_env = block.owner.class == Environment | ||
5 | + tags = is_env ? block.owner.tag_counts : block.owner.article_tags | ||
6 | + if block.limit | ||
7 | + tags_tmp = tags.sort_by{ |k,v| -v }[0..(block.limit-1)] | ||
8 | + tags = {} | ||
9 | + tags_tmp.map{ |k,v| tags[k] = v } | ||
10 | + end | ||
11 | +%> | ||
12 | + | ||
13 | +<% unless tags.empty? %> | ||
14 | + <div class='tag_cloud'> | ||
15 | + <% if is_env %> | ||
16 | + <%= tag_cloud(tags, :tag, | ||
17 | + {:host => block.owner.default_hostname, :controller=>'search', :action => 'tag'}, | ||
18 | + :max_size => 16, :min_size => 9) %> | ||
19 | + <% else %> | ||
20 | + <%= tag_cloud(tags, :id, | ||
21 | + block.owner.public_profile_url.merge(:controller => 'profile', :action => 'content_tagged'), | ||
22 | + :max_size => 16, :min_size => 9) %> | ||
23 | + <% end %> | ||
24 | + </div> | ||
25 | +<% end %> |
app/views/box_organizer/_highlights_block.html.erb
@@ -3,7 +3,7 @@ | @@ -3,7 +3,7 @@ | ||
3 | <strong><%= _('Highlights') %></strong> | 3 | <strong><%= _('Highlights') %></strong> |
4 | 4 | ||
5 | <table class="noborder"><tbody id="highlights-data-table"> | 5 | <table class="noborder"><tbody id="highlights-data-table"> |
6 | - <tr><th><%= _('Image') %></th><th><%= _('Address') %></th><th><%= _('Position') %></th></tr> | 6 | + <tr><th><%= _('Image') %></th><th><%= _('Address') %></th><th><%= _('Position') %></th><th><%= _('New Window') %></th></tr> |
7 | <% @block.images.each_with_index do |image, index| %> | 7 | <% @block.images.each_with_index do |image, index| %> |
8 | <%= highlights_block_config_image_fields @block, image, index %> | 8 | <%= highlights_block_config_image_fields @block, image, index %> |
9 | <% end %> | 9 | <% end %> |
app/views/cms/_drag_and_drop_note.html.erb
app/views/cms/_text_editor_sidebar.html.erb
@@ -17,8 +17,8 @@ | @@ -17,8 +17,8 @@ | ||
17 | :parent_id, profile, default_folder, {}, {}, | 17 | :parent_id, profile, default_folder, {}, {}, |
18 | "type='Folder' or type='Gallery'" | 18 | "type='Folder' or type='Gallery'" |
19 | ) %> | 19 | ) %> |
20 | + <%= button(:newfolder, _('New folder'), '#', :id => 'new-folder-button') %> | ||
20 | </div> | 21 | </div> |
21 | - <%= button(:newfolder, _('New folder'), '#', :id => 'new-folder-button') %> | ||
22 | <p><%= file_field_tag('file', :multiple => true) %></p> | 22 | <p><%= file_field_tag('file', :multiple => true) %></p> |
23 | <% end %> | 23 | <% end %> |
24 | </div> | 24 | </div> |
@@ -31,7 +31,7 @@ | @@ -31,7 +31,7 @@ | ||
31 | <div id='published-media' class='text-editor-sidebar-box' data-url='<%= url_for({:controller => 'cms', :action => 'published_media_items', :profile => profile.identifier}) %>'> | 31 | <div id='published-media' class='text-editor-sidebar-box' data-url='<%= url_for({:controller => 'cms', :action => 'published_media_items', :profile => profile.identifier}) %>'> |
32 | <%= select_profile_folder(nil, :parent_id, profile, 'recent-media', {}, {}, | 32 | <%= select_profile_folder(nil, :parent_id, profile, 'recent-media', {}, {}, |
33 | "type='Folder' or type='Gallery'", {:root_label => _('Recent media')}) %> | 33 | "type='Folder' or type='Gallery'", {:root_label => _('Recent media')}) %> |
34 | - <%= labelled_form_field _('Search'), text_field_tag('q') %> | 34 | + <%= labelled_form_field _('Search among your uploaded files'), text_field_tag('q', '', placeholder: _('Write words about the file you are looking for')) %> |
35 | <%= render :partial => 'drag_and_drop_note' %> | 35 | <%= render :partial => 'drag_and_drop_note' %> |
36 | <div class='items'> | 36 | <div class='items'> |
37 | <%= render :partial => 'published_media_items' %> | 37 | <%= render :partial => 'published_media_items' %> |
app/views/profile/send_mail.html.erb
@@ -4,6 +4,9 @@ | @@ -4,6 +4,9 @@ | ||
4 | 4 | ||
5 | <%= error_messages_for :mailing %> | 5 | <%= error_messages_for :mailing %> |
6 | 6 | ||
7 | + <% to = @mailing.data[:members_filtered].present? ? @mailing.recipients.map{|r| r.name}.join(', ') : _('All members')%> | ||
8 | + <%= labelled_form_field(_('To:'), text_area(:data, 'members_filtered', :value => to, :rows => 4, :disabled => 'disabled', :class => 'send-mail-recipients')) %> | ||
9 | + | ||
7 | <%= form_for :mailing, :url => {:action => 'send_mail'}, :html => {:id => 'mailing-form'} do |f| %> | 10 | <%= form_for :mailing, :url => {:action => 'send_mail'}, :html => {:id => 'mailing-form'} do |f| %> |
8 | 11 | ||
9 | <%= labelled_form_field(_('Subject:'), f.text_field(:subject)) %> | 12 | <%= labelled_form_field(_('Subject:'), f.text_field(:subject)) %> |
app/views/profile_editor/_moderation.html.erb
1 | <h2><%= _('Moderation options') %></h2> | 1 | <h2><%= _('Moderation options') %></h2> |
2 | <% if profile.community? %> | 2 | <% if profile.community? %> |
3 | <div style='margin-bottom: 1em'> | 3 | <div style='margin-bottom: 1em'> |
4 | + <h4><%= _('Email Configuration:')%></h4> | ||
5 | + </div> | ||
6 | + <div style='margin-bottom: 0.5em'> | ||
7 | + <%= check_box(:profile_data, :profile_admin_mail_notification, :style => 'float: left') %> | ||
8 | + <div style='margin-left: 30px'> | ||
9 | + <%= _('Send administrator Email for every task') %> | ||
10 | + </div> | ||
11 | + </div> | ||
12 | + | ||
13 | + <div style='margin-bottom: 1em'> | ||
4 | <h4><%= _('Invitation moderation:')%></h4> | 14 | <h4><%= _('Invitation moderation:')%></h4> |
5 | </div> | 15 | </div> |
6 | <div style='margin-bottom: 0.5em'> | 16 | <div style='margin-bottom: 0.5em'> |
app/views/profile_members/_index_buttons.html.erb
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | <%= button :person, _('Invite people to join'), :controller => 'invite', :action => 'invite_friends' %> | 5 | <%= button :person, _('Invite people to join'), :controller => 'invite', :action => 'invite_friends' %> |
6 | <% end %> | 6 | <% end %> |
7 | <% if profile.community? and user.has_permission?(:send_mail_to_members, profile) %> | 7 | <% if profile.community? and user.has_permission?(:send_mail_to_members, profile) %> |
8 | - <%= button :send, _('Send e-mail to members'), :controller => 'profile', :action => 'send_mail' %> | 8 | + <%= submit_button(:send, _('Send e-mail to members')) %> |
9 | <% end %> | 9 | <% end %> |
10 | <% @plugins.dispatch(:manage_members_extra_buttons).each do |plugin_button| %> | 10 | <% @plugins.dispatch(:manage_members_extra_buttons).each do |plugin_button| %> |
11 | <%= button plugin_button[:icon], plugin_button[:title], plugin_button[:url] %> | 11 | <%= button plugin_button[:icon], plugin_button[:title], plugin_button[:url] %> |
@@ -0,0 +1,18 @@ | @@ -0,0 +1,18 @@ | ||
1 | +<%= form_tag '#', :method => 'post' do %> | ||
2 | + | ||
3 | + <%= field_set_tag _('Filter'), :class => 'filter_fields' do %> | ||
4 | + <p> | ||
5 | + <%= labelled_text_field(_('Name or Email')+': ', "filters[name]", @filters[:name], {:id => 'filter-name-autocomplete',:size => 30}) %> | ||
6 | + </p> | ||
7 | + | ||
8 | + <p><%= _('Roles:') %> </p> | ||
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/> | ||
11 | + <% end %> | ||
12 | + <p> | ||
13 | + <%= submit_button(:search, _('Search')) %> | ||
14 | + </p> | ||
15 | + <% end %> | ||
16 | +<% end %> | ||
17 | + | ||
18 | +<%= javascript_include_tag params[:controller] %> | ||
0 | \ No newline at end of file | 19 | \ No newline at end of file |
app/views/profile_members/_members_list.html.erb
1 | -<% collection = @collection == :profile_admins ? profile.admins : profile.members_by_name %> | 1 | +<% members = @data ? @data[:members] : profile.members_by('name') %> |
2 | +<% collection = @collection == :profile_admins ? profile.admins : members %> | ||
2 | <% title = @title ? @title : _('Current members') %> | 3 | <% title = @title ? @title : _('Current members') %> |
3 | <% remove_action = @remove_action ? @remove_action : {:action => 'unassociate'} %> | 4 | <% remove_action = @remove_action ? @remove_action : {:action => 'unassociate'} %> |
5 | +<%= javascript_include_tag params[:controller] %> | ||
4 | 6 | ||
5 | <h3><%= title %></h3> | 7 | <h3><%= title %></h3> |
6 | 8 | ||
7 | <table> | 9 | <table> |
10 | + <col width="1"> | ||
8 | <tr> | 11 | <tr> |
12 | + <th><%= check_box_tag 'checkbox-all', 1, false, :onClick => "toggle(this)" %></th> | ||
9 | <th><%= _('Member') %></th> | 13 | <th><%= _('Member') %></th> |
10 | <th><%= _('Actions') %></th> | 14 | <th><%= _('Actions') %></th> |
11 | </tr> | 15 | </tr> |
16 | + | ||
12 | <% collection.each do |m| %> | 17 | <% collection.each do |m| %> |
13 | <tr title="<%= m.name %>"> | 18 | <tr title="<%= m.name %>"> |
19 | + <td><%= labelled_check_box('', 'members_filtered[]', m.id.to_s, false, :id => 'checkbox-'+m.identifier) %></td> | ||
14 | <td><%= link_to_profile m.short_name, m.identifier, :title => m.name %> </td> | 20 | <td><%= link_to_profile m.short_name, m.identifier, :title => m.name %> </td> |
15 | <td> | 21 | <td> |
16 | <div class="members-buttons-cell"> | 22 | <div class="members-buttons-cell"> |
@@ -26,3 +32,8 @@ | @@ -26,3 +32,8 @@ | ||
26 | </tr> | 32 | </tr> |
27 | <% end %> | 33 | <% end %> |
28 | </table> | 34 | </table> |
35 | +<% if collection.empty? %> | ||
36 | + <p> | ||
37 | + <em><%= _('No members found to: %s') % profile.name %></em> | ||
38 | + </p> | ||
39 | +<% end %> |
app/views/profile_members/index.html.erb
1 | <h1><%= h profile.short_name(50) %></h1> | 1 | <h1><%= h profile.short_name(50) %></h1> |
2 | 2 | ||
3 | -<%= render :partial => 'index_buttons' %> | 3 | +<%= render :partial => 'members_filter' %> |
4 | 4 | ||
5 | -<div id="members-list"> | ||
6 | - <%= render :partial => 'members_list' %> | ||
7 | -</div> | 5 | +<%= form_tag 'profile_members/send_mail', :method => 'post' do %> |
6 | + <div id="members-list"> | ||
7 | + <%= render :partial => 'members_list' %> | ||
8 | + </div> | ||
8 | 9 | ||
9 | -<%= render :partial => 'index_buttons' %> | 10 | + <%= render :partial => 'index_buttons' %> |
11 | + | ||
12 | +<% end %> |
app/views/region_validators/region.html.erb
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | <ul> | 5 | <ul> |
6 | <% for validator in @region.validators %> | 6 | <% for validator in @region.validators %> |
7 | <li> | 7 | <li> |
8 | - <%= link_to_homepage validator.name, validator.identifier %> | 8 | + <%= link_to_homepage validator.name, validator %> |
9 | <%= link_to _('Remove validation rights'), { :action => 'remove', :id => @region.id, :validator_id => validator }, :method => 'post' %> | 9 | <%= link_to _('Remove validation rights'), { :action => 'remove', :id => @region.id, :validator_id => validator }, :method => 'post' %> |
10 | </li> | 10 | </li> |
11 | <% end %> | 11 | <% end %> |
app/views/search/_full_enterprise.html.erb
@@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
5 | @order == 'more_recent' ? enterprise.send(@order + '_label') + show_date(enterprise.created_at) : enterprise.send(@order + '_label') %> | 5 | @order == 'more_recent' ? enterprise.send(@order + '_label') + show_date(enterprise.created_at) : enterprise.send(@order + '_label') %> |
6 | </div> | 6 | </div> |
7 | <div class="search-enterprise-item-column-right"> | 7 | <div class="search-enterprise-item-column-right"> |
8 | - <%= link_to_homepage(enterprise.name, enterprise.identifier, :class => "search-result-title") %> | 8 | + <%= link_to_homepage enterprise.name, enterprise, class: "search-result-title" %> |
9 | <div class="search-enterprise-description"> | 9 | <div class="search-enterprise-description"> |
10 | <% if enterprise.description %> | 10 | <% if enterprise.description %> |
11 | <% body_stripped = strip_tags(enterprise.description) %> | 11 | <% body_stripped = strip_tags(enterprise.description) %> |
app/views/search/_full_product.html.erb
@@ -44,7 +44,7 @@ | @@ -44,7 +44,7 @@ | ||
44 | <div class="search-product-item-second-column"> | 44 | <div class="search-product-item-second-column"> |
45 | <%= link_to_product product, :class => 'search-result-title' %> | 45 | <%= link_to_product product, :class => 'search-result-title' %> |
46 | <div class="search-product-supplier"> | 46 | <div class="search-product-supplier"> |
47 | - <span class="search-field-label"><%= _('Supplier') %> </span><%= link_to_homepage(product.enterprise.name, product.enterprise.identifier) %> | 47 | + <span class="search-field-label"><%= _('Supplier') %> </span><%= link_to_homepage product.enterprise.name, product.enterprise %> |
48 | </div> | 48 | </div> |
49 | <div class="search-product-description"> | 49 | <div class="search-product-description"> |
50 | <% if product.description %> | 50 | <% if product.description %> |
app/views/search/_sellers_form.html.erb
@@ -1,24 +0,0 @@ | @@ -1,24 +0,0 @@ | ||
1 | -<h3><%= title %></h3> | ||
2 | - | ||
3 | -<%= form_tag({:controller => 'search', :action => 'assets'}, {:method => 'get'}) do %> | ||
4 | - | ||
5 | - <div class="search-in-opt"><%= _('Search in:') %> | ||
6 | - <dir> | ||
7 | - <%= labelled_radio_button _('Enterprises'), 'asset', 'enterprises', true %><br /> | ||
8 | - <%= labelled_radio_button _('Products'), 'asset', 'products', false %> | ||
9 | - </dir> | ||
10 | - </div> | ||
11 | - | ||
12 | - <div class="formfield search-from-opt"> | ||
13 | - <%= select_city(true) %> | ||
14 | - </div> | ||
15 | - | ||
16 | - <div class="formfield search-distance-opt"> | ||
17 | - <%= labelled_select(_('Distance:'), 'radius', :first, :last, nil, [15, 30, 50, 100, 150, 200, 300, 400, 500, 1000].map{|n|[n, n.to_s + 'km']}) %> | ||
18 | - </div> | ||
19 | - | ||
20 | - <div class="button-bar"> | ||
21 | - <%= submit_button :search, _('Search') %> | ||
22 | - </div> | ||
23 | - | ||
24 | -<% end %> |
app/views/shared/block.html.erb
1 | <% if block.cacheable? && use_cache %> | 1 | <% if block.cacheable? && use_cache %> |
2 | <% cache_timeout(block.cache_key(language, user), block.timeout) do %> | 2 | <% cache_timeout(block.cache_key(language, user), block.timeout) do %> |
3 | - <%= display_block_content(block, user, main_content) %> | 3 | + <%= display_block_content(block, main_content) %> |
4 | <% end %> | 4 | <% end %> |
5 | <% else %> | 5 | <% else %> |
6 | - <%= display_block_content(block, user, main_content) %> | 6 | + <%= display_block_content(block, main_content) %> |
7 | <% end %> | 7 | <% end %> |
db/schema.rb
@@ -11,7 +11,7 @@ | @@ -11,7 +11,7 @@ | ||
11 | # | 11 | # |
12 | # It's strongly recommended that you check this file into your version control system. | 12 | # It's strongly recommended that you check this file into your version control system. |
13 | 13 | ||
14 | -ActiveRecord::Schema.define(version: 20160202142247) do | 14 | +ActiveRecord::Schema.define(version: 20160309122141) do |
15 | 15 | ||
16 | # These are extensions that must be enabled in order to support this database | 16 | # These are extensions that must be enabled in order to support this database |
17 | enable_extension "plpgsql" | 17 | enable_extension "plpgsql" |
@@ -51,7 +51,7 @@ ActiveRecord::Schema.define(version: 20160202142247) do | @@ -51,7 +51,7 @@ ActiveRecord::Schema.define(version: 20160202142247) do | ||
51 | add_index "action_tracker_notifications", ["profile_id", "action_tracker_id"], name: "index_action_tracker_notif_on_prof_id_act_tracker_id", unique: true, using: :btree | 51 | add_index "action_tracker_notifications", ["profile_id", "action_tracker_id"], name: "index_action_tracker_notif_on_prof_id_act_tracker_id", unique: true, using: :btree |
52 | add_index "action_tracker_notifications", ["profile_id"], name: "index_action_tracker_notifications_on_profile_id", using: :btree | 52 | add_index "action_tracker_notifications", ["profile_id"], name: "index_action_tracker_notifications_on_profile_id", using: :btree |
53 | 53 | ||
54 | - create_table "article_followers", id: false, force: :cascade do |t| | 54 | + create_table "article_followers", force: :cascade do |t| |
55 | t.integer "person_id" | 55 | t.integer "person_id" |
56 | t.integer "article_id" | 56 | t.integer "article_id" |
57 | t.datetime "since" | 57 | t.datetime "since" |
@@ -471,6 +471,7 @@ ActiveRecord::Schema.define(version: 20160202142247) do | @@ -471,6 +471,7 @@ ActiveRecord::Schema.define(version: 20160202142247) do | ||
471 | t.string "locale" | 471 | t.string "locale" |
472 | t.datetime "created_at" | 472 | t.datetime "created_at" |
473 | t.datetime "updated_at" | 473 | t.datetime "updated_at" |
474 | + t.text "data" | ||
474 | end | 475 | end |
475 | 476 | ||
476 | create_table "national_region_types", force: :cascade do |t| | 477 | create_table "national_region_types", force: :cascade do |t| |
features/send_email_to_organization_members.feature
@@ -31,7 +31,8 @@ Feature: send emails to organization members | @@ -31,7 +31,8 @@ Feature: send emails to organization members | ||
31 | Scenario: Send e-mail to members | 31 | Scenario: Send e-mail to members |
32 | Given I am logged in as "joaosilva" | 32 | Given I am logged in as "joaosilva" |
33 | And I go to Sample Community's members management | 33 | And I go to Sample Community's members management |
34 | - And I follow "Send e-mail to members" | 34 | + And I check "checkbox-manoel" |
35 | + And I press "Send e-mail to members" | ||
35 | And I fill in "Subject" with "Hello, member!" | 36 | And I fill in "Subject" with "Hello, member!" |
36 | And I fill in "Body" with "We have some news" | 37 | And I fill in "Body" with "We have some news" |
37 | When I press "Send" | 38 | When I press "Send" |
@@ -40,7 +41,8 @@ Feature: send emails to organization members | @@ -40,7 +41,8 @@ Feature: send emails to organization members | ||
40 | Scenario: Not send e-mail to members if subject is blank | 41 | Scenario: Not send e-mail to members if subject is blank |
41 | Given I am logged in as "joaosilva" | 42 | Given I am logged in as "joaosilva" |
42 | And I go to Sample Community's members management | 43 | And I go to Sample Community's members management |
43 | - And I follow "Send e-mail to members" | 44 | + And I check "checkbox-manoel" |
45 | + And I press "Send e-mail to members" | ||
44 | And I fill in "Body" with "We have some news" | 46 | And I fill in "Body" with "We have some news" |
45 | When I press "Send" | 47 | When I press "Send" |
46 | Then I should be on /profile/sample-community/send_mail | 48 | Then I should be on /profile/sample-community/send_mail |
@@ -48,7 +50,8 @@ Feature: send emails to organization members | @@ -48,7 +50,8 @@ Feature: send emails to organization members | ||
48 | Scenario: Not send e-mail to members if body is blank | 50 | Scenario: Not send e-mail to members if body is blank |
49 | Given I am logged in as "joaosilva" | 51 | Given I am logged in as "joaosilva" |
50 | And I go to Sample Community's members management | 52 | And I go to Sample Community's members management |
51 | - And I follow "Send e-mail to members" | 53 | + And I check "checkbox-manoel" |
54 | + And I press "Send e-mail to members" | ||
52 | And I fill in "Subject" with "Hello, user!" | 55 | And I fill in "Subject" with "Hello, user!" |
53 | When I press "Send" | 56 | When I press "Send" |
54 | Then I should be on /profile/sample-community/send_mail | 57 | Then I should be on /profile/sample-community/send_mail |
@@ -56,7 +59,8 @@ Feature: send emails to organization members | @@ -56,7 +59,8 @@ Feature: send emails to organization members | ||
56 | Scenario: Cancel creation of mailing | 59 | Scenario: Cancel creation of mailing |
57 | Given I am logged in as "joaosilva" | 60 | Given I am logged in as "joaosilva" |
58 | And I go to Sample Community's members management | 61 | And I go to Sample Community's members management |
59 | - And I follow "Send e-mail to members" | 62 | + And I check "checkbox-manoel" |
63 | + And I press "Send e-mail to members" | ||
60 | When I follow "Cancel e-mail" | 64 | When I follow "Cancel e-mail" |
61 | Then I should be on Sample Community's members management | 65 | Then I should be on Sample Community's members management |
62 | 66 |
gitignore.example
@@ -23,6 +23,7 @@ public/user_themes | @@ -23,6 +23,7 @@ public/user_themes | ||
23 | public/designs/themes/default | 23 | public/designs/themes/default |
24 | public/designs/themes/* | 24 | public/designs/themes/* |
25 | public/designs/icons/default | 25 | public/designs/icons/default |
26 | +cache | ||
26 | 27 | ||
27 | public/assets | 28 | public/assets |
28 | .sass-cache | 29 | .sass-cache |
lib/tasks/ci.rake
@@ -57,7 +57,8 @@ namespace :ci do | @@ -57,7 +57,8 @@ namespace :ci do | ||
57 | 57 | ||
58 | sh 'ruby', '-Itest', *tests unless tests.empty? | 58 | sh 'ruby', '-Itest', *tests unless tests.empty? |
59 | sh 'cucumber', *features unless features.empty? | 59 | sh 'cucumber', *features unless features.empty? |
60 | - sh 'xvfb-run', '-a', 'cucumber', '-p', 'selenium', *features unless features.empty? | 60 | + sh 'xvfb-run', '-a', '--server-args="-screen 0, 1280x1024x24"', |
61 | + 'cucumber', '-p', 'selenium', *features unless features.empty? | ||
61 | 62 | ||
62 | changed_plugins.each do |plugin| | 63 | changed_plugins.each do |plugin| |
63 | if $broken_plugins.include?(plugin) | 64 | if $broken_plugins.include?(plugin) |
lib/tasks/selenium.rake
1 | desc 'Runs Seleniun acceptance tests' | 1 | desc 'Runs Seleniun acceptance tests' |
2 | task :selenium do | 2 | task :selenium do |
3 | puts "Firefox version = #{`firefox --version`}" | 3 | puts "Firefox version = #{`firefox --version`}" |
4 | - sh "xvfb-run -a cucumber -p selenium --format #{ENV['CUCUMBER_FORMAT'] || 'progress'}" | 4 | + sh "xvfb-run -a --server-args=\"-screen 0, 1280x1024x24\" cucumber -p selenium --format #{ENV['CUCUMBER_FORMAT'] || 'progress'}" |
5 | end | 5 | end |
plugins/custom_forms/db/migrate/20151008130948_create_text_field_type_in_custom_forms_plugin.rb
0 → 100644
@@ -0,0 +1,13 @@ | @@ -0,0 +1,13 @@ | ||
1 | +class CreateTextFieldTypeInCustomFormsPlugin < ActiveRecord::Migration | ||
2 | + def up | ||
3 | + rename_column :custom_forms_plugin_fields, :select_field_type, :show_as | ||
4 | + change_column :custom_forms_plugin_fields, :show_as, :string, :null => true, :default => nil | ||
5 | + update("UPDATE custom_forms_plugin_fields SET show_as='text' WHERE type = 'CustomFormsPlugin::TextField'") | ||
6 | + end | ||
7 | + | ||
8 | + def down | ||
9 | + rename_column :custom_forms_plugin_fields, :show_as, :select_field_type | ||
10 | + change_column :custom_forms_plugin_fields, :select_field_type, :string, :null => false, :default => 'radio' | ||
11 | + update("UPDATE custom_forms_plugin_fields SET select_field_type='radio' WHERE type = 'CustomFormsPlugin::TextField'") | ||
12 | + end | ||
13 | +end |
plugins/custom_forms/lib/custom_forms_plugin/field.rb
@@ -2,8 +2,9 @@ class CustomFormsPlugin::Field < ActiveRecord::Base | @@ -2,8 +2,9 @@ class CustomFormsPlugin::Field < ActiveRecord::Base | ||
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 |
5 | + validates_length_of :default_value, :maximum => 255 | ||
5 | 6 | ||
6 | - attr_accessible :name, :form, :mandatory, :type, :position, :default_value, :select_field_type, :alternatives_attributes | 7 | + attr_accessible :name, :form, :mandatory, :type, :position, :default_value, :show_as, :alternatives_attributes |
7 | 8 | ||
8 | belongs_to :form, :class_name => 'CustomFormsPlugin::Form' | 9 | belongs_to :form, :class_name => 'CustomFormsPlugin::Form' |
9 | has_many :answers, :class_name => 'CustomFormsPlugin::Answer', :dependent => :destroy | 10 | has_many :answers, :class_name => 'CustomFormsPlugin::Answer', :dependent => :destroy |
plugins/custom_forms/lib/custom_forms_plugin/helper.rb
@@ -85,7 +85,11 @@ module CustomFormsPlugin::Helper | @@ -85,7 +85,11 @@ module CustomFormsPlugin::Helper | ||
85 | 85 | ||
86 | def display_text_field(field, answer, form) | 86 | def display_text_field(field, answer, form) |
87 | value = answer.present? ? answer.value : field.default_value | 87 | value = answer.present? ? answer.value : field.default_value |
88 | - text_field(form, "#{field.id}", :value => value, :disabled => display_disabled?(field, answer)) | 88 | + if field.show_as == 'textarea' |
89 | + text_area(form, "#{field.id}", :value => value, :disabled => display_disabled?(field, answer)) | ||
90 | + else | ||
91 | + text_field(form, "#{field.id}", :value => value, :disabled => display_disabled?(field, answer)) | ||
92 | + end | ||
89 | end | 93 | end |
90 | 94 | ||
91 | def default_selected(field, answer) | 95 | def default_selected(field, answer) |
@@ -93,7 +97,7 @@ module CustomFormsPlugin::Helper | @@ -93,7 +97,7 @@ module CustomFormsPlugin::Helper | ||
93 | end | 97 | end |
94 | 98 | ||
95 | def display_select_field(field, answer, form) | 99 | def display_select_field(field, answer, form) |
96 | - case field.select_field_type | 100 | + case field.show_as |
97 | when 'select' | 101 | when 'select' |
98 | selected = default_selected(field, answer) | 102 | selected = default_selected(field, answer) |
99 | select_tag form.to_s + "[#{field.id}]", options_for_select([['','']] + field.alternatives.map {|a| [a.label, a.id.to_s]}, selected), :disabled => display_disabled?(field, answer) | 103 | select_tag form.to_s + "[#{field.id}]", options_for_select([['','']] + field.alternatives.map {|a| [a.label, a.id.to_s]}, selected), :disabled => display_disabled?(field, answer) |
@@ -114,11 +118,11 @@ module CustomFormsPlugin::Helper | @@ -114,11 +118,11 @@ module CustomFormsPlugin::Helper | ||
114 | end | 118 | end |
115 | 119 | ||
116 | def radio_button?(field) | 120 | def radio_button?(field) |
117 | - type_for_options(field.class) == 'select_field' && field.select_field_type == 'radio' | 121 | + type_for_options(field.class) == 'select_field' && field.show_as == 'radio' |
118 | end | 122 | end |
119 | 123 | ||
120 | def check_box?(field) | 124 | def check_box?(field) |
121 | - type_for_options(field.class) == 'select_field' && field.select_field_type == 'check_box' | 125 | + type_for_options(field.class) == 'select_field' && field.show_as == 'check_box' |
122 | end | 126 | end |
123 | 127 | ||
124 | end | 128 | end |
plugins/custom_forms/lib/custom_forms_plugin/select_field.rb
1 | class CustomFormsPlugin::SelectField < CustomFormsPlugin::Field | 1 | class CustomFormsPlugin::SelectField < CustomFormsPlugin::Field |
2 | self.table_name = :custom_forms_plugin_fields | 2 | self.table_name = :custom_forms_plugin_fields |
3 | - validates_inclusion_of :select_field_type, :in => %w(radio check_box select multiple_select) | 3 | + validates_inclusion_of :show_as, :in => %w(radio check_box select multiple_select) |
4 | validates_length_of :alternatives, :minimum => 1, :message => 'can\'t be empty' | 4 | validates_length_of :alternatives, :minimum => 1, :message => 'can\'t be empty' |
5 | + | ||
6 | + after_initialize do | ||
7 | + self.show_as ||= 'radio' | ||
8 | + end | ||
5 | end | 9 | end |
plugins/custom_forms/lib/custom_forms_plugin/text_field.rb
@@ -2,4 +2,9 @@ class CustomFormsPlugin::TextField < CustomFormsPlugin::Field | @@ -2,4 +2,9 @@ class CustomFormsPlugin::TextField < CustomFormsPlugin::Field | ||
2 | 2 | ||
3 | self.table_name = :custom_forms_plugin_fields | 3 | self.table_name = :custom_forms_plugin_fields |
4 | 4 | ||
5 | + validates_inclusion_of :show_as, :in => %w(text textarea) | ||
6 | + | ||
7 | + after_initialize do | ||
8 | + self.show_as ||= 'text' | ||
9 | + end | ||
5 | end | 10 | end |
plugins/custom_forms/po/pt/custom_forms.po
@@ -13,16 +13,16 @@ msgid "" | @@ -13,16 +13,16 @@ msgid "" | ||
13 | msgstr "" | 13 | msgstr "" |
14 | "Project-Id-Version: 1.3~rc2-1-ga15645d\n" | 14 | "Project-Id-Version: 1.3~rc2-1-ga15645d\n" |
15 | "POT-Creation-Date: 2015-10-30 16:35-0300\n" | 15 | "POT-Creation-Date: 2015-10-30 16:35-0300\n" |
16 | -"PO-Revision-Date: 2015-08-07 16:48+0200\n" | ||
17 | -"Last-Translator: Antonio Terceiro <terceiro@softwarelivre.org>\n" | ||
18 | -"Language-Team: Portuguese <https://hosted.weblate.org/projects/noosfero/" | ||
19 | -"plugin-custom-forms/pt/>\n" | 16 | +"PO-Revision-Date: 2016-03-14 15:58+0000\n" |
17 | +"Last-Translator: Eduardo Vital <vitaldu@gmail.com>\n" | ||
18 | +"Language-Team: Portuguese <https://hosted.weblate.org/projects/noosfero" | ||
19 | +"/plugin-custom-forms/pt/>\n" | ||
20 | "Language: pt\n" | 20 | "Language: pt\n" |
21 | "MIME-Version: 1.0\n" | 21 | "MIME-Version: 1.0\n" |
22 | "Content-Type: text/plain; charset=UTF-8\n" | 22 | "Content-Type: text/plain; charset=UTF-8\n" |
23 | "Content-Transfer-Encoding: 8bit\n" | 23 | "Content-Transfer-Encoding: 8bit\n" |
24 | "Plural-Forms: nplurals=2; plural=n != 1;\n" | 24 | "Plural-Forms: nplurals=2; plural=n != 1;\n" |
25 | -"X-Generator: Weblate 2.4-dev\n" | 25 | +"X-Generator: Weblate 2.5\n" |
26 | 26 | ||
27 | #: plugins/custom_forms/lib/custom_forms_plugin/form.rb:67 | 27 | #: plugins/custom_forms/lib/custom_forms_plugin/form.rb:67 |
28 | msgid "Invalid string format of access." | 28 | msgid "Invalid string format of access." |
@@ -184,7 +184,7 @@ msgstr "E-mail" | @@ -184,7 +184,7 @@ msgstr "E-mail" | ||
184 | 184 | ||
185 | #: plugins/custom_forms/views/custom_forms_plugin_profile/show.html.erb:31 | 185 | #: plugins/custom_forms/views/custom_forms_plugin_profile/show.html.erb:31 |
186 | msgid "Your e-mail will be visible to this form's owners." | 186 | msgid "Your e-mail will be visible to this form's owners." |
187 | -msgstr "" | 187 | +msgstr "Seu e-mail ficará visível para o dono deste formulário." |
188 | 188 | ||
189 | #: plugins/custom_forms/views/custom_forms_plugin_myprofile/new.html.erb:1 | 189 | #: plugins/custom_forms/views/custom_forms_plugin_myprofile/new.html.erb:1 |
190 | msgid "New form" | 190 | msgid "New form" |
@@ -220,11 +220,11 @@ msgstr "Radio" | @@ -220,11 +220,11 @@ msgstr "Radio" | ||
220 | 220 | ||
221 | #: plugins/custom_forms/views/custom_forms_plugin_myprofile/custom_forms_plugin/_select_field.html.erb:7 | 221 | #: plugins/custom_forms/views/custom_forms_plugin_myprofile/custom_forms_plugin/_select_field.html.erb:7 |
222 | msgid "Checkbox" | 222 | msgid "Checkbox" |
223 | -msgstr "Checkbox" | 223 | +msgstr "Caixa de seleção" |
224 | 224 | ||
225 | #: plugins/custom_forms/views/custom_forms_plugin_myprofile/custom_forms_plugin/_select_field.html.erb:9 | 225 | #: plugins/custom_forms/views/custom_forms_plugin_myprofile/custom_forms_plugin/_select_field.html.erb:9 |
226 | msgid "Drop down" | 226 | msgid "Drop down" |
227 | -msgstr "Drop down" | 227 | +msgstr "Lista suspensa" |
228 | 228 | ||
229 | #: plugins/custom_forms/views/custom_forms_plugin_myprofile/custom_forms_plugin/_select_field.html.erb:11 | 229 | #: plugins/custom_forms/views/custom_forms_plugin_myprofile/custom_forms_plugin/_select_field.html.erb:11 |
230 | msgid "Multiple Select" | 230 | msgid "Multiple Select" |
@@ -262,7 +262,7 @@ msgstr "Disparado depois da aprovação de um novo integrante" | @@ -262,7 +262,7 @@ msgstr "Disparado depois da aprovação de um novo integrante" | ||
262 | #: plugins/custom_forms/views/custom_forms_plugin_myprofile/_form.html.erb:29 | 262 | #: plugins/custom_forms/views/custom_forms_plugin_myprofile/_form.html.erb:29 |
263 | #: plugins/custom_forms/views/custom_forms_plugin_myprofile/_form.html.erb:38 | 263 | #: plugins/custom_forms/views/custom_forms_plugin_myprofile/_form.html.erb:38 |
264 | msgid "This field will be added automatically to your form" | 264 | msgid "This field will be added automatically to your form" |
265 | -msgstr "" | 265 | +msgstr "Esse campo será adicionado automaticamente no seu formulário" |
266 | 266 | ||
267 | #: plugins/custom_forms/views/custom_forms_plugin_myprofile/_form.html.erb:55 | 267 | #: plugins/custom_forms/views/custom_forms_plugin_myprofile/_form.html.erb:55 |
268 | msgid "Add a new text field" | 268 | msgid "Add a new text field" |
@@ -315,18 +315,16 @@ msgid "Back to forms" | @@ -315,18 +315,16 @@ msgid "Back to forms" | ||
315 | msgstr "Voltar para os formulários" | 315 | msgstr "Voltar para os formulários" |
316 | 316 | ||
317 | #: plugins/custom_forms/views/custom_forms_plugin_myprofile/show_submission.html.erb:10 | 317 | #: plugins/custom_forms/views/custom_forms_plugin_myprofile/show_submission.html.erb:10 |
318 | -#, fuzzy | ||
319 | msgid "Submission date" | 318 | msgid "Submission date" |
320 | -msgstr "Submissão salva" | 319 | +msgstr "Data da submissão" |
321 | 320 | ||
322 | #: plugins/custom_forms/views/custom_forms_plugin_myprofile/show_submission.html.erb:14 | 321 | #: plugins/custom_forms/views/custom_forms_plugin_myprofile/show_submission.html.erb:14 |
323 | -#, fuzzy | ||
324 | msgid "Author" | 322 | msgid "Author" |
325 | -msgstr "Nome do autor" | 323 | +msgstr "Autor" |
326 | 324 | ||
327 | #: plugins/custom_forms/views/custom_forms_plugin_myprofile/show_submission.html.erb:26 | 325 | #: plugins/custom_forms/views/custom_forms_plugin_myprofile/show_submission.html.erb:26 |
328 | msgid "Unauthenticated" | 326 | msgid "Unauthenticated" |
329 | -msgstr "" | 327 | +msgstr "Não autenticado" |
330 | 328 | ||
331 | #: plugins/custom_forms/views/custom_forms_plugin_myprofile/show_submission.html.erb:48 | 329 | #: plugins/custom_forms/views/custom_forms_plugin_myprofile/show_submission.html.erb:48 |
332 | msgid "Back to submissions" | 330 | msgid "Back to submissions" |
plugins/custom_forms/public/style.css
@@ -95,6 +95,11 @@ tr.addition-buttons { | @@ -95,6 +95,11 @@ tr.addition-buttons { | ||
95 | color: rgba(0,0,0,0.5); | 95 | color: rgba(0,0,0,0.5); |
96 | } | 96 | } |
97 | 97 | ||
98 | +#custom-forms-plugin_submission textarea { | ||
99 | + width: 100%; | ||
100 | + height: 10em; | ||
101 | +} | ||
102 | + | ||
98 | #custom-forms-plugin_submission-view th { | 103 | #custom-forms-plugin_submission-view th { |
99 | border: none; | 104 | border: none; |
100 | text-align: right; | 105 | text-align: right; |
plugins/custom_forms/test/functional/custom_forms_plugin_myprofile_controller_test.rb
@@ -54,7 +54,7 @@ class CustomFormsPluginMyprofileControllerTest < ActionController::TestCase | @@ -54,7 +54,7 @@ class CustomFormsPluginMyprofileControllerTest < ActionController::TestCase | ||
54 | }, | 54 | }, |
55 | 2 => { | 55 | 2 => { |
56 | :name => 'Color', | 56 | :name => 'Color', |
57 | - :select_field_type => 'radio', | 57 | + :show_as => 'radio', |
58 | :type => 'CustomFormsPlugin::SelectField', | 58 | :type => 'CustomFormsPlugin::SelectField', |
59 | :alternatives_attributes => { | 59 | :alternatives_attributes => { |
60 | 1 => {:label => 'Red'}, | 60 | 1 => {:label => 'Red'}, |
@@ -82,7 +82,7 @@ class CustomFormsPluginMyprofileControllerTest < ActionController::TestCase | @@ -82,7 +82,7 @@ class CustomFormsPluginMyprofileControllerTest < ActionController::TestCase | ||
82 | 82 | ||
83 | assert_equal 'Color', f2.name | 83 | assert_equal 'Color', f2.name |
84 | assert_equal f2.alternatives.map(&:label).sort, ['Red', 'Blue', 'Black'].sort | 84 | assert_equal f2.alternatives.map(&:label).sort, ['Red', 'Blue', 'Black'].sort |
85 | - assert_equal f2.select_field_type, 'radio' | 85 | + assert_equal f2.show_as, 'radio' |
86 | assert f2.kind_of?(CustomFormsPlugin::SelectField) | 86 | assert f2.kind_of?(CustomFormsPlugin::SelectField) |
87 | end | 87 | end |
88 | 88 |
plugins/custom_forms/test/unit/custom_forms_plugin/select_field_test.rb
@@ -13,16 +13,16 @@ class CustomFormsPlugin::SelectFieldTest < ActiveSupport::TestCase | @@ -13,16 +13,16 @@ class CustomFormsPlugin::SelectFieldTest < ActiveSupport::TestCase | ||
13 | select = CustomFormsPlugin::SelectField.new(:name => 'select_field001' ) | 13 | select = CustomFormsPlugin::SelectField.new(:name => 'select_field001' ) |
14 | select.alternatives << CustomFormsPlugin::Alternative.new(:label => 'option') | 14 | select.alternatives << CustomFormsPlugin::Alternative.new(:label => 'option') |
15 | 15 | ||
16 | - select.update_attribute(:select_field_type, 'random') | 16 | + select.update_attribute(:show_as, 'random') |
17 | assert select.invalid? | 17 | assert select.invalid? |
18 | 18 | ||
19 | - select.update_attribute(:select_field_type, 'radio') | 19 | + select.update_attribute(:show_as, 'radio') |
20 | assert select.valid? | 20 | assert select.valid? |
21 | - select.update_attribute(:select_field_type, 'check_box') | 21 | + select.update_attribute(:show_as, 'check_box') |
22 | assert select.valid? | 22 | assert select.valid? |
23 | - select.update_attribute(:select_field_type, 'select') | 23 | + select.update_attribute(:show_as, 'select') |
24 | assert select.valid? | 24 | assert select.valid? |
25 | - select.update_attribute(:select_field_type, 'multiple_select') | 25 | + select.update_attribute(:show_as, 'multiple_select') |
26 | assert select.valid? | 26 | assert select.valid? |
27 | end | 27 | end |
28 | end | 28 | end |
plugins/custom_forms/test/unit/custom_forms_plugin/text_field_test.rb
0 → 100644
@@ -0,0 +1,22 @@ | @@ -0,0 +1,22 @@ | ||
1 | +require File.dirname(__FILE__) + '/../../../../../test/test_helper' | ||
2 | + | ||
3 | +class CustomFormsPlugin::TextFieldTest < ActiveSupport::TestCase | ||
4 | + should 'validate type' do | ||
5 | + text = CustomFormsPlugin::TextField.new(:name => 'text-field-010' ) | ||
6 | + | ||
7 | + text.update_attribute(:show_as, 'random') | ||
8 | + assert text.invalid? | ||
9 | + text.update_attribute(:show_as, 'radio') | ||
10 | + assert text.invalid? | ||
11 | + | ||
12 | + text.update_attribute(:show_as, 'text') | ||
13 | + assert text.valid? | ||
14 | + text.update_attribute(:show_as, 'textarea') | ||
15 | + assert text.valid? | ||
16 | + end | ||
17 | + | ||
18 | + should 'field type defaults to text when initialized' do | ||
19 | + text = CustomFormsPlugin::TextField.new(:name => 'text_field001' ) | ||
20 | + assert_equal 'text', text.show_as | ||
21 | + end | ||
22 | +end |
plugins/custom_forms/views/custom_forms_plugin_myprofile/_edit_select.html.erb
@@ -1,32 +0,0 @@ | @@ -1,32 +0,0 @@ | ||
1 | -<div class='edit-information edit-select'> | ||
2 | - <h2><%= c_('Options') %></h2> | ||
3 | - <table class='action-table' style='width: 420px'> | ||
4 | - <tr> | ||
5 | - <th style='width: 40%'><%= _('Name') %></th> | ||
6 | - <th style='width: 40%'><%= _('Value') %></th> | ||
7 | - <th style='width: 20%'><%= c_('Delete') %></th> | ||
8 | - </tr> | ||
9 | - <% option_counter = 1 %> | ||
10 | - <% (field.choices || {}).each do |name, value| %> | ||
11 | - <%= render :partial => 'option', :locals => {:name => name, :value => value, :counter => counter, :option_counter => option_counter} %> | ||
12 | - <% option_counter += 1 %> | ||
13 | - <% end %> | ||
14 | - <%= render :partial => 'empty_option', :locals => {:counter => counter, :option_counter => option_counter} %> | ||
15 | - <tr class='new-item'> | ||
16 | - <td colspan='3'> | ||
17 | - <%= button(:add, _('Add a new option'), '#', :class => 'new-option', :field_id => counter)%> | ||
18 | - </td> | ||
19 | - </tr> | ||
20 | - </table> | ||
21 | - | ||
22 | - <h3><%= c_('Type') %></h3> | ||
23 | - <%= labelled_radio_button 'Radio', "fields[#{counter}][kind]", 'radio', !field.multiple && !field.list %><br /> | ||
24 | - <%= labelled_radio_button 'Checkbox', "fields[#{counter}][kind]", 'check_box', field.multiple && !field.list %><br /> | ||
25 | - <%= labelled_radio_button 'Select', "fields[#{counter}][kind]", 'select', !field.multiple && field.list %><br /> | ||
26 | - <%= labelled_radio_button 'Multiple Select', "fields[#{counter}][kind]", 'multiple_select', field.multiple && field.list %><br /> | ||
27 | - | ||
28 | - <% button_bar do %> | ||
29 | - <%= button :ok, _('Ok'), '#', :div_id => elem_id %> | ||
30 | - <% end %> | ||
31 | -</div> | ||
32 | - |
plugins/custom_forms/views/custom_forms_plugin_myprofile/_empty_field.html.erb
@@ -1,10 +0,0 @@ | @@ -1,10 +0,0 @@ | ||
1 | -<tr id="empty-field" style='display: none' last_id=<%= counter %>> | ||
2 | - <td style="text-align: left"><%= text_field "fields[#{counter}]", :name, :size => 25 %></td> | ||
3 | - <td><%= select "fields[#{counter}]", :type, type_options, :selected => type_for_options(field.class) %></td> | ||
4 | - <td><%= check_box "fields[#{counter}]", :mandatory %></td> | ||
5 | - <%= hidden_field "fields[#{counter}]", :form_id, :value => @form.id %> | ||
6 | - <td class='actions'> | ||
7 | - <%= button_without_text :edit, c_('Edit'), '', :field_id => counter %> | ||
8 | - <%= button_without_text :remove, c_('Remove'), '#', class: 'remove-field', field_id: counter, data: {confirm: _('Are you sure you want to remove this field?')} %> | ||
9 | - </td> | ||
10 | -</tr> |
plugins/custom_forms/views/custom_forms_plugin_myprofile/_empty_option.html.erb
@@ -1,8 +0,0 @@ | @@ -1,8 +0,0 @@ | ||
1 | -<tr id=<%= "empty-option-#{counter}" %> option_id=<%= option_counter %> style="display: none;"> | ||
2 | - <td><%= text_field_tag("fields[#{counter}][choices][#{option_counter}][name]") %></td> | ||
3 | - <td><%= text_field_tag("fields[#{counter}][choices][#{option_counter}][value]") %></td> | ||
4 | - <td class='actions'> | ||
5 | - <%= button_without_text :remove, c_('Remove'), '#', class: 'remove-option', field_id: counter, option_id: option_counter, data: {confirm: _('Are you sure you want to remove this option?')} %> | ||
6 | - </td> | ||
7 | -</tr> | ||
8 | - |
plugins/custom_forms/views/custom_forms_plugin_myprofile/custom_forms_plugin/_select_field.html.erb
1 | <%= render :layout => 'field', :locals => { :f => f } do %> | 1 | <%= render :layout => 'field', :locals => { :f => f } do %> |
2 | <div class="field-select-type"> | 2 | <div class="field-select-type"> |
3 | <%= _('Type:') %> | 3 | <%= _('Type:') %> |
4 | - <%= f.radio_button(:select_field_type, 'radio') %> | ||
5 | - <%= f.label(:select_field_type, _('Radio'), :value => 'radio') %> | ||
6 | - <%= f.radio_button(:select_field_type, 'check_box') %> | ||
7 | - <%= f.label(:select_field_type, _('Checkbox'), :value => 'check_box') %> | ||
8 | - <%= f.radio_button(:select_field_type, 'select') %> | ||
9 | - <%= f.label(:select_field_type, _('Drop down'), :value => 'select') %> | ||
10 | - <%= f.radio_button(:select_field_type, 'multiple_select') %> | ||
11 | - <%= f.label(:select_field_type, _('Multiple Select'), :value => 'multiple_select') %> | 4 | + <%= f.radio_button(:show_as, 'radio') %> |
5 | + <%= f.label(:show_as, _('Radio'), :value => 'radio') %> | ||
6 | + <%= f.radio_button(:show_as, 'check_box') %> | ||
7 | + <%= f.label(:show_as, _('Checkbox'), :value => 'check_box') %> | ||
8 | + <%= f.radio_button(:show_as, 'select') %> | ||
9 | + <%= f.label(:show_as, _('Drop down'), :value => 'select') %> | ||
10 | + <%= f.radio_button(:show_as, 'multiple_select') %> | ||
11 | + <%= f.label(:show_as, _('Multiple Select'), :value => 'multiple_select') %> | ||
12 | </div> | 12 | </div> |
13 | 13 | ||
14 | <table> | 14 | <table> |
plugins/custom_forms/views/custom_forms_plugin_myprofile/custom_forms_plugin/_text_field.html.erb
1 | <%= render :layout => 'field', :locals => { :f => f } do %> | 1 | <%= render :layout => 'field', :locals => { :f => f } do %> |
2 | + <div class="field-select-type"> | ||
3 | + <%= _('Type:') %> | ||
4 | + <%= f.radio_button(:show_as, 'text') %> | ||
5 | + <%= f.label(:show_as, _('One-line text'), :value => 'text') %> | ||
6 | + <%= f.radio_button(:show_as, 'textarea') %> | ||
7 | + <%= f.label(:show_as, _('Multiline text'), :value => 'textarea') %> | ||
8 | + </div> | ||
9 | + | ||
2 | <div class="field-text-default"> | 10 | <div class="field-text-default"> |
3 | <%= f.label(:default_value, _('Default text:')) %> | 11 | <%= f.label(:default_value, _('Default text:')) %> |
4 | <%= f.text_field(:default_value) %> | 12 | <%= f.text_field(:default_value) %> |
13 | + <small><%= _('Maximum of 255 characters') %></small> | ||
5 | </div> | 14 | </div> |
6 | <% end %> | 15 | <% end %> |
plugins/ldap/po/pt/ldap.po
@@ -13,16 +13,16 @@ msgid "" | @@ -13,16 +13,16 @@ msgid "" | ||
13 | msgstr "" | 13 | msgstr "" |
14 | "Project-Id-Version: 1.3~rc2-1-ga15645d\n" | 14 | "Project-Id-Version: 1.3~rc2-1-ga15645d\n" |
15 | "POT-Creation-Date: 2015-10-30 16:35-0300\n" | 15 | "POT-Creation-Date: 2015-10-30 16:35-0300\n" |
16 | -"PO-Revision-Date: 2014-12-18 18:40-0200\n" | ||
17 | -"Last-Translator: Luciano Prestes Cavalcanti <lucianopcbr@gmail.com>\n" | ||
18 | -"Language-Team: Portuguese <https://hosted.weblate.org/projects/noosfero/" | ||
19 | -"noosfero/pt/>\n" | 16 | +"PO-Revision-Date: 2016-03-14 16:09+0000\n" |
17 | +"Last-Translator: Eduardo Vital <vitaldu@gmail.com>\n" | ||
18 | +"Language-Team: Portuguese <https://hosted.weblate.org/projects/noosfero" | ||
19 | +"/plugin-ldap/pt/>\n" | ||
20 | "Language: pt\n" | 20 | "Language: pt\n" |
21 | "MIME-Version: 1.0\n" | 21 | "MIME-Version: 1.0\n" |
22 | "Content-Type: text/plain; charset=UTF-8\n" | 22 | "Content-Type: text/plain; charset=UTF-8\n" |
23 | "Content-Transfer-Encoding: 8bit\n" | 23 | "Content-Transfer-Encoding: 8bit\n" |
24 | "Plural-Forms: nplurals=2; plural=n != 1;\n" | 24 | "Plural-Forms: nplurals=2; plural=n != 1;\n" |
25 | -"X-Generator: Weblate 2.0\n" | 25 | +"X-Generator: Weblate 2.5\n" |
26 | 26 | ||
27 | #: plugins/ldap/lib/ldap_plugin.rb:11 | 27 | #: plugins/ldap/lib/ldap_plugin.rb:11 |
28 | msgid "A plugin that add ldap support." | 28 | msgid "A plugin that add ldap support." |
@@ -42,7 +42,7 @@ msgstr "Gerenciamento do Ldap" | @@ -42,7 +42,7 @@ msgstr "Gerenciamento do Ldap" | ||
42 | 42 | ||
43 | #: plugins/ldap/views/ldap_plugin_admin/index.html.erb:7 | 43 | #: plugins/ldap/views/ldap_plugin_admin/index.html.erb:7 |
44 | msgid "LDAP Configuration" | 44 | msgid "LDAP Configuration" |
45 | -msgstr "" | 45 | +msgstr "Configuração do LDAP" |
46 | 46 | ||
47 | #: plugins/ldap/views/ldap_plugin_admin/index.html.erb:8 | 47 | #: plugins/ldap/views/ldap_plugin_admin/index.html.erb:8 |
48 | msgid "Value" | 48 | msgid "Value" |
@@ -85,9 +85,8 @@ msgid "Attributes" | @@ -85,9 +85,8 @@ msgid "Attributes" | ||
85 | msgstr "Atributos" | 85 | msgstr "Atributos" |
86 | 86 | ||
87 | #: plugins/ldap/views/ldap_plugin_admin/index.html.erb:47 | 87 | #: plugins/ldap/views/ldap_plugin_admin/index.html.erb:47 |
88 | -#, fuzzy | ||
89 | msgid "LDAP Field" | 88 | msgid "LDAP Field" |
90 | -msgstr "Filtro LDAP" | 89 | +msgstr "Campo do LDAP" |
91 | 90 | ||
92 | #: plugins/ldap/views/ldap_plugin_admin/index.html.erb:54 | 91 | #: plugins/ldap/views/ldap_plugin_admin/index.html.erb:54 |
93 | msgid "Fullname" | 92 | msgid "Fullname" |
@@ -98,12 +97,13 @@ msgid "Mail" | @@ -98,12 +97,13 @@ msgid "Mail" | ||
98 | msgstr "Mail" | 97 | msgstr "Mail" |
99 | 98 | ||
100 | #: plugins/ldap/views/ldap_plugin_admin/index.html.erb:65 | 99 | #: plugins/ldap/views/ldap_plugin_admin/index.html.erb:65 |
100 | +#, fuzzy | ||
101 | msgid "Behaviour Configuration" | 101 | msgid "Behaviour Configuration" |
102 | -msgstr "" | 102 | +msgstr "Configuração de comportamento" |
103 | 103 | ||
104 | #: plugins/ldap/views/ldap_plugin_admin/index.html.erb:70 | 104 | #: plugins/ldap/views/ldap_plugin_admin/index.html.erb:70 |
105 | msgid "Allow password recovery" | 105 | msgid "Allow password recovery" |
106 | -msgstr "" | 106 | +msgstr "Permitir recuperação de senha" |
107 | 107 | ||
108 | #: plugins/ldap/views/ldap_plugin_admin/index.html.erb:78 | 108 | #: plugins/ldap/views/ldap_plugin_admin/index.html.erb:78 |
109 | msgid "Back to plugins administration panel" | 109 | msgid "Back to plugins administration panel" |
plugins/newsletter/controllers/newsletter_plugin_admin_controller.rb
@@ -30,14 +30,14 @@ class NewsletterPluginAdminController < PluginAdminController | @@ -30,14 +30,14 @@ class NewsletterPluginAdminController < PluginAdminController | ||
30 | end | 30 | end |
31 | 31 | ||
32 | #TODO: Make this query faster | 32 | #TODO: Make this query faster |
33 | - def search_communities | ||
34 | - communities = environment.communities | 33 | + def search_profiles |
34 | + profiles = environment.profiles | ||
35 | blogs = Blog.joins(:profile).where(profiles: {environment_id: environment.id}) | 35 | blogs = Blog.joins(:profile).where(profiles: {environment_id: environment.id}) |
36 | 36 | ||
37 | - found_communities = find_by_contents(:communities, environment, communities, params['q'], {:page => 1})[:results] | 37 | + found_profiles = find_by_contents(:profiles, environment, profiles, params['q'], {:page => 1})[:results] |
38 | found_blogs = find_by_contents(:blogs, environment, blogs, params['q'], {:page => 1})[:results] | 38 | found_blogs = find_by_contents(:blogs, environment, blogs, params['q'], {:page => 1})[:results] |
39 | 39 | ||
40 | - results = (found_blogs + found_communities.map(&:blogs).flatten).uniq | 40 | + results = (found_blogs + found_profiles.map(&:blogs).flatten).uniq |
41 | render :text => results.map { |blog| {:id => blog.id, :name => _("%s in %s") % [blog.name, blog.profile.name]} }.to_json | 41 | render :text => results.map { |blog| {:id => blog.id, :name => _("%s in %s") % [blog.name, blog.profile.name]} }.to_json |
42 | end | 42 | end |
43 | 43 |
plugins/newsletter/features/newsletter_plugin.feature
1 | Feature: newsletter plugin | 1 | Feature: newsletter plugin |
2 | 2 | ||
3 | Background: | 3 | Background: |
4 | - Given the following users | ||
5 | - | login | name | | ||
6 | - | joaosilva | Joao Silva | | ||
7 | - And I am logged in as "joaosilva" | 4 | + Given I am logged in as admin |
8 | 5 | ||
9 | Scenario: as admin I can configure plugin | 6 | Scenario: as admin I can configure plugin |
10 | - Given I am logged in as admin | ||
11 | When I go to the environment control panel | 7 | When I go to the environment control panel |
12 | And I follow "Plugins" | 8 | And I follow "Plugins" |
13 | Then I should see "Configuration" linking to "/admin/plugin/newsletter" | 9 | Then I should see "Configuration" linking to "/admin/plugin/newsletter" |
14 | 10 | ||
15 | Scenario: in the newsletter settings I can see the field to enable/disable | 11 | Scenario: in the newsletter settings I can see the field to enable/disable |
16 | - Given I am logged in as admin | ||
17 | When I go to the environment control panel | 12 | When I go to the environment control panel |
18 | And I follow "Plugins" | 13 | And I follow "Plugins" |
19 | And I follow "Configuration" | 14 | And I follow "Configuration" |
20 | Then I should see "Enable send of newsletter to members on this environment" | 15 | Then I should see "Enable send of newsletter to members on this environment" |
21 | 16 | ||
22 | Scenario: redirect to newsletter visualization after save and visualize | 17 | Scenario: redirect to newsletter visualization after save and visualize |
23 | - Given I am logged in as admin | ||
24 | - And "NewsletterPlugin" plugin is enabled | 18 | + Given "NewsletterPlugin" plugin is enabled |
25 | When I go to the environment control panel | 19 | When I go to the environment control panel |
26 | And I follow "Plugins" | 20 | And I follow "Plugins" |
27 | And I follow "Configuration" | 21 | And I follow "Configuration" |
@@ -30,11 +24,58 @@ Feature: newsletter plugin | @@ -30,11 +24,58 @@ Feature: newsletter plugin | ||
30 | And I should not see "Newsletter settings" | 24 | And I should not see "Newsletter settings" |
31 | 25 | ||
32 | Scenario: stay on newsletter settings page after save | 26 | Scenario: stay on newsletter settings page after save |
33 | - Given I am logged in as admin | ||
34 | - And "NewsletterPlugin" plugin is enabled | 27 | + Given "NewsletterPlugin" plugin is enabled |
35 | When I go to the environment control panel | 28 | When I go to the environment control panel |
36 | And I follow "Plugins" | 29 | And I follow "Plugins" |
37 | And I follow "Configuration" | 30 | And I follow "Configuration" |
38 | And I press "Save" | 31 | And I press "Save" |
39 | Then I should see "Newsletter settings" | 32 | Then I should see "Newsletter settings" |
40 | And I should not see "If you can't view this email, click here" | 33 | And I should not see "If you can't view this email, click here" |
34 | + | ||
35 | + @selenium | ||
36 | + Scenario: search community and select blog for newsletter | ||
37 | + Given the following communities | ||
38 | + | identifier | name | | ||
39 | + | sample-community | Sample Community | | ||
40 | + And the following blogs | ||
41 | + | owner | name | | ||
42 | + | sample-community | Sample Blog | | ||
43 | + And "NewsletterPlugin" plugin is enabled | ||
44 | + When I go to the environment control panel | ||
45 | + And I follow "Plugins" | ||
46 | + And I follow "Configuration" | ||
47 | + And I type in "Sample Community" into autocomplete list "search-profiles" and I choose "Sample Blog in Sample Community" | ||
48 | + And I press "Save" | ||
49 | + Then I should see "Sample Blog in Sample Community" | ||
50 | + | ||
51 | + @selenium | ||
52 | + Scenario: search profile and select blog for newsletter | ||
53 | + Given the following users | ||
54 | + | login | name | | ||
55 | + | joaosilva | Joao Silva | | ||
56 | + And the following blogs | ||
57 | + | owner | name | | ||
58 | + | joaosilva | Joao Blog | | ||
59 | + And "NewsletterPlugin" plugin is enabled | ||
60 | + When I go to the environment control panel | ||
61 | + And I follow "Plugins" | ||
62 | + And I follow "Configuration" | ||
63 | + And I type in "Silva" into autocomplete list "search-profiles" and I choose "Joao Blog in Joao Silva" | ||
64 | + And I press "Save" | ||
65 | + Then I should see "Joao Blog in Joao Silva" | ||
66 | + | ||
67 | + @selenium | ||
68 | + Scenario: search blog and select it for newsletter | ||
69 | + Given the following communities | ||
70 | + | identifier | name | | ||
71 | + | sample-community | Sample Community | | ||
72 | + And the following blogs | ||
73 | + | owner | name | | ||
74 | + | sample-community | Sample Blog | | ||
75 | + And "NewsletterPlugin" plugin is enabled | ||
76 | + When I go to the environment control panel | ||
77 | + And I follow "Plugins" | ||
78 | + And I follow "Configuration" | ||
79 | + And I type in "Sample Blog" into autocomplete list "search-profiles" and I choose "Sample Blog in Sample Community" | ||
80 | + And I press "Save" | ||
81 | + Then I should see "Sample Blog in Sample Community" |
plugins/newsletter/po/newsletter.pot
@@ -158,7 +158,7 @@ msgid "Blogs from which news will be compiled" | @@ -158,7 +158,7 @@ msgid "Blogs from which news will be compiled" | ||
158 | msgstr "" | 158 | msgstr "" |
159 | 159 | ||
160 | #: plugins/newsletter/views/newsletter_plugin_admin/index.html.erb:36 | 160 | #: plugins/newsletter/views/newsletter_plugin_admin/index.html.erb:36 |
161 | -msgid "Type in the communities' or blogs' names" | 161 | +msgid "Type in the profiles' or blogs' names" |
162 | msgstr "" | 162 | msgstr "" |
163 | 163 | ||
164 | #: plugins/newsletter/views/newsletter_plugin_admin/index.html.erb:42 | 164 | #: plugins/newsletter/views/newsletter_plugin_admin/index.html.erb:42 |
plugins/newsletter/po/pt/newsletter.po
@@ -164,8 +164,8 @@ msgid "Blogs from which news will be compiled" | @@ -164,8 +164,8 @@ msgid "Blogs from which news will be compiled" | ||
164 | msgstr "Blogs utilizados como fonte do boletim informativo" | 164 | msgstr "Blogs utilizados como fonte do boletim informativo" |
165 | 165 | ||
166 | #: plugins/newsletter/views/newsletter_plugin_admin/index.html.erb:36 | 166 | #: plugins/newsletter/views/newsletter_plugin_admin/index.html.erb:36 |
167 | -msgid "Type in the communities' or blogs' names" | ||
168 | -msgstr "Digite nomes de comunidades ou blogs" | 167 | +msgid "Type in the profiles' or blogs' names" |
168 | +msgstr "Digite nomes de perfis ou blogs" | ||
169 | 169 | ||
170 | #: plugins/newsletter/views/newsletter_plugin_admin/index.html.erb:42 | 170 | #: plugins/newsletter/views/newsletter_plugin_admin/index.html.erb:42 |
171 | msgid "Recipients" | 171 | msgid "Recipients" |
plugins/newsletter/views/newsletter_plugin_admin/index.html.erb
@@ -29,11 +29,11 @@ | @@ -29,11 +29,11 @@ | ||
29 | %> | 29 | %> |
30 | 30 | ||
31 | <p><%= _('Blogs from which news will be compiled') %></p> | 31 | <p><%= _('Blogs from which news will be compiled') %></p> |
32 | - <% search_action = url_for(:action => 'search_communities') %> | 32 | + <% search_action = url_for(:action => 'search_profiles') %> |
33 | <% selected_blogs = @blogs.map { |blog| {:id => blog.id, :name => _("%s in %s") % [blog.name, blog.profile.name]} } %> | 33 | <% selected_blogs = @blogs.map { |blog| {:id => blog.id, :name => _("%s in %s") % [blog.name, blog.profile.name]} } %> |
34 | <%= token_input_field_tag( | 34 | <%= token_input_field_tag( |
35 | - 'newsletter[blog_ids]', 'search-communities', search_action, | ||
36 | - { hint_text: _('Type in the communities\' or blogs\' names'), | 35 | + 'newsletter[blog_ids]', 'search-profiles', search_action, |
36 | + { hint_text: _('Type in the profiles\' or blogs\' names'), | ||
37 | focus: false, pre_populate: selected_blogs }) %> | 37 | focus: false, pre_populate: selected_blogs }) %> |
38 | 38 | ||
39 | <br/> | 39 | <br/> |
plugins/oauth_client/lib/ext/profile.rb
1 | require_dependency 'profile' | 1 | require_dependency 'profile' |
2 | 2 | ||
3 | -Profile.descendants.each do |subclass| | ||
4 | - subclass.class_eval do | 3 | +class Profile |
5 | 4 | ||
6 | - has_many :oauth_auths, foreign_key: :profile_id, class_name: 'OauthClientPlugin::Auth', dependent: :destroy | ||
7 | - has_many :oauth_providers, through: :oauth_auths, source: :provider | 5 | + has_many :oauth_auths, foreign_key: :profile_id, class_name: 'OauthClientPlugin::Auth', dependent: :destroy |
6 | + has_many :oauth_providers, through: :oauth_auths, source: :provider | ||
8 | 7 | ||
9 | - end | ||
10 | end | 8 | end |
plugins/shopping_cart/po/pt/shopping_cart.po
@@ -13,16 +13,16 @@ msgid "" | @@ -13,16 +13,16 @@ msgid "" | ||
13 | msgstr "" | 13 | msgstr "" |
14 | "Project-Id-Version: 1.3~rc2-1-ga15645d\n" | 14 | "Project-Id-Version: 1.3~rc2-1-ga15645d\n" |
15 | "POT-Creation-Date: 2015-10-30 16:34-0300\n" | 15 | "POT-Creation-Date: 2015-10-30 16:34-0300\n" |
16 | -"PO-Revision-Date: 2015-11-15 18:17-0300\n" | ||
17 | -"Last-Translator: Michal Čihař <michal@cihar.com>\n" | ||
18 | -"Language-Team: Portuguese <https://hosted.weblate.org/projects/noosfero/" | ||
19 | -"plugin-shopping-cart/pt/>\n" | 16 | +"PO-Revision-Date: 2016-03-14 15:52+0000\n" |
17 | +"Last-Translator: Eduardo Vital <vitaldu@gmail.com>\n" | ||
18 | +"Language-Team: Portuguese <https://hosted.weblate.org/projects/noosfero" | ||
19 | +"/plugin-shopping-cart/pt/>\n" | ||
20 | "Language: pt\n" | 20 | "Language: pt\n" |
21 | "MIME-Version: 1.0\n" | 21 | "MIME-Version: 1.0\n" |
22 | "Content-Type: text/plain; charset=UTF-8\n" | 22 | "Content-Type: text/plain; charset=UTF-8\n" |
23 | "Content-Transfer-Encoding: 8bit\n" | 23 | "Content-Transfer-Encoding: 8bit\n" |
24 | "Plural-Forms: nplurals=2; plural=n != 1;\n" | 24 | "Plural-Forms: nplurals=2; plural=n != 1;\n" |
25 | -"X-Generator: Weblate 2.3-dev\n" | 25 | +"X-Generator: Weblate 2.5\n" |
26 | 26 | ||
27 | #: plugins/shopping_cart/lib/shopping_cart_plugin.rb:10 | 27 | #: plugins/shopping_cart/lib/shopping_cart_plugin.rb:10 |
28 | msgid "A shopping basket feature for enterprises" | 28 | msgid "A shopping basket feature for enterprises" |
@@ -304,7 +304,7 @@ msgstr "Nome" | @@ -304,7 +304,7 @@ msgstr "Nome" | ||
304 | 304 | ||
305 | #: plugins/shopping_cart/views/shopping_cart_plugin/buy.html.erb:16 | 305 | #: plugins/shopping_cart/views/shopping_cart_plugin/buy.html.erb:16 |
306 | msgid "Email" | 306 | msgid "Email" |
307 | -msgstr "" | 307 | +msgstr "E-mail" |
308 | 308 | ||
309 | #: plugins/shopping_cart/views/shopping_cart_plugin/buy.html.erb:17 | 309 | #: plugins/shopping_cart/views/shopping_cart_plugin/buy.html.erb:17 |
310 | msgid "Contact phone" | 310 | msgid "Contact phone" |
plugins/site_tour/lib/ext/person.rb
plugins/sub_organizations/views/sub_organizations_plugin_profile/_full_related_organizations.html.erb
@@ -10,7 +10,7 @@ | @@ -10,7 +10,7 @@ | ||
10 | <%= profile_image_link organization, :big, 'div' %> | 10 | <%= profile_image_link organization, :big, 'div' %> |
11 | </div> | 11 | </div> |
12 | <div class="related-organizations-item-column-right"> | 12 | <div class="related-organizations-item-column-right"> |
13 | - <%= link_to_homepage(organization.name, organization.identifier, :class => "search-result-title") %> | 13 | + <%= link_to_homepage(organization.name, organization, :class => "search-result-title") %> |
14 | <div class="related-organizations-description"> | 14 | <div class="related-organizations-description"> |
15 | <% if organization.description %> | 15 | <% if organization.description %> |
16 | <% body_stripped = strip_tags(organization.description) %> | 16 | <% body_stripped = strip_tags(organization.description) %> |
plugins/tolerance_time/po/pt/tolerance_time.po
@@ -13,16 +13,16 @@ msgid "" | @@ -13,16 +13,16 @@ msgid "" | ||
13 | msgstr "" | 13 | msgstr "" |
14 | "Project-Id-Version: 1.3~rc2-1-ga15645d\n" | 14 | "Project-Id-Version: 1.3~rc2-1-ga15645d\n" |
15 | "POT-Creation-Date: 2015-10-30 16:35-0300\n" | 15 | "POT-Creation-Date: 2015-10-30 16:35-0300\n" |
16 | -"PO-Revision-Date: 2014-12-18 18:40-0200\n" | ||
17 | -"Last-Translator: Luciano Prestes Cavalcanti <lucianopcbr@gmail.com>\n" | ||
18 | -"Language-Team: Portuguese <https://hosted.weblate.org/projects/noosfero/" | ||
19 | -"noosfero/pt/>\n" | 16 | +"PO-Revision-Date: 2016-03-14 16:06+0000\n" |
17 | +"Last-Translator: Eduardo Vital <vitaldu@gmail.com>\n" | ||
18 | +"Language-Team: Portuguese <https://hosted.weblate.org/projects/noosfero" | ||
19 | +"/plugin-tolerance-time/pt/>\n" | ||
20 | "Language: pt\n" | 20 | "Language: pt\n" |
21 | "MIME-Version: 1.0\n" | 21 | "MIME-Version: 1.0\n" |
22 | "Content-Type: text/plain; charset=UTF-8\n" | 22 | "Content-Type: text/plain; charset=UTF-8\n" |
23 | "Content-Transfer-Encoding: 8bit\n" | 23 | "Content-Transfer-Encoding: 8bit\n" |
24 | "Plural-Forms: nplurals=2; plural=n != 1;\n" | 24 | "Plural-Forms: nplurals=2; plural=n != 1;\n" |
25 | -"X-Generator: Weblate 2.0\n" | 25 | +"X-Generator: Weblate 2.5\n" |
26 | 26 | ||
27 | #: plugins/tolerance_time/lib/tolerance_time_plugin.rb:8 | 27 | #: plugins/tolerance_time/lib/tolerance_time_plugin.rb:8 |
28 | msgid "Adds a tolerance time for editing content after its publication" | 28 | msgid "Adds a tolerance time for editing content after its publication" |
@@ -43,24 +43,23 @@ msgstr "" | @@ -43,24 +43,23 @@ msgstr "" | ||
43 | 43 | ||
44 | #: plugins/tolerance_time/lib/tolerance_time_plugin.rb:59 | 44 | #: plugins/tolerance_time/lib/tolerance_time_plugin.rb:59 |
45 | msgid "editing" | 45 | msgid "editing" |
46 | -msgstr "" | 46 | +msgstr "edição" |
47 | 47 | ||
48 | #: plugins/tolerance_time/lib/tolerance_time_plugin.rb:63 | 48 | #: plugins/tolerance_time/lib/tolerance_time_plugin.rb:63 |
49 | msgid "cloning" | 49 | msgid "cloning" |
50 | -msgstr "" | 50 | +msgstr "clonagem" |
51 | 51 | ||
52 | #: plugins/tolerance_time/lib/tolerance_time_plugin.rb:70 | 52 | #: plugins/tolerance_time/lib/tolerance_time_plugin.rb:70 |
53 | -#, fuzzy | ||
54 | msgid "The tolerance time for %s this content is over." | 53 | msgid "The tolerance time for %s this content is over." |
55 | -msgstr "O tempo de tolerância para edição deste conteúdo acabou." | 54 | +msgstr "O tempo de tolerância para %s deste conteúdo acabou." |
56 | 55 | ||
57 | #: plugins/tolerance_time/controllers/tolerance_time_plugin_myprofile_controller.rb:10 | 56 | #: plugins/tolerance_time/controllers/tolerance_time_plugin_myprofile_controller.rb:10 |
58 | msgid "Tolerance updated" | 57 | msgid "Tolerance updated" |
59 | -msgstr "A tolerância foi atualizada" | 58 | +msgstr "O tempo de tolerância foi atualizado" |
60 | 59 | ||
61 | #: plugins/tolerance_time/controllers/tolerance_time_plugin_myprofile_controller.rb:12 | 60 | #: plugins/tolerance_time/controllers/tolerance_time_plugin_myprofile_controller.rb:12 |
62 | msgid "Tolerance could not be updated" | 61 | msgid "Tolerance could not be updated" |
63 | -msgstr "A tolerância não pode ser atualizada" | 62 | +msgstr "O tempo de tolerância não pode ser atualizado" |
64 | 63 | ||
65 | #: plugins/tolerance_time/views/tolerance_time_plugin_myprofile/index.html.erb:1 | 64 | #: plugins/tolerance_time/views/tolerance_time_plugin_myprofile/index.html.erb:1 |
66 | msgid "Tolerance Adjustments" | 65 | msgid "Tolerance Adjustments" |
@@ -79,6 +78,7 @@ msgid "Hours" | @@ -79,6 +78,7 @@ msgid "Hours" | ||
79 | msgstr "Horas" | 78 | msgstr "Horas" |
80 | 79 | ||
81 | #: plugins/tolerance_time/views/tolerance_time_plugin_myprofile/index.html.erb:10 | 80 | #: plugins/tolerance_time/views/tolerance_time_plugin_myprofile/index.html.erb:10 |
81 | +#, fuzzy | ||
82 | msgid "Content edition tolerance time" | 82 | msgid "Content edition tolerance time" |
83 | msgstr "Tempo de tolerância para edição de conteúdo" | 83 | msgstr "Tempo de tolerância para edição de conteúdo" |
84 | 84 | ||
@@ -87,5 +87,6 @@ msgid "Comment edition tolerance time" | @@ -87,5 +87,6 @@ msgid "Comment edition tolerance time" | ||
87 | msgstr "Tempo de tolerância para edição de comentários" | 87 | msgstr "Tempo de tolerância para edição de comentários" |
88 | 88 | ||
89 | #: plugins/tolerance_time/views/tolerance_time_plugin_myprofile/index.html.erb:18 | 89 | #: plugins/tolerance_time/views/tolerance_time_plugin_myprofile/index.html.erb:18 |
90 | +#, fuzzy | ||
90 | msgid "Empty means unlimited and zero means right away." | 91 | msgid "Empty means unlimited and zero means right away." |
91 | -msgstr "Vazio significa ilimitado e zero significa imediatamente." | 92 | +msgstr "Campo vazio significa ilimitado e zero significa imediatamente." |
plugins/work_assignment/po/pt/work_assignment.po
@@ -13,16 +13,16 @@ msgid "" | @@ -13,16 +13,16 @@ msgid "" | ||
13 | msgstr "" | 13 | msgstr "" |
14 | "Project-Id-Version: 1.3~rc2-1-ga15645d\n" | 14 | "Project-Id-Version: 1.3~rc2-1-ga15645d\n" |
15 | "POT-Creation-Date: 2015-10-30 16:35-0300\n" | 15 | "POT-Creation-Date: 2015-10-30 16:35-0300\n" |
16 | -"PO-Revision-Date: 2015-08-07 16:48+0200\n" | ||
17 | -"Last-Translator: Antonio Terceiro <terceiro@softwarelivre.org>\n" | ||
18 | -"Language-Team: Portuguese <https://hosted.weblate.org/projects/noosfero/" | ||
19 | -"plugin-work-assignment/pt/>\n" | 16 | +"PO-Revision-Date: 2016-03-14 15:58+0000\n" |
17 | +"Last-Translator: Eduardo Vital <vitaldu@gmail.com>\n" | ||
18 | +"Language-Team: Portuguese <https://hosted.weblate.org/projects/noosfero" | ||
19 | +"/plugin-work-assignment/pt/>\n" | ||
20 | "Language: pt\n" | 20 | "Language: pt\n" |
21 | "MIME-Version: 1.0\n" | 21 | "MIME-Version: 1.0\n" |
22 | "Content-Type: text/plain; charset=UTF-8\n" | 22 | "Content-Type: text/plain; charset=UTF-8\n" |
23 | "Content-Transfer-Encoding: 8bit\n" | 23 | "Content-Transfer-Encoding: 8bit\n" |
24 | "Plural-Forms: nplurals=2; plural=n != 1;\n" | 24 | "Plural-Forms: nplurals=2; plural=n != 1;\n" |
25 | -"X-Generator: Weblate 2.4-dev\n" | 25 | +"X-Generator: Weblate 2.5\n" |
26 | 26 | ||
27 | #: plugins/work_assignment/lib/work_assignment_plugin.rb:8 | 27 | #: plugins/work_assignment/lib/work_assignment_plugin.rb:8 |
28 | msgid "New kind of content for organizations." | 28 | msgid "New kind of content for organizations." |
@@ -66,7 +66,7 @@ msgstr "Nome" | @@ -66,7 +66,7 @@ msgstr "Nome" | ||
66 | 66 | ||
67 | #: plugins/work_assignment/lib/work_assignment_plugin/helper.rb:9 | 67 | #: plugins/work_assignment/lib/work_assignment_plugin/helper.rb:9 |
68 | msgid "Submission date" | 68 | msgid "Submission date" |
69 | -msgstr "Data de submissão" | 69 | +msgstr "Data da submissão" |
70 | 70 | ||
71 | #: plugins/work_assignment/lib/work_assignment_plugin/helper.rb:10 | 71 | #: plugins/work_assignment/lib/work_assignment_plugin/helper.rb:10 |
72 | msgid "Versions" | 72 | msgid "Versions" |
po/pt/noosfero.po
@@ -13,7 +13,7 @@ msgid "" | @@ -13,7 +13,7 @@ msgid "" | ||
13 | msgstr "" | 13 | msgstr "" |
14 | "Project-Id-Version: 1.3~rc2-8-g01ea9f7\n" | 14 | "Project-Id-Version: 1.3~rc2-8-g01ea9f7\n" |
15 | "POT-Creation-Date: 2015-11-04 12:36-0300\n" | 15 | "POT-Creation-Date: 2015-11-04 12:36-0300\n" |
16 | -"PO-Revision-Date: 2016-02-18 14:44+0000\n" | 16 | +"PO-Revision-Date: 2016-03-14 15:58+0000\n" |
17 | "Last-Translator: Eduardo Vital <vitaldu@gmail.com>\n" | 17 | "Last-Translator: Eduardo Vital <vitaldu@gmail.com>\n" |
18 | "Language-Team: Portuguese " | 18 | "Language-Team: Portuguese " |
19 | "<https://hosted.weblate.org/projects/noosfero/noosfero/pt/>\n" | 19 | "<https://hosted.weblate.org/projects/noosfero/noosfero/pt/>\n" |
@@ -22,7 +22,7 @@ msgstr "" | @@ -22,7 +22,7 @@ msgstr "" | ||
22 | "Content-Type: text/plain; charset=UTF-8\n" | 22 | "Content-Type: text/plain; charset=UTF-8\n" |
23 | "Content-Transfer-Encoding: 8bit\n" | 23 | "Content-Transfer-Encoding: 8bit\n" |
24 | "Plural-Forms: nplurals=2; plural=n != 1;\n" | 24 | "Plural-Forms: nplurals=2; plural=n != 1;\n" |
25 | -"X-Generator: Weblate 2.5-dev\n" | 25 | +"X-Generator: Weblate 2.5\n" |
26 | 26 | ||
27 | #: app/models/approve_comment.rb:17 | 27 | #: app/models/approve_comment.rb:17 |
28 | msgid "Anonymous" | 28 | msgid "Anonymous" |
public/designs/themes/noosfero/style.css
@@ -0,0 +1,25 @@ | @@ -0,0 +1,25 @@ | ||
1 | +(function($) { | ||
2 | + | ||
3 | + //Autocomplete to list members | ||
4 | + $('#filter-name-autocomplete').autocomplete({ | ||
5 | + minLength:2, | ||
6 | + source:function(request,response){ | ||
7 | + $.ajax({ | ||
8 | + url:document.location.pathname+'/search_members', | ||
9 | + dataType:'json', | ||
10 | + data:{ | ||
11 | + filter_name:request.term | ||
12 | + }, | ||
13 | + success:response | ||
14 | + }); | ||
15 | + } | ||
16 | + }); | ||
17 | +})(jQuery); | ||
18 | + | ||
19 | + | ||
20 | +function toggle(source) { | ||
21 | + checkboxes = document.getElementsByName('members_filtered[]'); | ||
22 | + for(var i=0, n=checkboxes.length;i<n;i++) { | ||
23 | + checkboxes[i].checked = source.checked; | ||
24 | + } | ||
25 | +} |
public/stylesheets/cms.scss
@@ -166,6 +166,12 @@ table.cms-articles .icon:hover { | @@ -166,6 +166,12 @@ table.cms-articles .icon:hover { | ||
166 | white-space: nowrap; | 166 | white-space: nowrap; |
167 | } | 167 | } |
168 | 168 | ||
169 | +.controller-cms td.article-name { | ||
170 | + text-overflow: ellipsis; | ||
171 | + white-space: nowrap; | ||
172 | + overflow: hidden; | ||
173 | +} | ||
174 | + | ||
169 | .controller-cms .article-controls { | 175 | .controller-cms .article-controls { |
170 | white-space: nowrap; | 176 | white-space: nowrap; |
171 | } | 177 | } |
public/stylesheets/content/blog.scss
public/stylesheets/content/folder.scss
public/stylesheets/content/image-gallery.scss
@@ -13,6 +13,7 @@ | @@ -13,6 +13,7 @@ | ||
13 | list-style: none; | 13 | list-style: none; |
14 | overflow: hidden; | 14 | overflow: hidden; |
15 | background-repeat: no-repeat; | 15 | background-repeat: no-repeat; |
16 | + word-wrap: break-word; | ||
16 | } | 17 | } |
17 | .image-gallery-item span { | 18 | .image-gallery-item span { |
18 | text-align: center; | 19 | text-align: center; |
script/install-dependencies/debian-jessie.sh
1 | -binary_packages='deb http://download.noosfero.org/debian/jessie ./' | 1 | +binary_packages='deb http://download.noosfero.org/debian/jessie-test ./' |
2 | 2 | ||
3 | source_packages=$(echo "$binary_packages" | sed -e 's/^deb/deb-src/') | 3 | source_packages=$(echo "$binary_packages" | sed -e 's/^deb/deb-src/') |
4 | 4 | ||
@@ -10,7 +10,7 @@ EOF | @@ -10,7 +10,7 @@ EOF | ||
10 | 10 | ||
11 | sudo apt-key add - <<EOF | 11 | sudo apt-key add - <<EOF |
12 | -----BEGIN PGP PUBLIC KEY BLOCK----- | 12 | -----BEGIN PGP PUBLIC KEY BLOCK----- |
13 | -Version: GnuPG v1.4.9 (GNU/Linux) | 13 | +Version: GnuPG v1.4.12 (GNU/Linux) |
14 | 14 | ||
15 | mQGiBE1HCIURBADw6SnRbc1qCHdTV9wD0rxSMIWevzUX+bnDgvV455yudqtVFUhX | 15 | mQGiBE1HCIURBADw6SnRbc1qCHdTV9wD0rxSMIWevzUX+bnDgvV455yudqtVFUhX |
16 | 2QYvtlwclllbLWKzRdiM7GsBi+2DyWli4B17xl86A5RBQNdc1v1vWZG3QwURxd4E | 16 | 2QYvtlwclllbLWKzRdiM7GsBi+2DyWli4B17xl86A5RBQNdc1v1vWZG3QwURxd4E |
script/quick-start
@@ -130,6 +130,7 @@ fi | @@ -130,6 +130,7 @@ fi | ||
130 | # create needed directory | 130 | # create needed directory |
131 | mkdir -p tmp/pids | 131 | mkdir -p tmp/pids |
132 | mkdir -p tmp/cache | 132 | mkdir -p tmp/cache |
133 | +mkdir -p cache | ||
133 | 134 | ||
134 | # use default gitignore rules | 135 | # use default gitignore rules |
135 | if [ ! -f .gitignore ]; then | 136 | if [ ! -f .gitignore ]; then |
test/functional/mailconf_controller_test.rb
@@ -71,8 +71,10 @@ class MailconfControllerTest < ActionController::TestCase | @@ -71,8 +71,10 @@ class MailconfControllerTest < ActionController::TestCase | ||
71 | env = Environment.default | 71 | env = Environment.default |
72 | env.force_www = true | 72 | env.force_www = true |
73 | env.save! | 73 | env.save! |
74 | + env.domains.delete_all | ||
75 | + env.domains.create! name: 'example.com' | ||
74 | get :index, :profile => 'ze' | 76 | get :index, :profile => 'ze' |
75 | - assert_tag :tag => 'li', :content => /ze@colivre.net/ | 77 | + assert_tag :tag => 'li', :content => /ze@example.com/ |
76 | end | 78 | end |
77 | 79 | ||
78 | should 'not display www in email address when force_www=false' do | 80 | should 'not display www in email address when force_www=false' do |
@@ -80,8 +82,10 @@ class MailconfControllerTest < ActionController::TestCase | @@ -80,8 +82,10 @@ class MailconfControllerTest < ActionController::TestCase | ||
80 | env = Environment.default | 82 | env = Environment.default |
81 | env.force_www = false | 83 | env.force_www = false |
82 | env.save! | 84 | env.save! |
85 | + env.domains.delete_all | ||
86 | + env.domains.create! name: 'example.com' | ||
83 | get :index, :profile => 'ze' | 87 | get :index, :profile => 'ze' |
84 | - assert_tag :tag => 'li', :content => /ze@colivre.net/ | 88 | + assert_tag :tag => 'li', :content => /ze@example.com/ |
85 | end | 89 | end |
86 | 90 | ||
87 | should 'create task to environment admin when enable email' do | 91 | should 'create task to environment admin when enable email' do |
test/functional/profile_controller_test.rb
@@ -1465,11 +1465,41 @@ class ProfileControllerTest < ActionController::TestCase | @@ -1465,11 +1465,41 @@ class ProfileControllerTest < ActionController::TestCase | ||
1465 | create_user_with_permission('profile_moderator_user', 'send_mail_to_members', community) | 1465 | create_user_with_permission('profile_moderator_user', 'send_mail_to_members', community) |
1466 | login_as('profile_moderator_user') | 1466 | login_as('profile_moderator_user') |
1467 | @controller.stubs(:locale).returns('pt') | 1467 | @controller.stubs(:locale).returns('pt') |
1468 | + | ||
1468 | assert_difference 'Delayed::Job.count', 1 do | 1469 | assert_difference 'Delayed::Job.count', 1 do |
1469 | post :send_mail, :profile => community.identifier, :mailing => {:subject => 'Hello', :body => 'We have some news'} | 1470 | post :send_mail, :profile => community.identifier, :mailing => {:subject => 'Hello', :body => 'We have some news'} |
1470 | end | 1471 | end |
1471 | end | 1472 | end |
1472 | 1473 | ||
1474 | + should 'send to members_filtered if available' do | ||
1475 | + community = fast_create(Community) | ||
1476 | + create_user_with_permission('profile_moderator_user', 'send_mail_to_members', community) | ||
1477 | + person = create_user('Any').person | ||
1478 | + community.add_member(person) | ||
1479 | + community.save! | ||
1480 | + login_as('profile_moderator_user') | ||
1481 | + | ||
1482 | + post :send_mail, :profile => community.identifier, :mailing => {:subject => 'Hello', :body => 'We have some news'} | ||
1483 | + assert_equivalent community.members, OrganizationMailing.last.recipients | ||
1484 | + | ||
1485 | + @request.session[:members_filtered] = [person.id] | ||
1486 | + post :send_mail, :profile => community.identifier, :mailing => {:subject => 'RUN!!', :body => 'Run to the hills!!'} | ||
1487 | + assert_equal [person], OrganizationMailing.last.recipients | ||
1488 | + end | ||
1489 | + | ||
1490 | + should 'send email to all members if there is no valid member in members_filtered' do | ||
1491 | + community = fast_create(Community) | ||
1492 | + create_user_with_permission('profile_moderator_user', 'send_mail_to_members', community) | ||
1493 | + person = create_user('Any').person | ||
1494 | + community.add_member(person) | ||
1495 | + community.save! | ||
1496 | + login_as('profile_moderator_user') | ||
1497 | + | ||
1498 | + @request.session[:members_filtered] = [Profile.last.id+1] | ||
1499 | + post :send_mail, :profile => community.identifier, :mailing => {:subject => 'RUN!!', :body => 'Run to the hills!!'} | ||
1500 | + assert_empty OrganizationMailing.last.recipients | ||
1501 | + end | ||
1502 | + | ||
1473 | should 'save mailing' do | 1503 | should 'save mailing' do |
1474 | community = fast_create(Community) | 1504 | community = fast_create(Community) |
1475 | create_user_with_permission('profile_moderator_user', 'send_mail_to_members', community) | 1505 | create_user_with_permission('profile_moderator_user', 'send_mail_to_members', community) |
test/functional/profile_editor_controller_test.rb
@@ -1213,4 +1213,11 @@ class ProfileEditorControllerTest < ActionController::TestCase | @@ -1213,4 +1213,11 @@ class ProfileEditorControllerTest < ActionController::TestCase | ||
1213 | assert_no_tag :tag => 'a', :attributes => { :href => "/myprofile/default_user/profile_roles" } | 1213 | assert_no_tag :tag => 'a', :attributes => { :href => "/myprofile/default_user/profile_roles" } |
1214 | end | 1214 | end |
1215 | 1215 | ||
1216 | + should 'save profile admin option to receive email for every task' do | ||
1217 | + comm = fast_create(Community) | ||
1218 | + assert comm.profile_admin_mail_notification | ||
1219 | + post :edit, :profile => comm.identifier, :profile_data => { :profile_admin_mail_notification => '0' } | ||
1220 | + refute comm.reload.profile_admin_mail_notification | ||
1221 | + end | ||
1222 | + | ||
1216 | end | 1223 | end |
test/functional/profile_members_controller_test.rb
@@ -31,6 +31,31 @@ class ProfileMembersControllerTest < ActionController::TestCase | @@ -31,6 +31,31 @@ class ProfileMembersControllerTest < ActionController::TestCase | ||
31 | assert_template 'index' | 31 | assert_template 'index' |
32 | end | 32 | end |
33 | 33 | ||
34 | + should 'access index and filter members by name and roles' do | ||
35 | + | ||
36 | + ent = fast_create(Enterprise, :identifier => 'test_enterprise', :name => 'test enterprise') | ||
37 | + roles = { | ||
38 | + :admin => Profile::Roles.admin(Environment.default), | ||
39 | + :member => Profile::Roles.member(Environment.default) | ||
40 | + } | ||
41 | + | ||
42 | + member = create_user('test_member', :email => 'testmember@test.com.br').person | ||
43 | + member.add_role(roles[:member], ent) | ||
44 | + | ||
45 | + admin = create_user('test_admin').person | ||
46 | + admin.add_role roles[:admin], ent | ||
47 | + | ||
48 | + user = create_user_with_permission('test_user', 'manage_memberships', ent) | ||
49 | + login_as :test_user | ||
50 | + | ||
51 | + post :index, :profile => 'test_enterprise' , :filters => {:name => 'testmember@test.com.br', :roles => [roles[:member].id]} | ||
52 | + | ||
53 | + assert_response :success | ||
54 | + assert_template 'index' | ||
55 | + | ||
56 | + assert_includes assigns(:data)[:members], member | ||
57 | + end | ||
58 | + | ||
34 | should 'show form to change role' do | 59 | should 'show form to change role' do |
35 | ent = fast_create(Enterprise, :identifier => 'test_enterprise', :name => 'test enterprise') | 60 | ent = fast_create(Enterprise, :identifier => 'test_enterprise', :name => 'test enterprise') |
36 | role = Profile::Roles.member(Environment.default) | 61 | role = Profile::Roles.member(Environment.default) |
@@ -171,7 +196,7 @@ class ProfileMembersControllerTest < ActionController::TestCase | @@ -171,7 +196,7 @@ class ProfileMembersControllerTest < ActionController::TestCase | ||
171 | login_as :test_user | 196 | login_as :test_user |
172 | 197 | ||
173 | get :index, :profile => community.identifier | 198 | get :index, :profile => community.identifier |
174 | - assert_tag :tag => 'a', :attributes => {:href => /send_mail/} | 199 | + assert_tag :tag => 'input', :attributes => {:value => 'Send e-mail to members'} |
175 | end | 200 | end |
176 | 201 | ||
177 | should 'not display send email to members if doesn\'t have the permission' do | 202 | should 'not display send email to members if doesn\'t have the permission' do |
test/integration/enable_disable_features_test.rb
@@ -13,17 +13,15 @@ class EnableDisableFeaturesTest < ActionDispatch::IntegrationTest | @@ -13,17 +13,15 @@ class EnableDisableFeaturesTest < ActionDispatch::IntegrationTest | ||
13 | assert_tag :tag => 'input', :attributes => { :name => 'environment[enabled_features][]', :value => 'feature2' } | 13 | assert_tag :tag => 'input', :attributes => { :name => 'environment[enabled_features][]', :value => 'feature2' } |
14 | assert_tag :tag => 'input', :attributes => { :name => 'environment[enabled_features][]', :value => 'feature3' } | 14 | assert_tag :tag => 'input', :attributes => { :name => 'environment[enabled_features][]', :value => 'feature3' } |
15 | 15 | ||
16 | - post '/admin/features/update' | ||
17 | - assert_response :redirect | 16 | + post_via_redirect '/admin/features/update' |
17 | + assert_response :success | ||
18 | 18 | ||
19 | - follow_redirect! | ||
20 | assert_response :success | 19 | assert_response :success |
21 | assert_equal '/admin/features', path | 20 | assert_equal '/admin/features', path |
22 | 21 | ||
23 | - post '/admin/features/update', :environments => { :enabled_features => [ 'feature1' ], :organization_approval_method => 'region' } | ||
24 | - assert_response :redirect | 22 | + post_via_redirect '/admin/features/update', :environments => { :enabled_features => [ 'feature1' ], :organization_approval_method => 'region' } |
23 | + assert_response :success | ||
25 | 24 | ||
26 | - follow_redirect! | ||
27 | assert_equal '/admin/features', path | 25 | assert_equal '/admin/features', path |
28 | 26 | ||
29 | end | 27 | end |
test/integration/enterprise_registration_test.rb
@@ -61,10 +61,9 @@ class EnterpriseRegistrationTest < ActionDispatch::IntegrationTest | @@ -61,10 +61,9 @@ class EnterpriseRegistrationTest < ActionDispatch::IntegrationTest | ||
61 | assert_response :success | 61 | assert_response :success |
62 | assert_tag :form, :attributes => { :action => "/myprofile/myorg/enterprise_validation/approve/#{code}" } | 62 | assert_tag :form, :attributes => { :action => "/myprofile/myorg/enterprise_validation/approve/#{code}" } |
63 | 63 | ||
64 | - post "/myprofile/myorg/enterprise_validation/approve/#{code}" | ||
65 | - assert_response :redirect | 64 | + post_via_redirect "/myprofile/myorg/enterprise_validation/approve/#{code}" |
65 | + assert_response :success | ||
66 | 66 | ||
67 | - follow_redirect! | ||
68 | assert_equal "/myprofile/myorg/enterprise_validation/view_processed/#{code}", path | 67 | assert_equal "/myprofile/myorg/enterprise_validation/view_processed/#{code}", path |
69 | assert_tag :span, :attributes => { :class => 'validation_approved' } | 68 | assert_tag :span, :attributes => { :class => 'validation_approved' } |
70 | end | 69 | end |
test/integration/manage_documents_test.rb
@@ -24,11 +24,10 @@ class ManageDocumentsTest < ActionDispatch::IntegrationTest | @@ -24,11 +24,10 @@ class ManageDocumentsTest < ActionDispatch::IntegrationTest | ||
24 | assert_tag :tag => 'form', :attributes => { :action => '/myprofile/myuser/cms/new', :method => /post/i } | 24 | assert_tag :tag => 'form', :attributes => { :action => '/myprofile/myuser/cms/new', :method => /post/i } |
25 | 25 | ||
26 | assert_difference 'Article.count' do | 26 | assert_difference 'Article.count' do |
27 | - post '/myprofile/myuser/cms/new', :type => 'TinyMceArticle', :article => { :name => 'my article', :body => 'this is the body of ther article'} | 27 | + post_via_redirect '/myprofile/myuser/cms/new', :type => 'TinyMceArticle', :article => { :name => 'my article', :body => 'this is the body of ther article'} |
28 | end | 28 | end |
29 | 29 | ||
30 | - assert_response :redirect | ||
31 | - follow_redirect! | 30 | + assert_response :success |
32 | a = Article.find_by_path('my-article') | 31 | a = Article.find_by_path('my-article') |
33 | assert_equal "/myuser/#{a.slug}", path | 32 | assert_equal "/myuser/#{a.slug}", path |
34 | end | 33 | end |
@@ -55,14 +54,13 @@ class ManageDocumentsTest < ActionDispatch::IntegrationTest | @@ -55,14 +54,13 @@ class ManageDocumentsTest < ActionDispatch::IntegrationTest | ||
55 | assert_tag :tag => 'form', :attributes => { :action => "/myprofile/myuser/cms/edit/#{article.id}", :method => /post/i } | 54 | assert_tag :tag => 'form', :attributes => { :action => "/myprofile/myuser/cms/edit/#{article.id}", :method => /post/i } |
56 | 55 | ||
57 | assert_no_difference 'Article.count' do | 56 | assert_no_difference 'Article.count' do |
58 | - post "/myprofile/myuser/cms/edit/#{article.id}", :article => { :name => 'my article', :body => 'this is the body of the article'} | 57 | + post_via_redirect "/myprofile/myuser/cms/edit/#{article.id}", :article => { :name => 'my article', :body => 'this is the body of the article'} |
59 | end | 58 | end |
60 | 59 | ||
61 | article.reload | 60 | article.reload |
62 | assert_equal 'this is the body of the article', article.body | 61 | assert_equal 'this is the body of the article', article.body |
63 | 62 | ||
64 | - assert_response :redirect | ||
65 | - follow_redirect! | 63 | + assert_response :success |
66 | a = Article.find_by_path('my-article') | 64 | a = Article.find_by_path('my-article') |
67 | assert_equal "/myuser/#{a.slug}", path | 65 | assert_equal "/myuser/#{a.slug}", path |
68 | end | 66 | end |
@@ -84,10 +82,9 @@ class ManageDocumentsTest < ActionDispatch::IntegrationTest | @@ -84,10 +82,9 @@ class ManageDocumentsTest < ActionDispatch::IntegrationTest | ||
84 | assert_response :success | 82 | assert_response :success |
85 | 83 | ||
86 | assert_tag tag: 'a', attributes: { href: "/myprofile/myuser/cms/destroy/#{article.id}", 'data-confirm' => /Are you sure/ } | 84 | assert_tag tag: 'a', attributes: { href: "/myprofile/myuser/cms/destroy/#{article.id}", 'data-confirm' => /Are you sure/ } |
87 | - post "/myprofile/myuser/cms/destroy/#{article.id}" | 85 | + post_via_redirect "/myprofile/myuser/cms/destroy/#{article.id}" |
88 | 86 | ||
89 | - assert_response :redirect | ||
90 | - follow_redirect! | 87 | + assert_response :success |
91 | assert_equal "/myuser", path | 88 | assert_equal "/myuser", path |
92 | 89 | ||
93 | # the article was actually deleted | 90 | # the article was actually deleted |
test/integration/manage_friendships_test.rb
@@ -24,11 +24,10 @@ class ManageFriendshipsTest < ActionDispatch::IntegrationTest | @@ -24,11 +24,10 @@ class ManageFriendshipsTest < ActionDispatch::IntegrationTest | ||
24 | get "/myprofile/#{@person.identifier}/friends/remove/#{@friend.id}" | 24 | get "/myprofile/#{@person.identifier}/friends/remove/#{@friend.id}" |
25 | assert_response :success | 25 | assert_response :success |
26 | 26 | ||
27 | - post "/myprofile/#{@person.identifier}/friends/remove/#{@friend.id}", | 27 | + post_via_redirect "/myprofile/#{@person.identifier}/friends/remove/#{@friend.id}", |
28 | :confirmation => '1' | 28 | :confirmation => '1' |
29 | - assert_response :redirect | 29 | + assert_response :success |
30 | 30 | ||
31 | - follow_redirect! | ||
32 | 31 | ||
33 | assert assigns(:friends).empty? | 32 | assert assigns(:friends).empty? |
34 | refute @person.is_a_friend?(@friend) | 33 | refute @person.is_a_friend?(@friend) |
test/support/integration_test.rb
@@ -14,9 +14,8 @@ class ActionDispatch::IntegrationTest | @@ -14,9 +14,8 @@ class ActionDispatch::IntegrationTest | ||
14 | def login(username, password) | 14 | def login(username, password) |
15 | ActionDispatch::Integration::Session.any_instance.stubs(:https?).returns(true) | 15 | ActionDispatch::Integration::Session.any_instance.stubs(:https?).returns(true) |
16 | 16 | ||
17 | - post '/account/login', :user => { :login => username, :password => password } | ||
18 | - assert_response :redirect | ||
19 | - follow_redirect! | 17 | + post_via_redirect '/account/login', :user => { :login => username, :password => password } |
18 | + assert_response :success | ||
20 | assert_not_equal '/account/login', path | 19 | assert_not_equal '/account/login', path |
21 | end | 20 | end |
22 | 21 |
test/unit/application_helper_test.rb
@@ -80,12 +80,6 @@ class ApplicationHelperTest < ActionView::TestCase | @@ -80,12 +80,6 @@ class ApplicationHelperTest < ActionView::TestCase | ||
80 | assert_equal '', show_date(nil) | 80 | assert_equal '', show_date(nil) |
81 | end | 81 | end |
82 | 82 | ||
83 | - | ||
84 | - should 'append with-text class and keep existing classes' do | ||
85 | - expects(:button_without_text).with('type', 'label', 'url', { :class => 'with-text class1'}) | ||
86 | - button('type', 'label', 'url', { :class => 'class1' }) | ||
87 | - end | ||
88 | - | ||
89 | should 'generate correct link to category' do | 83 | should 'generate correct link to category' do |
90 | cat = mock | 84 | cat = mock |
91 | cat.expects(:path).returns('my-category/my-subcatagory') | 85 | cat.expects(:path).returns('my-category/my-subcatagory') |
test/unit/article_block_test.rb
@@ -7,15 +7,6 @@ class ArticleBlockTest < ActiveSupport::TestCase | @@ -7,15 +7,6 @@ class ArticleBlockTest < ActiveSupport::TestCase | ||
7 | assert_not_equal Block.description, ArticleBlock.description | 7 | assert_not_equal Block.description, ArticleBlock.description |
8 | end | 8 | end |
9 | 9 | ||
10 | - should "take article's content" do | ||
11 | - block = ArticleBlock.new | ||
12 | - article = mock | ||
13 | - article.expects(:to_html).returns("Article content") | ||
14 | - block.stubs(:article).returns(article) | ||
15 | - | ||
16 | - assert_match(/Article content/, instance_eval(&block.content)) | ||
17 | - end | ||
18 | - | ||
19 | should 'refer to an article' do | 10 | should 'refer to an article' do |
20 | profile = create_user('testuser').person | 11 | profile = create_user('testuser').person |
21 | article = profile.articles.build(:name => 'test article') | 12 | article = profile.articles.build(:name => 'test article') |
@@ -85,6 +76,31 @@ class ArticleBlockTest < ActiveSupport::TestCase | @@ -85,6 +76,31 @@ class ArticleBlockTest < ActiveSupport::TestCase | ||
85 | assert_equal [a],block.available_articles | 76 | assert_equal [a],block.available_articles |
86 | end | 77 | end |
87 | 78 | ||
79 | + protected | ||
80 | + include NoosferoTestHelper | ||
81 | + | ||
82 | +end | ||
83 | + | ||
84 | +require 'boxes_helper' | ||
85 | +require 'block_helper' | ||
86 | + | ||
87 | +class ArticleBlockViewTest < ActionView::TestCase | ||
88 | + include BoxesHelper | ||
89 | + | ||
90 | + ActionView::Base.send :include, ArticleHelper | ||
91 | + ActionView::Base.send :include, ButtonsHelper | ||
92 | + ActionView::Base.send :include, BlockHelper | ||
93 | + | ||
94 | + should "take article's content" do | ||
95 | + block = ArticleBlock.new | ||
96 | + article = mock | ||
97 | + article.expects(:to_html).returns("Article content") | ||
98 | + block.stubs(:article).returns(article) | ||
99 | + ActionView::Base.any_instance.stubs(:block_title).returns("") | ||
100 | + | ||
101 | + assert_match(/Article content/, render_block_content(block)) | ||
102 | + end | ||
103 | + | ||
88 | should "display empty title if title is blank" do | 104 | should "display empty title if title is blank" do |
89 | block = ArticleBlock.new | 105 | block = ArticleBlock.new |
90 | article = mock | 106 | article = mock |
@@ -92,7 +108,7 @@ class ArticleBlockTest < ActiveSupport::TestCase | @@ -92,7 +108,7 @@ class ArticleBlockTest < ActiveSupport::TestCase | ||
92 | block.expects(:title).returns('') | 108 | block.expects(:title).returns('') |
93 | block.stubs(:article).returns(article) | 109 | block.stubs(:article).returns(article) |
94 | 110 | ||
95 | - assert_equal "<h3 class=\"block-title empty\"><span></span></h3>Article content", instance_eval(&block.content) | 111 | + assert_equal "<h3 class=\"block-title empty\"><span></span></h3>\n Article content\n", render_block_content(block) |
96 | end | 112 | end |
97 | 113 | ||
98 | should "display title if defined" do | 114 | should "display title if defined" do |
@@ -102,7 +118,7 @@ class ArticleBlockTest < ActiveSupport::TestCase | @@ -102,7 +118,7 @@ class ArticleBlockTest < ActiveSupport::TestCase | ||
102 | block.expects(:title).returns('Article title') | 118 | block.expects(:title).returns('Article title') |
103 | block.stubs(:article).returns(article) | 119 | block.stubs(:article).returns(article) |
104 | 120 | ||
105 | - assert_equal "<h3 class=\"block-title\"><span>Article title</span></h3>Article content", instance_eval(&block.content) | 121 | + assert_equal "<h3 class=\"block-title\"><span>Article title</span></h3>\n Article content\n", render_block_content(block) |
106 | end | 122 | end |
107 | 123 | ||
108 | should 'display image if article is an image' do | 124 | should 'display image if article is an image' do |
@@ -113,7 +129,7 @@ class ArticleBlockTest < ActiveSupport::TestCase | @@ -113,7 +129,7 @@ class ArticleBlockTest < ActiveSupport::TestCase | ||
113 | block.article = image | 129 | block.article = image |
114 | block.save! | 130 | block.save! |
115 | 131 | ||
116 | - assert_tag_in_string instance_eval(&block.content), | 132 | + assert_tag_in_string render_block_content(block), |
117 | :tag => 'img', | 133 | :tag => 'img', |
118 | :attributes => { | 134 | :attributes => { |
119 | :src => image.public_filename(:display), | 135 | :src => image.public_filename(:display), |
@@ -129,7 +145,7 @@ class ArticleBlockTest < ActiveSupport::TestCase | @@ -129,7 +145,7 @@ class ArticleBlockTest < ActiveSupport::TestCase | ||
129 | block.article = image | 145 | block.article = image |
130 | block.save! | 146 | block.save! |
131 | 147 | ||
132 | - assert_no_match(/Previous/, instance_eval(&block.content)) | 148 | + assert_no_match(/Previous/, render_block_content(block)) |
133 | end | 149 | end |
134 | 150 | ||
135 | should 'display link to archive if article is an archive' do | 151 | should 'display link to archive if article is an archive' do |
@@ -141,11 +157,6 @@ class ArticleBlockTest < ActiveSupport::TestCase | @@ -141,11 +157,6 @@ class ArticleBlockTest < ActiveSupport::TestCase | ||
141 | block.save! | 157 | block.save! |
142 | 158 | ||
143 | UploadedFile.any_instance.stubs(:url).returns('myhost.mydomain/path/to/file') | 159 | UploadedFile.any_instance.stubs(:url).returns('myhost.mydomain/path/to/file') |
144 | - | ||
145 | - assert_tag_in_string instance_eval(&block.content), :tag => 'a', :content => _('Download') | 160 | + assert_tag_in_string render_block_content(block), :tag => 'a', :content => _('Download') |
146 | end | 161 | end |
147 | - | ||
148 | - protected | ||
149 | - include NoosferoTestHelper | ||
150 | - | ||
151 | end | 162 | end |
test/unit/article_test.rb
@@ -22,21 +22,6 @@ class ArticleTest < ActiveSupport::TestCase | @@ -22,21 +22,6 @@ class ArticleTest < ActiveSupport::TestCase | ||
22 | refute a.errors[:profile_id.to_s].present? | 22 | refute a.errors[:profile_id.to_s].present? |
23 | end | 23 | end |
24 | 24 | ||
25 | - should 'keep unique users in list of followers' do | ||
26 | - person1 = create_user('article_owner').person | ||
27 | - person2 = create_user('article_follower').person | ||
28 | - | ||
29 | - article = fast_create(Article, :profile_id => person1.id) | ||
30 | - | ||
31 | - article.person_followers=[person2] | ||
32 | - article.save | ||
33 | - article.reload | ||
34 | - article.person_followers=[person2] | ||
35 | - article.save | ||
36 | - | ||
37 | - assert_equal 1, article.reload.person_followers.size | ||
38 | - end | ||
39 | - | ||
40 | should 'require value for name' do | 25 | should 'require value for name' do |
41 | a = Article.new | 26 | a = Article.new |
42 | a.valid? | 27 | a.valid? |
@@ -1713,11 +1698,6 @@ class ArticleTest < ActiveSupport::TestCase | @@ -1713,11 +1698,6 @@ class ArticleTest < ActiveSupport::TestCase | ||
1713 | assert post.allow_edit?(author) | 1698 | assert post.allow_edit?(author) |
1714 | end | 1699 | end |
1715 | 1700 | ||
1716 | - should 'has a empty list of followers by default' do | ||
1717 | - a = Article.new | ||
1718 | - assert_equal [], a.person_followers | ||
1719 | - end | ||
1720 | - | ||
1721 | should 'get first image from lead' do | 1701 | should 'get first image from lead' do |
1722 | a = fast_create(Article, :body => '<p>Foo</p><p><img src="bar.png" />Bar<img src="foo.png" /></p>', | 1702 | a = fast_create(Article, :body => '<p>Foo</p><p><img src="bar.png" />Bar<img src="foo.png" /></p>', |
1723 | :abstract => '<p>Lead</p><p><img src="leadbar.png" />Bar<img src="leadfoo.png" /></p>') | 1703 | :abstract => '<p>Lead</p><p><img src="leadbar.png" />Bar<img src="leadfoo.png" /></p>') |
@@ -2252,4 +2232,61 @@ class ArticleTest < ActiveSupport::TestCase | @@ -2252,4 +2232,61 @@ class ArticleTest < ActiveSupport::TestCase | ||
2252 | assert_equal "/#{a2.path}", a2.full_path | 2232 | assert_equal "/#{a2.path}", a2.full_path |
2253 | end | 2233 | end |
2254 | 2234 | ||
2235 | + should "increment followers count when a person follow an article" do | ||
2236 | + a = fast_create(Article) | ||
2237 | + p = fast_create(Person) | ||
2238 | + assert_difference "a.reload.followers_count" do | ||
2239 | + a.person_followers << p | ||
2240 | + end | ||
2241 | + end | ||
2242 | + | ||
2243 | + should "decrement followers count when a person unfollow an article" do | ||
2244 | + p = fast_create(Person) | ||
2245 | + a = fast_create(Article, :profile_id => p) | ||
2246 | + a.person_followers << p | ||
2247 | + assert_difference "a.reload.followers_count", -1 do | ||
2248 | + a.person_followers.destroy_all | ||
2249 | + end | ||
2250 | + end | ||
2251 | + | ||
2252 | + should 'the owner not in followers list' do | ||
2253 | + person1 = create_user('article_owner').person | ||
2254 | + person2 = create_user('article_follower').person | ||
2255 | + | ||
2256 | + article = fast_create(Article, :profile_id => person1.id) | ||
2257 | + | ||
2258 | + article.person_followers=[person2] | ||
2259 | + article.save | ||
2260 | + article.reload | ||
2261 | + article.person_followers=[person2] | ||
2262 | + article.save | ||
2263 | + | ||
2264 | + assert_equal [person2], article.reload.person_followers | ||
2265 | + end | ||
2266 | + | ||
2267 | + should 'has a empty list of followers by default' do | ||
2268 | + a = Article.new | ||
2269 | + assert_equal [], a.person_followers | ||
2270 | + end | ||
2271 | + | ||
2272 | + should 'a follower not be duplicated' do | ||
2273 | + follower = create_user('article_follower').person | ||
2274 | + | ||
2275 | + article = fast_create(Article, :profile_id => fast_create(Person)) | ||
2276 | + | ||
2277 | + article.person_followers<< follower | ||
2278 | + assert_raises (ActiveRecord::RecordNotUnique) { article.person_followers<< follower } | ||
2279 | + end | ||
2280 | + | ||
2281 | + should 'an article be follower by many users' do | ||
2282 | + article = fast_create(Article, :profile_id => fast_create(Person)) | ||
2283 | + | ||
2284 | + 1.upto(10).map do |n| | ||
2285 | + article.person_followers<< fast_create(Person) | ||
2286 | + end | ||
2287 | + article.save | ||
2288 | + assert_equal 10, article.reload.person_followers.count | ||
2289 | + end | ||
2290 | + | ||
2291 | + | ||
2255 | end | 2292 | end |
test/unit/blog_archives_block_test.rb
@@ -17,6 +17,69 @@ class BlogArchivesBlockTest < ActiveSupport::TestCase | @@ -17,6 +17,69 @@ class BlogArchivesBlockTest < ActiveSupport::TestCase | ||
17 | assert l.editable? | 17 | assert l.editable? |
18 | end | 18 | end |
19 | 19 | ||
20 | + should 'has field to configure blog' do | ||
21 | + b = BlogArchivesBlock.new | ||
22 | + assert b.respond_to?(:blog_id) | ||
23 | + assert b.respond_to?(:blog_id=) | ||
24 | + end | ||
25 | + | ||
26 | + should 'not try to load a removed blog' do | ||
27 | + block = fast_create(BlogArchivesBlock) | ||
28 | + block.blog_id = profile.blog.id | ||
29 | + block.save! | ||
30 | + block.stubs(:owner).returns(profile) | ||
31 | + profile.blog.destroy | ||
32 | + assert_nothing_raised do | ||
33 | + assert_nil block.blog | ||
34 | + end | ||
35 | + end | ||
36 | + | ||
37 | + should 'load next blog if configured blog was removed' do | ||
38 | + other_blog = fast_create(Blog, :profile_id => profile.id) | ||
39 | + block = fast_create(BlogArchivesBlock) | ||
40 | + block.blog_id = profile.blog.id | ||
41 | + block.save! | ||
42 | + block.stubs(:owner).returns(profile) | ||
43 | + profile.blog.destroy | ||
44 | + assert_nothing_raised do | ||
45 | + assert_equal other_blog, block.blog | ||
46 | + end | ||
47 | + end | ||
48 | + | ||
49 | +#FIXME Performance issues with display_to. Must convert it to a scope. | ||
50 | +# Checkout this page for further information: http://noosfero.org/Development/ActionItem2705 | ||
51 | +# | ||
52 | +# should 'not count articles if the user can\'t see them' do | ||
53 | +# person = create_user('testuser').person | ||
54 | +# blog = fast_create(Blog, :profile_id => profile.id, :path => 'blog_path') | ||
55 | +# block = fast_create(BlogArchivesBlock) | ||
56 | +# | ||
57 | +# feed = mock() | ||
58 | +# feed.stubs(:url).returns(blog.url) | ||
59 | +# blog.stubs(:feed).returns(feed) | ||
60 | +# block.stubs(:blog).returns(blog) | ||
61 | +# block.stubs(:owner).returns(profile) | ||
62 | +# | ||
63 | +# public_post = fast_create(TextileArticle, :profile_id => profile.id, :parent_id => blog.id, :published => true, :published_at => Time.mktime(2012, 'jan')) | ||
64 | +# private_post = fast_create(TextileArticle, :profile_id => profile.id, :parent_id => blog.id, :published => false, :published_at => Time.mktime(2012, 'jan')) | ||
65 | +# | ||
66 | +# assert_match /January \(1\)/, block.content({:person => person}) | ||
67 | +# assert_match /January \(1\)/, block.content() | ||
68 | +# assert_match /January \(2\)/, block.content({:person => profile}) | ||
69 | +# end | ||
70 | +end | ||
71 | + | ||
72 | +require 'boxes_helper' | ||
73 | + | ||
74 | +class BlogArchivesBlockViewTest < ActionView::TestCase | ||
75 | + include BoxesHelper | ||
76 | + | ||
77 | + def setup | ||
78 | + @profile = create_user('flatline').person | ||
79 | + @profile.articles << Blog.new(:name => 'Blog One', :profile => @profile) | ||
80 | + end | ||
81 | + attr_reader :profile | ||
82 | + | ||
20 | should 'list amount posts by year' do | 83 | should 'list amount posts by year' do |
21 | date = DateTime.parse('2008-01-10') | 84 | date = DateTime.parse('2008-01-10') |
22 | blog = profile.blog | 85 | blog = profile.blog |
@@ -26,7 +89,9 @@ class BlogArchivesBlockTest < ActiveSupport::TestCase | @@ -26,7 +89,9 @@ class BlogArchivesBlockTest < ActiveSupport::TestCase | ||
26 | end | 89 | end |
27 | block = BlogArchivesBlock.new | 90 | block = BlogArchivesBlock.new |
28 | block.stubs(:owner).returns(profile) | 91 | block.stubs(:owner).returns(profile) |
29 | - assert_tag_in_string block.content, :tag => 'li', :content => '2008 (10)' | 92 | + ActionView::Base.any_instance.stubs(:block_title).returns("") |
93 | + ActionView::Base.any_instance.stubs(:month_name).returns("") | ||
94 | + assert_tag_in_string render_block_content(block), :tag => 'li', :content => '2008 (10)' | ||
30 | end | 95 | end |
31 | 96 | ||
32 | should 'list amount posts by month' do | 97 | should 'list amount posts by month' do |
@@ -38,7 +103,18 @@ class BlogArchivesBlockTest < ActiveSupport::TestCase | @@ -38,7 +103,18 @@ class BlogArchivesBlockTest < ActiveSupport::TestCase | ||
38 | end | 103 | end |
39 | block = BlogArchivesBlock.new | 104 | block = BlogArchivesBlock.new |
40 | block.stubs(:owner).returns(profile) | 105 | block.stubs(:owner).returns(profile) |
41 | - assert_tag_in_string block.content, :tag => 'a', :content => 'January (10)', :attributes => {:href => /^http:\/\/.*\/flatline\/blog-one\?month=1&year=2008$/ } | 106 | + ActionView::Base.any_instance.stubs(:block_title).returns("") |
107 | + ActionView::Base.any_instance.stubs(:month_name).with(1).returns("January") | ||
108 | + ActionView::Base.any_instance.stubs(:month_name).with(2).returns("February") | ||
109 | + ActionView::Base.any_instance.stubs(:month_name).with(3).returns("March") | ||
110 | + ActionView::Base.any_instance.stubs(:month_name).with(4).returns("April") | ||
111 | + ActionView::Base.any_instance.stubs(:month_name).with(5).returns("May") | ||
112 | + ActionView::Base.any_instance.stubs(:month_name).with(6).returns("June") | ||
113 | + ActionView::Base.any_instance.stubs(:month_name).with(7).returns("July") | ||
114 | + ActionView::Base.any_instance.stubs(:month_name).with(8).returns("August") | ||
115 | + ActionView::Base.any_instance.stubs(:month_name).with(9).returns("September") | ||
116 | + ActionView::Base.any_instance.stubs(:month_name).with(10).returns("Octuber") | ||
117 | + assert_tag_in_string render_block_content(block), :tag => 'a', :content => 'January (10)', :attributes => {:href => /^http:\/\/.*\/flatline\/blog-one\?month=1&year=2008$/ } | ||
42 | end | 118 | end |
43 | 119 | ||
44 | should 'order list of amount posts' do | 120 | should 'order list of amount posts' do |
@@ -49,7 +125,18 @@ class BlogArchivesBlockTest < ActiveSupport::TestCase | @@ -49,7 +125,18 @@ class BlogArchivesBlockTest < ActiveSupport::TestCase | ||
49 | end | 125 | end |
50 | block = BlogArchivesBlock.new | 126 | block = BlogArchivesBlock.new |
51 | block.stubs(:owner).returns(profile) | 127 | block.stubs(:owner).returns(profile) |
52 | - assert_tag_in_string block.content, :tag => 'li', :content => 'January (1)', | 128 | + ActionView::Base.any_instance.stubs(:block_title).returns("") |
129 | + ActionView::Base.any_instance.stubs(:month_name).with(1).returns("January") | ||
130 | + ActionView::Base.any_instance.stubs(:month_name).with(2).returns("February") | ||
131 | + ActionView::Base.any_instance.stubs(:month_name).with(3).returns("March") | ||
132 | + ActionView::Base.any_instance.stubs(:month_name).with(4).returns("April") | ||
133 | + ActionView::Base.any_instance.stubs(:month_name).with(5).returns("May") | ||
134 | + ActionView::Base.any_instance.stubs(:month_name).with(6).returns("June") | ||
135 | + ActionView::Base.any_instance.stubs(:month_name).with(7).returns("July") | ||
136 | + ActionView::Base.any_instance.stubs(:month_name).with(8).returns("August") | ||
137 | + ActionView::Base.any_instance.stubs(:month_name).with(9).returns("September") | ||
138 | + ActionView::Base.any_instance.stubs(:month_name).with(10).returns("Octuber") | ||
139 | + assert_tag_in_string render_block_content(block), :tag => 'li', :content => 'January (1)', | ||
53 | :sibling => {:tag => 'li', :content => 'February (1)', | 140 | :sibling => {:tag => 'li', :content => 'February (1)', |
54 | :sibling => {:tag => 'li', :content => 'March (1)', | 141 | :sibling => {:tag => 'li', :content => 'March (1)', |
55 | :sibling => {:tag => 'li', :content => 'April (1)', | 142 | :sibling => {:tag => 'li', :content => 'April (1)', |
@@ -63,7 +150,9 @@ class BlogArchivesBlockTest < ActiveSupport::TestCase | @@ -63,7 +150,9 @@ class BlogArchivesBlockTest < ActiveSupport::TestCase | ||
63 | end | 150 | end |
64 | block = BlogArchivesBlock.new | 151 | block = BlogArchivesBlock.new |
65 | block.stubs(:owner).returns(profile) | 152 | block.stubs(:owner).returns(profile) |
66 | - assert_match(/2009.*2008.*2007.*2006.*2005/m, block.content) | 153 | + ActionView::Base.any_instance.stubs(:block_title).returns("") |
154 | + ActionView::Base.any_instance.stubs(:month_name).returns("") | ||
155 | + assert_match(/2009.*2008.*2007.*2006.*2005/m, render_block_content(block)) | ||
67 | end | 156 | end |
68 | 157 | ||
69 | should 'order months from later to former' do | 158 | should 'order months from later to former' do |
@@ -73,20 +162,20 @@ class BlogArchivesBlockTest < ActiveSupport::TestCase | @@ -73,20 +162,20 @@ class BlogArchivesBlockTest < ActiveSupport::TestCase | ||
73 | end | 162 | end |
74 | block = BlogArchivesBlock.new | 163 | block = BlogArchivesBlock.new |
75 | block.stubs(:owner).returns(profile) | 164 | block.stubs(:owner).returns(profile) |
76 | - assert_match(/.*March.*February.*January.*/m, block.content) | 165 | + ActionView::Base.any_instance.stubs(:block_title).returns("") |
166 | + ActionView::Base.any_instance.stubs(:month_name).with(1).returns("January") | ||
167 | + ActionView::Base.any_instance.stubs(:month_name).with(2).returns("February") | ||
168 | + ActionView::Base.any_instance.stubs(:month_name).with(3).returns("March") | ||
169 | + assert_match(/.*March.*February.*January.*/m, render_block_content(block)) | ||
77 | end | 170 | end |
78 | 171 | ||
79 | should 'not display any content if has no blog' do | 172 | should 'not display any content if has no blog' do |
80 | profile.blogs.destroy_all | 173 | profile.blogs.destroy_all |
81 | block = BlogArchivesBlock.new | 174 | block = BlogArchivesBlock.new |
82 | block.stubs(:owner).returns(profile) | 175 | block.stubs(:owner).returns(profile) |
83 | - assert_nil block.content | ||
84 | - end | ||
85 | - | ||
86 | - should 'has field to configure blog' do | ||
87 | - b = BlogArchivesBlock.new | ||
88 | - assert b.respond_to?(:blog_id) | ||
89 | - assert b.respond_to?(:blog_id=) | 176 | + ActionView::Base.any_instance.stubs(:block_title).returns("") |
177 | + ActionView::Base.any_instance.stubs(:month_name).returns("") | ||
178 | + assert_empty render_block_content(block) | ||
90 | end | 179 | end |
91 | 180 | ||
92 | should 'show posts from first blog' do | 181 | should 'show posts from first blog' do |
@@ -98,8 +187,10 @@ class BlogArchivesBlockTest < ActiveSupport::TestCase | @@ -98,8 +187,10 @@ class BlogArchivesBlockTest < ActiveSupport::TestCase | ||
98 | end | 187 | end |
99 | block = BlogArchivesBlock.new | 188 | block = BlogArchivesBlock.new |
100 | block.stubs(:owner).returns(profile) | 189 | block.stubs(:owner).returns(profile) |
101 | - assert_match(/blog-one/m, block.content) | ||
102 | - assert_no_match(/blog-two/m, block.content) | 190 | + ActionView::Base.any_instance.stubs(:block_title).returns("") |
191 | + ActionView::Base.any_instance.stubs(:month_name).returns("") | ||
192 | + assert_match(/blog-one/m, render_block_content(block)) | ||
193 | + assert_no_match(/blog-two/m, render_block_content(block)) | ||
103 | end | 194 | end |
104 | 195 | ||
105 | should 'list amount native posts by year' do | 196 | should 'list amount native posts by year' do |
@@ -115,7 +206,9 @@ class BlogArchivesBlockTest < ActiveSupport::TestCase | @@ -115,7 +206,9 @@ class BlogArchivesBlockTest < ActiveSupport::TestCase | ||
115 | end | 206 | end |
116 | block = BlogArchivesBlock.new | 207 | block = BlogArchivesBlock.new |
117 | block.stubs(:owner).returns(profile) | 208 | block.stubs(:owner).returns(profile) |
118 | - assert_tag_in_string block.content, :tag => 'li', :content => '2008 (2)' | 209 | + ActionView::Base.any_instance.stubs(:block_title).returns("") |
210 | + ActionView::Base.any_instance.stubs(:month_name).returns("") | ||
211 | + assert_tag_in_string render_block_content(block), :tag => 'li', :content => '2008 (2)' | ||
119 | end | 212 | end |
120 | 213 | ||
121 | should 'list amount native posts by month' do | 214 | should 'list amount native posts by month' do |
@@ -131,51 +224,8 @@ class BlogArchivesBlockTest < ActiveSupport::TestCase | @@ -131,51 +224,8 @@ class BlogArchivesBlockTest < ActiveSupport::TestCase | ||
131 | end | 224 | end |
132 | block = BlogArchivesBlock.new | 225 | block = BlogArchivesBlock.new |
133 | block.stubs(:owner).returns(profile) | 226 | block.stubs(:owner).returns(profile) |
134 | - assert_tag_in_string block.content, :tag => 'a', :content => 'January (2)', :attributes => {:href => /^http:\/\/.*\/flatline\/blog-one\?month=1&year=2008$/ } | ||
135 | - end | ||
136 | - | ||
137 | - should 'not try to load a removed blog' do | ||
138 | - block = fast_create(BlogArchivesBlock) | ||
139 | - block.blog_id = profile.blog.id | ||
140 | - block.save! | ||
141 | - block.stubs(:owner).returns(profile) | ||
142 | - profile.blog.destroy | ||
143 | - assert_nothing_raised do | ||
144 | - assert_nil block.blog | ||
145 | - end | 227 | + ActionView::Base.any_instance.stubs(:block_title).returns("") |
228 | + ActionView::Base.any_instance.stubs(:month_name).with(1).returns("January") | ||
229 | + assert_tag_in_string render_block_content(block), :tag => 'a', :content => 'January (2)', :attributes => {:href => /^http:\/\/.*\/flatline\/blog-one\?month=1&year=2008$/ } | ||
146 | end | 230 | end |
147 | - | ||
148 | - should 'load next blog if configured blog was removed' do | ||
149 | - other_blog = fast_create(Blog, :profile_id => profile.id) | ||
150 | - block = fast_create(BlogArchivesBlock) | ||
151 | - block.blog_id = profile.blog.id | ||
152 | - block.save! | ||
153 | - block.stubs(:owner).returns(profile) | ||
154 | - profile.blog.destroy | ||
155 | - assert_nothing_raised do | ||
156 | - assert_equal other_blog, block.blog | ||
157 | - end | ||
158 | - end | ||
159 | - | ||
160 | -#FIXME Performance issues with display_to. Must convert it to a scope. | ||
161 | -# Checkout this page for further information: http://noosfero.org/Development/ActionItem2705 | ||
162 | -# | ||
163 | -# should 'not count articles if the user can\'t see them' do | ||
164 | -# person = create_user('testuser').person | ||
165 | -# blog = fast_create(Blog, :profile_id => profile.id, :path => 'blog_path') | ||
166 | -# block = fast_create(BlogArchivesBlock) | ||
167 | -# | ||
168 | -# feed = mock() | ||
169 | -# feed.stubs(:url).returns(blog.url) | ||
170 | -# blog.stubs(:feed).returns(feed) | ||
171 | -# block.stubs(:blog).returns(blog) | ||
172 | -# block.stubs(:owner).returns(profile) | ||
173 | -# | ||
174 | -# public_post = fast_create(TextileArticle, :profile_id => profile.id, :parent_id => blog.id, :published => true, :published_at => Time.mktime(2012, 'jan')) | ||
175 | -# private_post = fast_create(TextileArticle, :profile_id => profile.id, :parent_id => blog.id, :published => false, :published_at => Time.mktime(2012, 'jan')) | ||
176 | -# | ||
177 | -# assert_match /January \(1\)/, block.content({:person => person}) | ||
178 | -# assert_match /January \(1\)/, block.content() | ||
179 | -# assert_match /January \(2\)/, block.content({:person => profile}) | ||
180 | -# end | ||
181 | end | 231 | end |
test/unit/blog_test.rb
@@ -266,4 +266,23 @@ class BlogTest < ActiveSupport::TestCase | @@ -266,4 +266,23 @@ class BlogTest < ActiveSupport::TestCase | ||
266 | 266 | ||
267 | assert_equal blog.image(true).filename, 'noosfero-network.png' | 267 | assert_equal blog.image(true).filename, 'noosfero-network.png' |
268 | end | 268 | end |
269 | + | ||
270 | + should 'count total number of posts by year' do | ||
271 | + p = create_user('testuser').person | ||
272 | + blog = fast_create(Blog, :profile_id => p.id, :name => 'Blog test') | ||
273 | + create(TextileArticle, :name => 'Post 1', :parent => blog, :profile => p, :published_at => DateTime.parse('16-08-2010')) | ||
274 | + create(TextileArticle, :name => 'Post 2', :parent => blog, :profile => p, :published_at => DateTime.parse('17-08-2010')) | ||
275 | + create(TextileArticle, :name => 'Post 3', :parent => blog, :profile => p, :published_at => DateTime.parse('10-05-2012')) | ||
276 | + assert_equal [[2012.0, 1], [2010.0, 2]], blog.total_number_of_posts(:by_year) | ||
277 | + end | ||
278 | + | ||
279 | + should 'count total number of posts by month' do | ||
280 | + p = create_user('testuser').person | ||
281 | + blog = fast_create(Blog, :profile_id => p.id, :name => 'Blog test') | ||
282 | + create(TextileArticle, :name => 'Post 1', :parent => blog, :profile => p, :published_at => DateTime.parse('16-08-2010')) | ||
283 | + create(TextileArticle, :name => 'Post 2', :parent => blog, :profile => p, :published_at => DateTime.parse('17-08-2010')) | ||
284 | + create(TextileArticle, :name => 'Post 3', :parent => blog, :profile => p, :published_at => DateTime.parse('11-10-2010')) | ||
285 | + assert_equal [[10.0, 1], [8.0, 2]], blog.total_number_of_posts(:by_month, 2010) | ||
286 | + end | ||
287 | + | ||
269 | end | 288 | end |
@@ -0,0 +1,11 @@ | @@ -0,0 +1,11 @@ | ||
1 | +# encoding: UTF-8 | ||
2 | +require_relative "../test_helper" | ||
3 | + | ||
4 | +class ButtonsHelperTest < ActionView::TestCase | ||
5 | + include ButtonsHelper | ||
6 | + | ||
7 | + should 'append with-text class and keep existing classes' do | ||
8 | + expects(:button_without_text).with('type', 'label', 'url', { :class => 'with-text class1'}) | ||
9 | + button('type', 'label', 'url', { :class => 'class1' }) | ||
10 | + end | ||
11 | +end | ||
0 | \ No newline at end of file | 12 | \ No newline at end of file |
test/unit/categories_block_test.rb
@@ -17,11 +17,13 @@ class CategoriesBlockTest < ActiveSupport::TestCase | @@ -17,11 +17,13 @@ class CategoriesBlockTest < ActiveSupport::TestCase | ||
17 | assert_not_nil category_block.help | 17 | assert_not_nil category_block.help |
18 | end | 18 | end |
19 | 19 | ||
20 | + include BoxesHelper | ||
21 | + | ||
20 | should 'display category block' do | 22 | should 'display category block' do |
21 | block = CategoriesBlock.new | 23 | block = CategoriesBlock.new |
22 | 24 | ||
23 | - self.expects(:render).with(:file => 'blocks/categories', :locals => { :block => block}) | ||
24 | - instance_eval(& block.content) | 25 | + self.expects(:render).with(template: 'blocks/categories', locals: {block: block}) |
26 | + render_block_content(block) | ||
25 | end | 27 | end |
26 | 28 | ||
27 | should 'be editable' do | 29 | should 'be editable' do |
test/unit/communities_block_test.rb
@@ -27,14 +27,44 @@ class CommunitiesBlockTest < ActiveSupport::TestCase | @@ -27,14 +27,44 @@ class CommunitiesBlockTest < ActiveSupport::TestCase | ||
27 | assert_same list, block.profiles | 27 | assert_same list, block.profiles |
28 | end | 28 | end |
29 | 29 | ||
30 | + should 'list non-public communities' do | ||
31 | + user = create_user('testuser').person | ||
32 | + | ||
33 | + public_community = fast_create(Community, :environment_id => Environment.default.id) | ||
34 | + public_community.add_member(user) | ||
35 | + | ||
36 | + private_community = fast_create(Community, :environment_id => Environment.default.id, :public_profile => false) | ||
37 | + private_community.add_member(user) | ||
38 | + | ||
39 | + block = CommunitiesBlock.new | ||
40 | + block.expects(:owner).at_least_once.returns(user) | ||
41 | + | ||
42 | + assert_equivalent [public_community, private_community], block.profiles | ||
43 | + end | ||
44 | + | ||
45 | +end | ||
46 | + | ||
47 | +require 'boxes_helper' | ||
48 | + | ||
49 | +class CommunitiesBlockViewTest < ActionView::TestCase | ||
50 | + include BoxesHelper | ||
51 | + | ||
30 | should 'support profile as block owner' do | 52 | should 'support profile as block owner' do |
31 | profile = Profile.new | 53 | profile = Profile.new |
54 | + profile.identifier = 42 | ||
55 | + | ||
56 | + ActionView::Base.any_instance.stubs(:user).with(anything).returns(profile) | ||
57 | + ActionView::Base.any_instance.stubs(:profile).with(anything).returns(profile) | ||
32 | 58 | ||
33 | block = CommunitiesBlock.new | 59 | block = CommunitiesBlock.new |
34 | block.expects(:owner).returns(profile).at_least_once | 60 | block.expects(:owner).returns(profile).at_least_once |
35 | 61 | ||
36 | - self.expects(:render).with(:file => 'blocks/communities', :locals => { :owner => profile, :suggestions => block.suggestions }) | ||
37 | - instance_eval(&block.footer) | 62 | + footer = render_block_footer(block) |
63 | + | ||
64 | + assert_tag_in_string footer, tag: 'a', attributes: {href: '/profile/42/communities'} | ||
65 | + | ||
66 | + ActionView::Base.any_instance.unstub(:user) | ||
67 | + ActionView::Base.any_instance.unstub(:profile) | ||
38 | end | 68 | end |
39 | 69 | ||
40 | should 'support environment as block owner' do | 70 | should 'support environment as block owner' do |
@@ -42,31 +72,24 @@ class CommunitiesBlockTest < ActiveSupport::TestCase | @@ -42,31 +72,24 @@ class CommunitiesBlockTest < ActiveSupport::TestCase | ||
42 | block = CommunitiesBlock.new | 72 | block = CommunitiesBlock.new |
43 | block.expects(:owner).returns(env).at_least_once | 73 | block.expects(:owner).returns(env).at_least_once |
44 | 74 | ||
45 | - self.expects(:render).with(:file => 'blocks/communities', :locals => { :owner => env, :suggestions => block.suggestions }) | ||
46 | - instance_eval(&block.footer) | ||
47 | - end | ||
48 | - | ||
49 | - should 'give empty footer on unsupported owner type' do | ||
50 | - block = CommunitiesBlock.new | ||
51 | - block.expects(:owner).returns(1).at_least_once | 75 | + profile = Profile.new |
76 | + profile.identifier = 42 | ||
52 | 77 | ||
53 | - self.expects(:render).with(anything).never | ||
54 | - assert_equal '', block.footer | ||
55 | - end | 78 | + ActionView::Base.any_instance.stubs(:user).with(anything).returns(profile) |
79 | + ActionView::Base.any_instance.stubs(:profile).with(anything).returns(profile) | ||
56 | 80 | ||
57 | - should 'list non-public communities' do | ||
58 | - user = create_user('testuser').person | 81 | + footer = render_block_footer(block) |
59 | 82 | ||
60 | - public_community = fast_create(Community, :environment_id => Environment.default.id) | ||
61 | - public_community.add_member(user) | 83 | + assert_tag_in_string footer, tag: 'a', attributes: {href: '/search/communities'} |
62 | 84 | ||
63 | - private_community = fast_create(Community, :environment_id => Environment.default.id, :public_profile => false) | ||
64 | - private_community.add_member(user) | 85 | + ActionView::Base.any_instance.unstub(:user) |
86 | + ActionView::Base.any_instance.unstub(:profile) | ||
87 | + end | ||
65 | 88 | ||
89 | + should 'give empty footer on unsupported owner type' do | ||
66 | block = CommunitiesBlock.new | 90 | block = CommunitiesBlock.new |
67 | - block.expects(:owner).at_least_once.returns(user) | 91 | + block.expects(:owner).returns(1).at_least_once |
68 | 92 | ||
69 | - assert_equivalent [public_community, private_community], block.profiles | 93 | + assert_equal '', render_block_footer(block) |
70 | end | 94 | end |
71 | - | ||
72 | end | 95 | end |
test/unit/community_test.rb
@@ -3,7 +3,8 @@ require_relative "../test_helper" | @@ -3,7 +3,8 @@ require_relative "../test_helper" | ||
3 | class CommunityTest < ActiveSupport::TestCase | 3 | class CommunityTest < ActiveSupport::TestCase |
4 | 4 | ||
5 | def setup | 5 | def setup |
6 | - @person = fast_create(Person) | 6 | + @user = User.current = create_user |
7 | + @person = @user.person | ||
7 | end | 8 | end |
8 | 9 | ||
9 | attr_reader :person | 10 | attr_reader :person |
@@ -287,8 +288,8 @@ class CommunityTest < ActiveSupport::TestCase | @@ -287,8 +288,8 @@ class CommunityTest < ActiveSupport::TestCase | ||
287 | 288 | ||
288 | should "update the action of article creation when an community's article is commented" do | 289 | should "update the action of article creation when an community's article is commented" do |
289 | ActionTrackerNotification.delete_all | 290 | ActionTrackerNotification.delete_all |
290 | - p1 = Person.first | ||
291 | community = fast_create(Community) | 291 | community = fast_create(Community) |
292 | + p1 = person | ||
292 | p2 = create_user.person | 293 | p2 = create_user.person |
293 | p3 = create_user.person | 294 | p3 = create_user.person |
294 | community.add_member(p3) | 295 | community.add_member(p3) |
test/unit/disabled_enterprise_message_block_test.rb
@@ -6,16 +6,30 @@ class DisabledEnterpriseMessageBlockTest < ActiveSupport::TestCase | @@ -6,16 +6,30 @@ class DisabledEnterpriseMessageBlockTest < ActiveSupport::TestCase | ||
6 | assert_not_equal Block.description, DisabledEnterpriseMessageBlock.description | 6 | assert_not_equal Block.description, DisabledEnterpriseMessageBlock.description |
7 | end | 7 | end |
8 | 8 | ||
9 | + include BoxesHelper | ||
10 | + | ||
9 | should 'display message for disabled enterprise' do | 11 | should 'display message for disabled enterprise' do |
10 | - e = Environment.default | ||
11 | - e.expects(:message_for_disabled_enterprise).returns('This message is for disabled enterprises') | ||
12 | - block = DisabledEnterpriseMessageBlock.new | ||
13 | - p = Profile.new | ||
14 | - block.expects(:owner).returns(p) | ||
15 | - p.expects(:environment).returns(e) | ||
16 | - | ||
17 | - expects(:render).with(:file => 'blocks/disabled_enterprise_message', :locals => { :message => 'This message is for disabled enterprises'}) | ||
18 | - instance_eval(&block.content) | 12 | + environment = Environment.default |
13 | + environment.message_for_disabled_enterprise = 'This message is for disabled enterprises' | ||
14 | + environment.save | ||
15 | + | ||
16 | + enterprise = fast_create(Enterprise, :identifier => 'disabled-enterprise', :environment_id => environment.id) | ||
17 | + enterprise.boxes << Box.new | ||
18 | + enterprise.boxes.first.blocks << DisabledEnterpriseMessageBlock.new | ||
19 | + block = enterprise.boxes.first.blocks.first | ||
20 | + | ||
21 | + ApplicationHelper.class_eval do | ||
22 | + alias_method :original_profile, :profile | ||
23 | + def profile | ||
24 | + return Enterprise['disabled-enterprise'] | ||
25 | + end | ||
26 | + end | ||
27 | + | ||
28 | + assert_match 'This message is for disabled enterprises', render_block_content(block) | ||
29 | + | ||
30 | + ApplicationHelper.class_eval do | ||
31 | + alias_method :profile, :original_profile | ||
32 | + end | ||
19 | end | 33 | end |
20 | 34 | ||
21 | should 'not be editable' do | 35 | should 'not be editable' do |
test/unit/enterprises_block_test.rb
@@ -27,32 +27,6 @@ class EnterprisesBlockTest < ActiveSupport::TestCase | @@ -27,32 +27,6 @@ class EnterprisesBlockTest < ActiveSupport::TestCase | ||
27 | assert_same list, block.profiles | 27 | assert_same list, block.profiles |
28 | end | 28 | end |
29 | 29 | ||
30 | - should 'link to all enterprises for profile' do | ||
31 | - profile = Profile.new | ||
32 | - profile.expects(:identifier).returns('theprofile') | ||
33 | - block = EnterprisesBlock.new | ||
34 | - block.expects(:owner).returns(profile) | ||
35 | - | ||
36 | - expects(:link_to).with('View all', :controller => 'profile', :profile => 'theprofile', :action => 'enterprises') | ||
37 | - | ||
38 | - instance_eval(&block.footer) | ||
39 | - end | ||
40 | - | ||
41 | - should 'link to all enterprises for environment' do | ||
42 | - env = Environment.default | ||
43 | - block = EnterprisesBlock.new | ||
44 | - block.expects(:owner).returns(env) | ||
45 | - | ||
46 | - expects(:link_to).with('View all', :controller => 'search', :action => 'assets', :asset => 'enterprises') | ||
47 | - instance_eval(&block.footer) | ||
48 | - end | ||
49 | - | ||
50 | - should 'give empty footer for unsupported owner type' do | ||
51 | - block = EnterprisesBlock.new | ||
52 | - block.expects(:owner).returns(1) | ||
53 | - assert_equal '', block.footer | ||
54 | - end | ||
55 | - | ||
56 | should 'count number of owner enterprises' do | 30 | should 'count number of owner enterprises' do |
57 | user = create_user('testuser').person | 31 | user = create_user('testuser').person |
58 | 32 | ||
@@ -71,3 +45,35 @@ class EnterprisesBlockTest < ActiveSupport::TestCase | @@ -71,3 +45,35 @@ class EnterprisesBlockTest < ActiveSupport::TestCase | ||
71 | end | 45 | end |
72 | 46 | ||
73 | end | 47 | end |
48 | + | ||
49 | +require 'boxes_helper' | ||
50 | + | ||
51 | +class EnterprisesBlockViewTest < ActionView::TestCase | ||
52 | + include BoxesHelper | ||
53 | + | ||
54 | + should 'link to all enterprises for profile' do | ||
55 | + profile = Profile.new | ||
56 | + profile.identifier = 'theprofile' | ||
57 | + block = EnterprisesBlock.new | ||
58 | + block.expects(:owner).twice.returns(profile) | ||
59 | + | ||
60 | + ActionView::Base.any_instance.expects(:link_to).with('View all', :controller => 'profile', :profile => 'theprofile', :action => 'enterprises') | ||
61 | + | ||
62 | + render_block_footer(block) | ||
63 | + end | ||
64 | + | ||
65 | + should 'link to all enterprises for environment' do | ||
66 | + env = Environment.default | ||
67 | + block = EnterprisesBlock.new | ||
68 | + block.expects(:owner).twice.returns(env) | ||
69 | + | ||
70 | + ActionView::Base.any_instance.expects(:link_to).with('View all', :controller => 'search', :action => 'assets', :asset => 'enterprises') | ||
71 | + render_block_footer(block) | ||
72 | + end | ||
73 | + | ||
74 | + should 'give empty footer for unsupported owner type' do | ||
75 | + block = EnterprisesBlock.new | ||
76 | + block.expects(:owner).twice.returns(1) | ||
77 | + assert_equal '', render_block_footer(block) | ||
78 | + end | ||
79 | +end |
test/unit/featured_products_block_test.rb
1 | require_relative "../test_helper" | 1 | require_relative "../test_helper" |
2 | +require 'boxes_helper' | ||
2 | 3 | ||
3 | class FeaturedProductsBlockTest < ActiveSupport::TestCase | 4 | class FeaturedProductsBlockTest < ActiveSupport::TestCase |
5 | + include BoxesHelper | ||
4 | 6 | ||
5 | def setup | 7 | def setup |
6 | @profile = fast_create(Profile) | 8 | @profile = fast_create(Profile) |
@@ -107,8 +109,8 @@ class FeaturedProductsBlockTest < ActiveSupport::TestCase | @@ -107,8 +109,8 @@ class FeaturedProductsBlockTest < ActiveSupport::TestCase | ||
107 | should 'display feature products block' do | 109 | should 'display feature products block' do |
108 | block = FeaturedProductsBlock.new | 110 | block = FeaturedProductsBlock.new |
109 | 111 | ||
110 | - self.expects(:render).with(:file => 'blocks/featured_products', :locals => { :block => block}) | ||
111 | - instance_eval(& block.content) | 112 | + self.expects(:render).with(template: 'blocks/featured_products', locals: {block: block}) |
113 | + render_block_content(block) | ||
112 | end | 114 | end |
113 | 115 | ||
114 | should "return just highlighted products with image for selection" do | 116 | should "return just highlighted products with image for selection" do |
test/unit/feed_reader_block_test.rb
@@ -26,19 +26,6 @@ class FeedReaderBlockTest < ActiveSupport::TestCase | @@ -26,19 +26,6 @@ class FeedReaderBlockTest < ActiveSupport::TestCase | ||
26 | assert feed.editable? | 26 | assert feed.editable? |
27 | end | 27 | end |
28 | 28 | ||
29 | - should 'display feed posts from content' do | ||
30 | - feed.feed_items = [] | ||
31 | - %w[ last-post second-post first-post ].each do |i| | ||
32 | - feed.feed_items << {:title => i, :link => "http://localhost/#{i}"} | ||
33 | - end | ||
34 | - feed.feed_title = 'Feed for unit tests' | ||
35 | - feed_content = feed.content | ||
36 | - assert_tag_in_string feed_content, :tag => 'h3', :content => 'Feed for unit tests' | ||
37 | - assert_tag_in_string feed_content, :tag => 'a', :attributes => { :href => 'http://localhost/last-post' }, :content => 'last-post' | ||
38 | - assert_tag_in_string feed_content, :tag => 'a', :attributes => { :href => 'http://localhost/second-post' }, :content => 'second-post' | ||
39 | - assert_tag_in_string feed_content, :tag => 'a', :attributes => { :href => 'http://localhost/first-post' }, :content => 'first-post' | ||
40 | - end | ||
41 | - | ||
42 | should 'display channel title as title by default' do | 29 | should 'display channel title as title by default' do |
43 | feed.feed_title = 'Feed for unit tests' | 30 | feed.feed_title = 'Feed for unit tests' |
44 | assert_equal 'Feed for unit tests', feed.title | 31 | assert_equal 'Feed for unit tests', feed.title |
@@ -48,17 +35,6 @@ class FeedReaderBlockTest < ActiveSupport::TestCase | @@ -48,17 +35,6 @@ class FeedReaderBlockTest < ActiveSupport::TestCase | ||
48 | assert_equal 'Feed Reader', feed.title | 35 | assert_equal 'Feed Reader', feed.title |
49 | end | 36 | end |
50 | 37 | ||
51 | - should 'notice when content not fetched yet' do | ||
52 | - assert_equal'Feed content was not loaded yet', feed.footer | ||
53 | - end | ||
54 | - | ||
55 | - should 'display last fetched date' do | ||
56 | - now = Time.new(2014,1,1) | ||
57 | - feed.feed_items = ['one', 'two'] | ||
58 | - feed.fetched_at = now | ||
59 | - assert_equal "Updated: #{show_date(now)}", feed.footer | ||
60 | - end | ||
61 | - | ||
62 | should 'clear feed title and items' do | 38 | should 'clear feed title and items' do |
63 | feed.feed_items = %w[ last-post second-post first-post ] | 39 | feed.feed_items = %w[ last-post second-post first-post ] |
64 | feed.feed_title = 'Feed Test' | 40 | feed.feed_title = 'Feed Test' |
@@ -90,26 +66,10 @@ class FeedReaderBlockTest < ActiveSupport::TestCase | @@ -90,26 +66,10 @@ class FeedReaderBlockTest < ActiveSupport::TestCase | ||
90 | assert_equal %w[ last-post second-post first-post ], feed.feed_items.map{|i|i[:title]} | 66 | assert_equal %w[ last-post second-post first-post ], feed.feed_items.map{|i|i[:title]} |
91 | end | 67 | end |
92 | 68 | ||
93 | - should 'display only limit posts' do | ||
94 | - feed.limit = 1; feed.save! | ||
95 | - %w[ first-post second-post ].each do |i| | ||
96 | - feed.add_item(i, "http://localhost/#{i}", Date.today, "some contet for #{i}") | ||
97 | - end | ||
98 | - | ||
99 | - assert_tag_in_string feed.formatted_feed_content, :tag => 'a', :attributes => { :href => 'http://localhost/second-post' }, :content => 'second-post' | ||
100 | - assert_no_tag_in_string feed.formatted_feed_content, :tag => 'a', :attributes => { :href => 'http://localhost/first-post' }, :content => 'first-post' | ||
101 | - end | ||
102 | - | ||
103 | should 'have empty error message by default' do | 69 | should 'have empty error message by default' do |
104 | assert FeedReaderBlock.new.error_message.blank?, 'new feed reader block expected to have empty error message' | 70 | assert FeedReaderBlock.new.error_message.blank?, 'new feed reader block expected to have empty error message' |
105 | end | 71 | end |
106 | 72 | ||
107 | - should "display error message as content when it's the case" do | ||
108 | - msg = "there was a problem" | ||
109 | - feed.error_message = msg | ||
110 | - assert_match(msg, feed.content) | ||
111 | - end | ||
112 | - | ||
113 | should 'expire after a period' do | 73 | should 'expire after a period' do |
114 | # save current time | 74 | # save current time |
115 | now = Time.now | 75 | now = Time.now |
@@ -195,3 +155,67 @@ class FeedReaderBlockTest < ActiveSupport::TestCase | @@ -195,3 +155,67 @@ class FeedReaderBlockTest < ActiveSupport::TestCase | ||
195 | end | 155 | end |
196 | 156 | ||
197 | end | 157 | end |
158 | + | ||
159 | +require 'boxes_helper' | ||
160 | +require 'block_helper' | ||
161 | +require 'dates_helper' | ||
162 | + | ||
163 | +class FeedReaderBlockViewTest < ActionView::TestCase | ||
164 | + include BoxesHelper | ||
165 | + include DatesHelper | ||
166 | + | ||
167 | + ActionView::Base.send :include, BlockHelper | ||
168 | + ActionView::Base.send :include, DatesHelper | ||
169 | + | ||
170 | + def setup | ||
171 | + @feed = create(:feed_reader_block) | ||
172 | + end | ||
173 | + attr_reader :feed | ||
174 | + | ||
175 | + should "display error message as content when it's the case" do | ||
176 | + msg = "there was a problem" | ||
177 | + feed.error_message = msg | ||
178 | + | ||
179 | + ActionView::Base.any_instance.stubs(:block_title).returns("") | ||
180 | + | ||
181 | + assert_match(msg, render_block_content(feed)) | ||
182 | + end | ||
183 | + | ||
184 | + should 'display feed posts from content' do | ||
185 | + feed.feed_items = [] | ||
186 | + %w[ last-post second-post first-post ].each do |i| | ||
187 | + feed.feed_items << {:title => i, :link => "http://localhost/#{i}"} | ||
188 | + end | ||
189 | + feed.feed_title = 'Feed for unit tests' | ||
190 | + | ||
191 | + feed_content = render_block_content(feed) | ||
192 | + | ||
193 | + assert_tag_in_string feed_content, :tag => 'h3', :content => 'Feed for unit tests' | ||
194 | + assert_tag_in_string feed_content, :tag => 'a', :attributes => { :href => 'http://localhost/last-post' }, :content => 'last-post' | ||
195 | + assert_tag_in_string feed_content, :tag => 'a', :attributes => { :href => 'http://localhost/second-post' }, :content => 'second-post' | ||
196 | + assert_tag_in_string feed_content, :tag => 'a', :attributes => { :href => 'http://localhost/first-post' }, :content => 'first-post' | ||
197 | + end | ||
198 | + | ||
199 | + should 'display only limit posts' do | ||
200 | + feed.limit = 1; feed.save! | ||
201 | + %w[ first-post second-post ].each do |i| | ||
202 | + feed.add_item(i, "http://localhost/#{i}", Date.today, "some contet for #{i}") | ||
203 | + end | ||
204 | + | ||
205 | + ActionView::Base.any_instance.stubs(:block_title).returns("") | ||
206 | + | ||
207 | + assert_tag_in_string render_block_content(feed), :tag => 'a', :attributes => { :href => 'http://localhost/second-post' }, :content => 'second-post' | ||
208 | + assert_no_tag_in_string render_block_content(feed), :tag => 'a', :attributes => { :href => 'http://localhost/first-post' }, :content => 'first-post' | ||
209 | + end | ||
210 | + | ||
211 | + should 'notice when content not fetched yet' do | ||
212 | + assert_equal " Feed content was not loaded yet\n", render_block_footer(feed) | ||
213 | + end | ||
214 | + | ||
215 | + should 'display last fetched date' do | ||
216 | + now = Time.new(2014,1,1) | ||
217 | + feed.feed_items = ['one', 'two'] | ||
218 | + feed.fetched_at = now | ||
219 | + assert_equal " Updated: #{show_date(now)}\n", render_block_footer(feed) | ||
220 | + end | ||
221 | +end |
test/unit/highlights_block_test.rb
@@ -54,7 +54,19 @@ class HighlightsBlockTest < ActiveSupport::TestCase | @@ -54,7 +54,19 @@ class HighlightsBlockTest < ActiveSupport::TestCase | ||
54 | should 'remove images with blank fields' do | 54 | should 'remove images with blank fields' do |
55 | h = HighlightsBlock.new(:images => [{:image_id => 1, :address => '/address', :position => 1, :title => 'address'}, {:image_id => '', :address => '', :position => '', :title => ''}]) | 55 | h = HighlightsBlock.new(:images => [{:image_id => 1, :address => '/address', :position => 1, :title => 'address'}, {:image_id => '', :address => '', :position => '', :title => ''}]) |
56 | h.save! | 56 | h.save! |
57 | - assert_equal [{:image_id => 1, :address => '/address', :position => 1, :title => 'address', :image_src => nil}], h.images | 57 | + assert_equal [{:image_id => 1, :address => '/address', :position => 1, :title => 'address', :new_window => false, :image_src => nil}], h.images |
58 | + end | ||
59 | + | ||
60 | + should 'replace 1 and 0 by true and false in new_window attribute' do | ||
61 | + image1 = {:image_id => 1, :address => '/address-1', :position => 1, :title => 'address-1', :new_window => '0'} | ||
62 | + image2 = {:image_id => 2, :address => '/address-2', :position => 2, :title => 'address-2', :new_window => '1'} | ||
63 | + h = HighlightsBlock.new(:images => [image1, image2]) | ||
64 | + h.save! | ||
65 | + image1[:new_window] = false | ||
66 | + image1[:image_src] = nil | ||
67 | + image2[:new_window] = true | ||
68 | + image2[:image_src] = nil | ||
69 | + assert_equivalent [image1, image2], h.images | ||
58 | end | 70 | end |
59 | 71 | ||
60 | should 'be able to update display setting' do | 72 | should 'be able to update display setting' do |
@@ -68,11 +80,13 @@ class HighlightsBlockTest < ActiveSupport::TestCase | @@ -68,11 +80,13 @@ class HighlightsBlockTest < ActiveSupport::TestCase | ||
68 | assert_equal 'always', block.display | 80 | assert_equal 'always', block.display |
69 | end | 81 | end |
70 | 82 | ||
83 | + include BoxesHelper | ||
84 | + | ||
71 | should 'display highlights block' do | 85 | should 'display highlights block' do |
72 | block = HighlightsBlock.new | 86 | block = HighlightsBlock.new |
73 | - self.expects(:render).with(:file => 'blocks/highlights', :locals => { :block => block}) | 87 | + self.expects(:render).with(template: 'blocks/highlights', locals: {block: block}) |
74 | 88 | ||
75 | - instance_eval(& block.content) | 89 | + render_block_content(block) |
76 | end | 90 | end |
77 | 91 | ||
78 | should 'not list non existent image' do | 92 | should 'not list non existent image' do |
@@ -84,7 +98,7 @@ class HighlightsBlockTest < ActiveSupport::TestCase | @@ -84,7 +98,7 @@ class HighlightsBlockTest < ActiveSupport::TestCase | ||
84 | block.save! | 98 | block.save! |
85 | block.reload | 99 | block.reload |
86 | assert_equal 2, block.images.count | 100 | assert_equal 2, block.images.count |
87 | - assert_equal [{:image_id => 1, :address => '/address', :position => 1, :title => 'address', :image_src => 'address'}], block.featured_images | 101 | + assert_equal [{:image_id => 1, :address => '/address', :position => 1, :title => 'address', :new_window => false, :image_src => 'address'}], block.featured_images |
88 | end | 102 | end |
89 | 103 | ||
90 | should 'list images in order' do | 104 | should 'list images in order' do |
@@ -155,7 +169,7 @@ class HighlightsBlockTest < ActiveSupport::TestCase | @@ -155,7 +169,7 @@ class HighlightsBlockTest < ActiveSupport::TestCase | ||
155 | block.images = [i1] | 169 | block.images = [i1] |
156 | block.save! | 170 | block.save! |
157 | 171 | ||
158 | - assert_tag_in_string instance_eval(& block.content), :tag => 'img', :attributes => { :src => "/social/img_address" } | 172 | + assert_tag_in_string render_block_content(block), :tag => 'img', :attributes => { :src => "/social/img_address" } |
159 | end | 173 | end |
160 | 174 | ||
161 | [Environment, Profile].each do |klass| | 175 | [Environment, Profile].each do |klass| |
test/unit/link_list_block_test.rb
@@ -2,6 +2,8 @@ require_relative "../test_helper" | @@ -2,6 +2,8 @@ require_relative "../test_helper" | ||
2 | 2 | ||
3 | class LinkListBlockTest < ActiveSupport::TestCase | 3 | class LinkListBlockTest < ActiveSupport::TestCase |
4 | 4 | ||
5 | + include BoxesHelper | ||
6 | + | ||
5 | should 'default describe' do | 7 | should 'default describe' do |
6 | assert_not_equal Block.description, LinkListBlock.description | 8 | assert_not_equal Block.description, LinkListBlock.description |
7 | end | 9 | end |
@@ -23,7 +25,7 @@ class LinkListBlockTest < ActiveSupport::TestCase | @@ -23,7 +25,7 @@ class LinkListBlockTest < ActiveSupport::TestCase | ||
23 | 25 | ||
24 | should 'list links' do | 26 | should 'list links' do |
25 | l = LinkListBlock.new(:links => [{:name => 'products', :address => '/cat/products'}]) | 27 | l = LinkListBlock.new(:links => [{:name => 'products', :address => '/cat/products'}]) |
26 | - assert_match /products/, l.content | 28 | + assert_match /products/, render_block_content(l) |
27 | end | 29 | end |
28 | 30 | ||
29 | should 'remove links with blank fields' do | 31 | should 'remove links with blank fields' do |
@@ -36,7 +38,7 @@ class LinkListBlockTest < ActiveSupport::TestCase | @@ -36,7 +38,7 @@ class LinkListBlockTest < ActiveSupport::TestCase | ||
36 | profile = Profile.new(:identifier => 'test_profile') | 38 | profile = Profile.new(:identifier => 'test_profile') |
37 | l = LinkListBlock.new(:links => [{:name => 'categ', :address => '/{profile}/address'}]) | 39 | l = LinkListBlock.new(:links => [{:name => 'categ', :address => '/{profile}/address'}]) |
38 | l.stubs(:owner).returns(profile) | 40 | l.stubs(:owner).returns(profile) |
39 | - assert_tag_in_string l.content, :tag => 'a', :attributes => {:href => '/test_profile/address'} | 41 | + assert_tag_in_string render_block_content(l), :tag => 'a', :attributes => {:href => '/test_profile/address'} |
40 | end | 42 | end |
41 | 43 | ||
42 | should 'replace {portal} with environment portal identifier' do | 44 | should 'replace {portal} with environment portal identifier' do |
@@ -49,7 +51,7 @@ class LinkListBlockTest < ActiveSupport::TestCase | @@ -49,7 +51,7 @@ class LinkListBlockTest < ActiveSupport::TestCase | ||
49 | stubs(:environment).returns(env) | 51 | stubs(:environment).returns(env) |
50 | l = LinkListBlock.new(:links => [{:name => 'categ', :address => '/{portal}/address'}]) | 52 | l = LinkListBlock.new(:links => [{:name => 'categ', :address => '/{portal}/address'}]) |
51 | l.stubs(:owner).returns(env) | 53 | l.stubs(:owner).returns(env) |
52 | - assert_tag_in_string l.content, :tag => 'a', :attributes => {:href => '/portal-community/address'} | 54 | + assert_tag_in_string render_block_content(l), :tag => 'a', :attributes => {:href => '/portal-community/address'} |
53 | end | 55 | end |
54 | 56 | ||
55 | should 'not change address if no {portal} there' do | 57 | should 'not change address if no {portal} there' do |
@@ -62,19 +64,19 @@ class LinkListBlockTest < ActiveSupport::TestCase | @@ -62,19 +64,19 @@ class LinkListBlockTest < ActiveSupport::TestCase | ||
62 | stubs(:environment).returns(env) | 64 | stubs(:environment).returns(env) |
63 | l = LinkListBlock.new(:links => [{:name => 'categ', :address => '/address'}]) | 65 | l = LinkListBlock.new(:links => [{:name => 'categ', :address => '/address'}]) |
64 | l.stubs(:owner).returns(env) | 66 | l.stubs(:owner).returns(env) |
65 | - assert_tag_in_string l.content, :tag => 'a', :attributes => {:href => '/address'} | 67 | + assert_tag_in_string render_block_content(l), :tag => 'a', :attributes => {:href => '/address'} |
66 | end | 68 | end |
67 | 69 | ||
68 | should 'handle /prefix if not already added' do | 70 | should 'handle /prefix if not already added' do |
69 | Noosfero.stubs(:root).returns('/prefix') | 71 | Noosfero.stubs(:root).returns('/prefix') |
70 | l = LinkListBlock.new(:links => [{:name => "foo", :address => '/bar'}] ) | 72 | l = LinkListBlock.new(:links => [{:name => "foo", :address => '/bar'}] ) |
71 | - assert_tag_in_string l.content, :tag => 'a', :attributes => { :href => '/prefix/bar' } | 73 | + assert_tag_in_string render_block_content(l), :tag => 'a', :attributes => { :href => '/prefix/bar' } |
72 | end | 74 | end |
73 | 75 | ||
74 | should 'not add /prefix if already there' do | 76 | should 'not add /prefix if already there' do |
75 | Noosfero.stubs(:root).returns('/prefix') | 77 | Noosfero.stubs(:root).returns('/prefix') |
76 | l = LinkListBlock.new(:links => [{:name => "foo", :address => '/prefix/bar'}] ) | 78 | l = LinkListBlock.new(:links => [{:name => "foo", :address => '/prefix/bar'}] ) |
77 | - assert_tag_in_string l.content, :tag => 'a', :attributes => { :href => '/prefix/bar' } | 79 | + assert_tag_in_string render_block_content(l), :tag => 'a', :attributes => { :href => '/prefix/bar' } |
78 | end | 80 | end |
79 | 81 | ||
80 | should 'display options for icons' do | 82 | should 'display options for icons' do |
@@ -85,29 +87,29 @@ class LinkListBlockTest < ActiveSupport::TestCase | @@ -85,29 +87,29 @@ class LinkListBlockTest < ActiveSupport::TestCase | ||
85 | end | 87 | end |
86 | 88 | ||
87 | should 'link with icon' do | 89 | should 'link with icon' do |
88 | - l = LinkListBlock.new | ||
89 | - assert_match /class="icon-save"/, l.link_html({:icon => 'save', :name => 'test', :address => 'test.com'}) | 90 | + l = LinkListBlock.new(:links => [{:icon => 'save', :name => 'test', :address => 'test.com'}]) |
91 | + assert_match /a class="icon-[^"]+"/, render_block_content(l) | ||
90 | end | 92 | end |
91 | 93 | ||
92 | should 'no class without icon' do | 94 | should 'no class without icon' do |
93 | - l = LinkListBlock.new | ||
94 | - assert_no_match /class="/, l.link_html({:icon => nil, :name => 'test', :address => 'test.com'}) | 95 | + l = LinkListBlock.new(:links => [{:icon => nil, :name => 'test', :address => 'test.com'}]) |
96 | + assert_no_match /a class="icon-[^"]+"/, render_block_content(l) | ||
95 | end | 97 | end |
96 | 98 | ||
97 | should 'not add link to javascript' do | 99 | should 'not add link to javascript' do |
98 | l = LinkListBlock.new(:links => [{:name => 'link', :address => "javascript:alert('Message test')"}]) | 100 | l = LinkListBlock.new(:links => [{:name => 'link', :address => "javascript:alert('Message test')"}]) |
99 | - assert_no_match /href="javascript/, l.link_html(l.links.first) | 101 | + assert_no_match /href="javascript/, render_block_content(l) |
100 | end | 102 | end |
101 | 103 | ||
102 | should 'not add link to onclick' do | 104 | should 'not add link to onclick' do |
103 | l = LinkListBlock.new(:links => [{:name => 'link', :address => "#\" onclick=\"alert(123456)"}]) | 105 | l = LinkListBlock.new(:links => [{:name => 'link', :address => "#\" onclick=\"alert(123456)"}]) |
104 | - assert_no_tag_in_string l.link_html(l.links.first), :attributes => { :onclick => /.*/ } | 106 | + assert_no_tag_in_string render_block_content(l), :attributes => { :onclick => /.*/ } |
105 | end | 107 | end |
106 | 108 | ||
107 | should 'add protocol in front of incomplete external links' do | 109 | should 'add protocol in front of incomplete external links' do |
108 | {'/local/link' => '/local/link', 'http://example.org' => 'http://example.org', 'example.org' => '//example.org'}.each do |input, output| | 110 | {'/local/link' => '/local/link', 'http://example.org' => 'http://example.org', 'example.org' => '//example.org'}.each do |input, output| |
109 | l = LinkListBlock.new(:links => [{:name => 'categ', :address => input}]) | 111 | l = LinkListBlock.new(:links => [{:name => 'categ', :address => input}]) |
110 | - assert_tag_in_string l.content, :tag => 'a', :attributes => {:href => output} | 112 | + assert_tag_in_string render_block_content(l), :tag => 'a', :attributes => {:href => output} |
111 | end | 113 | end |
112 | end | 114 | end |
113 | 115 | ||
@@ -128,7 +130,13 @@ class LinkListBlockTest < ActiveSupport::TestCase | @@ -128,7 +130,13 @@ class LinkListBlockTest < ActiveSupport::TestCase | ||
128 | 130 | ||
129 | should 'link with title' do | 131 | should 'link with title' do |
130 | l = LinkListBlock.new | 132 | l = LinkListBlock.new |
131 | - assert_match /title="mytitle"/, l.link_html({:name => 'mylink', :address => '/myaddress', :title => 'mytitle'}) | 133 | + l = LinkListBlock.new(:links => [{:name => 'mylink', :address => '/myaddress', :title => 'mytitle'}]) |
134 | + assert_match /title="mytitle"/, render_block_content(l) | ||
135 | + end | ||
136 | + | ||
137 | + should 'display default message to brand new blocks with no links' do | ||
138 | + l = LinkListBlock.new | ||
139 | + assert_match /Please, edit this block to add links/, render_block_content(l) | ||
132 | end | 140 | end |
133 | 141 | ||
134 | end | 142 | end |
test/unit/location_block_test.rb
@@ -18,7 +18,7 @@ class LocationBlockTest < ActiveSupport::TestCase | @@ -18,7 +18,7 @@ class LocationBlockTest < ActiveSupport::TestCase | ||
18 | end | 18 | end |
19 | 19 | ||
20 | should 'display no localization map without lat' do | 20 | should 'display no localization map without lat' do |
21 | - assert_tag_in_string extract_block_content(block.content), :tag => 'i' | 21 | + assert_tag_in_string extract_block_content(render_block_content(block)), :tag => 'i' |
22 | end | 22 | end |
23 | 23 | ||
24 | should 'be editable' do | 24 | should 'be editable' do |
@@ -31,7 +31,7 @@ class LocationBlockTest < ActiveSupport::TestCase | @@ -31,7 +31,7 @@ class LocationBlockTest < ActiveSupport::TestCase | ||
31 | 31 | ||
32 | should 'use google maps api v3 with ssl' do | 32 | should 'use google maps api v3 with ssl' do |
33 | @block.owner.lat = '-12.34'; @block.owner.save! | 33 | @block.owner.lat = '-12.34'; @block.owner.save! |
34 | - content = extract_block_content(@block.content) | 34 | + content = extract_block_content(render_block_content(@block)) |
35 | 35 | ||
36 | assert_match 'https://maps.google.com/maps/api/staticmap', content | 36 | assert_match 'https://maps.google.com/maps/api/staticmap', content |
37 | assert_no_match /key=/, content | 37 | assert_no_match /key=/, content |
test/unit/manage_products_helper_test.rb
@@ -5,6 +5,7 @@ class ManageProductsHelperTest < ActionView::TestCase | @@ -5,6 +5,7 @@ class ManageProductsHelperTest < ActionView::TestCase | ||
5 | 5 | ||
6 | include ManageProductsHelper | 6 | include ManageProductsHelper |
7 | include ContentViewerHelper | 7 | include ContentViewerHelper |
8 | + include ArticleHelper | ||
8 | include ActionView::Helpers::AssetTagHelper | 9 | include ActionView::Helpers::AssetTagHelper |
9 | include ApplicationHelper | 10 | include ApplicationHelper |
10 | 11 | ||
@@ -43,7 +44,7 @@ class ManageProductsHelperTest < ActionView::TestCase | @@ -43,7 +44,7 @@ class ManageProductsHelperTest < ActionView::TestCase | ||
43 | end | 44 | end |
44 | 45 | ||
45 | should 'display link to edit product when user has permission' do | 46 | should 'display link to edit product when user has permission' do |
46 | - user = mock | 47 | + user = User.new(:email => 'display-link@email.invalid.com') |
47 | user.expects(:has_permission?).with(anything, anything).returns(true) | 48 | user.expects(:has_permission?).with(anything, anything).returns(true) |
48 | @controller = mock | 49 | @controller = mock |
49 | @controller.expects(:user).returns(user).at_least_once | 50 | @controller.expects(:user).returns(user).at_least_once |
@@ -57,7 +58,7 @@ class ManageProductsHelperTest < ActionView::TestCase | @@ -57,7 +58,7 @@ class ManageProductsHelperTest < ActionView::TestCase | ||
57 | end | 58 | end |
58 | 59 | ||
59 | should 'not display link to edit product category when user does not have permission' do | 60 | should 'not display link to edit product category when user does not have permission' do |
60 | - user = mock | 61 | + user = User.new(:email => 'not-display-link@email.invalid.com') |
61 | user.expects(:has_permission?).with(anything, anything).returns(false) | 62 | user.expects(:has_permission?).with(anything, anything).returns(false) |
62 | @controller = mock | 63 | @controller = mock |
63 | @controller.expects(:user).returns(user).at_least_once | 64 | @controller.expects(:user).returns(user).at_least_once |
@@ -68,7 +69,7 @@ class ManageProductsHelperTest < ActionView::TestCase | @@ -68,7 +69,7 @@ class ManageProductsHelperTest < ActionView::TestCase | ||
68 | end | 69 | end |
69 | 70 | ||
70 | should 'display link to edit product category when user has permission' do | 71 | should 'display link to edit product category when user has permission' do |
71 | - user = mock | 72 | + user = User.new(:email => 'display-link@email.invalid.com') |
72 | user.expects(:has_permission?).with(anything, anything).returns(true) | 73 | user.expects(:has_permission?).with(anything, anything).returns(true) |
73 | @controller = mock | 74 | @controller = mock |
74 | @controller.expects(:user).returns(user).at_least_once | 75 | @controller.expects(:user).returns(user).at_least_once |
@@ -82,7 +83,7 @@ class ManageProductsHelperTest < ActionView::TestCase | @@ -82,7 +83,7 @@ class ManageProductsHelperTest < ActionView::TestCase | ||
82 | end | 83 | end |
83 | 84 | ||
84 | should 'not display ui_button to edit product when user does not have permission' do | 85 | should 'not display ui_button to edit product when user does not have permission' do |
85 | - user = mock | 86 | + user = User.new(:email => 'not-display-uibutton@email.invalid.com') |
86 | user.expects(:has_permission?).with(anything, anything).returns(false) | 87 | user.expects(:has_permission?).with(anything, anything).returns(false) |
87 | @controller = mock | 88 | @controller = mock |
88 | @controller.expects(:user).returns(user).at_least_once | 89 | @controller.expects(:user).returns(user).at_least_once |
@@ -93,7 +94,7 @@ class ManageProductsHelperTest < ActionView::TestCase | @@ -93,7 +94,7 @@ class ManageProductsHelperTest < ActionView::TestCase | ||
93 | end | 94 | end |
94 | 95 | ||
95 | should 'display ui_button_to_remote to edit product when user has permission' do | 96 | should 'display ui_button_to_remote to edit product when user has permission' do |
96 | - user = mock | 97 | + user = User.new(:email => 'display-uibuttontoremote@email.invalid.com') |
97 | user.expects(:has_permission?).with(anything, anything).returns(true) | 98 | user.expects(:has_permission?).with(anything, anything).returns(true) |
98 | @controller = mock | 99 | @controller = mock |
99 | @controller.expects(:user).returns(user).at_least_once | 100 | @controller.expects(:user).returns(user).at_least_once |
@@ -108,7 +109,7 @@ class ManageProductsHelperTest < ActionView::TestCase | @@ -108,7 +109,7 @@ class ManageProductsHelperTest < ActionView::TestCase | ||
108 | 109 | ||
109 | 110 | ||
110 | should 'display ui_button to edit product when user has permission' do | 111 | should 'display ui_button to edit product when user has permission' do |
111 | - user = mock | 112 | + user = User.new(:email => 'display-uibutton@email.invalid.com') |
112 | user.expects(:has_permission?).with(anything, anything).returns(true) | 113 | user.expects(:has_permission?).with(anything, anything).returns(true) |
113 | @controller = mock | 114 | @controller = mock |
114 | @controller.expects(:user).returns(user).at_least_once | 115 | @controller.expects(:user).returns(user).at_least_once |
test/unit/my_network_block_test.rb
@@ -19,14 +19,6 @@ class MyNetworkBlockTest < ActiveSupport::TestCase | @@ -19,14 +19,6 @@ class MyNetworkBlockTest < ActiveSupport::TestCase | ||
19 | assert_not_equal Block.new.default_title, MyNetworkBlock.new.default_title | 19 | assert_not_equal Block.new.default_title, MyNetworkBlock.new.default_title |
20 | end | 20 | end |
21 | 21 | ||
22 | - should 'display my-profile' do | ||
23 | - self.expects(:render).with(:file => 'blocks/my_network', :locals => { | ||
24 | - :title => 'My network', | ||
25 | - :owner => owner | ||
26 | - }) | ||
27 | - instance_eval(&block.content) | ||
28 | - end | ||
29 | - | ||
30 | should 'be able to update display setting' do | 22 | should 'be able to update display setting' do |
31 | user = create_user('testinguser').person | 23 | user = create_user('testinguser').person |
32 | box = fast_create(Box, :owner_id => user.id) | 24 | box = fast_create(Box, :owner_id => user.id) |
@@ -37,3 +29,22 @@ class MyNetworkBlockTest < ActiveSupport::TestCase | @@ -37,3 +29,22 @@ class MyNetworkBlockTest < ActiveSupport::TestCase | ||
37 | end | 29 | end |
38 | 30 | ||
39 | end | 31 | end |
32 | + | ||
33 | +class MyNetworkBlockViewTest < ActionView::TestCase | ||
34 | + include BoxesHelper | ||
35 | + | ||
36 | + def setup | ||
37 | + @block = MyNetworkBlock.new | ||
38 | + @owner = Person.new(:identifier => 'testuser') | ||
39 | + @block.stubs(:owner).returns(@owner) | ||
40 | + owner.stubs(:environment).returns(Environment.default) | ||
41 | + end | ||
42 | + attr_reader :owner, :block | ||
43 | + | ||
44 | + should 'display my-profile' do | ||
45 | + ActionView::Base.any_instance.stubs(:block_title).with(anything).returns(true) | ||
46 | + ActionView::Base.any_instance.stubs(:user).with(anything).returns(owner) | ||
47 | + ActionView::Base.any_instance.stubs(:render_profile_actions) | ||
48 | + assert_match "#{Environment.default.top_url}/profile/testuser", render_block_content(block) | ||
49 | + end | ||
50 | +end |
test/unit/organization_mailing_test.rb
@@ -98,6 +98,11 @@ class OrganizationMailingTest < ActiveSupport::TestCase | @@ -98,6 +98,11 @@ class OrganizationMailingTest < ActiveSupport::TestCase | ||
98 | assert_equal [Person['user_one'], Person['user_two']], mailing.recipients | 98 | assert_equal [Person['user_one'], Person['user_two']], mailing.recipients |
99 | end | 99 | end |
100 | 100 | ||
101 | + should 'return recipients previously filtered' do | ||
102 | + mailing = create(OrganizationMailing, :source => community, :subject => 'Hello', :body => 'We have some news', :person => person, :data => {:members_filtered => [Person['user_one'].id,Person['user_two'].id]}) | ||
103 | + assert_equivalent [Person['user_one'], Person['user_two']], mailing.recipients | ||
104 | + end | ||
105 | + | ||
101 | should 'return recipients according to limit' do | 106 | should 'return recipients according to limit' do |
102 | mailing = create(OrganizationMailing, :source => community, :subject => 'Hello', :body => 'We have some news', :person => person) | 107 | mailing = create(OrganizationMailing, :source => community, :subject => 'Hello', :body => 'We have some news', :person => person) |
103 | assert_equal [Person['user_one']], mailing.recipients(0, 1) | 108 | assert_equal [Person['user_one']], mailing.recipients(0, 1) |
test/unit/person_test.rb
@@ -1932,6 +1932,16 @@ class PersonTest < ActiveSupport::TestCase | @@ -1932,6 +1932,16 @@ class PersonTest < ActiveSupport::TestCase | ||
1932 | community.add_member person | 1932 | community.add_member person |
1933 | 1933 | ||
1934 | assert !person.member_relation_of(community).empty?, "Person '#{person.identifier}' is not a member of Community '#{community.identifier}'" | 1934 | assert !person.member_relation_of(community).empty?, "Person '#{person.identifier}' is not a member of Community '#{community.identifier}'" |
1935 | - assert person.member_since_date(community) == Date.today,"Person '#{person.identifier}' is not added like a member of Community '#{community.identifier}' today" | 1935 | + assert_equal Date.current, person.member_since_date(community), "Person '#{person.identifier}' is not added like a member of Community '#{community.identifier}' today" |
1936 | end | 1936 | end |
1937 | + | ||
1938 | + should 'a person follows many articles' do | ||
1939 | + person = create_user('article_follower').person | ||
1940 | + | ||
1941 | + 1.upto(10).map do |n| | ||
1942 | + person.following_articles << fast_create(Article, :profile_id => fast_create(Person)) | ||
1943 | + end | ||
1944 | + assert_equal 10, person.following_articles.count | ||
1945 | + end | ||
1946 | + | ||
1937 | end | 1947 | end |
test/unit/products_block_test.rb
@@ -20,33 +20,6 @@ class ProductsBlockTest < ActiveSupport::TestCase | @@ -20,33 +20,6 @@ class ProductsBlockTest < ActiveSupport::TestCase | ||
20 | assert_not_equal Block.description, ProductsBlock.description | 20 | assert_not_equal Block.description, ProductsBlock.description |
21 | end | 21 | end |
22 | 22 | ||
23 | - should "list owner products" do | ||
24 | - enterprise = create(Enterprise, :name => 'testenterprise', :identifier => 'testenterprise') | ||
25 | - create(Product, :enterprise => enterprise, :name => 'product one', :product_category => @product_category) | ||
26 | - create(Product, :enterprise => enterprise, :name => 'product two', :product_category => @product_category) | ||
27 | - | ||
28 | - block.expects(:products).returns(enterprise.products) | ||
29 | - | ||
30 | - content = block.content | ||
31 | - | ||
32 | - assert_tag_in_string content, :content => 'Products' | ||
33 | - | ||
34 | - assert_tag_in_string content, :tag => 'li', :attributes => { :class => 'product' }, :descendant => { :tag => 'a', :content => /product one/ } | ||
35 | - assert_tag_in_string content, :tag => 'li', :attributes => { :class => 'product' }, :descendant => { :tag => 'a', :content => /product two/ } | ||
36 | - end | ||
37 | - | ||
38 | - should 'point to all products in footer' do | ||
39 | - enterprise = create(Enterprise, :name => 'testenterprise', :identifier => 'testenterprise') | ||
40 | - create(Product, :enterprise => enterprise, :name => 'product one', :product_category => @product_category) | ||
41 | - create(Product, :enterprise => enterprise, :name => 'product two', :product_category => @product_category) | ||
42 | - | ||
43 | - block.stubs(:owner).returns(enterprise) | ||
44 | - | ||
45 | - footer = block.footer | ||
46 | - | ||
47 | - assert_tag_in_string footer, :tag => 'a', :attributes => { :href => /\/catalog\/testenterprise$/ }, :content => 'View all products' | ||
48 | - end | ||
49 | - | ||
50 | should 'list 4 random products by default' do | 23 | should 'list 4 random products by default' do |
51 | enterprise = create(Enterprise, :name => 'testenterprise', :identifier => 'testenterprise') | 24 | enterprise = create(Enterprise, :name => 'testenterprise', :identifier => 'testenterprise') |
52 | create(Product, :enterprise => enterprise, :name => 'product one', :product_category => @product_category) | 25 | create(Product, :enterprise => enterprise, :name => 'product one', :product_category => @product_category) |
@@ -120,18 +93,35 @@ class ProductsBlockTest < ActiveSupport::TestCase | @@ -120,18 +93,35 @@ class ProductsBlockTest < ActiveSupport::TestCase | ||
120 | assert_equivalent [p1, p2, p3, p4], block.products | 93 | assert_equivalent [p1, p2, p3, p4], block.products |
121 | end | 94 | end |
122 | end | 95 | end |
96 | +end | ||
123 | 97 | ||
124 | - should 'generate footer when enterprise has own hostname' do | 98 | +require 'boxes_helper' |
99 | +require 'block_helper' | ||
100 | + | ||
101 | +class ProductsBlockViewTest < ActionView::TestCase | ||
102 | + include BoxesHelper | ||
103 | + | ||
104 | + ActionView::Base.send :include, BlockHelper | ||
105 | + | ||
106 | + def setup | ||
107 | + @block = ProductsBlock.new | ||
108 | + @product_category = fast_create(ProductCategory, :name => 'Products') | ||
109 | + end | ||
110 | + attr_reader :block | ||
111 | + | ||
112 | + should "list owner products" do | ||
125 | enterprise = create(Enterprise, :name => 'testenterprise', :identifier => 'testenterprise') | 113 | enterprise = create(Enterprise, :name => 'testenterprise', :identifier => 'testenterprise') |
126 | - enterprise.domains << Domain.new(:name => 'sometest.com'); enterprise.save! | ||
127 | create(Product, :enterprise => enterprise, :name => 'product one', :product_category => @product_category) | 114 | create(Product, :enterprise => enterprise, :name => 'product one', :product_category => @product_category) |
128 | create(Product, :enterprise => enterprise, :name => 'product two', :product_category => @product_category) | 115 | create(Product, :enterprise => enterprise, :name => 'product two', :product_category => @product_category) |
129 | 116 | ||
130 | - block.stubs(:owner).returns(enterprise) | 117 | + block.expects(:products).returns(enterprise.products) |
131 | 118 | ||
132 | - footer = block.footer | 119 | + content = render_block_content(block) |
133 | 120 | ||
134 | - assert_tag_in_string footer, :tag => 'a', :attributes => { :href => /\/catalog\/testenterprise$/ }, :content => 'View all products' | 121 | + assert_tag_in_string content, :content => 'Products' |
122 | + | ||
123 | + assert_tag_in_string content, :tag => 'li', :attributes => { :class => 'product' }, :descendant => { :tag => 'a', :content => /product one/ } | ||
124 | + assert_tag_in_string content, :tag => 'li', :attributes => { :class => 'product' }, :descendant => { :tag => 'a', :content => /product two/ } | ||
135 | end | 125 | end |
136 | 126 | ||
137 | should 'display the default minor image if thumbnails were not processed' do | 127 | should 'display the default minor image if thumbnails were not processed' do |
@@ -139,8 +129,9 @@ class ProductsBlockTest < ActiveSupport::TestCase | @@ -139,8 +129,9 @@ class ProductsBlockTest < ActiveSupport::TestCase | ||
139 | create(Product, :enterprise => enterprise, :name => 'product', :product_category => @product_category, :image_builder => { :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')}) | 129 | create(Product, :enterprise => enterprise, :name => 'product', :product_category => @product_category, :image_builder => { :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')}) |
140 | 130 | ||
141 | block.expects(:products).returns(enterprise.products) | 131 | block.expects(:products).returns(enterprise.products) |
132 | + ActionView::Base.any_instance.stubs(:block_title).returns("") | ||
142 | 133 | ||
143 | - content = block.content | 134 | + content = render_block_content(block) |
144 | 135 | ||
145 | assert_tag_in_string content, :tag => 'a', :attributes => { :style => /image-loading-minor.png/ } | 136 | assert_tag_in_string content, :tag => 'a', :attributes => { :style => /image-loading-minor.png/ } |
146 | end | 137 | end |
@@ -151,9 +142,34 @@ class ProductsBlockTest < ActiveSupport::TestCase | @@ -151,9 +142,34 @@ class ProductsBlockTest < ActiveSupport::TestCase | ||
151 | 142 | ||
152 | process_delayed_job_queue | 143 | process_delayed_job_queue |
153 | block.expects(:products).returns(enterprise.products.reload) | 144 | block.expects(:products).returns(enterprise.products.reload) |
145 | + ActionView::Base.any_instance.stubs(:block_title).returns("") | ||
154 | 146 | ||
155 | - content = block.content | 147 | + content = render_block_content(block) |
156 | assert_tag_in_string content, :tag => 'a', :attributes => { :style => /rails_minor.png/ } | 148 | assert_tag_in_string content, :tag => 'a', :attributes => { :style => /rails_minor.png/ } |
157 | end | 149 | end |
158 | 150 | ||
151 | + should 'point to all products in footer' do | ||
152 | + enterprise = create(Enterprise, :name => 'testenterprise', :identifier => 'testenterprise') | ||
153 | + create(Product, :enterprise => enterprise, :name => 'product one', :product_category => @product_category) | ||
154 | + create(Product, :enterprise => enterprise, :name => 'product two', :product_category => @product_category) | ||
155 | + | ||
156 | + block.stubs(:owner).returns(enterprise) | ||
157 | + | ||
158 | + footer = render_block_footer(block) | ||
159 | + | ||
160 | + assert_tag_in_string footer, :tag => 'a', :attributes => { :href => /\/catalog\/testenterprise$/ }, :content => 'View all products' | ||
161 | + end | ||
162 | + | ||
163 | + should 'generate footer when enterprise has own hostname' do | ||
164 | + enterprise = create(Enterprise, :name => 'testenterprise', :identifier => 'testenterprise') | ||
165 | + enterprise.domains << Domain.new(:name => 'sometest.com'); enterprise.save! | ||
166 | + create(Product, :enterprise => enterprise, :name => 'product one', :product_category => @product_category) | ||
167 | + create(Product, :enterprise => enterprise, :name => 'product two', :product_category => @product_category) | ||
168 | + | ||
169 | + block.stubs(:owner).returns(enterprise) | ||
170 | + | ||
171 | + footer = render_block_footer(block) | ||
172 | + | ||
173 | + assert_tag_in_string footer, :tag => 'a', :attributes => { :href => /\/catalog\/testenterprise$/ }, :content => 'View all products' | ||
174 | + end | ||
159 | end | 175 | end |
test/unit/profile_image_block_test.rb
1 | require_relative "../test_helper" | 1 | require_relative "../test_helper" |
2 | +require 'boxes_helper' | ||
2 | 3 | ||
3 | class ProfileImageBlockTest < ActiveSupport::TestCase | 4 | class ProfileImageBlockTest < ActiveSupport::TestCase |
5 | + include BoxesHelper | ||
4 | 6 | ||
5 | should 'provide description' do | 7 | should 'provide description' do |
6 | assert_not_equal Block.description, ProfileImageBlock.description | 8 | assert_not_equal Block.description, ProfileImageBlock.description |
@@ -9,8 +11,8 @@ class ProfileImageBlockTest < ActiveSupport::TestCase | @@ -9,8 +11,8 @@ class ProfileImageBlockTest < ActiveSupport::TestCase | ||
9 | should 'display profile image' do | 11 | should 'display profile image' do |
10 | block = ProfileImageBlock.new | 12 | block = ProfileImageBlock.new |
11 | 13 | ||
12 | - self.expects(:render).with(:file => 'blocks/profile_image', :locals => { :block => block, :show_name => false}) | ||
13 | - instance_eval(& block.content) | 14 | + self.expects(:render).with(template: 'blocks/profile_image', locals: { block: block }) |
15 | + render_block_content(block) | ||
14 | end | 16 | end |
15 | 17 | ||
16 | should 'be editable' do | 18 | should 'be editable' do |
test/unit/profile_info_block_test.rb
@@ -16,9 +16,11 @@ class ProfileInfoBlockTest < ActiveSupport::TestCase | @@ -16,9 +16,11 @@ class ProfileInfoBlockTest < ActiveSupport::TestCase | ||
16 | assert_not_equal Block.description, ProfileInfoBlock.description | 16 | assert_not_equal Block.description, ProfileInfoBlock.description |
17 | end | 17 | end |
18 | 18 | ||
19 | + include BoxesHelper | ||
20 | + | ||
19 | should 'display profile information' do | 21 | should 'display profile information' do |
20 | - self.expects(:render).with(:file => 'blocks/profile_info', :locals => { :block => block}) | ||
21 | - instance_eval(& block.content) | 22 | + self.expects(:render).with(template: 'blocks/profile_info', locals: { block: block }) |
23 | + render_block_content(block) | ||
22 | end | 24 | end |
23 | 25 | ||
24 | end | 26 | end |
test/unit/profile_list_block_test.rb
@@ -20,6 +20,8 @@ class ProfileListBlockTest < ActiveSupport::TestCase | @@ -20,6 +20,8 @@ class ProfileListBlockTest < ActiveSupport::TestCase | ||
20 | assert_equal 20, block.limit | 20 | assert_equal 20, block.limit |
21 | end | 21 | end |
22 | 22 | ||
23 | + include BoxesHelper | ||
24 | + | ||
23 | should 'list people' do | 25 | should 'list people' do |
24 | env = fast_create(Environment) | 26 | env = fast_create(Environment) |
25 | 27 | ||
@@ -30,15 +32,20 @@ class ProfileListBlockTest < ActiveSupport::TestCase | @@ -30,15 +32,20 @@ class ProfileListBlockTest < ActiveSupport::TestCase | ||
30 | block = ProfileListBlock.new | 32 | block = ProfileListBlock.new |
31 | block.stubs(:owner).returns(env) | 33 | block.stubs(:owner).returns(env) |
32 | 34 | ||
33 | - self.expects(:profile_image_link).with(person1, :minor).once | ||
34 | - self.expects(:profile_image_link).with(person2, :minor).once | ||
35 | - self.expects(:profile_image_link).with(person3, :minor).once | ||
36 | - | ||
37 | - self.stubs(:tag).returns('<div></div>') | ||
38 | - self.expects(:content_tag).returns('<div></div>').at_least_once | ||
39 | - self.expects(:block_title).returns('block title').at_least_once | 35 | + ApplicationHelper.class_eval do |
36 | + alias_method :original_profile_image_link, :profile_image_link | ||
37 | + def profile_image_link( profile, size=:portrait, tag='li', extra_info = nil ) | ||
38 | + "<#{profile.name}>" | ||
39 | + end | ||
40 | + end | ||
40 | 41 | ||
41 | - assert_kind_of String, instance_eval(&block.content) | 42 | + content = render_block_content(block) |
43 | + assert_match '<testperson1>', content | ||
44 | + assert_match '<testperson2>', content | ||
45 | + assert_match '<testperson3>', content | ||
46 | + ApplicationHelper.class_eval do | ||
47 | + alias_method :profile_image_link, :original_profile_image_link | ||
48 | + end | ||
42 | end | 49 | end |
43 | 50 | ||
44 | should 'list private profiles' do | 51 | should 'list private profiles' do |
test/unit/profile_search_block_test.rb
@@ -10,20 +10,22 @@ class ProfileSearchBlockTest < ActiveSupport::TestCase | @@ -10,20 +10,22 @@ class ProfileSearchBlockTest < ActiveSupport::TestCase | ||
10 | assert_equal Block.new.default_title, ProfileSearchBlock.new.default_title | 10 | assert_equal Block.new.default_title, ProfileSearchBlock.new.default_title |
11 | end | 11 | end |
12 | 12 | ||
13 | + include BoxesHelper | ||
14 | + | ||
13 | should 'render profile search' do | 15 | should 'render profile search' do |
14 | person = fast_create(Person) | 16 | person = fast_create(Person) |
15 | 17 | ||
16 | block = ProfileSearchBlock.new | 18 | block = ProfileSearchBlock.new |
17 | block.stubs(:owner).returns(person) | 19 | block.stubs(:owner).returns(person) |
18 | 20 | ||
19 | - self.expects(:render).with(:file => 'blocks/profile_search', :locals => { :title => block.title}) | ||
20 | - instance_eval(& block.content) | 21 | + self.expects(:render).with(template: 'blocks/profile_search', locals: { block: block }) |
22 | + render_block_content(block) | ||
21 | end | 23 | end |
22 | 24 | ||
23 | should 'provide view_title' do | 25 | should 'provide view_title' do |
24 | person = fast_create(Person) | 26 | person = fast_create(Person) |
25 | person.boxes << Box.new | 27 | person.boxes << Box.new |
26 | - block = ProfileSearchBlock.new(:title => 'Title from block') | 28 | + block = ProfileSearchBlock.new(title: 'Title from block') |
27 | person.boxes.first.blocks << block | 29 | person.boxes.first.blocks << block |
28 | block.save! | 30 | block.save! |
29 | assert_equal 'Title from block', block.view_title | 31 | assert_equal 'Title from block', block.view_title |
test/unit/profile_test.rb
@@ -1816,6 +1816,21 @@ class ProfileTest < ActiveSupport::TestCase | @@ -1816,6 +1816,21 @@ class ProfileTest < ActiveSupport::TestCase | ||
1816 | assert_equal [person], community.members | 1816 | assert_equal [person], community.members |
1817 | end | 1817 | end |
1818 | 1818 | ||
1819 | + should 'return a list members by email of a community' do | ||
1820 | + someone = create_user('Someone', email:'someone@test.com.br') | ||
1821 | + someperson = create_user('Someperson',email:'someperson@test.com.br') | ||
1822 | + | ||
1823 | + community = fast_create(Community) | ||
1824 | + community.add_member(someone.person) | ||
1825 | + community.add_member(someperson.person) | ||
1826 | + | ||
1827 | + result = community.members_like 'email', '@test.com.br' | ||
1828 | + | ||
1829 | + assert_includes result, someone.person | ||
1830 | + assert_includes result, someperson.person | ||
1831 | + | ||
1832 | + end | ||
1833 | + | ||
1819 | should 'count unique members of a community' do | 1834 | should 'count unique members of a community' do |
1820 | person = fast_create(Person) | 1835 | person = fast_create(Person) |
1821 | community = fast_create(Community) | 1836 | community = fast_create(Community) |
test/unit/raw_html_block_test.rb
@@ -17,9 +17,11 @@ class RawHTMLBlockTest < ActiveSupport::TestCase | @@ -17,9 +17,11 @@ class RawHTMLBlockTest < ActiveSupport::TestCase | ||
17 | assert_equal html, block.html | 17 | assert_equal html, block.html |
18 | end | 18 | end |
19 | 19 | ||
20 | + include BoxesHelper | ||
21 | + | ||
20 | should 'return html as content' do | 22 | should 'return html as content' do |
21 | block = RawHTMLBlock.new(:html => "HTML") | 23 | block = RawHTMLBlock.new(:html => "HTML") |
22 | - assert_match(/HTML$/, block.content) | 24 | + assert_match /HTML$/, render_block_content(block) |
23 | end | 25 | end |
24 | 26 | ||
25 | should 'not be editable for users without permission' do | 27 | should 'not be editable for users without permission' do |
test/unit/recent_documents_block_test.rb
@@ -35,17 +35,6 @@ class RecentDocumentsBlockTest < ActiveSupport::TestCase | @@ -35,17 +35,6 @@ class RecentDocumentsBlockTest < ActiveSupport::TestCase | ||
35 | assert_equivalent block.docs, articles | 35 | assert_equivalent block.docs, articles |
36 | end | 36 | end |
37 | 37 | ||
38 | - should 'link to documents' do | ||
39 | - articles.each do |a| | ||
40 | - expects(:link_to).with(a.title, a.url) | ||
41 | - end | ||
42 | - stubs(:block_title).returns("") | ||
43 | - stubs(:content_tag).returns("") | ||
44 | - stubs(:li).returns("") | ||
45 | - | ||
46 | - instance_eval(&block.content) | ||
47 | - end | ||
48 | - | ||
49 | should 'respect the maximum number of items as configured' do | 38 | should 'respect the maximum number of items as configured' do |
50 | block.limit = 3 | 39 | block.limit = 3 |
51 | 40 | ||
@@ -68,21 +57,6 @@ class RecentDocumentsBlockTest < ActiveSupport::TestCase | @@ -68,21 +57,6 @@ class RecentDocumentsBlockTest < ActiveSupport::TestCase | ||
68 | assert block.limit > 0 | 57 | assert block.limit > 0 |
69 | end | 58 | end |
70 | 59 | ||
71 | - should 'display a link to sitemap with title "All content"' do | ||
72 | - expects(:link_to).with('All content', :controller => 'profile', :action => 'sitemap', :profile => profile.identifier) | ||
73 | - expects(:_).with('All content').returns('All content') | ||
74 | - | ||
75 | - instance_eval(&(block.footer)) | ||
76 | - end | ||
77 | - | ||
78 | - should 'not display link to sitemap when owner is environment' do | ||
79 | - block = RecentDocumentsBlock.new | ||
80 | - box = mock | ||
81 | - block.expects(:box).returns(box).at_least_once | ||
82 | - box.expects(:owner).returns(Environment.new).at_least_once | ||
83 | - assert_equal nil, block.footer | ||
84 | - end | ||
85 | - | ||
86 | should 'be able to update display setting' do | 60 | should 'be able to update display setting' do |
87 | assert @block.update!(:display => 'always') | 61 | assert @block.update!(:display => 'always') |
88 | @block.reload | 62 | @block.reload |
@@ -100,3 +74,56 @@ class RecentDocumentsBlockTest < ActiveSupport::TestCase | @@ -100,3 +74,56 @@ class RecentDocumentsBlockTest < ActiveSupport::TestCase | ||
100 | assert_equal 0, block.get_limit | 74 | assert_equal 0, block.get_limit |
101 | end | 75 | end |
102 | end | 76 | end |
77 | + | ||
78 | +require 'boxes_helper' | ||
79 | + | ||
80 | +class RecentDocumentsBlockViewTest < ActionView::TestCase | ||
81 | + include BoxesHelper | ||
82 | + | ||
83 | + def setup | ||
84 | + @articles = [] | ||
85 | + @profile = create_user('testinguser').person | ||
86 | + @profile.articles.destroy_all | ||
87 | + ['first', 'second', 'third', 'fourth', 'fifth'].each do |name| | ||
88 | + article = @profile.articles.create!(:name => name) | ||
89 | + @articles << article | ||
90 | + end | ||
91 | + | ||
92 | + box = Box.new | ||
93 | + box.owner = profile | ||
94 | + box.save! | ||
95 | + | ||
96 | + | ||
97 | + @block = RecentDocumentsBlock.new | ||
98 | + @block.box_id = box.id | ||
99 | + @block.save! | ||
100 | + | ||
101 | + end | ||
102 | + attr_reader :block, :profile, :articles | ||
103 | + | ||
104 | + should 'link to documents' do | ||
105 | + articles.each do |a| | ||
106 | + ActionView::Base.any_instance.expects(:link_to).with(a.title, a.url) | ||
107 | + end | ||
108 | + ActionView::Base.any_instance.stubs(:block_title).returns("") | ||
109 | + ActionView::Base.any_instance.stubs(:content_tag).returns("") | ||
110 | + ActionView::Base.any_instance.stubs(:li).returns("") | ||
111 | + | ||
112 | + render_block_content(block) | ||
113 | + end | ||
114 | + | ||
115 | + should 'display a link to sitemap with title "All content"' do | ||
116 | + ActionView::Base.any_instance.expects(:link_to).with('All content', :controller => 'profile', :action => 'sitemap', :profile => profile.identifier) | ||
117 | + ActionView::Base.any_instance.expects(:_).with('All content').returns('All content') | ||
118 | + | ||
119 | + render_block_footer(block) | ||
120 | + end | ||
121 | + | ||
122 | + should 'not display link to sitemap when owner is environment' do | ||
123 | + block = RecentDocumentsBlock.new | ||
124 | + box = mock | ||
125 | + block.expects(:box).returns(box).at_least_once | ||
126 | + box.expects(:owner).returns(Environment.new).at_least_once | ||
127 | + assert_equal '', render_block_footer(block) | ||
128 | + end | ||
129 | +end |
test/unit/sellers_search_block_test.rb
@@ -10,10 +10,4 @@ class SellersSearchBlockTest < ActiveSupport::TestCase | @@ -10,10 +10,4 @@ class SellersSearchBlockTest < ActiveSupport::TestCase | ||
10 | assert_not_equal Block.new.default_title, SellersSearchBlock.new.default_title | 10 | assert_not_equal Block.new.default_title, SellersSearchBlock.new.default_title |
11 | end | 11 | end |
12 | 12 | ||
13 | - should 'not use a fixed title' do | ||
14 | - block = SellersSearchBlock.new(:title => 'my custom title') | ||
15 | - expects(:render).with(:file => 'search/_sellers_form', :locals => { :title => 'my custom title'}) | ||
16 | - instance_eval(&block.content) | ||
17 | - end | ||
18 | - | ||
19 | end | 13 | end |
test/unit/slideshow_block_test.rb
1 | require_relative "../test_helper" | 1 | require_relative "../test_helper" |
2 | +require 'boxes_helper' | ||
2 | 3 | ||
3 | class SlideshowBlockTest < ActiveSupport::TestCase | 4 | class SlideshowBlockTest < ActiveSupport::TestCase |
5 | + include BoxesHelper | ||
4 | 6 | ||
5 | def setup | 7 | def setup |
6 | @profile = fast_create(Profile) | 8 | @profile = fast_create(Profile) |
@@ -30,7 +32,7 @@ class SlideshowBlockTest < ActiveSupport::TestCase | @@ -30,7 +32,7 @@ class SlideshowBlockTest < ActiveSupport::TestCase | ||
30 | 32 | ||
31 | block = SlideshowBlock.new | 33 | block = SlideshowBlock.new |
32 | block.stubs(:gallery).returns(gallery) | 34 | block.stubs(:gallery).returns(gallery) |
33 | - block.content | 35 | + render_block_content(block) |
34 | end | 36 | end |
35 | 37 | ||
36 | should 'list in random order' do | 38 | should 'list in random order' do |
@@ -42,7 +44,7 @@ class SlideshowBlockTest < ActiveSupport::TestCase | @@ -42,7 +44,7 @@ class SlideshowBlockTest < ActiveSupport::TestCase | ||
42 | block.stubs(:block_images).returns(images) | 44 | block.stubs(:block_images).returns(images) |
43 | images.expects(:shuffle).once.returns(shuffled) | 45 | images.expects(:shuffle).once.returns(shuffled) |
44 | 46 | ||
45 | - block.content | 47 | + render_block_content(block) |
46 | end | 48 | end |
47 | 49 | ||
48 | should 'not shuffle by default' do | 50 | should 'not shuffle by default' do |
test/unit/tags_block_test.rb
@@ -25,47 +25,80 @@ class TagsBlockTest < ActiveSupport::TestCase | @@ -25,47 +25,80 @@ class TagsBlockTest < ActiveSupport::TestCase | ||
25 | assert_not_equal Block.new.default_title, TagsBlock.new.default_title | 25 | assert_not_equal Block.new.default_title, TagsBlock.new.default_title |
26 | end | 26 | end |
27 | 27 | ||
28 | - should 'generate links to tags' do | ||
29 | - assert_match /profile\/testinguser\/tags\/first-tag/, block.content | ||
30 | - assert_match /profile\/testinguser\/tags\/second-tag/, block.content | ||
31 | - assert_match /profile\/testinguser\/tags\/third-tag/, block.content | 28 | + include BoxesHelper |
29 | + | ||
30 | + should 'return the max value in the range between zero and limit' do | ||
31 | + block = TagsBlock.new | ||
32 | + assert_equal 12, block.get_limit | ||
32 | end | 33 | end |
33 | 34 | ||
34 | - should 'generate links to tags on a environment page' do | ||
35 | - @otheruser = create_user('othertestinguser').person | ||
36 | - @otheruser.articles.build(:name => 'article A', :tag_list => 'other-tag').save! | ||
37 | - @otheruser.articles.build(:name => 'article B', :tag_list => 'other-tag, second-tag').save! | ||
38 | - box = create(Box, :owner => Environment.default) | ||
39 | - @block = create(TagsBlock, :box => box) | 35 | + should '' do |
36 | + block = TagsBlock.new | ||
37 | + block.limit = -5 | ||
38 | + assert_equal 0, block.get_limit | ||
39 | + end | ||
40 | +end | ||
41 | + | ||
42 | +require 'tags_helper' | ||
43 | + | ||
44 | +class TagsBlockViewTest < ActionView::TestCase | ||
45 | + include BoxesHelper | ||
46 | + | ||
47 | + ActionView::Base.send :include, TagsHelper | ||
48 | + | ||
49 | + def setup | ||
50 | + @user = create_user('testinguser').person | ||
51 | + @user.articles.build(:name => 'article 1', :tag_list => 'first-tag').save! | ||
52 | + @user.articles.build(:name => 'article 2', :tag_list => 'first-tag, second-tag').save! | ||
53 | + @user.articles.build(:name => 'article 3', :tag_list => 'first-tag, second-tag, third-tag').save! | ||
40 | 54 | ||
41 | - assert_match /3 items[^>]+\/tag\/first-tag/, block.content | ||
42 | - assert_match /3 items[^>]+\/tag\/second-tag/, block.content | ||
43 | - assert_match /one item[^>]+\/tag\/third-tag/, block.content | ||
44 | - assert_match /2 item[^>]+\/tag\/other-tag"/, block.content | 55 | + box = Box.new |
56 | + box.owner = @user | ||
57 | + box.save! | ||
58 | + @block = TagsBlock.new | ||
59 | + @block.box = box | ||
60 | + @block.save | ||
45 | end | 61 | end |
62 | + attr_reader :block | ||
46 | 63 | ||
47 | should 'return (none) when no tags to display' do | 64 | should 'return (none) when no tags to display' do |
65 | + ActionView::Base.any_instance.stubs(:block_title).returns("") | ||
48 | block.owner.expects(:article_tags).returns([]) | 66 | block.owner.expects(:article_tags).returns([]) |
49 | - assert_equal '', block.content | 67 | + assert_equal "\n\n\n", render_block_content(block) |
50 | end | 68 | end |
51 | 69 | ||
52 | - should 'generate links when profile has own hostname' do | ||
53 | - @user.domains << Domain.new(:name => 'testuser.net'); @user.save! | ||
54 | - assert_match /profile\/testinguser\/tags\/first-tag/, block.content | 70 | + should 'order tags alphabetically' do |
71 | + ActionView::Base.any_instance.stubs(:block_title).returns("") | ||
72 | + assert /\/first-tag".*\/second-tag".*\/third-tag"/m =~ render_block_content(block) | ||
55 | end | 73 | end |
56 | 74 | ||
57 | - should 'order tags alphabetically' do | ||
58 | - assert /\/first-tag".*\/second-tag".*\/third-tag"/m =~ block.content | 75 | + should 'generate links to tags' do |
76 | + ActionView::Base.any_instance.stubs(:block_title).returns("") | ||
77 | + content = render_block_content(block) | ||
78 | + assert_match /profile\/testinguser\/tags\/first-tag/, content | ||
79 | + assert_match /profile\/testinguser\/tags\/second-tag/, content | ||
80 | + assert_match /profile\/testinguser\/tags\/third-tag/, content | ||
59 | end | 81 | end |
60 | 82 | ||
61 | - should 'return the max value in the range between zero and limit' do | ||
62 | - block = TagsBlock.new | ||
63 | - assert_equal 12, block.get_limit | 83 | + should 'generate links to tags on a environment page' do |
84 | + @otheruser = create_user('othertestinguser').person | ||
85 | + @otheruser.articles.build(:name => 'article A', :tag_list => 'other-tag').save! | ||
86 | + @otheruser.articles.build(:name => 'article B', :tag_list => 'other-tag, second-tag').save! | ||
87 | + box = create(Box, :owner => Environment.default) | ||
88 | + @block = create(TagsBlock, :box => box) | ||
89 | + ActionView::Base.any_instance.stubs(:block_title).returns("") | ||
90 | + | ||
91 | + content = render_block_content(block) | ||
92 | + assert_match /3 items[^>]+\/tag\/first-tag/, content | ||
93 | + assert_match /3 items[^>]+\/tag\/second-tag/, content | ||
94 | + assert_match /one item[^>]+\/tag\/third-tag/, content | ||
95 | + assert_match /2 item[^>]+\/tag\/other-tag"/, content | ||
64 | end | 96 | end |
65 | 97 | ||
66 | - should '' do | ||
67 | - block = TagsBlock.new | ||
68 | - block.limit = -5 | ||
69 | - assert_equal 0, block.get_limit | 98 | + |
99 | + should 'generate links when profile has own hostname' do | ||
100 | + @user.domains << Domain.new(:name => 'testuser.net'); @user.save! | ||
101 | + ActionView::Base.any_instance.stubs(:block_title).returns("") | ||
102 | + assert_match /profile\/testinguser\/tags\/first-tag/, render_block_content(block) | ||
70 | end | 103 | end |
71 | end | 104 | end |
test/unit/task_test.rb
@@ -182,6 +182,31 @@ class TaskTest < ActiveSupport::TestCase | @@ -182,6 +182,31 @@ class TaskTest < ActiveSupport::TestCase | ||
182 | task.save! | 182 | task.save! |
183 | end | 183 | end |
184 | 184 | ||
185 | + should 'not send notification to target if notification is disabled in profile' do | ||
186 | + task = Task.new | ||
187 | + target = fast_create(Organization) | ||
188 | + target.stubs(:notification_emails).returns(['adm@example.com']) | ||
189 | + target.stubs(:profile_admin_mail_notification).returns(false) | ||
190 | + task.target = target | ||
191 | + task.stubs(:target_notification_message).returns('some non nil message to be sent to target') | ||
192 | + TaskMailer.expects(:target_notification).never | ||
193 | + task.save! | ||
194 | + end | ||
195 | + | ||
196 | + should 'send notification to target if notification is enabled in profile' do | ||
197 | + task = Task.new | ||
198 | + target = fast_create(Organization) | ||
199 | + target.stubs(:notification_emails).returns(['adm@example.com']) | ||
200 | + target.stubs(:profile_admin_mail_notification).returns(true) | ||
201 | + task.target = target | ||
202 | + task.stubs(:target_notification_message).returns('some non nil message to be sent to target') | ||
203 | + | ||
204 | + mailer = mock | ||
205 | + mailer.expects(:deliver).once | ||
206 | + TaskMailer.expects(:target_notification).returns(mailer).once | ||
207 | + task.save! | ||
208 | + end | ||
209 | + | ||
185 | should 'be able to list pending tasks' do | 210 | should 'be able to list pending tasks' do |
186 | Task.delete_all | 211 | Task.delete_all |
187 | t1 = Task.create! | 212 | t1 = Task.create! |
test/unit/textile_article_test.rb
@@ -3,7 +3,8 @@ require_relative "../test_helper" | @@ -3,7 +3,8 @@ require_relative "../test_helper" | ||
3 | class TextileArticleTest < ActiveSupport::TestCase | 3 | class TextileArticleTest < ActiveSupport::TestCase |
4 | 4 | ||
5 | def setup | 5 | def setup |
6 | - @profile = create_user('testing').person | 6 | + @user = User.current = create_user 'testing' |
7 | + @profile = @user.person | ||
7 | end | 8 | end |
8 | attr_reader :profile | 9 | attr_reader :profile |
9 | 10 | ||
@@ -16,7 +17,7 @@ class TextileArticleTest < ActiveSupport::TestCase | @@ -16,7 +17,7 @@ class TextileArticleTest < ActiveSupport::TestCase | ||
16 | end | 17 | end |
17 | 18 | ||
18 | should 'convert Textile to HTML' do | 19 | should 'convert Textile to HTML' do |
19 | - assert_equal '<p><strong>my text</strong></p>', build(TextileArticle, :body => '*my text*').to_html | 20 | + assert_equal '<p><strong>my text</strong></p>', build(TextileArticle, body: '*my text*').to_html |
20 | end | 21 | end |
21 | 22 | ||
22 | should 'accept empty body' do | 23 | should 'accept empty body' do |
@@ -34,23 +35,21 @@ class TextileArticleTest < ActiveSupport::TestCase | @@ -34,23 +35,21 @@ class TextileArticleTest < ActiveSupport::TestCase | ||
34 | 35 | ||
35 | should 'notify activity on create' do | 36 | should 'notify activity on create' do |
36 | ActionTracker::Record.delete_all | 37 | ActionTracker::Record.delete_all |
37 | - create TextileArticle, :name => 'test', :profile_id => fast_create(Profile).id, :published => true | 38 | + create TextileArticle, name: 'test', profile_id: profile.id, published: true |
38 | assert_equal 1, ActionTracker::Record.count | 39 | assert_equal 1, ActionTracker::Record.count |
39 | end | 40 | end |
40 | 41 | ||
41 | should 'not group trackers activity of article\'s creation' do | 42 | should 'not group trackers activity of article\'s creation' do |
42 | - profile = fast_create(Profile) | ||
43 | assert_difference 'ActionTracker::Record.count', 3 do | 43 | assert_difference 'ActionTracker::Record.count', 3 do |
44 | - create TextileArticle, :name => 'bar', :profile_id => profile.id, :published => true | ||
45 | - create TextileArticle, :name => 'another bar', :profile_id => profile.id, :published => true | ||
46 | - create TextileArticle, :name => 'another bar', :profile_id => fast_create(Profile).id, :published => true | 44 | + create TextileArticle, name: 'bar', profile_id: profile.id, published: true |
45 | + create TextileArticle, name: 'another bar', profile_id: profile.id, published: true | ||
46 | + create TextileArticle, name: 'another bar 2', profile_id: profile.id, published: true | ||
47 | end | 47 | end |
48 | end | 48 | end |
49 | 49 | ||
50 | should 'not update activity on update of an article' do | 50 | should 'not update activity on update of an article' do |
51 | ActionTracker::Record.delete_all | 51 | ActionTracker::Record.delete_all |
52 | - profile = fast_create(Profile) | ||
53 | - article = create(TextileArticle, :profile_id => profile.id) | 52 | + article = create(TextileArticle, profile_id: profile.id) |
54 | time = article.activity.updated_at | 53 | time = article.activity.updated_at |
55 | Time.stubs(:now).returns(time + 1.day) | 54 | Time.stubs(:now).returns(time + 1.day) |
56 | assert_no_difference 'ActionTracker::Record.count' do | 55 | assert_no_difference 'ActionTracker::Record.count' do |
@@ -62,8 +61,8 @@ class TextileArticleTest < ActiveSupport::TestCase | @@ -62,8 +61,8 @@ class TextileArticleTest < ActiveSupport::TestCase | ||
62 | 61 | ||
63 | should 'not create trackers activity when updating articles' do | 62 | should 'not create trackers activity when updating articles' do |
64 | ActionTracker::Record.delete_all | 63 | ActionTracker::Record.delete_all |
65 | - a1 = create TextileArticle, :name => 'bar', :profile_id => fast_create(Profile).id, :published => true | ||
66 | - a2 = create TextileArticle, :name => 'another bar', :profile_id => fast_create(Profile).id, :published => true | 64 | + a1 = create TextileArticle, name: 'bar', profile_id: profile.id, published: true |
65 | + a2 = create TextileArticle, name: 'another bar', profile_id: profile.id, published: true | ||
67 | assert_no_difference 'ActionTracker::Record.count' do | 66 | assert_no_difference 'ActionTracker::Record.count' do |
68 | a1.name = 'foo';a1.save! | 67 | a1.name = 'foo';a1.save! |
69 | a2.name = 'another foo';a2.save! | 68 | a2.name = 'another foo';a2.save! |
@@ -72,7 +71,7 @@ class TextileArticleTest < ActiveSupport::TestCase | @@ -72,7 +71,7 @@ class TextileArticleTest < ActiveSupport::TestCase | ||
72 | 71 | ||
73 | should 'remove activity after destroying article' do | 72 | should 'remove activity after destroying article' do |
74 | ActionTracker::Record.delete_all | 73 | ActionTracker::Record.delete_all |
75 | - a = create TextileArticle, :name => 'bar', :profile_id => fast_create(Profile).id, :published => true | 74 | + a = create TextileArticle, name: 'bar', profile_id: profile.id, published: true |
76 | assert_difference 'ActionTracker::Record.count', -1 do | 75 | assert_difference 'ActionTracker::Record.count', -1 do |
77 | a.destroy | 76 | a.destroy |
78 | end | 77 | end |
@@ -80,8 +79,8 @@ class TextileArticleTest < ActiveSupport::TestCase | @@ -80,8 +79,8 @@ class TextileArticleTest < ActiveSupport::TestCase | ||
80 | 79 | ||
81 | should 'remove activity after article is destroyed' do | 80 | should 'remove activity after article is destroyed' do |
82 | ActionTracker::Record.delete_all | 81 | ActionTracker::Record.delete_all |
83 | - a1 = create TextileArticle, :name => 'bar', :profile_id => fast_create(Profile).id, :published => true | ||
84 | - a2 = create TextileArticle, :name => 'another bar', :profile_id => fast_create(Profile).id, :published => true | 82 | + a1 = create TextileArticle, name: 'bar', profile_id: profile.id, published: true |
83 | + a2 = create TextileArticle, name: 'another bar', profile_id: profile.id, published: true | ||
85 | assert_equal 2, ActionTracker::Record.count | 84 | assert_equal 2, ActionTracker::Record.count |
86 | assert_difference 'ActionTracker::Record.count', -2 do | 85 | assert_difference 'ActionTracker::Record.count', -2 do |
87 | a1.destroy | 86 | a1.destroy |
@@ -95,20 +94,20 @@ class TextileArticleTest < ActiveSupport::TestCase | @@ -95,20 +94,20 @@ class TextileArticleTest < ActiveSupport::TestCase | ||
95 | p1 = Person.first | 94 | p1 = Person.first |
96 | community.add_member(p1) | 95 | community.add_member(p1) |
97 | assert p1.is_member_of?(community) | 96 | assert p1.is_member_of?(community) |
98 | - article = create TextileArticle, :name => 'test', :profile_id => community.id | 97 | + article = create TextileArticle, name: 'test', profile_id: community.id |
99 | assert_equal article, ActionTracker::Record.last.target | 98 | assert_equal article, ActionTracker::Record.last.target |
100 | end | 99 | end |
101 | 100 | ||
102 | should "the tracker action target be defined as the article on articles'creation in profile" do | 101 | should "the tracker action target be defined as the article on articles'creation in profile" do |
103 | ActionTracker::Record.delete_all | 102 | ActionTracker::Record.delete_all |
104 | person = Person.first | 103 | person = Person.first |
105 | - article = create TextileArticle, :name => 'test', :profile_id => person.id | 104 | + article = create TextileArticle, name: 'test', profile_id: person.id |
106 | assert_equal article, ActionTracker::Record.last.target | 105 | assert_equal article, ActionTracker::Record.last.target |
107 | end | 106 | end |
108 | 107 | ||
109 | should 'not notify activity if the article is not advertise' do | 108 | should 'not notify activity if the article is not advertise' do |
110 | ActionTracker::Record.delete_all | 109 | ActionTracker::Record.delete_all |
111 | - a = create TextileArticle, :name => 'bar', :profile_id => fast_create(Profile).id, :published => true, :advertise => false | 110 | + a = create TextileArticle, name: 'bar', profile_id: profile.id, published: true, advertise: false |
112 | assert_equal true, a.published? | 111 | assert_equal true, a.published? |
113 | assert_equal true, a.notifiable? | 112 | assert_equal true, a.notifiable? |
114 | assert_equal false, a.image? | 113 | assert_equal false, a.image? |
@@ -121,7 +120,7 @@ class TextileArticleTest < ActiveSupport::TestCase | @@ -121,7 +120,7 @@ class TextileArticleTest < ActiveSupport::TestCase | ||
121 | end | 120 | end |
122 | 121 | ||
123 | should "the common trackable conditions return the correct value" do | 122 | should "the common trackable conditions return the correct value" do |
124 | - a = build(TextileArticle, :profile => profile) | 123 | + a = build(TextileArticle, profile: profile) |
125 | a.published = a.advertise = true | 124 | a.published = a.advertise = true |
126 | assert_equal true, a.published? | 125 | assert_equal true, a.published? |
127 | assert_equal true, a.notifiable? | 126 | assert_equal true, a.notifiable? |
@@ -139,7 +138,7 @@ class TextileArticleTest < ActiveSupport::TestCase | @@ -139,7 +138,7 @@ class TextileArticleTest < ActiveSupport::TestCase | ||
139 | end | 138 | end |
140 | 139 | ||
141 | should 'generate proper HTML for links' do | 140 | should 'generate proper HTML for links' do |
142 | - assert_tag_in_string build_article('"Noosfero":http://noosfero.org/').to_html, :tag => 'a', :attributes => { :href => 'http://noosfero.org/' } | 141 | + assert_tag_in_string build_article('"Noosfero":http://noosfero.org/').to_html, tag: 'a', attributes: { href: 'http://noosfero.org/' } |
143 | end | 142 | end |
144 | 143 | ||
145 | should 'not mess up with textile markup' do | 144 | should 'not mess up with textile markup' do |
@@ -153,7 +152,7 @@ class TextileArticleTest < ActiveSupport::TestCase | @@ -153,7 +152,7 @@ class TextileArticleTest < ActiveSupport::TestCase | ||
153 | end | 152 | end |
154 | 153 | ||
155 | should 'not allow Javascript on links' do | 154 | should 'not allow Javascript on links' do |
156 | - assert_no_tag_in_string build_article('<a href="javascript: alert(\'BOOM\')" onclick="javascript: alert(\'BOOM\')"></a>').to_html, :tag => 'a', :attributes => { :href => /./, :onclick => /./ } | 155 | + assert_no_tag_in_string build_article('<a href="javascript: alert(\'BOOM\')" onclick="javascript: alert(\'BOOM\')"></a>').to_html, tag: 'a', attributes: { href: /./, onclick: /./ } |
157 | end | 156 | end |
158 | 157 | ||
159 | should 'allow harmless HTML' do | 158 | should 'allow harmless HTML' do |
@@ -163,11 +162,11 @@ class TextileArticleTest < ActiveSupport::TestCase | @@ -163,11 +162,11 @@ class TextileArticleTest < ActiveSupport::TestCase | ||
163 | end | 162 | end |
164 | 163 | ||
165 | should 'use Textile markup for lead as well' do | 164 | should 'use Textile markup for lead as well' do |
166 | - assert_tag_in_string build_article(nil, :abstract => '"Noosfero":http://noosfero.org/').lead, :tag => 'a', :attributes => { :href => 'http://noosfero.org/' } | 165 | + assert_tag_in_string build_article(nil, abstract: '"Noosfero":http://noosfero.org/').lead, tag: 'a', attributes: { href: 'http://noosfero.org/' } |
167 | end | 166 | end |
168 | 167 | ||
169 | should 'not allow arbitrary HTML in the lead' do | 168 | should 'not allow arbitrary HTML in the lead' do |
170 | - assert_not_equal '<script>alert(1)</script>', build_article(nil, :abstract => '<script>alert(1)</script>').lead | 169 | + assert_not_equal '<script>alert(1)</script>', build_article(nil, abstract: '<script>alert(1)</script>').lead |
171 | end | 170 | end |
172 | 171 | ||
173 | should 'not add hard breaks for single line breaks' do | 172 | should 'not add hard breaks for single line breaks' do |
@@ -182,7 +181,7 @@ class TextileArticleTest < ActiveSupport::TestCase | @@ -182,7 +181,7 @@ class TextileArticleTest < ActiveSupport::TestCase | ||
182 | protected | 181 | protected |
183 | 182 | ||
184 | def build_article(input = nil, options = {}) | 183 | def build_article(input = nil, options = {}) |
185 | - article = build(TextileArticle, {:body => input}.merge(options)) | 184 | + article = build(TextileArticle, {body: input}.merge(options)) |
186 | article.valid? # trigger the xss terminate thingy | 185 | article.valid? # trigger the xss terminate thingy |
187 | article | 186 | article |
188 | end | 187 | end |
test/unit/user_test.rb
@@ -509,6 +509,7 @@ class UserTest < ActiveSupport::TestCase | @@ -509,6 +509,7 @@ class UserTest < ActiveSupport::TestCase | ||
509 | should 'deliver e-mail with activation code after creation' do | 509 | should 'deliver e-mail with activation code after creation' do |
510 | assert_difference 'ActionMailer::Base.deliveries.size', 1 do | 510 | assert_difference 'ActionMailer::Base.deliveries.size', 1 do |
511 | new_user :email => 'pending@activation.com' | 511 | new_user :email => 'pending@activation.com' |
512 | + process_delayed_job_queue | ||
512 | end | 513 | end |
513 | assert_equal 'pending@activation.com', ActionMailer::Base.deliveries.last['to'].to_s | 514 | assert_equal 'pending@activation.com', ActionMailer::Base.deliveries.last['to'].to_s |
514 | end | 515 | end |
@@ -639,6 +640,7 @@ class UserTest < ActiveSupport::TestCase | @@ -639,6 +640,7 @@ class UserTest < ActiveSupport::TestCase | ||
639 | env.save | 640 | env.save |
640 | 641 | ||
641 | user = new_user :email => 'pending@activation.com' | 642 | user = new_user :email => 'pending@activation.com' |
643 | + process_delayed_job_queue | ||
642 | assert_difference 'ActionMailer::Base.deliveries.size', 1 do | 644 | assert_difference 'ActionMailer::Base.deliveries.size', 1 do |
643 | user.activate | 645 | user.activate |
644 | process_delayed_job_queue | 646 | process_delayed_job_queue |
@@ -659,6 +661,7 @@ class UserTest < ActiveSupport::TestCase | @@ -659,6 +661,7 @@ class UserTest < ActiveSupport::TestCase | ||
659 | env.save | 661 | env.save |
660 | 662 | ||
661 | user = new_user :email => 'pending@activation.com' | 663 | user = new_user :email => 'pending@activation.com' |
664 | + process_delayed_job_queue | ||
662 | assert_difference 'ActionMailer::Base.deliveries.size', 1 do | 665 | assert_difference 'ActionMailer::Base.deliveries.size', 1 do |
663 | user.activate | 666 | user.activate |
664 | process_delayed_job_queue | 667 | process_delayed_job_queue |
@@ -678,6 +681,7 @@ class UserTest < ActiveSupport::TestCase | @@ -678,6 +681,7 @@ class UserTest < ActiveSupport::TestCase | ||
678 | env.save | 681 | env.save |
679 | 682 | ||
680 | user = new_user :name => 'John Doe', :email => 'pending@activation.com' | 683 | user = new_user :name => 'John Doe', :email => 'pending@activation.com' |
684 | + process_delayed_job_queue | ||
681 | assert_difference 'ActionMailer::Base.deliveries.size', 1 do | 685 | assert_difference 'ActionMailer::Base.deliveries.size', 1 do |
682 | user.activate | 686 | user.activate |
683 | process_delayed_job_queue | 687 | process_delayed_job_queue |