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 | 24 | - libreadline-dev |
25 | 25 | - libsqlite3-dev |
26 | 26 | - libxslt1-dev |
27 | + artifacts: | |
28 | + paths: | |
29 | + - $(ls tmp/artifact* | tr "\n" ":") | |
27 | 30 | |
28 | 31 | # workaround for https://github.com/travis-ci/travis-ci/issues/4536 |
29 | 32 | before_install: |
... | ... | @@ -32,7 +35,7 @@ before_install: |
32 | 35 | cache: bundler |
33 | 36 | |
34 | 37 | before_script: |
35 | - - mkdir -p tmp/{pids,cache} log | |
38 | + - mkdir -p tmp/{pids,cache} log cache | |
36 | 39 | - script/noosfero-plugins disableall |
37 | 40 | #- bundle exec rake makemo &>/dev/null |
38 | 41 | # database | ... | ... |
... | ... | @@ -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 | 2 | protect 'manage_memberships', :profile |
3 | 3 | |
4 | 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 | 26 | end |
8 | 27 | |
9 | 28 | def update_roles |
... | ... | @@ -156,4 +175,13 @@ class ProfileMembersController < MyProfileController |
156 | 175 | end |
157 | 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 | 187 | end | ... | ... |
app/controllers/public/content_viewer_controller.rb
... | ... | @@ -239,8 +239,12 @@ class ContentViewerController < ApplicationController |
239 | 239 | |
240 | 240 | def get_posts(year = nil, month = nil) |
241 | 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 | 248 | else |
245 | 249 | return @page.posts |
246 | 250 | end | ... | ... |
app/controllers/public/profile_controller.rb
... | ... | @@ -370,6 +370,7 @@ class ProfileController < PublicController |
370 | 370 | |
371 | 371 | def send_mail |
372 | 372 | @mailing = profile.mailings.build(params[:mailing]) |
373 | + @mailing.data = session[:members_filtered] ? {:members_filtered => session[:members_filtered]} : {} | |
373 | 374 | if request.post? |
374 | 375 | @mailing.locale = locale |
375 | 376 | @mailing.person = user | ... | ... |
app/helpers/application_helper.rb
... | ... | @@ -48,6 +48,8 @@ module ApplicationHelper |
48 | 48 | |
49 | 49 | include PluginsHelper |
50 | 50 | |
51 | + include ButtonsHelper | |
52 | + | |
51 | 53 | def locale |
52 | 54 | (@page && !@page.language.blank?) ? @page.language : FastGettext.locale |
53 | 55 | end |
... | ... | @@ -148,14 +150,8 @@ module ApplicationHelper |
148 | 150 | link_to text, profile_path(:profile => profile) , options |
149 | 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 | 155 | end |
160 | 156 | |
161 | 157 | def link_if_permitted(link, permission = nil, target = nil) |
... | ... | @@ -215,52 +211,6 @@ module ApplicationHelper |
215 | 211 | result |
216 | 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 | 214 | def icon(icon_name, html_options = {}) |
265 | 215 | the_class = "button #{icon_name}" |
266 | 216 | if html_options.has_key?(:class) |
... | ... | @@ -940,13 +890,6 @@ module ApplicationHelper |
940 | 890 | content_for(:head) { stylesheet_link_tag(*args) } |
941 | 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 | 893 | # Please, use link_to by default! |
951 | 894 | # This method was created to work around to inexplicable |
952 | 895 | # chain of problems when display_short_format was called |
... | ... | @@ -1049,10 +992,11 @@ module ApplicationHelper |
1049 | 992 | end |
1050 | 993 | |
1051 | 994 | def search_contents_menu |
995 | + host = environment.default_hostname | |
1052 | 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 | 1001 | if logged_in? |
1058 | 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 | 1008 | alias :browse_contents_menu :search_contents_menu |
1065 | 1009 | |
1066 | 1010 | def search_people_menu |
1011 | + host = environment.default_hostname | |
1067 | 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 | 1017 | if logged_in? |
1073 | 1018 | links.push(_('My friends') => {:href => url_for({:profile => current_user.login, :controller => 'friends'})}) |
... | ... | @@ -1080,10 +1025,11 @@ module ApplicationHelper |
1080 | 1025 | alias :browse_people_menu :search_people_menu |
1081 | 1026 | |
1082 | 1027 | def search_communities_menu |
1028 | + host = environment.default_hostname | |
1083 | 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 | 1034 | if logged_in? |
1089 | 1035 | links.push(_('My communities') => {:href => url_for({:profile => current_user.login, :controller => 'memberships'})}) |
... | ... | @@ -1368,16 +1314,6 @@ module ApplicationHelper |
1368 | 1314 | @no_design_blocks = true |
1369 | 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 | 1317 | def convert_macro(html, source) |
1382 | 1318 | doc = Nokogiri::HTML.fragment html |
1383 | 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 | 181 | end |
182 | 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 | 201 | end | ... | ... |
app/helpers/block_helper.rb
... | ... | @@ -14,6 +14,7 @@ module BlockHelper |
14 | 14 | </td> |
15 | 15 | <td>#{text_field_tag 'block[images][][address]', image[:address], :class => 'highlight-address', :size => 20}</td> |
16 | 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 | 18 | </tr><tr class=\"image-title\" data-row-number='#{row_number}'> |
18 | 19 | <td colspan=\"3\"><label>#{ |
19 | 20 | content_tag('span', _('Title')) + | ... | ... |
app/helpers/boxes_helper.rb
... | ... | @@ -87,10 +87,38 @@ module BoxesHelper |
87 | 87 | box_decorator == DontMoveBlocks |
88 | 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 | 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 | 122 | unless footer_content.blank? |
95 | 123 | footer_content = content_tag('div', footer_content, :class => 'block-footer-content' ) |
96 | 124 | end | ... | ... |
... | ... | @@ -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 | 7 | |
8 | 8 | def labelled_check_box( human_name, name, value = "1", checked = false, options = {} ) |
9 | 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 | 14 | end |
14 | 15 | |
15 | 16 | def labelled_text_field( human_name, name, value=nil, options={} ) | ... | ... |
app/mailers/mailing.rb
... | ... | @@ -2,7 +2,10 @@ require_dependency 'mailing_job' |
2 | 2 | |
3 | 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 | 9 | validates_presence_of :source_id, :subject, :body |
7 | 10 | belongs_to :source, :foreign_key => :source_id, :polymorphic => true |
8 | 11 | belongs_to :person | ... | ... |
app/mailers/organization_mailing.rb
... | ... | @@ -5,9 +5,17 @@ class OrganizationMailing < Mailing |
5 | 5 | end |
6 | 6 | |
7 | 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 | 16 | .where("m.person_id" => nil) |
17 | + end | |
18 | + result | |
11 | 19 | end |
12 | 20 | |
13 | 21 | def each_recipient | ... | ... |
app/models/article_block.rb
... | ... | @@ -18,18 +18,6 @@ class ArticleBlock < Block |
18 | 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 | 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 | 21 | def article_id |
34 | 22 | self.settings[:article_id] |
35 | 23 | end | ... | ... |
app/models/blog.rb
... | ... | @@ -93,4 +93,20 @@ class Blog < Folder |
93 | 93 | posts.where("type != 'RssFeed'").order(:updated_at).limit(limit) |
94 | 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 | 112 | end | ... | ... |
app/models/blog_archives_block.rb
... | ... | @@ -21,30 +21,6 @@ class BlogArchivesBlock < Block |
21 | 21 | blog_id && owner.blogs.exists?(blog_id) ? owner.blogs.find(blog_id) : owner.blog |
22 | 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 | 24 | def self.expire_on |
49 | 25 | { :profile => [:article], :environment => [:article] } |
50 | 26 | end | ... | ... |
app/models/categories_block.rb
... | ... | @@ -30,13 +30,6 @@ class CategoriesBlock < Block |
30 | 30 | Category.top_level_for(self.owner).from_types(self.category_types) |
31 | 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 | 33 | def self.expire_on |
41 | 34 | { :profile => [], :environment => [:category] } |
42 | 35 | end | ... | ... |
app/models/communities_block.rb
... | ... | @@ -27,15 +27,6 @@ class CommunitiesBlock < ProfileListBlock |
27 | 27 | owner.profile_suggestions.of_community.enabled.limit(3).includes(:suggestion) |
28 | 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 | 30 | def profiles |
40 | 31 | owner.communities |
41 | 32 | end | ... | ... |
app/models/disabled_enterprise_message_block.rb
... | ... | @@ -12,13 +12,6 @@ class DisabledEnterpriseMessageBlock < Block |
12 | 12 | _('Message') |
13 | 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 | 15 | def editable?(user=nil) |
23 | 16 | false |
24 | 17 | end | ... | ... |
app/models/enterprises_block.rb
... | ... | @@ -12,22 +12,6 @@ class EnterprisesBlock < ProfileListBlock |
12 | 12 | _('Enterprises') |
13 | 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 | 15 | def profiles |
32 | 16 | owner.enterprises |
33 | 17 | end | ... | ... |
app/models/fans_block.rb
... | ... | @@ -12,14 +12,6 @@ class FansBlock < ProfileListBlock |
12 | 12 | _('This block presents the fans of an enterprise.') |
13 | 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 | 15 | def profiles |
24 | 16 | owner.fans |
25 | 17 | end | ... | ... |
app/models/favorite_enterprises_block.rb
... | ... | @@ -12,14 +12,6 @@ class FavoriteEnterprisesBlock < ProfileListBlock |
12 | 12 | _('Favorite Enterprises') |
13 | 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 | 15 | def profiles |
24 | 16 | owner.favorite_enterprises |
25 | 17 | end | ... | ... |
app/models/featured_products_block.rb
... | ... | @@ -32,11 +32,4 @@ class FeaturedProductsBlock < Block |
32 | 32 | self.owner.highlighted_products_with_image |
33 | 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 | 35 | end | ... | ... |
app/models/feed_reader_block.rb
... | ... | @@ -52,24 +52,6 @@ class FeedReaderBlock < Block |
52 | 52 | self.feed_title.nil? ? _('Feed Reader') : self.feed_title |
53 | 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 | 55 | def add_item(title, link, date, content) |
74 | 56 | self.feed_items.unshift( {:title => title, :link => link}) |
75 | 57 | end |
... | ... | @@ -85,8 +67,4 @@ class FeedReaderBlock < Block |
85 | 67 | self.save! |
86 | 68 | end |
87 | 69 | |
88 | - def content(args={}) | |
89 | - block_title(title) + formatted_feed_content | |
90 | - end | |
91 | - | |
92 | 70 | end | ... | ... |
app/models/highlights_block.rb
... | ... | @@ -15,6 +15,8 @@ class HighlightsBlock < Block |
15 | 15 | if !Noosfero.root.nil? and !i[:address].start_with?(Noosfero.root + '/') |
16 | 16 | i[:address] = Noosfero.root + i[:address] |
17 | 17 | end |
18 | + i[:new_window] = i[:new_window] == '1' ? true : false | |
19 | + | |
18 | 20 | begin |
19 | 21 | file = UploadedFile.find(i[:image_id]) |
20 | 22 | i[:image_src] = file.public_filename |
... | ... | @@ -41,13 +43,6 @@ class HighlightsBlock < Block |
41 | 43 | end |
42 | 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 | 46 | def folder_choices |
52 | 47 | owner.image_galleries |
53 | 48 | end | ... | ... |
app/models/link_list_block.rb
... | ... | @@ -59,20 +59,6 @@ class LinkListBlock < Block |
59 | 59 | _('Link list') |
60 | 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 | 62 | def expand_address(address) |
77 | 63 | add = if owner.respond_to?(:identifier) |
78 | 64 | address.gsub('{profile}', owner.identifier) |
... | ... | @@ -99,8 +85,6 @@ class LinkListBlock < Block |
99 | 85 | end |
100 | 86 | end |
101 | 87 | |
102 | - private | |
103 | - | |
104 | 88 | def sanitize_link(text) |
105 | 89 | sanitizer = HTML::WhiteListSanitizer.new |
106 | 90 | sanitizer.sanitize(text) | ... | ... |
app/models/location_block.rb
... | ... | @@ -13,12 +13,4 @@ class LocationBlock < Block |
13 | 13 | _('Shows where the profile is on the material world.') |
14 | 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 | 16 | end | ... | ... |
app/models/login_block.rb
app/models/main_block.rb
app/models/my_network_block.rb
... | ... | @@ -14,16 +14,6 @@ class MyNetworkBlock < Block |
14 | 14 | _('This block displays some info about your networking.') |
15 | 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 | 17 | def cacheable? |
28 | 18 | false |
29 | 19 | end | ... | ... |
app/models/person.rb
... | ... | @@ -16,10 +16,13 @@ class Person < Profile |
16 | 16 | acts_as_trackable :after_add => Proc.new {|p,t| notify_activity(t)} |
17 | 17 | acts_as_accessor |
18 | 18 | |
19 | - scope :members_of, -> resources { | |
19 | + scope :members_of, lambda { |resources, field = ''| | |
20 | 20 | resources = Array(resources) |
21 | + joins = [:role_assignments] | |
22 | + joins << :user if User.attribute_names.include? field | |
23 | + | |
21 | 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 | 28 | scope :not_members_of, -> resources { |
... | ... | @@ -48,8 +51,7 @@ class Person < Profile |
48 | 51 | ['( roles.key = ? AND role_assignments.accessor_type = ? AND role_assignments.accessor_id = ? ) OR ( |
49 | 52 | ( ( friendships.person_id = ? ) OR (profiles.public_profile = ?)) AND (profiles.visible = ?) )', 'environment_administrator', Profile.name, person.id, person.id, true, true] |
50 | 53 | ).uniq |
51 | - } | |
52 | - | |
54 | + } | |
53 | 55 | |
54 | 56 | def has_permission_with_admin?(permission, resource) |
55 | 57 | return true if resource.blank? || resource.admins.include?(self) | ... | ... |
app/models/product_categories_block.rb
... | ... | @@ -13,26 +13,6 @@ class ProductCategoriesBlock < Block |
13 | 13 | _('Helps to filter the products catalog.') |
14 | 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 | 16 | DISPLAY_OPTIONS = DISPLAY_OPTIONS.merge('catalog_only' => _('Only on the catalog')) |
37 | 17 | |
38 | 18 | def display | ... | ... |
app/models/products_block.rb
... | ... | @@ -19,26 +19,6 @@ class ProductsBlock < Block |
19 | 19 | _('This block presents a list of your products.') |
20 | 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 | 22 | settings_items :product_ids, type: Array |
43 | 23 | def product_ids=(array) |
44 | 24 | self.settings[:product_ids] = array | ... | ... |
app/models/profile.rb
... | ... | @@ -5,7 +5,7 @@ class Profile < ActiveRecord::Base |
5 | 5 | |
6 | 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 | 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 | 10 | # use for internationalizable human type names in search facets |
11 | 11 | # reimplement on subclasses |
... | ... | @@ -49,6 +49,9 @@ class Profile < ActiveRecord::Base |
49 | 49 | def self.organization_member_roles(env_id) |
50 | 50 | all_roles(env_id).select{ |r| r.key.match(/^profile_/) unless r.key.blank? || !r.profile_id.nil?} |
51 | 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 | 55 | def self.all_roles(env_id) |
53 | 56 | Role.where(environment_id: env_id) |
54 | 57 | end |
... | ... | @@ -155,15 +158,23 @@ class Profile < ActiveRecord::Base |
155 | 158 | |
156 | 159 | include TimeScopes |
157 | 160 | |
158 | - def members | |
161 | + def members(by_field = '') | |
159 | 162 | scopes = plugins.dispatch_scopes(:organization_members, self) |
160 | - scopes << Person.members_of(self) | |
163 | + scopes << Person.members_of(self,by_field) | |
161 | 164 | return scopes.first if scopes.size == 1 |
162 | 165 | ScopeTool.union *scopes |
163 | 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 | 178 | end |
168 | 179 | |
169 | 180 | class << self |
... | ... | @@ -234,6 +245,7 @@ class Profile < ActiveRecord::Base |
234 | 245 | settings_items :description |
235 | 246 | settings_items :fields_privacy, :type => :hash, :default => {} |
236 | 247 | settings_items :email_suggestions, :type => :boolean, :default => false |
248 | + settings_items :profile_admin_mail_notification, :type => :boolean, :default => true | |
237 | 249 | |
238 | 250 | validates_length_of :description, :maximum => 550, :allow_nil => true |
239 | 251 | |
... | ... | @@ -1102,6 +1114,10 @@ private :generate_url, :url_options |
1102 | 1114 | end |
1103 | 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 | 1121 | validates_inclusion_of :redirection_after_login, :in => Environment.login_redirection_options.keys, :allow_nil => true |
1106 | 1122 | def preferred_login_redirection |
1107 | 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 | 12 | _('This block presents the profile image') |
13 | 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 | 15 | def cacheable? |
27 | 16 | false |
28 | 17 | end | ... | ... |
app/models/profile_info_block.rb
... | ... | @@ -16,13 +16,6 @@ class ProfileInfoBlock < Block |
16 | 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 | 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 | 19 | def cacheable? |
27 | 20 | false |
28 | 21 | end | ... | ... |
app/models/profile_list_block.rb
... | ... | @@ -40,26 +40,6 @@ result = public_profiles.all(:limit => get_limit, :order => 'profiles.updated_at |
40 | 40 | _('Clicking on the people or groups will take you to their home page.') |
41 | 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 | 43 | def view_title |
64 | 44 | title.gsub('{#}', profile_count.to_s) |
65 | 45 | end | ... | ... |
app/models/profile_search_block.rb
... | ... | @@ -4,11 +4,4 @@ class ProfileSearchBlock < Block |
4 | 4 | _('Display a form to search the profile') |
5 | 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 | 7 | end | ... | ... |
app/models/raw_html_block.rb
app/models/recent_documents_block.rb
... | ... | @@ -22,24 +22,6 @@ class RecentDocumentsBlock < Block |
22 | 22 | |
23 | 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 | 25 | def docs |
44 | 26 | self.limit.nil? ? owner.recent_documents(nil, {}, false) : owner.recent_documents(self.get_limit, {}, false) |
45 | 27 | end | ... | ... |
app/models/sellers_search_block.rb
... | ... | @@ -22,10 +22,4 @@ class SellersSearchBlock < Block |
22 | 22 | _('This block presents a search engine for products.') |
23 | 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 | 25 | end | ... | ... |
app/models/slideshow_block.rb
... | ... | @@ -33,23 +33,6 @@ class SlideshowBlock < Block |
33 | 33 | gallery.images.reject {|item| item.folder?} |
34 | 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 | 36 | def folder_choices |
54 | 37 | owner.image_galleries |
55 | 38 | end | ... | ... |
app/models/tags_block.rb
... | ... | @@ -28,42 +28,6 @@ class TagsBlock < Block |
28 | 28 | Try to add some tags to some articles and you'l see your tag cloud growing.") |
29 | 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 | 31 | def timeout |
68 | 32 | 15.minutes |
69 | 33 | end | ... | ... |
app/models/task.rb
... | ... | @@ -67,7 +67,9 @@ class Task < ActiveRecord::Base |
67 | 67 | begin |
68 | 68 | target_msg = task.target_notification_message |
69 | 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 | 73 | end |
72 | 74 | rescue NotImplementedError => ex |
73 | 75 | Rails.logger.info ex.to_s |
... | ... | @@ -75,6 +77,14 @@ class Task < ActiveRecord::Base |
75 | 77 | end |
76 | 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 | 88 | # this method finished the task. It calls #perform, which must be overriden |
79 | 89 | # by subclasses. At the end a message (as returned by #finish_message) is |
80 | 90 | # sent to the requestor with #notify_requestor. | ... | ... |
app/views/account/index.html.erb
... | ... | @@ -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 @@ |
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 | -<% 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
... | ... | @@ -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 @@ |
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 @@ |
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 @@ |
1 | +<%= link_to _('View all'), :profile => block.owner.identifier, :controller => 'profile', :action => 'fans' %> | ... | ... |
... | ... | @@ -0,0 +1 @@ |
1 | +<%= link_to(_('View all products'), block.owner.public_profile_url.merge(:controller => 'catalog', :action => 'index')) %> | ... | ... |
... | ... | @@ -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 | 3 | <div class='highlights-border'> |
4 | 4 | <div class='highlights-container'> |
5 | 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 | 7 | <%= image_tag [Noosfero.root, img[:image_src]].join, alt: img[:title] %> |
8 | 8 | <p class="highlights-label"><%= img[:title] %></p> |
9 | 9 | </a> | ... | ... |
... | ... | @@ -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 | 2 | <%= block_title block.title %> |
3 | 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 | 5 | </div> |
6 | 6 | <% else %> |
7 | 7 | <i><%= _('This profile has no geographical position registered.') %></i> | ... | ... |
... | ... | @@ -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 | -<% 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 | 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 | 7 | <li><%= link_to _('Control panel'), :controller => 'profile_editor', :profile => profile.identifier %></li> |
8 | 8 | <% end %> |
9 | 9 | </ul> |
10 | 10 | |
11 | 11 | <div class="my-network-actions"> |
12 | - <%= render_profile_actions owner.class %> | |
12 | + <%= render_profile_actions block.owner.class %> | |
13 | 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 | 10 | <ul class="catalog-categories-list"> |
3 | 11 | <% categories.each do |category| %> |
4 | 12 | <%= category_with_sub_list(category) %> |
5 | 13 | <% end %> |
6 | 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 | 19 | <% end %> | ... | ... |
app/views/blocks/profile_image.html.erb
... | ... | @@ -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 @@ |
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 | 10 | <%= block_title(block.title) %> |
11 | + | |
2 | 12 | <% if images %> |
3 | 13 | <% description = images.any? { |img| !img.abstract.blank? } %> |
4 | 14 | <div class='slideshow-border<%= (description ? ' with-descriptions' : '')%>'> | ... | ... |
... | ... | @@ -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 | 3 | <strong><%= _('Highlights') %></strong> |
4 | 4 | |
5 | 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 | 7 | <% @block.images.each_with_index do |image, index| %> |
8 | 8 | <%= highlights_block_config_image_fields @block, image, index %> |
9 | 9 | <% end %> | ... | ... |
app/views/cms/_drag_and_drop_note.html.erb
app/views/cms/_text_editor_sidebar.html.erb
... | ... | @@ -17,8 +17,8 @@ |
17 | 17 | :parent_id, profile, default_folder, {}, {}, |
18 | 18 | "type='Folder' or type='Gallery'" |
19 | 19 | ) %> |
20 | + <%= button(:newfolder, _('New folder'), '#', :id => 'new-folder-button') %> | |
20 | 21 | </div> |
21 | - <%= button(:newfolder, _('New folder'), '#', :id => 'new-folder-button') %> | |
22 | 22 | <p><%= file_field_tag('file', :multiple => true) %></p> |
23 | 23 | <% end %> |
24 | 24 | </div> |
... | ... | @@ -31,7 +31,7 @@ |
31 | 31 | <div id='published-media' class='text-editor-sidebar-box' data-url='<%= url_for({:controller => 'cms', :action => 'published_media_items', :profile => profile.identifier}) %>'> |
32 | 32 | <%= select_profile_folder(nil, :parent_id, profile, 'recent-media', {}, {}, |
33 | 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 | 35 | <%= render :partial => 'drag_and_drop_note' %> |
36 | 36 | <div class='items'> |
37 | 37 | <%= render :partial => 'published_media_items' %> | ... | ... |
app/views/profile/send_mail.html.erb
... | ... | @@ -4,6 +4,9 @@ |
4 | 4 | |
5 | 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 | 10 | <%= form_for :mailing, :url => {:action => 'send_mail'}, :html => {:id => 'mailing-form'} do |f| %> |
8 | 11 | |
9 | 12 | <%= labelled_form_field(_('Subject:'), f.text_field(:subject)) %> | ... | ... |
app/views/profile_editor/_moderation.html.erb
1 | 1 | <h2><%= _('Moderation options') %></h2> |
2 | 2 | <% if profile.community? %> |
3 | 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 | 14 | <h4><%= _('Invitation moderation:')%></h4> |
5 | 15 | </div> |
6 | 16 | <div style='margin-bottom: 0.5em'> | ... | ... |
app/views/profile_members/_index_buttons.html.erb
... | ... | @@ -5,7 +5,7 @@ |
5 | 5 | <%= button :person, _('Invite people to join'), :controller => 'invite', :action => 'invite_friends' %> |
6 | 6 | <% end %> |
7 | 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 | 9 | <% end %> |
10 | 10 | <% @plugins.dispatch(:manage_members_extra_buttons).each do |plugin_button| %> |
11 | 11 | <%= button plugin_button[:icon], plugin_button[:title], plugin_button[:url] %> | ... | ... |
... | ... | @@ -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 | 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 | 3 | <% title = @title ? @title : _('Current members') %> |
3 | 4 | <% remove_action = @remove_action ? @remove_action : {:action => 'unassociate'} %> |
5 | +<%= javascript_include_tag params[:controller] %> | |
4 | 6 | |
5 | 7 | <h3><%= title %></h3> |
6 | 8 | |
7 | 9 | <table> |
10 | + <col width="1"> | |
8 | 11 | <tr> |
12 | + <th><%= check_box_tag 'checkbox-all', 1, false, :onClick => "toggle(this)" %></th> | |
9 | 13 | <th><%= _('Member') %></th> |
10 | 14 | <th><%= _('Actions') %></th> |
11 | 15 | </tr> |
16 | + | |
12 | 17 | <% collection.each do |m| %> |
13 | 18 | <tr title="<%= m.name %>"> |
19 | + <td><%= labelled_check_box('', 'members_filtered[]', m.id.to_s, false, :id => 'checkbox-'+m.identifier) %></td> | |
14 | 20 | <td><%= link_to_profile m.short_name, m.identifier, :title => m.name %> </td> |
15 | 21 | <td> |
16 | 22 | <div class="members-buttons-cell"> |
... | ... | @@ -26,3 +32,8 @@ |
26 | 32 | </tr> |
27 | 33 | <% end %> |
28 | 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 | 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 | 5 | <ul> |
6 | 6 | <% for validator in @region.validators %> |
7 | 7 | <li> |
8 | - <%= link_to_homepage validator.name, validator.identifier %> | |
8 | + <%= link_to_homepage validator.name, validator %> | |
9 | 9 | <%= link_to _('Remove validation rights'), { :action => 'remove', :id => @region.id, :validator_id => validator }, :method => 'post' %> |
10 | 10 | </li> |
11 | 11 | <% end %> | ... | ... |
app/views/search/_full_enterprise.html.erb
... | ... | @@ -5,7 +5,7 @@ |
5 | 5 | @order == 'more_recent' ? enterprise.send(@order + '_label') + show_date(enterprise.created_at) : enterprise.send(@order + '_label') %> |
6 | 6 | </div> |
7 | 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 | 9 | <div class="search-enterprise-description"> |
10 | 10 | <% if enterprise.description %> |
11 | 11 | <% body_stripped = strip_tags(enterprise.description) %> | ... | ... |
app/views/search/_full_product.html.erb
... | ... | @@ -44,7 +44,7 @@ |
44 | 44 | <div class="search-product-item-second-column"> |
45 | 45 | <%= link_to_product product, :class => 'search-result-title' %> |
46 | 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 | 48 | </div> |
49 | 49 | <div class="search-product-description"> |
50 | 50 | <% if product.description %> | ... | ... |
app/views/search/_sellers_form.html.erb
... | ... | @@ -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 | 1 | <% if block.cacheable? && use_cache %> |
2 | 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 | 4 | <% end %> |
5 | 5 | <% else %> |
6 | - <%= display_block_content(block, user, main_content) %> | |
6 | + <%= display_block_content(block, main_content) %> | |
7 | 7 | <% end %> | ... | ... |
db/schema.rb
... | ... | @@ -11,7 +11,7 @@ |
11 | 11 | # |
12 | 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 | 16 | # These are extensions that must be enabled in order to support this database |
17 | 17 | enable_extension "plpgsql" |
... | ... | @@ -51,7 +51,7 @@ ActiveRecord::Schema.define(version: 20160202142247) do |
51 | 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 | 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 | 55 | t.integer "person_id" |
56 | 56 | t.integer "article_id" |
57 | 57 | t.datetime "since" |
... | ... | @@ -471,6 +471,7 @@ ActiveRecord::Schema.define(version: 20160202142247) do |
471 | 471 | t.string "locale" |
472 | 472 | t.datetime "created_at" |
473 | 473 | t.datetime "updated_at" |
474 | + t.text "data" | |
474 | 475 | end |
475 | 476 | |
476 | 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 | 31 | Scenario: Send e-mail to members |
32 | 32 | Given I am logged in as "joaosilva" |
33 | 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 | 36 | And I fill in "Subject" with "Hello, member!" |
36 | 37 | And I fill in "Body" with "We have some news" |
37 | 38 | When I press "Send" |
... | ... | @@ -40,7 +41,8 @@ Feature: send emails to organization members |
40 | 41 | Scenario: Not send e-mail to members if subject is blank |
41 | 42 | Given I am logged in as "joaosilva" |
42 | 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 | 46 | And I fill in "Body" with "We have some news" |
45 | 47 | When I press "Send" |
46 | 48 | Then I should be on /profile/sample-community/send_mail |
... | ... | @@ -48,7 +50,8 @@ Feature: send emails to organization members |
48 | 50 | Scenario: Not send e-mail to members if body is blank |
49 | 51 | Given I am logged in as "joaosilva" |
50 | 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 | 55 | And I fill in "Subject" with "Hello, user!" |
53 | 56 | When I press "Send" |
54 | 57 | Then I should be on /profile/sample-community/send_mail |
... | ... | @@ -56,7 +59,8 @@ Feature: send emails to organization members |
56 | 59 | Scenario: Cancel creation of mailing |
57 | 60 | Given I am logged in as "joaosilva" |
58 | 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 | 64 | When I follow "Cancel e-mail" |
61 | 65 | Then I should be on Sample Community's members management |
62 | 66 | ... | ... |
gitignore.example
lib/tasks/ci.rake
... | ... | @@ -57,7 +57,8 @@ namespace :ci do |
57 | 57 | |
58 | 58 | sh 'ruby', '-Itest', *tests unless tests.empty? |
59 | 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 | 63 | changed_plugins.each do |plugin| |
63 | 64 | if $broken_plugins.include?(plugin) | ... | ... |
lib/tasks/selenium.rake
1 | 1 | desc 'Runs Seleniun acceptance tests' |
2 | 2 | task :selenium do |
3 | 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 | 5 | end | ... | ... |
plugins/custom_forms/db/migrate/20151008130948_create_text_field_type_in_custom_forms_plugin.rb
0 → 100644
... | ... | @@ -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 | 2 | self.table_name = :custom_forms_plugin_fields |
3 | 3 | |
4 | 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 | 9 | belongs_to :form, :class_name => 'CustomFormsPlugin::Form' |
9 | 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 | 85 | |
86 | 86 | def display_text_field(field, answer, form) |
87 | 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 | 93 | end |
90 | 94 | |
91 | 95 | def default_selected(field, answer) |
... | ... | @@ -93,7 +97,7 @@ module CustomFormsPlugin::Helper |
93 | 97 | end |
94 | 98 | |
95 | 99 | def display_select_field(field, answer, form) |
96 | - case field.select_field_type | |
100 | + case field.show_as | |
97 | 101 | when 'select' |
98 | 102 | selected = default_selected(field, answer) |
99 | 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 | 118 | end |
115 | 119 | |
116 | 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 | 122 | end |
119 | 123 | |
120 | 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 | 126 | end |
123 | 127 | |
124 | 128 | end | ... | ... |
plugins/custom_forms/lib/custom_forms_plugin/select_field.rb
1 | 1 | class CustomFormsPlugin::SelectField < CustomFormsPlugin::Field |
2 | 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 | 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 | 9 | end | ... | ... |
plugins/custom_forms/lib/custom_forms_plugin/text_field.rb
plugins/custom_forms/po/pt/custom_forms.po
... | ... | @@ -13,16 +13,16 @@ msgid "" |
13 | 13 | msgstr "" |
14 | 14 | "Project-Id-Version: 1.3~rc2-1-ga15645d\n" |
15 | 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 | 20 | "Language: pt\n" |
21 | 21 | "MIME-Version: 1.0\n" |
22 | 22 | "Content-Type: text/plain; charset=UTF-8\n" |
23 | 23 | "Content-Transfer-Encoding: 8bit\n" |
24 | 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 | 27 | #: plugins/custom_forms/lib/custom_forms_plugin/form.rb:67 |
28 | 28 | msgid "Invalid string format of access." |
... | ... | @@ -184,7 +184,7 @@ msgstr "E-mail" |
184 | 184 | |
185 | 185 | #: plugins/custom_forms/views/custom_forms_plugin_profile/show.html.erb:31 |
186 | 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 | 189 | #: plugins/custom_forms/views/custom_forms_plugin_myprofile/new.html.erb:1 |
190 | 190 | msgid "New form" |
... | ... | @@ -220,11 +220,11 @@ msgstr "Radio" |
220 | 220 | |
221 | 221 | #: plugins/custom_forms/views/custom_forms_plugin_myprofile/custom_forms_plugin/_select_field.html.erb:7 |
222 | 222 | msgid "Checkbox" |
223 | -msgstr "Checkbox" | |
223 | +msgstr "Caixa de seleção" | |
224 | 224 | |
225 | 225 | #: plugins/custom_forms/views/custom_forms_plugin_myprofile/custom_forms_plugin/_select_field.html.erb:9 |
226 | 226 | msgid "Drop down" |
227 | -msgstr "Drop down" | |
227 | +msgstr "Lista suspensa" | |
228 | 228 | |
229 | 229 | #: plugins/custom_forms/views/custom_forms_plugin_myprofile/custom_forms_plugin/_select_field.html.erb:11 |
230 | 230 | msgid "Multiple Select" |
... | ... | @@ -262,7 +262,7 @@ msgstr "Disparado depois da aprovação de um novo integrante" |
262 | 262 | #: plugins/custom_forms/views/custom_forms_plugin_myprofile/_form.html.erb:29 |
263 | 263 | #: plugins/custom_forms/views/custom_forms_plugin_myprofile/_form.html.erb:38 |
264 | 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 | 267 | #: plugins/custom_forms/views/custom_forms_plugin_myprofile/_form.html.erb:55 |
268 | 268 | msgid "Add a new text field" |
... | ... | @@ -315,18 +315,16 @@ msgid "Back to forms" |
315 | 315 | msgstr "Voltar para os formulários" |
316 | 316 | |
317 | 317 | #: plugins/custom_forms/views/custom_forms_plugin_myprofile/show_submission.html.erb:10 |
318 | -#, fuzzy | |
319 | 318 | msgid "Submission date" |
320 | -msgstr "Submissão salva" | |
319 | +msgstr "Data da submissão" | |
321 | 320 | |
322 | 321 | #: plugins/custom_forms/views/custom_forms_plugin_myprofile/show_submission.html.erb:14 |
323 | -#, fuzzy | |
324 | 322 | msgid "Author" |
325 | -msgstr "Nome do autor" | |
323 | +msgstr "Autor" | |
326 | 324 | |
327 | 325 | #: plugins/custom_forms/views/custom_forms_plugin_myprofile/show_submission.html.erb:26 |
328 | 326 | msgid "Unauthenticated" |
329 | -msgstr "" | |
327 | +msgstr "Não autenticado" | |
330 | 328 | |
331 | 329 | #: plugins/custom_forms/views/custom_forms_plugin_myprofile/show_submission.html.erb:48 |
332 | 330 | msgid "Back to submissions" | ... | ... |
plugins/custom_forms/public/style.css
plugins/custom_forms/test/functional/custom_forms_plugin_myprofile_controller_test.rb
... | ... | @@ -54,7 +54,7 @@ class CustomFormsPluginMyprofileControllerTest < ActionController::TestCase |
54 | 54 | }, |
55 | 55 | 2 => { |
56 | 56 | :name => 'Color', |
57 | - :select_field_type => 'radio', | |
57 | + :show_as => 'radio', | |
58 | 58 | :type => 'CustomFormsPlugin::SelectField', |
59 | 59 | :alternatives_attributes => { |
60 | 60 | 1 => {:label => 'Red'}, |
... | ... | @@ -82,7 +82,7 @@ class CustomFormsPluginMyprofileControllerTest < ActionController::TestCase |
82 | 82 | |
83 | 83 | assert_equal 'Color', f2.name |
84 | 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 | 86 | assert f2.kind_of?(CustomFormsPlugin::SelectField) |
87 | 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 | 13 | select = CustomFormsPlugin::SelectField.new(:name => 'select_field001' ) |
14 | 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 | 17 | assert select.invalid? |
18 | 18 | |
19 | - select.update_attribute(:select_field_type, 'radio') | |
19 | + select.update_attribute(:show_as, 'radio') | |
20 | 20 | assert select.valid? |
21 | - select.update_attribute(:select_field_type, 'check_box') | |
21 | + select.update_attribute(:show_as, 'check_box') | |
22 | 22 | assert select.valid? |
23 | - select.update_attribute(:select_field_type, 'select') | |
23 | + select.update_attribute(:show_as, 'select') | |
24 | 24 | assert select.valid? |
25 | - select.update_attribute(:select_field_type, 'multiple_select') | |
25 | + select.update_attribute(:show_as, 'multiple_select') | |
26 | 26 | assert select.valid? |
27 | 27 | end |
28 | 28 | end | ... | ... |
plugins/custom_forms/test/unit/custom_forms_plugin/text_field_test.rb
0 → 100644
... | ... | @@ -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 | -<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 | -<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 | -<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 | 1 | <%= render :layout => 'field', :locals => { :f => f } do %> |
2 | 2 | <div class="field-select-type"> |
3 | 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 | 12 | </div> |
13 | 13 | |
14 | 14 | <table> | ... | ... |
plugins/custom_forms/views/custom_forms_plugin_myprofile/custom_forms_plugin/_text_field.html.erb
1 | 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 | 10 | <div class="field-text-default"> |
3 | 11 | <%= f.label(:default_value, _('Default text:')) %> |
4 | 12 | <%= f.text_field(:default_value) %> |
13 | + <small><%= _('Maximum of 255 characters') %></small> | |
5 | 14 | </div> |
6 | 15 | <% end %> | ... | ... |
plugins/ldap/po/pt/ldap.po
... | ... | @@ -13,16 +13,16 @@ msgid "" |
13 | 13 | msgstr "" |
14 | 14 | "Project-Id-Version: 1.3~rc2-1-ga15645d\n" |
15 | 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 | 20 | "Language: pt\n" |
21 | 21 | "MIME-Version: 1.0\n" |
22 | 22 | "Content-Type: text/plain; charset=UTF-8\n" |
23 | 23 | "Content-Transfer-Encoding: 8bit\n" |
24 | 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 | 27 | #: plugins/ldap/lib/ldap_plugin.rb:11 |
28 | 28 | msgid "A plugin that add ldap support." |
... | ... | @@ -42,7 +42,7 @@ msgstr "Gerenciamento do Ldap" |
42 | 42 | |
43 | 43 | #: plugins/ldap/views/ldap_plugin_admin/index.html.erb:7 |
44 | 44 | msgid "LDAP Configuration" |
45 | -msgstr "" | |
45 | +msgstr "Configuração do LDAP" | |
46 | 46 | |
47 | 47 | #: plugins/ldap/views/ldap_plugin_admin/index.html.erb:8 |
48 | 48 | msgid "Value" |
... | ... | @@ -85,9 +85,8 @@ msgid "Attributes" |
85 | 85 | msgstr "Atributos" |
86 | 86 | |
87 | 87 | #: plugins/ldap/views/ldap_plugin_admin/index.html.erb:47 |
88 | -#, fuzzy | |
89 | 88 | msgid "LDAP Field" |
90 | -msgstr "Filtro LDAP" | |
89 | +msgstr "Campo do LDAP" | |
91 | 90 | |
92 | 91 | #: plugins/ldap/views/ldap_plugin_admin/index.html.erb:54 |
93 | 92 | msgid "Fullname" |
... | ... | @@ -98,12 +97,13 @@ msgid "Mail" |
98 | 97 | msgstr "Mail" |
99 | 98 | |
100 | 99 | #: plugins/ldap/views/ldap_plugin_admin/index.html.erb:65 |
100 | +#, fuzzy | |
101 | 101 | msgid "Behaviour Configuration" |
102 | -msgstr "" | |
102 | +msgstr "Configuração de comportamento" | |
103 | 103 | |
104 | 104 | #: plugins/ldap/views/ldap_plugin_admin/index.html.erb:70 |
105 | 105 | msgid "Allow password recovery" |
106 | -msgstr "" | |
106 | +msgstr "Permitir recuperação de senha" | |
107 | 107 | |
108 | 108 | #: plugins/ldap/views/ldap_plugin_admin/index.html.erb:78 |
109 | 109 | msgid "Back to plugins administration panel" | ... | ... |
plugins/newsletter/controllers/newsletter_plugin_admin_controller.rb
... | ... | @@ -30,14 +30,14 @@ class NewsletterPluginAdminController < PluginAdminController |
30 | 30 | end |
31 | 31 | |
32 | 32 | #TODO: Make this query faster |
33 | - def search_communities | |
34 | - communities = environment.communities | |
33 | + def search_profiles | |
34 | + profiles = environment.profiles | |
35 | 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 | 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 | 41 | render :text => results.map { |blog| {:id => blog.id, :name => _("%s in %s") % [blog.name, blog.profile.name]} }.to_json |
42 | 42 | end |
43 | 43 | ... | ... |
plugins/newsletter/features/newsletter_plugin.feature
1 | 1 | Feature: newsletter plugin |
2 | 2 | |
3 | 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 | 6 | Scenario: as admin I can configure plugin |
10 | - Given I am logged in as admin | |
11 | 7 | When I go to the environment control panel |
12 | 8 | And I follow "Plugins" |
13 | 9 | Then I should see "Configuration" linking to "/admin/plugin/newsletter" |
14 | 10 | |
15 | 11 | Scenario: in the newsletter settings I can see the field to enable/disable |
16 | - Given I am logged in as admin | |
17 | 12 | When I go to the environment control panel |
18 | 13 | And I follow "Plugins" |
19 | 14 | And I follow "Configuration" |
20 | 15 | Then I should see "Enable send of newsletter to members on this environment" |
21 | 16 | |
22 | 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 | 19 | When I go to the environment control panel |
26 | 20 | And I follow "Plugins" |
27 | 21 | And I follow "Configuration" |
... | ... | @@ -30,11 +24,58 @@ Feature: newsletter plugin |
30 | 24 | And I should not see "Newsletter settings" |
31 | 25 | |
32 | 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 | 28 | When I go to the environment control panel |
36 | 29 | And I follow "Plugins" |
37 | 30 | And I follow "Configuration" |
38 | 31 | And I press "Save" |
39 | 32 | Then I should see "Newsletter settings" |
40 | 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 | 158 | msgstr "" |
159 | 159 | |
160 | 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 | 162 | msgstr "" |
163 | 163 | |
164 | 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 | 164 | msgstr "Blogs utilizados como fonte do boletim informativo" |
165 | 165 | |
166 | 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 | 170 | #: plugins/newsletter/views/newsletter_plugin_admin/index.html.erb:42 |
171 | 171 | msgid "Recipients" | ... | ... |
plugins/newsletter/views/newsletter_plugin_admin/index.html.erb
... | ... | @@ -29,11 +29,11 @@ |
29 | 29 | %> |
30 | 30 | |
31 | 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 | 33 | <% selected_blogs = @blogs.map { |blog| {:id => blog.id, :name => _("%s in %s") % [blog.name, blog.profile.name]} } %> |
34 | 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 | 37 | focus: false, pre_populate: selected_blogs }) %> |
38 | 38 | |
39 | 39 | <br/> | ... | ... |
plugins/oauth_client/lib/ext/profile.rb
1 | 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 | 8 | end | ... | ... |
plugins/shopping_cart/po/pt/shopping_cart.po
... | ... | @@ -13,16 +13,16 @@ msgid "" |
13 | 13 | msgstr "" |
14 | 14 | "Project-Id-Version: 1.3~rc2-1-ga15645d\n" |
15 | 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 | 20 | "Language: pt\n" |
21 | 21 | "MIME-Version: 1.0\n" |
22 | 22 | "Content-Type: text/plain; charset=UTF-8\n" |
23 | 23 | "Content-Transfer-Encoding: 8bit\n" |
24 | 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 | 27 | #: plugins/shopping_cart/lib/shopping_cart_plugin.rb:10 |
28 | 28 | msgid "A shopping basket feature for enterprises" |
... | ... | @@ -304,7 +304,7 @@ msgstr "Nome" |
304 | 304 | |
305 | 305 | #: plugins/shopping_cart/views/shopping_cart_plugin/buy.html.erb:16 |
306 | 306 | msgid "Email" |
307 | -msgstr "" | |
307 | +msgstr "E-mail" | |
308 | 308 | |
309 | 309 | #: plugins/shopping_cart/views/shopping_cart_plugin/buy.html.erb:17 |
310 | 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 | 10 | <%= profile_image_link organization, :big, 'div' %> |
11 | 11 | </div> |
12 | 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 | 14 | <div class="related-organizations-description"> |
15 | 15 | <% if organization.description %> |
16 | 16 | <% body_stripped = strip_tags(organization.description) %> | ... | ... |
plugins/tolerance_time/po/pt/tolerance_time.po
... | ... | @@ -13,16 +13,16 @@ msgid "" |
13 | 13 | msgstr "" |
14 | 14 | "Project-Id-Version: 1.3~rc2-1-ga15645d\n" |
15 | 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 | 20 | "Language: pt\n" |
21 | 21 | "MIME-Version: 1.0\n" |
22 | 22 | "Content-Type: text/plain; charset=UTF-8\n" |
23 | 23 | "Content-Transfer-Encoding: 8bit\n" |
24 | 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 | 27 | #: plugins/tolerance_time/lib/tolerance_time_plugin.rb:8 |
28 | 28 | msgid "Adds a tolerance time for editing content after its publication" |
... | ... | @@ -43,24 +43,23 @@ msgstr "" |
43 | 43 | |
44 | 44 | #: plugins/tolerance_time/lib/tolerance_time_plugin.rb:59 |
45 | 45 | msgid "editing" |
46 | -msgstr "" | |
46 | +msgstr "edição" | |
47 | 47 | |
48 | 48 | #: plugins/tolerance_time/lib/tolerance_time_plugin.rb:63 |
49 | 49 | msgid "cloning" |
50 | -msgstr "" | |
50 | +msgstr "clonagem" | |
51 | 51 | |
52 | 52 | #: plugins/tolerance_time/lib/tolerance_time_plugin.rb:70 |
53 | -#, fuzzy | |
54 | 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 | 56 | #: plugins/tolerance_time/controllers/tolerance_time_plugin_myprofile_controller.rb:10 |
58 | 57 | msgid "Tolerance updated" |
59 | -msgstr "A tolerância foi atualizada" | |
58 | +msgstr "O tempo de tolerância foi atualizado" | |
60 | 59 | |
61 | 60 | #: plugins/tolerance_time/controllers/tolerance_time_plugin_myprofile_controller.rb:12 |
62 | 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 | 64 | #: plugins/tolerance_time/views/tolerance_time_plugin_myprofile/index.html.erb:1 |
66 | 65 | msgid "Tolerance Adjustments" |
... | ... | @@ -79,6 +78,7 @@ msgid "Hours" |
79 | 78 | msgstr "Horas" |
80 | 79 | |
81 | 80 | #: plugins/tolerance_time/views/tolerance_time_plugin_myprofile/index.html.erb:10 |
81 | +#, fuzzy | |
82 | 82 | msgid "Content edition tolerance time" |
83 | 83 | msgstr "Tempo de tolerância para edição de conteúdo" |
84 | 84 | |
... | ... | @@ -87,5 +87,6 @@ msgid "Comment edition tolerance time" |
87 | 87 | msgstr "Tempo de tolerância para edição de comentários" |
88 | 88 | |
89 | 89 | #: plugins/tolerance_time/views/tolerance_time_plugin_myprofile/index.html.erb:18 |
90 | +#, fuzzy | |
90 | 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 | 13 | msgstr "" |
14 | 14 | "Project-Id-Version: 1.3~rc2-1-ga15645d\n" |
15 | 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 | 20 | "Language: pt\n" |
21 | 21 | "MIME-Version: 1.0\n" |
22 | 22 | "Content-Type: text/plain; charset=UTF-8\n" |
23 | 23 | "Content-Transfer-Encoding: 8bit\n" |
24 | 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 | 27 | #: plugins/work_assignment/lib/work_assignment_plugin.rb:8 |
28 | 28 | msgid "New kind of content for organizations." |
... | ... | @@ -66,7 +66,7 @@ msgstr "Nome" |
66 | 66 | |
67 | 67 | #: plugins/work_assignment/lib/work_assignment_plugin/helper.rb:9 |
68 | 68 | msgid "Submission date" |
69 | -msgstr "Data de submissão" | |
69 | +msgstr "Data da submissão" | |
70 | 70 | |
71 | 71 | #: plugins/work_assignment/lib/work_assignment_plugin/helper.rb:10 |
72 | 72 | msgid "Versions" | ... | ... |
po/pt/noosfero.po
... | ... | @@ -13,7 +13,7 @@ msgid "" |
13 | 13 | msgstr "" |
14 | 14 | "Project-Id-Version: 1.3~rc2-8-g01ea9f7\n" |
15 | 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 | 17 | "Last-Translator: Eduardo Vital <vitaldu@gmail.com>\n" |
18 | 18 | "Language-Team: Portuguese " |
19 | 19 | "<https://hosted.weblate.org/projects/noosfero/noosfero/pt/>\n" |
... | ... | @@ -22,7 +22,7 @@ msgstr "" |
22 | 22 | "Content-Type: text/plain; charset=UTF-8\n" |
23 | 23 | "Content-Transfer-Encoding: 8bit\n" |
24 | 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 | 27 | #: app/models/approve_comment.rb:17 |
28 | 28 | msgid "Anonymous" | ... | ... |
public/designs/themes/noosfero/style.css
... | ... | @@ -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 | 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 | 175 | .controller-cms .article-controls { |
170 | 176 | white-space: nowrap; |
171 | 177 | } | ... | ... |
public/stylesheets/content/blog.scss
public/stylesheets/content/folder.scss
public/stylesheets/content/image-gallery.scss
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 | 3 | source_packages=$(echo "$binary_packages" | sed -e 's/^deb/deb-src/') |
4 | 4 | |
... | ... | @@ -10,7 +10,7 @@ EOF |
10 | 10 | |
11 | 11 | sudo apt-key add - <<EOF |
12 | 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 | 15 | mQGiBE1HCIURBADw6SnRbc1qCHdTV9wD0rxSMIWevzUX+bnDgvV455yudqtVFUhX |
16 | 16 | 2QYvtlwclllbLWKzRdiM7GsBi+2DyWli4B17xl86A5RBQNdc1v1vWZG3QwURxd4E | ... | ... |
script/quick-start
test/functional/mailconf_controller_test.rb
... | ... | @@ -71,8 +71,10 @@ class MailconfControllerTest < ActionController::TestCase |
71 | 71 | env = Environment.default |
72 | 72 | env.force_www = true |
73 | 73 | env.save! |
74 | + env.domains.delete_all | |
75 | + env.domains.create! name: 'example.com' | |
74 | 76 | get :index, :profile => 'ze' |
75 | - assert_tag :tag => 'li', :content => /ze@colivre.net/ | |
77 | + assert_tag :tag => 'li', :content => /ze@example.com/ | |
76 | 78 | end |
77 | 79 | |
78 | 80 | should 'not display www in email address when force_www=false' do |
... | ... | @@ -80,8 +82,10 @@ class MailconfControllerTest < ActionController::TestCase |
80 | 82 | env = Environment.default |
81 | 83 | env.force_www = false |
82 | 84 | env.save! |
85 | + env.domains.delete_all | |
86 | + env.domains.create! name: 'example.com' | |
83 | 87 | get :index, :profile => 'ze' |
84 | - assert_tag :tag => 'li', :content => /ze@colivre.net/ | |
88 | + assert_tag :tag => 'li', :content => /ze@example.com/ | |
85 | 89 | end |
86 | 90 | |
87 | 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 | 1465 | create_user_with_permission('profile_moderator_user', 'send_mail_to_members', community) |
1466 | 1466 | login_as('profile_moderator_user') |
1467 | 1467 | @controller.stubs(:locale).returns('pt') |
1468 | + | |
1468 | 1469 | assert_difference 'Delayed::Job.count', 1 do |
1469 | 1470 | post :send_mail, :profile => community.identifier, :mailing => {:subject => 'Hello', :body => 'We have some news'} |
1470 | 1471 | end |
1471 | 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 | 1503 | should 'save mailing' do |
1474 | 1504 | community = fast_create(Community) |
1475 | 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 | 1213 | assert_no_tag :tag => 'a', :attributes => { :href => "/myprofile/default_user/profile_roles" } |
1214 | 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 | 1223 | end | ... | ... |
test/functional/profile_members_controller_test.rb
... | ... | @@ -31,6 +31,31 @@ class ProfileMembersControllerTest < ActionController::TestCase |
31 | 31 | assert_template 'index' |
32 | 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 | 59 | should 'show form to change role' do |
35 | 60 | ent = fast_create(Enterprise, :identifier => 'test_enterprise', :name => 'test enterprise') |
36 | 61 | role = Profile::Roles.member(Environment.default) |
... | ... | @@ -171,7 +196,7 @@ class ProfileMembersControllerTest < ActionController::TestCase |
171 | 196 | login_as :test_user |
172 | 197 | |
173 | 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 | 200 | end |
176 | 201 | |
177 | 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 | 13 | assert_tag :tag => 'input', :attributes => { :name => 'environment[enabled_features][]', :value => 'feature2' } |
14 | 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 | 19 | assert_response :success |
21 | 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 | 25 | assert_equal '/admin/features', path |
28 | 26 | |
29 | 27 | end | ... | ... |
test/integration/enterprise_registration_test.rb
... | ... | @@ -61,10 +61,9 @@ class EnterpriseRegistrationTest < ActionDispatch::IntegrationTest |
61 | 61 | assert_response :success |
62 | 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 | 67 | assert_equal "/myprofile/myorg/enterprise_validation/view_processed/#{code}", path |
69 | 68 | assert_tag :span, :attributes => { :class => 'validation_approved' } |
70 | 69 | end | ... | ... |
test/integration/manage_documents_test.rb
... | ... | @@ -24,11 +24,10 @@ class ManageDocumentsTest < ActionDispatch::IntegrationTest |
24 | 24 | assert_tag :tag => 'form', :attributes => { :action => '/myprofile/myuser/cms/new', :method => /post/i } |
25 | 25 | |
26 | 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 | 28 | end |
29 | 29 | |
30 | - assert_response :redirect | |
31 | - follow_redirect! | |
30 | + assert_response :success | |
32 | 31 | a = Article.find_by_path('my-article') |
33 | 32 | assert_equal "/myuser/#{a.slug}", path |
34 | 33 | end |
... | ... | @@ -55,14 +54,13 @@ class ManageDocumentsTest < ActionDispatch::IntegrationTest |
55 | 54 | assert_tag :tag => 'form', :attributes => { :action => "/myprofile/myuser/cms/edit/#{article.id}", :method => /post/i } |
56 | 55 | |
57 | 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 | 58 | end |
60 | 59 | |
61 | 60 | article.reload |
62 | 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 | 64 | a = Article.find_by_path('my-article') |
67 | 65 | assert_equal "/myuser/#{a.slug}", path |
68 | 66 | end |
... | ... | @@ -84,10 +82,9 @@ class ManageDocumentsTest < ActionDispatch::IntegrationTest |
84 | 82 | assert_response :success |
85 | 83 | |
86 | 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 | 88 | assert_equal "/myuser", path |
92 | 89 | |
93 | 90 | # the article was actually deleted | ... | ... |
test/integration/manage_friendships_test.rb
... | ... | @@ -24,11 +24,10 @@ class ManageFriendshipsTest < ActionDispatch::IntegrationTest |
24 | 24 | get "/myprofile/#{@person.identifier}/friends/remove/#{@friend.id}" |
25 | 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 | 28 | :confirmation => '1' |
29 | - assert_response :redirect | |
29 | + assert_response :success | |
30 | 30 | |
31 | - follow_redirect! | |
32 | 31 | |
33 | 32 | assert assigns(:friends).empty? |
34 | 33 | refute @person.is_a_friend?(@friend) | ... | ... |
test/support/integration_test.rb
... | ... | @@ -14,9 +14,8 @@ class ActionDispatch::IntegrationTest |
14 | 14 | def login(username, password) |
15 | 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 | 19 | assert_not_equal '/account/login', path |
21 | 20 | end |
22 | 21 | ... | ... |
test/unit/application_helper_test.rb
... | ... | @@ -80,12 +80,6 @@ class ApplicationHelperTest < ActionView::TestCase |
80 | 80 | assert_equal '', show_date(nil) |
81 | 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 | 83 | should 'generate correct link to category' do |
90 | 84 | cat = mock |
91 | 85 | cat.expects(:path).returns('my-category/my-subcatagory') | ... | ... |
test/unit/article_block_test.rb
... | ... | @@ -7,15 +7,6 @@ class ArticleBlockTest < ActiveSupport::TestCase |
7 | 7 | assert_not_equal Block.description, ArticleBlock.description |
8 | 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 | 10 | should 'refer to an article' do |
20 | 11 | profile = create_user('testuser').person |
21 | 12 | article = profile.articles.build(:name => 'test article') |
... | ... | @@ -85,6 +76,31 @@ class ArticleBlockTest < ActiveSupport::TestCase |
85 | 76 | assert_equal [a],block.available_articles |
86 | 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 | 104 | should "display empty title if title is blank" do |
89 | 105 | block = ArticleBlock.new |
90 | 106 | article = mock |
... | ... | @@ -92,7 +108,7 @@ class ArticleBlockTest < ActiveSupport::TestCase |
92 | 108 | block.expects(:title).returns('') |
93 | 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 | 112 | end |
97 | 113 | |
98 | 114 | should "display title if defined" do |
... | ... | @@ -102,7 +118,7 @@ class ArticleBlockTest < ActiveSupport::TestCase |
102 | 118 | block.expects(:title).returns('Article title') |
103 | 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 | 122 | end |
107 | 123 | |
108 | 124 | should 'display image if article is an image' do |
... | ... | @@ -113,7 +129,7 @@ class ArticleBlockTest < ActiveSupport::TestCase |
113 | 129 | block.article = image |
114 | 130 | block.save! |
115 | 131 | |
116 | - assert_tag_in_string instance_eval(&block.content), | |
132 | + assert_tag_in_string render_block_content(block), | |
117 | 133 | :tag => 'img', |
118 | 134 | :attributes => { |
119 | 135 | :src => image.public_filename(:display), |
... | ... | @@ -129,7 +145,7 @@ class ArticleBlockTest < ActiveSupport::TestCase |
129 | 145 | block.article = image |
130 | 146 | block.save! |
131 | 147 | |
132 | - assert_no_match(/Previous/, instance_eval(&block.content)) | |
148 | + assert_no_match(/Previous/, render_block_content(block)) | |
133 | 149 | end |
134 | 150 | |
135 | 151 | should 'display link to archive if article is an archive' do |
... | ... | @@ -141,11 +157,6 @@ class ArticleBlockTest < ActiveSupport::TestCase |
141 | 157 | block.save! |
142 | 158 | |
143 | 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 | 161 | end |
147 | - | |
148 | - protected | |
149 | - include NoosferoTestHelper | |
150 | - | |
151 | 162 | end | ... | ... |
test/unit/article_test.rb
... | ... | @@ -22,21 +22,6 @@ class ArticleTest < ActiveSupport::TestCase |
22 | 22 | refute a.errors[:profile_id.to_s].present? |
23 | 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 | 25 | should 'require value for name' do |
41 | 26 | a = Article.new |
42 | 27 | a.valid? |
... | ... | @@ -1713,11 +1698,6 @@ class ArticleTest < ActiveSupport::TestCase |
1713 | 1698 | assert post.allow_edit?(author) |
1714 | 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 | 1701 | should 'get first image from lead' do |
1722 | 1702 | a = fast_create(Article, :body => '<p>Foo</p><p><img src="bar.png" />Bar<img src="foo.png" /></p>', |
1723 | 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 | 2232 | assert_equal "/#{a2.path}", a2.full_path |
2253 | 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 | 2292 | end | ... | ... |
test/unit/blog_archives_block_test.rb
... | ... | @@ -17,6 +17,69 @@ class BlogArchivesBlockTest < ActiveSupport::TestCase |
17 | 17 | assert l.editable? |
18 | 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 | 83 | should 'list amount posts by year' do |
21 | 84 | date = DateTime.parse('2008-01-10') |
22 | 85 | blog = profile.blog |
... | ... | @@ -26,7 +89,9 @@ class BlogArchivesBlockTest < ActiveSupport::TestCase |
26 | 89 | end |
27 | 90 | block = BlogArchivesBlock.new |
28 | 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 | 95 | end |
31 | 96 | |
32 | 97 | should 'list amount posts by month' do |
... | ... | @@ -38,7 +103,18 @@ class BlogArchivesBlockTest < ActiveSupport::TestCase |
38 | 103 | end |
39 | 104 | block = BlogArchivesBlock.new |
40 | 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 | 118 | end |
43 | 119 | |
44 | 120 | should 'order list of amount posts' do |
... | ... | @@ -49,7 +125,18 @@ class BlogArchivesBlockTest < ActiveSupport::TestCase |
49 | 125 | end |
50 | 126 | block = BlogArchivesBlock.new |
51 | 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 | 140 | :sibling => {:tag => 'li', :content => 'February (1)', |
54 | 141 | :sibling => {:tag => 'li', :content => 'March (1)', |
55 | 142 | :sibling => {:tag => 'li', :content => 'April (1)', |
... | ... | @@ -63,7 +150,9 @@ class BlogArchivesBlockTest < ActiveSupport::TestCase |
63 | 150 | end |
64 | 151 | block = BlogArchivesBlock.new |
65 | 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 | 156 | end |
68 | 157 | |
69 | 158 | should 'order months from later to former' do |
... | ... | @@ -73,20 +162,20 @@ class BlogArchivesBlockTest < ActiveSupport::TestCase |
73 | 162 | end |
74 | 163 | block = BlogArchivesBlock.new |
75 | 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 | 170 | end |
78 | 171 | |
79 | 172 | should 'not display any content if has no blog' do |
80 | 173 | profile.blogs.destroy_all |
81 | 174 | block = BlogArchivesBlock.new |
82 | 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 | 179 | end |
91 | 180 | |
92 | 181 | should 'show posts from first blog' do |
... | ... | @@ -98,8 +187,10 @@ class BlogArchivesBlockTest < ActiveSupport::TestCase |
98 | 187 | end |
99 | 188 | block = BlogArchivesBlock.new |
100 | 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 | 194 | end |
104 | 195 | |
105 | 196 | should 'list amount native posts by year' do |
... | ... | @@ -115,7 +206,9 @@ class BlogArchivesBlockTest < ActiveSupport::TestCase |
115 | 206 | end |
116 | 207 | block = BlogArchivesBlock.new |
117 | 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 | 212 | end |
120 | 213 | |
121 | 214 | should 'list amount native posts by month' do |
... | ... | @@ -131,51 +224,8 @@ class BlogArchivesBlockTest < ActiveSupport::TestCase |
131 | 224 | end |
132 | 225 | block = BlogArchivesBlock.new |
133 | 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 | 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 | 231 | end | ... | ... |
test/unit/blog_test.rb
... | ... | @@ -266,4 +266,23 @@ class BlogTest < ActiveSupport::TestCase |
266 | 266 | |
267 | 267 | assert_equal blog.image(true).filename, 'noosfero-network.png' |
268 | 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 | 288 | end | ... | ... |
... | ... | @@ -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 | 12 | \ No newline at end of file | ... | ... |
test/unit/categories_block_test.rb
... | ... | @@ -17,11 +17,13 @@ class CategoriesBlockTest < ActiveSupport::TestCase |
17 | 17 | assert_not_nil category_block.help |
18 | 18 | end |
19 | 19 | |
20 | + include BoxesHelper | |
21 | + | |
20 | 22 | should 'display category block' do |
21 | 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 | 27 | end |
26 | 28 | |
27 | 29 | should 'be editable' do | ... | ... |
test/unit/communities_block_test.rb
... | ... | @@ -27,14 +27,44 @@ class CommunitiesBlockTest < ActiveSupport::TestCase |
27 | 27 | assert_same list, block.profiles |
28 | 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 | 52 | should 'support profile as block owner' do |
31 | 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 | 59 | block = CommunitiesBlock.new |
34 | 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 | 68 | end |
39 | 69 | |
40 | 70 | should 'support environment as block owner' do |
... | ... | @@ -42,31 +72,24 @@ class CommunitiesBlockTest < ActiveSupport::TestCase |
42 | 72 | block = CommunitiesBlock.new |
43 | 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 | 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 | 94 | end |
71 | - | |
72 | 95 | end | ... | ... |
test/unit/community_test.rb
... | ... | @@ -3,7 +3,8 @@ require_relative "../test_helper" |
3 | 3 | class CommunityTest < ActiveSupport::TestCase |
4 | 4 | |
5 | 5 | def setup |
6 | - @person = fast_create(Person) | |
6 | + @user = User.current = create_user | |
7 | + @person = @user.person | |
7 | 8 | end |
8 | 9 | |
9 | 10 | attr_reader :person |
... | ... | @@ -287,8 +288,8 @@ class CommunityTest < ActiveSupport::TestCase |
287 | 288 | |
288 | 289 | should "update the action of article creation when an community's article is commented" do |
289 | 290 | ActionTrackerNotification.delete_all |
290 | - p1 = Person.first | |
291 | 291 | community = fast_create(Community) |
292 | + p1 = person | |
292 | 293 | p2 = create_user.person |
293 | 294 | p3 = create_user.person |
294 | 295 | community.add_member(p3) | ... | ... |
test/unit/disabled_enterprise_message_block_test.rb
... | ... | @@ -6,16 +6,30 @@ class DisabledEnterpriseMessageBlockTest < ActiveSupport::TestCase |
6 | 6 | assert_not_equal Block.description, DisabledEnterpriseMessageBlock.description |
7 | 7 | end |
8 | 8 | |
9 | + include BoxesHelper | |
10 | + | |
9 | 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 | 33 | end |
20 | 34 | |
21 | 35 | should 'not be editable' do | ... | ... |
test/unit/enterprises_block_test.rb
... | ... | @@ -27,32 +27,6 @@ class EnterprisesBlockTest < ActiveSupport::TestCase |
27 | 27 | assert_same list, block.profiles |
28 | 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 | 30 | should 'count number of owner enterprises' do |
57 | 31 | user = create_user('testuser').person |
58 | 32 | |
... | ... | @@ -71,3 +45,35 @@ class EnterprisesBlockTest < ActiveSupport::TestCase |
71 | 45 | end |
72 | 46 | |
73 | 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 | 1 | require_relative "../test_helper" |
2 | +require 'boxes_helper' | |
2 | 3 | |
3 | 4 | class FeaturedProductsBlockTest < ActiveSupport::TestCase |
5 | + include BoxesHelper | |
4 | 6 | |
5 | 7 | def setup |
6 | 8 | @profile = fast_create(Profile) |
... | ... | @@ -107,8 +109,8 @@ class FeaturedProductsBlockTest < ActiveSupport::TestCase |
107 | 109 | should 'display feature products block' do |
108 | 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 | 114 | end |
113 | 115 | |
114 | 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 | 26 | assert feed.editable? |
27 | 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 | 29 | should 'display channel title as title by default' do |
43 | 30 | feed.feed_title = 'Feed for unit tests' |
44 | 31 | assert_equal 'Feed for unit tests', feed.title |
... | ... | @@ -48,17 +35,6 @@ class FeedReaderBlockTest < ActiveSupport::TestCase |
48 | 35 | assert_equal 'Feed Reader', feed.title |
49 | 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 | 38 | should 'clear feed title and items' do |
63 | 39 | feed.feed_items = %w[ last-post second-post first-post ] |
64 | 40 | feed.feed_title = 'Feed Test' |
... | ... | @@ -90,26 +66,10 @@ class FeedReaderBlockTest < ActiveSupport::TestCase |
90 | 66 | assert_equal %w[ last-post second-post first-post ], feed.feed_items.map{|i|i[:title]} |
91 | 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 | 69 | should 'have empty error message by default' do |
104 | 70 | assert FeedReaderBlock.new.error_message.blank?, 'new feed reader block expected to have empty error message' |
105 | 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 | 73 | should 'expire after a period' do |
114 | 74 | # save current time |
115 | 75 | now = Time.now |
... | ... | @@ -195,3 +155,67 @@ class FeedReaderBlockTest < ActiveSupport::TestCase |
195 | 155 | end |
196 | 156 | |
197 | 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 | 54 | should 'remove images with blank fields' do |
55 | 55 | h = HighlightsBlock.new(:images => [{:image_id => 1, :address => '/address', :position => 1, :title => 'address'}, {:image_id => '', :address => '', :position => '', :title => ''}]) |
56 | 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 | 70 | end |
59 | 71 | |
60 | 72 | should 'be able to update display setting' do |
... | ... | @@ -68,11 +80,13 @@ class HighlightsBlockTest < ActiveSupport::TestCase |
68 | 80 | assert_equal 'always', block.display |
69 | 81 | end |
70 | 82 | |
83 | + include BoxesHelper | |
84 | + | |
71 | 85 | should 'display highlights block' do |
72 | 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 | 90 | end |
77 | 91 | |
78 | 92 | should 'not list non existent image' do |
... | ... | @@ -84,7 +98,7 @@ class HighlightsBlockTest < ActiveSupport::TestCase |
84 | 98 | block.save! |
85 | 99 | block.reload |
86 | 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 | 102 | end |
89 | 103 | |
90 | 104 | should 'list images in order' do |
... | ... | @@ -155,7 +169,7 @@ class HighlightsBlockTest < ActiveSupport::TestCase |
155 | 169 | block.images = [i1] |
156 | 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 | 173 | end |
160 | 174 | |
161 | 175 | [Environment, Profile].each do |klass| | ... | ... |
test/unit/link_list_block_test.rb
... | ... | @@ -2,6 +2,8 @@ require_relative "../test_helper" |
2 | 2 | |
3 | 3 | class LinkListBlockTest < ActiveSupport::TestCase |
4 | 4 | |
5 | + include BoxesHelper | |
6 | + | |
5 | 7 | should 'default describe' do |
6 | 8 | assert_not_equal Block.description, LinkListBlock.description |
7 | 9 | end |
... | ... | @@ -23,7 +25,7 @@ class LinkListBlockTest < ActiveSupport::TestCase |
23 | 25 | |
24 | 26 | should 'list links' do |
25 | 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 | 29 | end |
28 | 30 | |
29 | 31 | should 'remove links with blank fields' do |
... | ... | @@ -36,7 +38,7 @@ class LinkListBlockTest < ActiveSupport::TestCase |
36 | 38 | profile = Profile.new(:identifier => 'test_profile') |
37 | 39 | l = LinkListBlock.new(:links => [{:name => 'categ', :address => '/{profile}/address'}]) |
38 | 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 | 42 | end |
41 | 43 | |
42 | 44 | should 'replace {portal} with environment portal identifier' do |
... | ... | @@ -49,7 +51,7 @@ class LinkListBlockTest < ActiveSupport::TestCase |
49 | 51 | stubs(:environment).returns(env) |
50 | 52 | l = LinkListBlock.new(:links => [{:name => 'categ', :address => '/{portal}/address'}]) |
51 | 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 | 55 | end |
54 | 56 | |
55 | 57 | should 'not change address if no {portal} there' do |
... | ... | @@ -62,19 +64,19 @@ class LinkListBlockTest < ActiveSupport::TestCase |
62 | 64 | stubs(:environment).returns(env) |
63 | 65 | l = LinkListBlock.new(:links => [{:name => 'categ', :address => '/address'}]) |
64 | 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 | 68 | end |
67 | 69 | |
68 | 70 | should 'handle /prefix if not already added' do |
69 | 71 | Noosfero.stubs(:root).returns('/prefix') |
70 | 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 | 74 | end |
73 | 75 | |
74 | 76 | should 'not add /prefix if already there' do |
75 | 77 | Noosfero.stubs(:root).returns('/prefix') |
76 | 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 | 80 | end |
79 | 81 | |
80 | 82 | should 'display options for icons' do |
... | ... | @@ -85,29 +87,29 @@ class LinkListBlockTest < ActiveSupport::TestCase |
85 | 87 | end |
86 | 88 | |
87 | 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 | 92 | end |
91 | 93 | |
92 | 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 | 97 | end |
96 | 98 | |
97 | 99 | should 'not add link to javascript' do |
98 | 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 | 102 | end |
101 | 103 | |
102 | 104 | should 'not add link to onclick' do |
103 | 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 | 107 | end |
106 | 108 | |
107 | 109 | should 'add protocol in front of incomplete external links' do |
108 | 110 | {'/local/link' => '/local/link', 'http://example.org' => 'http://example.org', 'example.org' => '//example.org'}.each do |input, output| |
109 | 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 | 113 | end |
112 | 114 | end |
113 | 115 | |
... | ... | @@ -128,7 +130,13 @@ class LinkListBlockTest < ActiveSupport::TestCase |
128 | 130 | |
129 | 131 | should 'link with title' do |
130 | 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 | 140 | end |
133 | 141 | |
134 | 142 | end | ... | ... |
test/unit/location_block_test.rb
... | ... | @@ -18,7 +18,7 @@ class LocationBlockTest < ActiveSupport::TestCase |
18 | 18 | end |
19 | 19 | |
20 | 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 | 22 | end |
23 | 23 | |
24 | 24 | should 'be editable' do |
... | ... | @@ -31,7 +31,7 @@ class LocationBlockTest < ActiveSupport::TestCase |
31 | 31 | |
32 | 32 | should 'use google maps api v3 with ssl' do |
33 | 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 | 36 | assert_match 'https://maps.google.com/maps/api/staticmap', content |
37 | 37 | assert_no_match /key=/, content | ... | ... |
test/unit/manage_products_helper_test.rb
... | ... | @@ -5,6 +5,7 @@ class ManageProductsHelperTest < ActionView::TestCase |
5 | 5 | |
6 | 6 | include ManageProductsHelper |
7 | 7 | include ContentViewerHelper |
8 | + include ArticleHelper | |
8 | 9 | include ActionView::Helpers::AssetTagHelper |
9 | 10 | include ApplicationHelper |
10 | 11 | |
... | ... | @@ -43,7 +44,7 @@ class ManageProductsHelperTest < ActionView::TestCase |
43 | 44 | end |
44 | 45 | |
45 | 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 | 48 | user.expects(:has_permission?).with(anything, anything).returns(true) |
48 | 49 | @controller = mock |
49 | 50 | @controller.expects(:user).returns(user).at_least_once |
... | ... | @@ -57,7 +58,7 @@ class ManageProductsHelperTest < ActionView::TestCase |
57 | 58 | end |
58 | 59 | |
59 | 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 | 62 | user.expects(:has_permission?).with(anything, anything).returns(false) |
62 | 63 | @controller = mock |
63 | 64 | @controller.expects(:user).returns(user).at_least_once |
... | ... | @@ -68,7 +69,7 @@ class ManageProductsHelperTest < ActionView::TestCase |
68 | 69 | end |
69 | 70 | |
70 | 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 | 73 | user.expects(:has_permission?).with(anything, anything).returns(true) |
73 | 74 | @controller = mock |
74 | 75 | @controller.expects(:user).returns(user).at_least_once |
... | ... | @@ -82,7 +83,7 @@ class ManageProductsHelperTest < ActionView::TestCase |
82 | 83 | end |
83 | 84 | |
84 | 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 | 87 | user.expects(:has_permission?).with(anything, anything).returns(false) |
87 | 88 | @controller = mock |
88 | 89 | @controller.expects(:user).returns(user).at_least_once |
... | ... | @@ -93,7 +94,7 @@ class ManageProductsHelperTest < ActionView::TestCase |
93 | 94 | end |
94 | 95 | |
95 | 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 | 98 | user.expects(:has_permission?).with(anything, anything).returns(true) |
98 | 99 | @controller = mock |
99 | 100 | @controller.expects(:user).returns(user).at_least_once |
... | ... | @@ -108,7 +109,7 @@ class ManageProductsHelperTest < ActionView::TestCase |
108 | 109 | |
109 | 110 | |
110 | 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 | 113 | user.expects(:has_permission?).with(anything, anything).returns(true) |
113 | 114 | @controller = mock |
114 | 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 | 19 | assert_not_equal Block.new.default_title, MyNetworkBlock.new.default_title |
20 | 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 | 22 | should 'be able to update display setting' do |
31 | 23 | user = create_user('testinguser').person |
32 | 24 | box = fast_create(Box, :owner_id => user.id) |
... | ... | @@ -37,3 +29,22 @@ class MyNetworkBlockTest < ActiveSupport::TestCase |
37 | 29 | end |
38 | 30 | |
39 | 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 | 98 | assert_equal [Person['user_one'], Person['user_two']], mailing.recipients |
99 | 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 | 106 | should 'return recipients according to limit' do |
102 | 107 | mailing = create(OrganizationMailing, :source => community, :subject => 'Hello', :body => 'We have some news', :person => person) |
103 | 108 | assert_equal [Person['user_one']], mailing.recipients(0, 1) | ... | ... |
test/unit/person_test.rb
... | ... | @@ -1932,6 +1932,16 @@ class PersonTest < ActiveSupport::TestCase |
1932 | 1932 | community.add_member person |
1933 | 1933 | |
1934 | 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 | 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 | 1947 | end | ... | ... |
test/unit/products_block_test.rb
... | ... | @@ -20,33 +20,6 @@ class ProductsBlockTest < ActiveSupport::TestCase |
20 | 20 | assert_not_equal Block.description, ProductsBlock.description |
21 | 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 | 23 | should 'list 4 random products by default' do |
51 | 24 | enterprise = create(Enterprise, :name => 'testenterprise', :identifier => 'testenterprise') |
52 | 25 | create(Product, :enterprise => enterprise, :name => 'product one', :product_category => @product_category) |
... | ... | @@ -120,18 +93,35 @@ class ProductsBlockTest < ActiveSupport::TestCase |
120 | 93 | assert_equivalent [p1, p2, p3, p4], block.products |
121 | 94 | end |
122 | 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 | 113 | enterprise = create(Enterprise, :name => 'testenterprise', :identifier => 'testenterprise') |
126 | - enterprise.domains << Domain.new(:name => 'sometest.com'); enterprise.save! | |
127 | 114 | create(Product, :enterprise => enterprise, :name => 'product one', :product_category => @product_category) |
128 | 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 | 125 | end |
136 | 126 | |
137 | 127 | should 'display the default minor image if thumbnails were not processed' do |
... | ... | @@ -139,8 +129,9 @@ class ProductsBlockTest < ActiveSupport::TestCase |
139 | 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 | 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 | 136 | assert_tag_in_string content, :tag => 'a', :attributes => { :style => /image-loading-minor.png/ } |
146 | 137 | end |
... | ... | @@ -151,9 +142,34 @@ class ProductsBlockTest < ActiveSupport::TestCase |
151 | 142 | |
152 | 143 | process_delayed_job_queue |
153 | 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 | 148 | assert_tag_in_string content, :tag => 'a', :attributes => { :style => /rails_minor.png/ } |
157 | 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 | 175 | end | ... | ... |
test/unit/profile_image_block_test.rb
1 | 1 | require_relative "../test_helper" |
2 | +require 'boxes_helper' | |
2 | 3 | |
3 | 4 | class ProfileImageBlockTest < ActiveSupport::TestCase |
5 | + include BoxesHelper | |
4 | 6 | |
5 | 7 | should 'provide description' do |
6 | 8 | assert_not_equal Block.description, ProfileImageBlock.description |
... | ... | @@ -9,8 +11,8 @@ class ProfileImageBlockTest < ActiveSupport::TestCase |
9 | 11 | should 'display profile image' do |
10 | 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 | 16 | end |
15 | 17 | |
16 | 18 | should 'be editable' do | ... | ... |
test/unit/profile_info_block_test.rb
... | ... | @@ -16,9 +16,11 @@ class ProfileInfoBlockTest < ActiveSupport::TestCase |
16 | 16 | assert_not_equal Block.description, ProfileInfoBlock.description |
17 | 17 | end |
18 | 18 | |
19 | + include BoxesHelper | |
20 | + | |
19 | 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 | 24 | end |
23 | 25 | |
24 | 26 | end | ... | ... |
test/unit/profile_list_block_test.rb
... | ... | @@ -20,6 +20,8 @@ class ProfileListBlockTest < ActiveSupport::TestCase |
20 | 20 | assert_equal 20, block.limit |
21 | 21 | end |
22 | 22 | |
23 | + include BoxesHelper | |
24 | + | |
23 | 25 | should 'list people' do |
24 | 26 | env = fast_create(Environment) |
25 | 27 | |
... | ... | @@ -30,15 +32,20 @@ class ProfileListBlockTest < ActiveSupport::TestCase |
30 | 32 | block = ProfileListBlock.new |
31 | 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 | 49 | end |
43 | 50 | |
44 | 51 | should 'list private profiles' do | ... | ... |
test/unit/profile_search_block_test.rb
... | ... | @@ -10,20 +10,22 @@ class ProfileSearchBlockTest < ActiveSupport::TestCase |
10 | 10 | assert_equal Block.new.default_title, ProfileSearchBlock.new.default_title |
11 | 11 | end |
12 | 12 | |
13 | + include BoxesHelper | |
14 | + | |
13 | 15 | should 'render profile search' do |
14 | 16 | person = fast_create(Person) |
15 | 17 | |
16 | 18 | block = ProfileSearchBlock.new |
17 | 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 | 23 | end |
22 | 24 | |
23 | 25 | should 'provide view_title' do |
24 | 26 | person = fast_create(Person) |
25 | 27 | person.boxes << Box.new |
26 | - block = ProfileSearchBlock.new(:title => 'Title from block') | |
28 | + block = ProfileSearchBlock.new(title: 'Title from block') | |
27 | 29 | person.boxes.first.blocks << block |
28 | 30 | block.save! |
29 | 31 | assert_equal 'Title from block', block.view_title | ... | ... |
test/unit/profile_test.rb
... | ... | @@ -1816,6 +1816,21 @@ class ProfileTest < ActiveSupport::TestCase |
1816 | 1816 | assert_equal [person], community.members |
1817 | 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 | 1834 | should 'count unique members of a community' do |
1820 | 1835 | person = fast_create(Person) |
1821 | 1836 | community = fast_create(Community) | ... | ... |
test/unit/raw_html_block_test.rb
... | ... | @@ -17,9 +17,11 @@ class RawHTMLBlockTest < ActiveSupport::TestCase |
17 | 17 | assert_equal html, block.html |
18 | 18 | end |
19 | 19 | |
20 | + include BoxesHelper | |
21 | + | |
20 | 22 | should 'return html as content' do |
21 | 23 | block = RawHTMLBlock.new(:html => "HTML") |
22 | - assert_match(/HTML$/, block.content) | |
24 | + assert_match /HTML$/, render_block_content(block) | |
23 | 25 | end |
24 | 26 | |
25 | 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 | 35 | assert_equivalent block.docs, articles |
36 | 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 | 38 | should 'respect the maximum number of items as configured' do |
50 | 39 | block.limit = 3 |
51 | 40 | |
... | ... | @@ -68,21 +57,6 @@ class RecentDocumentsBlockTest < ActiveSupport::TestCase |
68 | 57 | assert block.limit > 0 |
69 | 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 | 60 | should 'be able to update display setting' do |
87 | 61 | assert @block.update!(:display => 'always') |
88 | 62 | @block.reload |
... | ... | @@ -100,3 +74,56 @@ class RecentDocumentsBlockTest < ActiveSupport::TestCase |
100 | 74 | assert_equal 0, block.get_limit |
101 | 75 | end |
102 | 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 | assert_not_equal Block.new.default_title, SellersSearchBlock.new.default_title |
11 | 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 | 13 | end | ... | ... |
test/unit/slideshow_block_test.rb
1 | 1 | require_relative "../test_helper" |
2 | +require 'boxes_helper' | |
2 | 3 | |
3 | 4 | class SlideshowBlockTest < ActiveSupport::TestCase |
5 | + include BoxesHelper | |
4 | 6 | |
5 | 7 | def setup |
6 | 8 | @profile = fast_create(Profile) |
... | ... | @@ -30,7 +32,7 @@ class SlideshowBlockTest < ActiveSupport::TestCase |
30 | 32 | |
31 | 33 | block = SlideshowBlock.new |
32 | 34 | block.stubs(:gallery).returns(gallery) |
33 | - block.content | |
35 | + render_block_content(block) | |
34 | 36 | end |
35 | 37 | |
36 | 38 | should 'list in random order' do |
... | ... | @@ -42,7 +44,7 @@ class SlideshowBlockTest < ActiveSupport::TestCase |
42 | 44 | block.stubs(:block_images).returns(images) |
43 | 45 | images.expects(:shuffle).once.returns(shuffled) |
44 | 46 | |
45 | - block.content | |
47 | + render_block_content(block) | |
46 | 48 | end |
47 | 49 | |
48 | 50 | should 'not shuffle by default' do | ... | ... |
test/unit/tags_block_test.rb
... | ... | @@ -25,47 +25,80 @@ class TagsBlockTest < ActiveSupport::TestCase |
25 | 25 | assert_not_equal Block.new.default_title, TagsBlock.new.default_title |
26 | 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 | 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 | 61 | end |
62 | + attr_reader :block | |
46 | 63 | |
47 | 64 | should 'return (none) when no tags to display' do |
65 | + ActionView::Base.any_instance.stubs(:block_title).returns("") | |
48 | 66 | block.owner.expects(:article_tags).returns([]) |
49 | - assert_equal '', block.content | |
67 | + assert_equal "\n\n\n", render_block_content(block) | |
50 | 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 | 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 | 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 | 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 | 103 | end |
71 | 104 | end | ... | ... |
test/unit/task_test.rb
... | ... | @@ -182,6 +182,31 @@ class TaskTest < ActiveSupport::TestCase |
182 | 182 | task.save! |
183 | 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 | 210 | should 'be able to list pending tasks' do |
186 | 211 | Task.delete_all |
187 | 212 | t1 = Task.create! | ... | ... |
test/unit/textile_article_test.rb
... | ... | @@ -3,7 +3,8 @@ require_relative "../test_helper" |
3 | 3 | class TextileArticleTest < ActiveSupport::TestCase |
4 | 4 | |
5 | 5 | def setup |
6 | - @profile = create_user('testing').person | |
6 | + @user = User.current = create_user 'testing' | |
7 | + @profile = @user.person | |
7 | 8 | end |
8 | 9 | attr_reader :profile |
9 | 10 | |
... | ... | @@ -16,7 +17,7 @@ class TextileArticleTest < ActiveSupport::TestCase |
16 | 17 | end |
17 | 18 | |
18 | 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 | 21 | end |
21 | 22 | |
22 | 23 | should 'accept empty body' do |
... | ... | @@ -34,23 +35,21 @@ class TextileArticleTest < ActiveSupport::TestCase |
34 | 35 | |
35 | 36 | should 'notify activity on create' do |
36 | 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 | 39 | assert_equal 1, ActionTracker::Record.count |
39 | 40 | end |
40 | 41 | |
41 | 42 | should 'not group trackers activity of article\'s creation' do |
42 | - profile = fast_create(Profile) | |
43 | 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 | 47 | end |
48 | 48 | end |
49 | 49 | |
50 | 50 | should 'not update activity on update of an article' do |
51 | 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 | 53 | time = article.activity.updated_at |
55 | 54 | Time.stubs(:now).returns(time + 1.day) |
56 | 55 | assert_no_difference 'ActionTracker::Record.count' do |
... | ... | @@ -62,8 +61,8 @@ class TextileArticleTest < ActiveSupport::TestCase |
62 | 61 | |
63 | 62 | should 'not create trackers activity when updating articles' do |
64 | 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 | 66 | assert_no_difference 'ActionTracker::Record.count' do |
68 | 67 | a1.name = 'foo';a1.save! |
69 | 68 | a2.name = 'another foo';a2.save! |
... | ... | @@ -72,7 +71,7 @@ class TextileArticleTest < ActiveSupport::TestCase |
72 | 71 | |
73 | 72 | should 'remove activity after destroying article' do |
74 | 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 | 75 | assert_difference 'ActionTracker::Record.count', -1 do |
77 | 76 | a.destroy |
78 | 77 | end |
... | ... | @@ -80,8 +79,8 @@ class TextileArticleTest < ActiveSupport::TestCase |
80 | 79 | |
81 | 80 | should 'remove activity after article is destroyed' do |
82 | 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 | 84 | assert_equal 2, ActionTracker::Record.count |
86 | 85 | assert_difference 'ActionTracker::Record.count', -2 do |
87 | 86 | a1.destroy |
... | ... | @@ -95,20 +94,20 @@ class TextileArticleTest < ActiveSupport::TestCase |
95 | 94 | p1 = Person.first |
96 | 95 | community.add_member(p1) |
97 | 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 | 98 | assert_equal article, ActionTracker::Record.last.target |
100 | 99 | end |
101 | 100 | |
102 | 101 | should "the tracker action target be defined as the article on articles'creation in profile" do |
103 | 102 | ActionTracker::Record.delete_all |
104 | 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 | 105 | assert_equal article, ActionTracker::Record.last.target |
107 | 106 | end |
108 | 107 | |
109 | 108 | should 'not notify activity if the article is not advertise' do |
110 | 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 | 111 | assert_equal true, a.published? |
113 | 112 | assert_equal true, a.notifiable? |
114 | 113 | assert_equal false, a.image? |
... | ... | @@ -121,7 +120,7 @@ class TextileArticleTest < ActiveSupport::TestCase |
121 | 120 | end |
122 | 121 | |
123 | 122 | should "the common trackable conditions return the correct value" do |
124 | - a = build(TextileArticle, :profile => profile) | |
123 | + a = build(TextileArticle, profile: profile) | |
125 | 124 | a.published = a.advertise = true |
126 | 125 | assert_equal true, a.published? |
127 | 126 | assert_equal true, a.notifiable? |
... | ... | @@ -139,7 +138,7 @@ class TextileArticleTest < ActiveSupport::TestCase |
139 | 138 | end |
140 | 139 | |
141 | 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 | 142 | end |
144 | 143 | |
145 | 144 | should 'not mess up with textile markup' do |
... | ... | @@ -153,7 +152,7 @@ class TextileArticleTest < ActiveSupport::TestCase |
153 | 152 | end |
154 | 153 | |
155 | 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 | 156 | end |
158 | 157 | |
159 | 158 | should 'allow harmless HTML' do |
... | ... | @@ -163,11 +162,11 @@ class TextileArticleTest < ActiveSupport::TestCase |
163 | 162 | end |
164 | 163 | |
165 | 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 | 166 | end |
168 | 167 | |
169 | 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 | 170 | end |
172 | 171 | |
173 | 172 | should 'not add hard breaks for single line breaks' do |
... | ... | @@ -182,7 +181,7 @@ class TextileArticleTest < ActiveSupport::TestCase |
182 | 181 | protected |
183 | 182 | |
184 | 183 | def build_article(input = nil, options = {}) |
185 | - article = build(TextileArticle, {:body => input}.merge(options)) | |
184 | + article = build(TextileArticle, {body: input}.merge(options)) | |
186 | 185 | article.valid? # trigger the xss terminate thingy |
187 | 186 | article |
188 | 187 | end | ... | ... |
test/unit/user_test.rb
... | ... | @@ -509,6 +509,7 @@ class UserTest < ActiveSupport::TestCase |
509 | 509 | should 'deliver e-mail with activation code after creation' do |
510 | 510 | assert_difference 'ActionMailer::Base.deliveries.size', 1 do |
511 | 511 | new_user :email => 'pending@activation.com' |
512 | + process_delayed_job_queue | |
512 | 513 | end |
513 | 514 | assert_equal 'pending@activation.com', ActionMailer::Base.deliveries.last['to'].to_s |
514 | 515 | end |
... | ... | @@ -639,6 +640,7 @@ class UserTest < ActiveSupport::TestCase |
639 | 640 | env.save |
640 | 641 | |
641 | 642 | user = new_user :email => 'pending@activation.com' |
643 | + process_delayed_job_queue | |
642 | 644 | assert_difference 'ActionMailer::Base.deliveries.size', 1 do |
643 | 645 | user.activate |
644 | 646 | process_delayed_job_queue |
... | ... | @@ -659,6 +661,7 @@ class UserTest < ActiveSupport::TestCase |
659 | 661 | env.save |
660 | 662 | |
661 | 663 | user = new_user :email => 'pending@activation.com' |
664 | + process_delayed_job_queue | |
662 | 665 | assert_difference 'ActionMailer::Base.deliveries.size', 1 do |
663 | 666 | user.activate |
664 | 667 | process_delayed_job_queue |
... | ... | @@ -678,6 +681,7 @@ class UserTest < ActiveSupport::TestCase |
678 | 681 | env.save |
679 | 682 | |
680 | 683 | user = new_user :name => 'John Doe', :email => 'pending@activation.com' |
684 | + process_delayed_job_queue | |
681 | 685 | assert_difference 'ActionMailer::Base.deliveries.size', 1 do |
682 | 686 | user.activate |
683 | 687 | process_delayed_job_queue | ... | ... |