Commit 42e1b8afae156864f9634468b64d7af41b42b5b6
Exists in
staging
and in
42 other branches
Merge branch 'master' into next
Showing
62 changed files
with
261 additions
and
193 deletions
Show diff stats
app/controllers/public/content_viewer_controller.rb
@@ -107,10 +107,12 @@ class ContentViewerController < ApplicationController | @@ -107,10 +107,12 @@ class ContentViewerController < ApplicationController | ||
107 | if translation.language == locale | 107 | if translation.language == locale |
108 | @page = translation | 108 | @page = translation |
109 | redirect_to :profile => @page.profile.identifier, :page => @page.explode_path | 109 | redirect_to :profile => @page.profile.identifier, :page => @page.explode_path |
110 | + return true | ||
110 | end | 111 | end |
111 | end | 112 | end |
112 | end | 113 | end |
113 | end | 114 | end |
115 | + false | ||
114 | end | 116 | end |
115 | 117 | ||
116 | def pass_without_comment_captcha? | 118 | def pass_without_comment_captcha? |
app/controllers/public/events_controller.rb
@@ -5,7 +5,11 @@ class EventsController < PublicController | @@ -5,7 +5,11 @@ class EventsController < PublicController | ||
5 | 5 | ||
6 | def events | 6 | def events |
7 | @events = [] | 7 | @events = [] |
8 | - @date = build_date(params[:year], params[:month], params[:day]) | 8 | + begin |
9 | + @date = build_date params[:year], params[:month], params[:day] | ||
10 | + rescue ArgumentError # invalid date | ||
11 | + return render_not_found | ||
12 | + end | ||
9 | 13 | ||
10 | if !params[:year] && !params[:month] && !params[:day] | 14 | if !params[:year] && !params[:month] && !params[:day] |
11 | @events = profile.events.next_events_from_month(@date).paginate(:per_page => per_page, :page => params[:page]) | 15 | @events = profile.events.next_events_from_month(@date).paginate(:per_page => per_page, :page => params[:page]) |
app/controllers/public/search_controller.rb
@@ -62,7 +62,7 @@ class SearchController < PublicController | @@ -62,7 +62,7 @@ class SearchController < PublicController | ||
62 | end | 62 | end |
63 | 63 | ||
64 | def articles | 64 | def articles |
65 | - @scope = @environment.articles.public.paginate(paginate_options) | 65 | + @scope = @environment.articles.public |
66 | full_text_search | 66 | full_text_search |
67 | end | 67 | end |
68 | 68 | ||
@@ -76,7 +76,7 @@ class SearchController < PublicController | @@ -76,7 +76,7 @@ class SearchController < PublicController | ||
76 | end | 76 | end |
77 | 77 | ||
78 | def products | 78 | def products |
79 | - @scope = @environment.products.paginate(paginate_options) | 79 | + @scope = @environment.products |
80 | full_text_search | 80 | full_text_search |
81 | end | 81 | end |
82 | 82 | ||
@@ -244,7 +244,7 @@ class SearchController < PublicController | @@ -244,7 +244,7 @@ class SearchController < PublicController | ||
244 | def visible_profiles(klass, *extra_relations) | 244 | def visible_profiles(klass, *extra_relations) |
245 | relations = [:image, :domains, :environment, :preferred_domain] | 245 | relations = [:image, :domains, :environment, :preferred_domain] |
246 | relations += extra_relations | 246 | relations += extra_relations |
247 | - @environment.send(klass.name.underscore.pluralize).visible.includes(relations).paginate(paginate_options) | 247 | + @environment.send(klass.name.underscore.pluralize).visible.includes(relations) |
248 | end | 248 | end |
249 | 249 | ||
250 | def per_page | 250 | def per_page |
app/helpers/boxes_helper.rb
@@ -251,8 +251,8 @@ module BoxesHelper | @@ -251,8 +251,8 @@ module BoxesHelper | ||
251 | content_tag('h2', _('Embed block code')) + | 251 | content_tag('h2', _('Embed block code')) + |
252 | content_tag('div', _('Below, you''ll see a field containing embed code for the block. Just copy the code and paste it into your website or blogging software.'), :style => 'margin-bottom: 1em;') + | 252 | content_tag('div', _('Below, you''ll see a field containing embed code for the block. Just copy the code and paste it into your website or blogging software.'), :style => 'margin-bottom: 1em;') + |
253 | content_tag('textarea', embed_code, :style => 'margin-bottom: 1em; width:100%; height:40%;', :readonly => 'readonly') + | 253 | content_tag('textarea', embed_code, :style => 'margin-bottom: 1em; width:100%; height:40%;', :readonly => 'readonly') + |
254 | - thickbox_close_button(_('Close')), :style => 'display: none;', :id => "embed-code-box-#{block.id}") | ||
255 | - buttons << thickbox_inline_popup_icon(:embed, _('Embed code'), {}, "embed-code-box-#{block.id}") << html | 254 | + modal_close_button(_('Close')), :style => 'display: none;', :id => "embed-code-box-#{block.id}") |
255 | + buttons << modal_inline_icon(:embed, _('Embed code'), {}, "#embed-code-box-#{block.id}") << html | ||
256 | end | 256 | end |
257 | 257 | ||
258 | content_tag('div', buttons.join("\n") + tag('br', :style => 'clear: left'), :class => 'button-bar') | 258 | content_tag('div', buttons.join("\n") + tag('br', :style => 'clear: left'), :class => 'button-bar') |
app/views/features/manage_fields.html.erb
1 | <h1><%= _('Manage fields displayed for profiles') %></h1> | 1 | <h1><%= _('Manage fields displayed for profiles') %></h1> |
2 | 2 | ||
3 | +<%= javascript_include_tag "manage-fields.js" %> | ||
4 | + | ||
3 | <% tabs = [] %> | 5 | <% tabs = [] %> |
4 | <% tabs << {:title => _("Person's fields"), :id => 'person-fields', | 6 | <% tabs << {:title => _("Person's fields"), :id => 'person-fields', |
5 | :content => (render :partial => 'manage_person_fields')} %> | 7 | :content => (render :partial => 'manage_person_fields')} %> |
@@ -11,5 +13,3 @@ | @@ -11,5 +13,3 @@ | ||
11 | <% end %> | 13 | <% end %> |
12 | 14 | ||
13 | <%= render_tabs(tabs) %> | 15 | <%= render_tabs(tabs) %> |
14 | - | ||
15 | -<%= javascript_include_tag "manage-fields.js" %> |
app/views/search/search.js.erb
config/initializers/newrelic.rb
db/migrate/20140724134601_fix_yaml_encoding.rb
@@ -18,9 +18,8 @@ class FixYamlEncoding < ActiveRecord::Migration | @@ -18,9 +18,8 @@ class FixYamlEncoding < ActiveRecord::Migration | ||
18 | private | 18 | private |
19 | 19 | ||
20 | def self.fix_encoding(model, param) | 20 | def self.fix_encoding(model, param) |
21 | - result = model.all | ||
22 | - puts "Fixing #{result.count} rows of #{model} (#{param})" | ||
23 | - result.each do |r| | 21 | + puts "Fixing #{model.count} rows of #{model} (#{param})" |
22 | + model.find_each do |r| | ||
24 | begin | 23 | begin |
25 | yaml = r.send(param) | 24 | yaml = r.send(param) |
26 | # if deserialization failed then a string is returned | 25 | # if deserialization failed then a string is returned |
debian/changelog
1 | +noosfero (1.1~rc4) wheezy; urgency=medium | ||
2 | + | ||
3 | + * Fourth release candidate for Noosfero 1.1 | ||
4 | + | ||
5 | + -- Antonio Terceiro <terceiro@debian.org> Wed, 01 Apr 2015 12:22:36 -0300 | ||
6 | + | ||
1 | noosfero (1.1~rc2) wheezy; urgency=low | 7 | noosfero (1.1~rc2) wheezy; urgency=low |
2 | 8 | ||
3 | * Second release candidate for Noosfero 1.1 | 9 | * Second release candidate for Noosfero 1.1 |
features/edit_article.feature
@@ -250,6 +250,7 @@ Feature: edit article | @@ -250,6 +250,7 @@ Feature: edit article | ||
250 | Scenario: add a translation to an article | 250 | Scenario: add a translation to an article |
251 | Given I am on joaosilva's sitemap | 251 | Given I am on joaosilva's sitemap |
252 | And I follow "Save the whales" | 252 | And I follow "Save the whales" |
253 | + And the following languages "en es" are available on environment | ||
253 | Then I should not see "Add translation" | 254 | Then I should not see "Add translation" |
254 | And I follow "Edit" | 255 | And I follow "Edit" |
255 | And I select "English" from "Language" | 256 | And I select "English" from "Language" |
@@ -267,6 +268,7 @@ Feature: edit article | @@ -267,6 +268,7 @@ Feature: edit article | ||
267 | | owner | name | language | | 268 | | owner | name | language | |
268 | | joaosilva | Article in English | en | | 269 | | joaosilva | Article in English | en | |
269 | And I am on joaosilva's sitemap | 270 | And I am on joaosilva's sitemap |
271 | + And the following languages "en pt" are available on environment | ||
270 | When I follow "Article in English" | 272 | When I follow "Article in English" |
271 | And I follow "Add translation" | 273 | And I follow "Add translation" |
272 | And I fill in "Title" with "Article in Portuguese" | 274 | And I fill in "Title" with "Article in Portuguese" |
features/login.feature
@@ -207,18 +207,3 @@ Feature: login | @@ -207,18 +207,3 @@ Feature: login | ||
207 | | Password | 123456 | | 207 | | Password | 123456 | |
208 | When I press "Log in" | 208 | When I press "Log in" |
209 | Then I should be on joaosilva's control panel | 209 | Then I should be on joaosilva's control panel |
210 | - | ||
211 | - Scenario: join community on login | ||
212 | - Given the following users | ||
213 | - | login | name | | ||
214 | - | mariasilva | Maria Silva | | ||
215 | - And the following communities | ||
216 | - | name | identifier | owner | | ||
217 | - | Free Software | freesoftware | mariasilva | | ||
218 | - And I am on /freesoftware | ||
219 | - When I follow "Join" | ||
220 | - And I fill in the following: | ||
221 | - | Username / Email | joaosilva | | ||
222 | - | Password | 123456 | | ||
223 | - And I press "Log in" | ||
224 | - Then "Joao Silva" should be a member of "Free Software" |
features/step_definitions/internationalization_steps.rb
@@ -22,6 +22,10 @@ Given /^Noosfero is configured to use (.+) as default$/ do |lang| | @@ -22,6 +22,10 @@ Given /^Noosfero is configured to use (.+) as default$/ do |lang| | ||
22 | Noosfero.default_locale = language_to_code(lang) | 22 | Noosfero.default_locale = language_to_code(lang) |
23 | end | 23 | end |
24 | 24 | ||
25 | +Given /^the following languages "([^"]*)" are available on environment$/ do |languages| | ||
26 | + Environment.default.update_attribute(:languages, languages.split) | ||
27 | +end | ||
28 | + | ||
25 | After do | 29 | After do |
26 | # reset everything back to normal | 30 | # reset everything back to normal |
27 | Noosfero.default_locale = nil | 31 | Noosfero.default_locale = nil |
features/step_definitions/noosfero_steps.rb
@@ -293,6 +293,7 @@ Given /^I am logged in as "(.+)"$/ do |username| | @@ -293,6 +293,7 @@ Given /^I am logged in as "(.+)"$/ do |username| | ||
293 | When %{I press "Log in"} | 293 | When %{I press "Log in"} |
294 | And %{I go to #{username}'s control panel} | 294 | And %{I go to #{username}'s control panel} |
295 | Then %{I should be on #{username}'s control panel} | 295 | Then %{I should be on #{username}'s control panel} |
296 | + @current_user = username | ||
296 | end | 297 | end |
297 | 298 | ||
298 | Given /^"([^"]*)" is environment admin$/ do |person| | 299 | Given /^"([^"]*)" is environment admin$/ do |person| |
lib/acts_as_having_image.rb
@@ -2,7 +2,7 @@ module ActsAsHavingImage | @@ -2,7 +2,7 @@ module ActsAsHavingImage | ||
2 | 2 | ||
3 | module ClassMethods | 3 | module ClassMethods |
4 | def acts_as_having_image | 4 | def acts_as_having_image |
5 | - belongs_to :image | 5 | + belongs_to :image, dependent: :destroy |
6 | scope :with_image, :conditions => [ "#{table_name}.image_id IS NOT NULL" ] | 6 | scope :with_image, :conditions => [ "#{table_name}.image_id IS NOT NULL" ] |
7 | scope :without_image, :conditions => [ "#{table_name}.image_id IS NULL" ] | 7 | scope :without_image, :conditions => [ "#{table_name}.image_id IS NULL" ] |
8 | self.send(:include, ActsAsHavingImage) | 8 | self.send(:include, ActsAsHavingImage) |
@@ -19,4 +19,4 @@ module ActsAsHavingImage | @@ -19,4 +19,4 @@ module ActsAsHavingImage | ||
19 | 19 | ||
20 | end | 20 | end |
21 | 21 | ||
22 | -ActiveRecord::Base.extend(ActsAsHavingImage::ClassMethods) | 22 | -ActiveRecord::Base.extend(ActsAsHavingImage::ClassMethods) |
23 | +ActiveRecord::Base.extend(ActsAsHavingImage::ClassMethods) | ||
23 | \ No newline at end of file | 24 | \ No newline at end of file |
lib/noosfero/version.rb
lib/tasks/plugins_tests.rake
@@ -4,7 +4,6 @@ $broken_plugins = %w[ | @@ -4,7 +4,6 @@ $broken_plugins = %w[ | ||
4 | comment_classification | 4 | comment_classification |
5 | ldap | 5 | ldap |
6 | solr | 6 | solr |
7 | - stoa | ||
8 | ] | 7 | ] |
9 | 8 | ||
10 | @all_plugins = Dir.glob('plugins/*').map { |f| File.basename(f) } - ['template'] | 9 | @all_plugins = Dir.glob('plugins/*').map { |f| File.basename(f) } - ['template'] |
plugins/comment_group/test/functional/comment_group_plugin_profile_controller_test.rb
@@ -22,8 +22,9 @@ class CommentGroupPluginProfileControllerTest < ActionController::TestCase | @@ -22,8 +22,9 @@ class CommentGroupPluginProfileControllerTest < ActionController::TestCase | ||
22 | comment = fast_create(Comment, :source_id => article, :author_id => profile, :title => 'a comment', :body => 'lalala', :group_id => 0) | 22 | comment = fast_create(Comment, :source_id => article, :author_id => profile, :title => 'a comment', :body => 'lalala', :group_id => 0) |
23 | xhr :get, :view_comments, :profile => @profile.identifier, :article_id => article.id, :group_id => 0 | 23 | xhr :get, :view_comments, :profile => @profile.identifier, :article_id => article.id, :group_id => 0 |
24 | assert_template 'comment_group_plugin_profile/view_comments' | 24 | assert_template 'comment_group_plugin_profile/view_comments' |
25 | - assert_match /comments_list_group_0/, @response.body | ||
26 | - assert_match /\"comment-count-0\", \"1\"/, @response.body | 25 | + assert_select_rjs '#comments_list_group_0' |
26 | + assert_select_rjs :replace_html, '#comment-count-0' | ||
27 | + assert_equal 1, assigns(:comments_count) | ||
27 | end | 28 | end |
28 | 29 | ||
29 | should 'do not show global comments' do | 30 | should 'do not show global comments' do |
@@ -31,8 +32,9 @@ class CommentGroupPluginProfileControllerTest < ActionController::TestCase | @@ -31,8 +32,9 @@ class CommentGroupPluginProfileControllerTest < ActionController::TestCase | ||
31 | fast_create(Comment, :source_id => article, :author_id => profile, :title => 'a comment', :body => 'lalala', :group_id => 0) | 32 | fast_create(Comment, :source_id => article, :author_id => profile, :title => 'a comment', :body => 'lalala', :group_id => 0) |
32 | xhr :get, :view_comments, :profile => @profile.identifier, :article_id => article.id, :group_id => 0 | 33 | xhr :get, :view_comments, :profile => @profile.identifier, :article_id => article.id, :group_id => 0 |
33 | assert_template 'comment_group_plugin_profile/view_comments' | 34 | assert_template 'comment_group_plugin_profile/view_comments' |
34 | - assert_match /comments_list_group_0/, @response.body | ||
35 | - assert_match /\"comment-count-0\", \"1\"/, @response.body | 35 | + assert_select_rjs '#comments_list_group_0' |
36 | + assert_select_rjs :replace_html, '#comment-count-0' | ||
37 | + assert_equal 1, assigns(:comments_count) | ||
36 | end | 38 | end |
37 | 39 | ||
38 | should 'show first page comments only' do | 40 | should 'show first page comments only' do |
plugins/context_content/lib/context_content_plugin/context_content_block.rb
@@ -58,7 +58,7 @@ class ContextContentPlugin::ContextContentBlock < Block | @@ -58,7 +58,7 @@ class ContextContentPlugin::ContextContentBlock < Block | ||
58 | def contents(page, p=1) | 58 | def contents(page, p=1) |
59 | return @children unless @children.blank? | 59 | return @children unless @children.blank? |
60 | if page | 60 | if page |
61 | - @children = page.children.with_types(types).paginate(:per_page => limit, :page => p) | 61 | + @children = page.children.with_types(types).order(:name).paginate(:per_page => limit, :page => p) |
62 | (@children.blank? && show_parent_content) ? contents(page.parent, p) : @children | 62 | (@children.blank? && show_parent_content) ? contents(page.parent, p) : @children |
63 | else | 63 | else |
64 | nil | 64 | nil |
plugins/context_content/test/unit/context_content_block_test.rb
@@ -51,18 +51,18 @@ class ContextContentBlockTest < ActiveSupport::TestCase | @@ -51,18 +51,18 @@ class ContextContentBlockTest < ActiveSupport::TestCase | ||
51 | should 'show contents for next page' do | 51 | should 'show contents for next page' do |
52 | @block.limit = 2 | 52 | @block.limit = 2 |
53 | folder = fast_create(Folder) | 53 | folder = fast_create(Folder) |
54 | - article1 = fast_create(TinyMceArticle, :parent_id => folder.id) | ||
55 | - article2 = fast_create(TinyMceArticle, :parent_id => folder.id) | ||
56 | - article3 = fast_create(TinyMceArticle, :parent_id => folder.id) | 54 | + article1 = fast_create(TinyMceArticle, :name => 'article 1', :parent_id => folder.id) |
55 | + article2 = fast_create(TinyMceArticle, :name => 'article 2', :parent_id => folder.id) | ||
56 | + article3 = fast_create(TinyMceArticle, :name => 'article 3', :parent_id => folder.id) | ||
57 | assert_equal [article3], @block.contents(folder, 2) | 57 | assert_equal [article3], @block.contents(folder, 2) |
58 | end | 58 | end |
59 | 59 | ||
60 | should 'show parent contents for next page' do | 60 | should 'show parent contents for next page' do |
61 | @block.limit = 2 | 61 | @block.limit = 2 |
62 | folder = fast_create(Folder) | 62 | folder = fast_create(Folder) |
63 | - article1 = fast_create(TinyMceArticle, :parent_id => folder.id) | ||
64 | - article2 = fast_create(TinyMceArticle, :parent_id => folder.id) | ||
65 | - article3 = fast_create(TinyMceArticle, :parent_id => folder.id) | 63 | + article1 = fast_create(TinyMceArticle, :name => 'article 1', :parent_id => folder.id) |
64 | + article2 = fast_create(TinyMceArticle, :name => 'article 2', :parent_id => folder.id) | ||
65 | + article3 = fast_create(TinyMceArticle, :name => 'article 3', :parent_id => folder.id) | ||
66 | assert_equal [article3], @block.contents(article1, 2) | 66 | assert_equal [article3], @block.contents(article1, 2) |
67 | end | 67 | end |
68 | 68 |
plugins/display_content/test/functional/display_content_plugin_admin_controller_test.rb
@@ -40,7 +40,7 @@ class DisplayContentPluginAdminControllerTest < ActionController::TestCase | @@ -40,7 +40,7 @@ class DisplayContentPluginAdminControllerTest < ActionController::TestCase | ||
40 | Article.delete_all | 40 | Article.delete_all |
41 | get :index, :block_id => block.id | 41 | get :index, :block_id => block.id |
42 | json_response = ActiveSupport::JSON.decode(@response.body) | 42 | json_response = ActiveSupport::JSON.decode(@response.body) |
43 | - assert_equivalent [], json_response | 43 | + assert_equal [], json_response |
44 | end | 44 | end |
45 | 45 | ||
46 | should 'index action returns an json with node content' do | 46 | should 'index action returns an json with node content' do |
@@ -52,7 +52,7 @@ class DisplayContentPluginAdminControllerTest < ActionController::TestCase | @@ -52,7 +52,7 @@ class DisplayContentPluginAdminControllerTest < ActionController::TestCase | ||
52 | expected_json = {'data' => article.title} | 52 | expected_json = {'data' => article.title} |
53 | expected_json['attr'] = { 'node_id' => article.id, 'parent_id' => article.parent_id} | 53 | expected_json['attr'] = { 'node_id' => article.id, 'parent_id' => article.parent_id} |
54 | 54 | ||
55 | - assert_equivalent [expected_json], json_response | 55 | + assert_hash_equivalent [expected_json], json_response |
56 | end | 56 | end |
57 | 57 | ||
58 | should 'index action returns an json with node checked if the node is in the nodes list' do | 58 | should 'index action returns an json with node checked if the node is in the nodes list' do |
@@ -67,7 +67,7 @@ class DisplayContentPluginAdminControllerTest < ActionController::TestCase | @@ -67,7 +67,7 @@ class DisplayContentPluginAdminControllerTest < ActionController::TestCase | ||
67 | expected_json['attr'] = { 'node_id' => article.id, 'parent_id' => article.parent_id} | 67 | expected_json['attr'] = { 'node_id' => article.id, 'parent_id' => article.parent_id} |
68 | expected_json['attr'].merge!({'class' => 'jstree-checked'}) | 68 | expected_json['attr'].merge!({'class' => 'jstree-checked'}) |
69 | 69 | ||
70 | - assert_equivalent [expected_json], json_response | 70 | + assert_hash_equivalent [expected_json], json_response |
71 | end | 71 | end |
72 | 72 | ||
73 | should 'index action returns an json with node undetermined if the node is in the parent nodes list' do | 73 | should 'index action returns an json with node undetermined if the node is in the parent nodes list' do |
@@ -95,7 +95,7 @@ class DisplayContentPluginAdminControllerTest < ActionController::TestCase | @@ -95,7 +95,7 @@ class DisplayContentPluginAdminControllerTest < ActionController::TestCase | ||
95 | expected_json['attr'] = { 'node_id' => f.id, 'parent_id' => f.parent_id} | 95 | expected_json['attr'] = { 'node_id' => f.id, 'parent_id' => f.parent_id} |
96 | expected_json['state'] = 'closed' | 96 | expected_json['state'] = 'closed' |
97 | 97 | ||
98 | - assert_equivalent [expected_json], json_response | 98 | + assert_hash_equivalent [expected_json], json_response |
99 | end | 99 | end |
100 | 100 | ||
101 | should 'index action returns an json with all the children nodes if some parent is in the parents list' do | 101 | should 'index action returns an json with all the children nodes if some parent is in the parents list' do |
@@ -118,7 +118,7 @@ class DisplayContentPluginAdminControllerTest < ActionController::TestCase | @@ -118,7 +118,7 @@ class DisplayContentPluginAdminControllerTest < ActionController::TestCase | ||
118 | expected_json['children'] = children | 118 | expected_json['children'] = children |
119 | expected_json['state'] = 'closed' | 119 | expected_json['state'] = 'closed' |
120 | 120 | ||
121 | - assert_equivalent [expected_json], json_response | 121 | + assert_hash_equivalent [expected_json], json_response |
122 | end | 122 | end |
123 | 123 | ||
124 | should 'index action returns an json with all the children nodes and root nodes if some parent is in the parents list and there is others root articles' do | 124 | should 'index action returns an json with all the children nodes and root nodes if some parent is in the parents list and there is others root articles' do |
@@ -148,7 +148,7 @@ class DisplayContentPluginAdminControllerTest < ActionController::TestCase | @@ -148,7 +148,7 @@ class DisplayContentPluginAdminControllerTest < ActionController::TestCase | ||
148 | value['attr'] = { 'node_id' => a3.id, 'parent_id' => a3.parent_id, "class" => "jstree-checked"} | 148 | value['attr'] = { 'node_id' => a3.id, 'parent_id' => a3.parent_id, "class" => "jstree-checked"} |
149 | expected_json.push(value) | 149 | expected_json.push(value) |
150 | 150 | ||
151 | - assert_equivalent expected_json, json_response | 151 | + assert_hash_equivalent expected_json, json_response |
152 | end | 152 | end |
153 | 153 | ||
154 | should 'index action returns an json without children nodes if the parent is not in the parents list' do | 154 | should 'index action returns an json without children nodes if the parent is not in the parents list' do |
@@ -170,7 +170,7 @@ class DisplayContentPluginAdminControllerTest < ActionController::TestCase | @@ -170,7 +170,7 @@ class DisplayContentPluginAdminControllerTest < ActionController::TestCase | ||
170 | value['attr'] = { 'node_id' => a3.id, 'parent_id' => a3.parent_id} | 170 | value['attr'] = { 'node_id' => a3.id, 'parent_id' => a3.parent_id} |
171 | expected_json.push(value) | 171 | expected_json.push(value) |
172 | 172 | ||
173 | - assert_equivalent expected_json, json_response | 173 | + assert_hash_equivalent expected_json, json_response |
174 | end | 174 | end |
175 | 175 | ||
176 | end | 176 | end |
plugins/display_content/test/functional/display_content_plugin_myprofile_controller_test.rb
@@ -41,7 +41,7 @@ class DisplayContentPluginMyprofileControllerTest < ActionController::TestCase | @@ -41,7 +41,7 @@ class DisplayContentPluginMyprofileControllerTest < ActionController::TestCase | ||
41 | Article.delete_all | 41 | Article.delete_all |
42 | get :index, :block_id => block.id, :profile => profile.identifier | 42 | get :index, :block_id => block.id, :profile => profile.identifier |
43 | json_response = ActiveSupport::JSON.decode(@response.body) | 43 | json_response = ActiveSupport::JSON.decode(@response.body) |
44 | - assert_equivalent [], json_response | 44 | + assert_equal [], json_response |
45 | end | 45 | end |
46 | 46 | ||
47 | should 'index action returns an json with node content' do | 47 | should 'index action returns an json with node content' do |
@@ -53,7 +53,7 @@ class DisplayContentPluginMyprofileControllerTest < ActionController::TestCase | @@ -53,7 +53,7 @@ class DisplayContentPluginMyprofileControllerTest < ActionController::TestCase | ||
53 | expected_json = {'data' => article.title} | 53 | expected_json = {'data' => article.title} |
54 | expected_json['attr'] = { 'node_id' => article.id, 'parent_id' => article.parent_id} | 54 | expected_json['attr'] = { 'node_id' => article.id, 'parent_id' => article.parent_id} |
55 | 55 | ||
56 | - assert_equivalent [expected_json], json_response | 56 | + assert_hash_equivalent [expected_json], json_response |
57 | end | 57 | end |
58 | 58 | ||
59 | should 'index action returns an json with node checked if the node is in the nodes list' do | 59 | should 'index action returns an json with node checked if the node is in the nodes list' do |
@@ -68,7 +68,7 @@ class DisplayContentPluginMyprofileControllerTest < ActionController::TestCase | @@ -68,7 +68,7 @@ class DisplayContentPluginMyprofileControllerTest < ActionController::TestCase | ||
68 | expected_json['attr'] = { 'node_id' => article.id, 'parent_id' => article.parent_id} | 68 | expected_json['attr'] = { 'node_id' => article.id, 'parent_id' => article.parent_id} |
69 | expected_json['attr'].merge!({'class' => 'jstree-checked'}) | 69 | expected_json['attr'].merge!({'class' => 'jstree-checked'}) |
70 | 70 | ||
71 | - assert_equivalent [expected_json], json_response | 71 | + assert_hash_equivalent [expected_json], json_response |
72 | end | 72 | end |
73 | 73 | ||
74 | should 'index action returns an json with node undetermined if the node is in the parent nodes list' do | 74 | should 'index action returns an json with node undetermined if the node is in the parent nodes list' do |
@@ -97,7 +97,7 @@ class DisplayContentPluginMyprofileControllerTest < ActionController::TestCase | @@ -97,7 +97,7 @@ class DisplayContentPluginMyprofileControllerTest < ActionController::TestCase | ||
97 | expected_json['attr'] = { 'node_id' => f.id, 'parent_id' => f.parent_id} | 97 | expected_json['attr'] = { 'node_id' => f.id, 'parent_id' => f.parent_id} |
98 | expected_json['state'] = 'closed' | 98 | expected_json['state'] = 'closed' |
99 | 99 | ||
100 | - assert_equivalent [expected_json], json_response | 100 | + assert_hash_equivalent [expected_json], json_response |
101 | end | 101 | end |
102 | 102 | ||
103 | should 'index action returns an json with all the children nodes if some parent is in the parents list' do | 103 | should 'index action returns an json with all the children nodes if some parent is in the parents list' do |
@@ -120,26 +120,26 @@ class DisplayContentPluginMyprofileControllerTest < ActionController::TestCase | @@ -120,26 +120,26 @@ class DisplayContentPluginMyprofileControllerTest < ActionController::TestCase | ||
120 | expected_json['children'] = children | 120 | expected_json['children'] = children |
121 | expected_json['state'] = 'closed' | 121 | expected_json['state'] = 'closed' |
122 | 122 | ||
123 | - assert_equivalent [expected_json], json_response | ||
124 | - end | ||
125 | - | ||
126 | - should 'index action returns an json with all the children nodes and root nodes if some parent is in the parents list and there is others root articles' do | ||
127 | - Article.delete_all | ||
128 | - f = fast_create(Folder, :name => 'test folder 1', :profile_id => profile.id) | ||
129 | - a1 = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id, :parent_id => f.id) | ||
130 | - a2 = fast_create(TextileArticle, :name => 'test article 2', :profile_id => profile.id, :parent_id => f.id) | ||
131 | - a3 = fast_create(TextileArticle, :name => 'test article 3', :profile_id => profile.id) | ||
132 | - block.checked_nodes = {a1.id => true} | ||
133 | - block.save! | ||
134 | - | ||
135 | - get :index, :block_id => block.id, :profile => profile.identifier | ||
136 | - json_response = ActiveSupport::JSON.decode(@response.body) | ||
137 | - expected_json = [] | ||
138 | - value = {'data' => f.title} | ||
139 | - value['attr'] = { 'node_id' => f.id, 'parent_id' => f.parent_id} | ||
140 | - children = [ | ||
141 | - {'data' => a1.title, 'attr' => {'node_id' => a1.id, 'parent_id' => a1.parent_id, "class" => "jstree-checked"}}, | ||
142 | - {'data' => a2.title, 'attr' => {'node_id' => a2.id, 'parent_id'=> a2.parent_id}} | 123 | + assert_hash_equivalent [expected_json], json_response |
124 | + end | ||
125 | + | ||
126 | + should 'index action returns an json with all the children nodes and root nodes if some parent is in the parents list and there is others root articles' do | ||
127 | + Article.delete_all | ||
128 | + f = fast_create(Folder, :name => 'test folder 1', :profile_id => profile.id) | ||
129 | + a1 = fast_create(TextileArticle, :name => 'test article 1', :profile_id => profile.id, :parent_id => f.id) | ||
130 | + a2 = fast_create(TextileArticle, :name => 'test article 2', :profile_id => profile.id, :parent_id => f.id) | ||
131 | + a3 = fast_create(TextileArticle, :name => 'test article 3', :profile_id => profile.id) | ||
132 | + block.checked_nodes = {a1.id => true} | ||
133 | + block.save! | ||
134 | + | ||
135 | + get :index, :block_id => block.id, :profile => profile.identifier | ||
136 | + json_response = ActiveSupport::JSON.decode(@response.body) | ||
137 | + expected_json = [] | ||
138 | + value = {'data' => f.title} | ||
139 | + value['attr'] = { 'node_id' => f.id, 'parent_id' => f.parent_id} | ||
140 | + children = [ | ||
141 | + {'data' => a1.title, 'attr' => {'node_id' => a1.id, 'parent_id' => a1.parent_id, "class" => "jstree-checked"}}, | ||
142 | + {'data' => a2.title, 'attr' => {'node_id' => a2.id, 'parent_id'=> a2.parent_id}} | ||
143 | ] | 143 | ] |
144 | value['attr'].merge!({'class' => 'jstree-undetermined'}) | 144 | value['attr'].merge!({'class' => 'jstree-undetermined'}) |
145 | value['children'] = children | 145 | value['children'] = children |
@@ -150,7 +150,7 @@ class DisplayContentPluginMyprofileControllerTest < ActionController::TestCase | @@ -150,7 +150,7 @@ class DisplayContentPluginMyprofileControllerTest < ActionController::TestCase | ||
150 | value['attr'] = { 'node_id' => a3.id, 'parent_id' => a3.parent_id} | 150 | value['attr'] = { 'node_id' => a3.id, 'parent_id' => a3.parent_id} |
151 | expected_json.push(value) | 151 | expected_json.push(value) |
152 | 152 | ||
153 | - assert_equivalent expected_json, json_response | 153 | + assert_hash_equivalent expected_json, json_response |
154 | end | 154 | end |
155 | 155 | ||
156 | should 'index action returns an json without children nodes if the parent is not in the parents list' do | 156 | should 'index action returns an json without children nodes if the parent is not in the parents list' do |
@@ -172,7 +172,7 @@ class DisplayContentPluginMyprofileControllerTest < ActionController::TestCase | @@ -172,7 +172,7 @@ class DisplayContentPluginMyprofileControllerTest < ActionController::TestCase | ||
172 | value['attr'] = { 'node_id' => a3.id, 'parent_id' => a3.parent_id} | 172 | value['attr'] = { 'node_id' => a3.id, 'parent_id' => a3.parent_id} |
173 | expected_json.push(value) | 173 | expected_json.push(value) |
174 | 174 | ||
175 | - assert_equivalent expected_json, json_response | 175 | + assert_hash_equivalent expected_json, json_response |
176 | end | 176 | end |
177 | 177 | ||
178 | end | 178 | end |
plugins/display_content/test/test_helper.rb
1 | -require File.dirname(__FILE__) + '/../../../test/test_helper' | 1 | +require_relative "../../../test/test_helper" |
2 | + | ||
3 | +def sort_by_data(array) | ||
4 | + return if array.blank? | ||
5 | + array.each {|el| el['children'] = sort_by_data(el['children']) } | ||
6 | + array.sort_by {|el| el['data']} | ||
7 | +end | ||
8 | + | ||
9 | +def assert_hash_equivalent(expected, response) | ||
10 | + assert_equal sort_by_data(expected), sort_by_data(response) | ||
11 | +end |
plugins/google_analytics/lib/ext/profile.rb
@@ -2,4 +2,9 @@ require_dependency 'profile' | @@ -2,4 +2,9 @@ require_dependency 'profile' | ||
2 | 2 | ||
3 | class Profile | 3 | class Profile |
4 | settings_items :google_analytics_profile_id | 4 | settings_items :google_analytics_profile_id |
5 | + attr_accessible :google_analytics_profile_id | ||
6 | + | ||
7 | + descendants.each do |descendant| | ||
8 | + descendant.attr_accessible :google_analytics_profile_id | ||
9 | + end | ||
5 | end | 10 | end |
plugins/google_analytics/lib/google_analytics_plugin.rb
@@ -19,12 +19,15 @@ class GoogleAnalyticsPlugin < Noosfero::Plugin | @@ -19,12 +19,15 @@ class GoogleAnalyticsPlugin < Noosfero::Plugin | ||
19 | 19 | ||
20 | def head_ending | 20 | def head_ending |
21 | unless profile_id.blank? | 21 | unless profile_id.blank? |
22 | - expanded_template('tracking-code.rhtml',{:profile_id => profile_id}) | 22 | + expanded_template('tracking-code.html.erb',{:profile_id => profile_id}) |
23 | end | 23 | end |
24 | end | 24 | end |
25 | 25 | ||
26 | def profile_editor_extras | 26 | def profile_editor_extras |
27 | - expanded_template('profile-editor-extras.rhtml',{:profile_id => profile_id}) | 27 | + analytics_id = profile_id |
28 | + lambda { | ||
29 | + render :file => 'profile-editor-extras', :locals => { :profile_id => analytics_id } | ||
30 | + } | ||
28 | end | 31 | end |
29 | 32 | ||
30 | end | 33 | end |
plugins/google_analytics/test/functional/profile_editor_controller_test.rb
0 → 100644
@@ -0,0 +1,31 @@ | @@ -0,0 +1,31 @@ | ||
1 | +require 'test_helper' | ||
2 | +require 'profile_editor_controller' | ||
3 | + | ||
4 | +# Re-raise errors caught by the controller. | ||
5 | +class ProfileEditorController; def rescue_action(e) raise e end; end | ||
6 | + | ||
7 | +class ProfileEditorControllerTest < ActionController::TestCase | ||
8 | + | ||
9 | + def setup | ||
10 | + @controller = ProfileEditorController.new | ||
11 | + @request = ActionController::TestRequest.new | ||
12 | + @response = ActionController::TestResponse.new | ||
13 | + @profile = create_user('default_user').person | ||
14 | + login_as(@profile.identifier) | ||
15 | + Environment.default.enable_plugin(GoogleAnalyticsPlugin.name) | ||
16 | + end | ||
17 | + | ||
18 | + attr_accessor :profile | ||
19 | + | ||
20 | + should 'add extra fields to profile editor info and settings' do | ||
21 | + get :edit, :profile => profile.identifier | ||
22 | + assert_tag_in_string @response.body, :tag => 'label', :content => /Google Analytics/, :attributes => { :for => 'profile_data_google_analytics_profile_id' } | ||
23 | + assert_tag_in_string @response.body, :tag => 'input', :attributes => { :id => 'profile_data_google_analytics_profile_id' } | ||
24 | + end | ||
25 | + | ||
26 | + should 'save code filled in on field' do | ||
27 | + post :edit, :profile => profile.identifier, :profile_data => {:google_analytics_profile_id => 12345678} | ||
28 | + assert_equal '12345678', Person.find(profile.id).google_analytics_profile_id | ||
29 | + end | ||
30 | + | ||
31 | +end |
plugins/google_analytics/test/unit/google_analytics_plugin_test.rb
@@ -27,11 +27,6 @@ class GoogleAnalyticsPluginTest < ActiveSupport::TestCase | @@ -27,11 +27,6 @@ class GoogleAnalyticsPluginTest < ActiveSupport::TestCase | ||
27 | assert_equal 'content', @plugin.head_ending | 27 | assert_equal 'content', @plugin.head_ending |
28 | end | 28 | end |
29 | 29 | ||
30 | - should 'add extra fields to profile editor info and settings' do | ||
31 | - assert_tag_in_string @plugin.profile_editor_extras, | ||
32 | - :tag => 'input', :attributes => {:id => 'profile_data_google_analytics_profile_id', :value => 10} | ||
33 | - end | ||
34 | - | ||
35 | should 'extends Profile with attr google_analytics_profile_id' do | 30 | should 'extends Profile with attr google_analytics_profile_id' do |
36 | assert_respond_to Profile.new, :google_analytics_profile_id | 31 | assert_respond_to Profile.new, :google_analytics_profile_id |
37 | end | 32 | end |
plugins/google_analytics/views/profile-editor-extras.html.erb
0 → 100644
@@ -0,0 +1,3 @@ | @@ -0,0 +1,3 @@ | ||
1 | +<h2><%= c_('Statistics') %></h2> | ||
2 | +<%= labelled_form_field(_('Google Analytics Profile ID'), text_field(:profile_data, :google_analytics_profile_id, :value => profile_id)) %> | ||
3 | +<%= link_to(_('See how to configure statistics for your profile'), '/doc/plugins/google_analytics', :target => '_blank') %> |
plugins/google_analytics/views/profile-editor-extras.rhtml
@@ -1,5 +0,0 @@ | @@ -1,5 +0,0 @@ | ||
1 | -<% extend ApplicationHelper %> | ||
2 | - | ||
3 | -<h2><%= c_('Statistics') %></h2> | ||
4 | -<%= labelled_form_field(_('Google Analytics Profile ID'), text_field(:profile_data, :google_analytics_profile_id, :value => profile_id)) %> | ||
5 | -<%= link_to(_('See how to configure statistics for your profile'), '/doc/plugins/google_analytics', :target => '_blank') %> |
@@ -0,0 +1,9 @@ | @@ -0,0 +1,9 @@ | ||
1 | +<script> | ||
2 | + (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ | ||
3 | + (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), | ||
4 | + m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) | ||
5 | + })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); | ||
6 | + | ||
7 | + ga('create', '<%= escape_javascript locals[:profile_id] %>', 'auto'); | ||
8 | + ga('send', 'pageview'); | ||
9 | +</script> |
plugins/google_analytics/views/tracking-code.rhtml
@@ -1,10 +0,0 @@ | @@ -1,10 +0,0 @@ | ||
1 | -<script type="text/javascript"> | ||
2 | - var _gaq = _gaq || []; | ||
3 | - _gaq.push(['_setAccount', '<%= escape_javascript locals[:profile_id] %>']); | ||
4 | - _gaq.push(['_trackPageview']); | ||
5 | - (function() { | ||
6 | - var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; | ||
7 | - ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; | ||
8 | - var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); | ||
9 | - })(); | ||
10 | -</script> |
plugins/pjax/public/javascripts/pjax.js
@@ -157,7 +157,7 @@ pjax = { | @@ -157,7 +157,7 @@ pjax = { | ||
157 | document._write = document.write; | 157 | document._write = document.write; |
158 | document.write = function (data) { | 158 | document.write = function (data) { |
159 | if (document.readyState != 'loading') | 159 | if (document.readyState != 'loading') |
160 | - content.append(data); | 160 | + pjax.content.append(data); |
161 | else | 161 | else |
162 | document._write(data); | 162 | document._write(data); |
163 | }; | 163 | }; |
plugins/profile_description_block/test/unit/profile_description_block_test.rb
1 | require File.expand_path(File.dirname(__FILE__) + "/../../../../test/test_helper") | 1 | require File.expand_path(File.dirname(__FILE__) + "/../../../../test/test_helper") |
2 | 2 | ||
3 | class ProfileDescriptionBlockTest < ActiveSupport::TestCase | 3 | class ProfileDescriptionBlockTest < ActiveSupport::TestCase |
4 | - def setup | ||
5 | - e = Environment.default | 4 | + def setup |
5 | + e = Environment.default | ||
6 | e.enabled_plugins = ['ProfileDescriptionPlugin'] | 6 | e.enabled_plugins = ['ProfileDescriptionPlugin'] |
7 | @person = create_user('test_user').person | 7 | @person = create_user('test_user').person |
8 | @profile = Profile.create!(:identifier => '1236', | 8 | @profile = Profile.create!(:identifier => '1236', |
9 | :name => 'blabla', | 9 | :name => 'blabla', |
10 | :description => "") | 10 | :description => "") |
11 | - end | 11 | + end |
12 | 12 | ||
13 | should 'describe itself' do | 13 | should 'describe itself' do |
14 | assert_not_equal Block.description, ProfileDescriptionBlock.description | 14 | assert_not_equal Block.description, ProfileDescriptionBlock.description |
@@ -17,7 +17,7 @@ class ProfileDescriptionBlockTest < ActiveSupport::TestCase | @@ -17,7 +17,7 @@ class ProfileDescriptionBlockTest < ActiveSupport::TestCase | ||
17 | should "show profile description inside block" do | 17 | should "show profile description inside block" do |
18 | new_block = ProfileDescriptionBlock.create! | 18 | new_block = ProfileDescriptionBlock.create! |
19 | @profile.boxes.first.blocks << new_block | 19 | @profile.boxes.first.blocks << new_block |
20 | - block_menssage = "Description field are empty" | 20 | + block_menssage = "Description field is empty" |
21 | assert (instance_eval(&Block.last.content).include?(block_menssage)), | 21 | assert (instance_eval(&Block.last.content).include?(block_menssage)), |
22 | "description block doesn't show not found description message" | 22 | "description block doesn't show not found description message" |
23 | description = "This is an test" | 23 | description = "This is an test" |
plugins/require_auth_to_comment/features/require_auth_to_comment.feature
1 | Feature: require authentication to comment | 1 | Feature: require authentication to comment |
2 | 2 | ||
3 | Background: | 3 | Background: |
4 | - Given plugin RequireAuthToCommentPlugin is enabled on environment | 4 | + Given plugin RequireAuthToComment is enabled on environment |
5 | And the following users | 5 | And the following users |
6 | | login | | 6 | | login | |
7 | | bozo | | 7 | | bozo | |
plugins/require_auth_to_comment/lib/ext/profile.rb
@@ -3,4 +3,8 @@ require_dependency 'profile' | @@ -3,4 +3,8 @@ require_dependency 'profile' | ||
3 | class Profile | 3 | class Profile |
4 | settings_items :allow_unauthenticated_comments, :type => :boolean | 4 | settings_items :allow_unauthenticated_comments, :type => :boolean |
5 | attr_accessible :allow_unauthenticated_comments | 5 | attr_accessible :allow_unauthenticated_comments |
6 | + | ||
7 | + descendants.each do |descendant| | ||
8 | + descendant.attr_accessible :allow_unauthenticated_comments | ||
9 | + end | ||
6 | end | 10 | end |
plugins/send_email/controllers/send_email_plugin_base_controller.rb
@@ -11,7 +11,8 @@ module SendEmailPluginBaseController | @@ -11,7 +11,8 @@ module SendEmailPluginBaseController | ||
11 | ) | 11 | ) |
12 | @mail.subject = params[:subject] unless params[:subject].blank? | 12 | @mail.subject = params[:subject] unless params[:subject].blank? |
13 | if @mail.valid? | 13 | if @mail.valid? |
14 | - SendEmailPlugin::Sender.send_message(request.referer, @context_url, @mail).deliver | 14 | + @referer = request.referer |
15 | + SendEmailPlugin::Sender.send_message(@referer, @context_url, @mail).deliver | ||
15 | if request.xhr? | 16 | if request.xhr? |
16 | render :text => _('Message sent') | 17 | render :text => _('Message sent') |
17 | else | 18 | else |
plugins/send_email/lib/send_email_plugin.rb
@@ -16,9 +16,9 @@ class SendEmailPlugin < Noosfero::Plugin | @@ -16,9 +16,9 @@ class SendEmailPlugin < Noosfero::Plugin | ||
16 | 16 | ||
17 | def parse_content(html, source) | 17 | def parse_content(html, source) |
18 | if context.profile | 18 | if context.profile |
19 | - html.gsub!(/\{sendemail\}/, "/profile/#{context.profile.identifier}/plugin/send_email/deliver") | 19 | + html.gsub!(/({|%7[Bb])sendemail(}|%7[Dd])/, "/profile/#{context.profile.identifier}/plugin/send_email/deliver") |
20 | else | 20 | else |
21 | - html.gsub!(/\{sendemail\}/, '/plugin/send_email/deliver') | 21 | + html.gsub!(/({|%7[Bb])sendemail(}|%7[Dd])/, '/plugin/send_email/deliver') |
22 | end | 22 | end |
23 | [html, source] | 23 | [html, source] |
24 | end | 24 | end |
plugins/send_email/lib/send_email_plugin/mail.rb
@@ -10,12 +10,11 @@ class SendEmailPlugin::Mail | @@ -10,12 +10,11 @@ class SendEmailPlugin::Mail | ||
10 | validate :recipients_format | 10 | validate :recipients_format |
11 | 11 | ||
12 | def initialize(attributes = {:subject => 'New mail'}) | 12 | def initialize(attributes = {:subject => 'New mail'}) |
13 | - @environment = attributes[:environment] | ||
14 | - @from = attributes[:from] | ||
15 | - @to = attributes[:to] | ||
16 | - @subject = attributes[:subject] | ||
17 | - @message = attributes[:message] | ||
18 | - @params = attributes[:params] | 13 | + if attributes |
14 | + attributes.each do |attr,value| | ||
15 | + self.send("#{attr}=", value) | ||
16 | + end | ||
17 | + end | ||
19 | end | 18 | end |
20 | 19 | ||
21 | def recipients_format | 20 | def recipients_format |
@@ -36,7 +35,7 @@ class SendEmailPlugin::Mail | @@ -36,7 +35,7 @@ class SendEmailPlugin::Mail | ||
36 | end | 35 | end |
37 | 36 | ||
38 | def params=(value = {}) | 37 | def params=(value = {}) |
39 | - [:action, :controller, :to, :message, :subject, :from].each{|k| value.delete(k)} | 38 | + [:profile, :action, :controller, :to, :message, :subject, :from, :commit].each{|k| value.delete(k)} |
40 | @params = value | 39 | @params = value |
41 | end | 40 | end |
42 | 41 |
plugins/send_email/lib/send_email_plugin/sender.rb
@@ -7,9 +7,9 @@ class SendEmailPlugin::Sender < Noosfero::Plugin::MailerBase | @@ -7,9 +7,9 @@ class SendEmailPlugin::Sender < Noosfero::Plugin::MailerBase | ||
7 | @params = mail.params | 7 | @params = mail.params |
8 | 8 | ||
9 | mail( | 9 | mail( |
10 | + content_type: 'text/plain', | ||
10 | to: mail.to, | 11 | to: mail.to, |
11 | from: mail.from, | 12 | from: mail.from, |
12 | - body: mail.params, | ||
13 | subject: "[#{mail.environment.name}] #{mail.subject}" | 13 | subject: "[#{mail.environment.name}] #{mail.subject}" |
14 | ) | 14 | ) |
15 | end | 15 | end |
plugins/send_email/test/functional/send_email_plugin_base_controller_test.rb
@@ -54,6 +54,13 @@ def run_common_tests | @@ -54,6 +54,13 @@ def run_common_tests | ||
54 | post :deliver, @extra_args.merge(:to => 'john@example.com', :message => 'Hi john', :subject => 'Hello john') | 54 | post :deliver, @extra_args.merge(:to => 'john@example.com', :message => 'Hi john', :subject => 'Hello john') |
55 | assert_equal '[Colivre.net] Hello john', ActionMailer::Base.deliveries.first.subject | 55 | assert_equal '[Colivre.net] Hello john', ActionMailer::Base.deliveries.first.subject |
56 | end | 56 | end |
57 | + | ||
58 | + should 'deliver mail with message from view' do | ||
59 | + Environment.any_instance.stubs(:send_email_plugin_allow_to).returns('john@example.com') | ||
60 | + post :deliver, @extra_args.merge(:to => 'john@example.com', :message => 'Hi john', :subject => 'Hello john') | ||
61 | + assert_match /Contact from/, ActionMailer::Base.deliveries.first.body.to_s | ||
62 | + end | ||
63 | + | ||
57 | end | 64 | end |
58 | 65 | ||
59 | class SendEmailPluginProfileControllerTest < ActionController::TestCase | 66 | class SendEmailPluginProfileControllerTest < ActionController::TestCase |
plugins/send_email/test/unit/send_email_plugin_sender_test.rb
@@ -15,12 +15,14 @@ class SendEmailPluginSenderTest < ActiveSupport::TestCase | @@ -15,12 +15,14 @@ class SendEmailPluginSenderTest < ActiveSupport::TestCase | ||
15 | end | 15 | end |
16 | 16 | ||
17 | should 'be able to deliver mail' do | 17 | should 'be able to deliver mail' do |
18 | + @mail.expects(:params).returns({}) | ||
18 | response = SendEmailPlugin::Sender.send_message("http://localhost/contact", 'http//profile', @mail) | 19 | response = SendEmailPlugin::Sender.send_message("http://localhost/contact", 'http//profile', @mail) |
19 | assert_equal 'noreply@localhost', response.from.join | 20 | assert_equal 'noreply@localhost', response.from.join |
20 | assert_equal "[Noosfero] #{@mail.subject}", response.subject | 21 | assert_equal "[Noosfero] #{@mail.subject}", response.subject |
21 | end | 22 | end |
22 | 23 | ||
23 | should 'deliver mail to john@example.com' do | 24 | should 'deliver mail to john@example.com' do |
25 | + @mail.expects(:params).returns({}) | ||
24 | response = SendEmailPlugin::Sender.send_message("http://localhost/contact", 'http//profile', @mail) | 26 | response = SendEmailPlugin::Sender.send_message("http://localhost/contact", 'http//profile', @mail) |
25 | assert_equal ['john@example.com'], response.to | 27 | assert_equal ['john@example.com'], response.to |
26 | end | 28 | end |
plugins/send_email/test/unit/send_email_plugin_test.rb
@@ -26,4 +26,12 @@ class SendEmailPluginTest < ActiveSupport::TestCase | @@ -26,4 +26,12 @@ class SendEmailPluginTest < ActiveSupport::TestCase | ||
26 | assert_match /profile\/#{@plugin.context.profile.identifier}\/plugin\/send_email\/deliver/, @plugin.parse_content("expand this macro {sendemail}", nil).first | 26 | assert_match /profile\/#{@plugin.context.profile.identifier}\/plugin\/send_email\/deliver/, @plugin.parse_content("expand this macro {sendemail}", nil).first |
27 | end | 27 | end |
28 | 28 | ||
29 | + should 'expand macro used on form on profile context' do | ||
30 | + profile = fast_create(Community) | ||
31 | + @plugin.context.stubs(:profile).returns(profile) | ||
32 | + article = RawHTMLArticle.create!(:name => 'Raw HTML', :body => "<form action='{sendemail}'></form>", :profile => profile) | ||
33 | + | ||
34 | + assert_match /profile\/#{profile.identifier}\/plugin\/send_email\/deliver/, @plugin.parse_content(article.to_html, nil).first | ||
35 | + end | ||
36 | + | ||
29 | end | 37 | end |
plugins/send_email/views/send_email_plugin/sender/message.html.erb
plugins/send_email/views/send_email_plugin/sender/send_message.html.erb
0 → 100644
plugins/send_email/views/send_email_plugin/success.html.erb
@@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
2 | 2 | ||
3 | <table class='sendemail-plugin-message-sent'> | 3 | <table class='sendemail-plugin-message-sent'> |
4 | <tr><td class='label'><strong><%= c_('Subject') %>:</strong></td><td class='value'><em><%=h @mail.subject %></em></td></tr> | 4 | <tr><td class='label'><strong><%= c_('Subject') %>:</strong></td><td class='value'><em><%=h @mail.subject %></em></td></tr> |
5 | - <tr><td class='label'><strong><%= c_('Message') %>:</strong></td><td class='value'><pre><%=h render :file => 'send_email_plugin/sender/message' %></pre></td></tr> | 5 | + <tr><td class='label'><strong><%= c_('Message') %>:</strong></td><td class='value'><pre><%=h render :file => 'send_email_plugin/sender/send_message' %></pre></td></tr> |
6 | </table> | 6 | </table> |
7 | 7 | ||
8 | <p><%= button :back, c_('Back'), :back %></p> | 8 | <p><%= button :back, c_('Back'), :back %></p> |
plugins/stoa/lib/stoa_plugin.rb
@@ -60,13 +60,14 @@ class StoaPlugin < Noosfero::Plugin | @@ -60,13 +60,14 @@ class StoaPlugin < Noosfero::Plugin | ||
60 | end | 60 | end |
61 | 61 | ||
62 | def account_controller_filters | 62 | def account_controller_filters |
63 | - block = lambda do |context| | 63 | + block = proc do |
64 | params[:profile_data] ||= {} | 64 | params[:profile_data] ||= {} |
65 | params[:profile_data][:invitation_code] = params[:invitation_code] | 65 | params[:profile_data][:invitation_code] = params[:invitation_code] |
66 | invitation = Task.pending.find(:first, :conditions => {:code => params[:invitation_code]}) | 66 | invitation = Task.pending.find(:first, :conditions => {:code => params[:invitation_code]}) |
67 | if request.post? | 67 | if request.post? |
68 | if !invitation && !StoaPlugin::UspUser.matches?(params[:profile_data][:usp_id], params[:confirmation_field], params[params[:confirmation_field]]) | 68 | if !invitation && !StoaPlugin::UspUser.matches?(params[:profile_data][:usp_id], params[:confirmation_field], params[params[:confirmation_field]]) |
69 | - @person = Person.new(:environment => context.environment) | 69 | + # `self` below is evaluated in the context of account_controller |
70 | + @person = Person.new(:environment => self.environment) | ||
70 | @person.errors.add(:usp_id, _(' validation failed')) | 71 | @person.errors.add(:usp_id, _(' validation failed')) |
71 | render :action => :signup | 72 | render :action => :signup |
72 | end | 73 | end |
plugins/stoa/lib/stoa_plugin/person_api.rb
@@ -16,7 +16,7 @@ class StoaPlugin::PersonApi < Noosfero::FieldsDecorator | @@ -16,7 +16,7 @@ class StoaPlugin::PersonApi < Noosfero::FieldsDecorator | ||
16 | end | 16 | end |
17 | 17 | ||
18 | def homepage | 18 | def homepage |
19 | - context.url_for(url) | 19 | + profile_homepage(context, object) |
20 | end | 20 | end |
21 | 21 | ||
22 | def birth_date | 22 | def birth_date |
@@ -35,6 +35,16 @@ class StoaPlugin::PersonApi < Noosfero::FieldsDecorator | @@ -35,6 +35,16 @@ class StoaPlugin::PersonApi < Noosfero::FieldsDecorator | ||
35 | end | 35 | end |
36 | 36 | ||
37 | def communities | 37 | def communities |
38 | - object.communities.public.map {|community| {:url => context.url_for(community.url), :name => community.name}} | 38 | + object.communities.public.map {|community| {:url => profile_homepage(context, community), :name => community.name}} |
39 | + end | ||
40 | + | ||
41 | + private | ||
42 | + | ||
43 | + def profile_homepage(context, profile) | ||
44 | + if context.respond_to?(:url_for) | ||
45 | + context.url_for(profile.url) | ||
46 | + else | ||
47 | + profile.environment.top_url + '/' + profile.identifier | ||
48 | + end | ||
39 | end | 49 | end |
40 | end | 50 | end |
plugins/stoa/test/functional/invite_controller_test.rb
@@ -57,7 +57,7 @@ class InviteControllerTest < ActionController::TestCase | @@ -57,7 +57,7 @@ class InviteControllerTest < ActionController::TestCase | ||
57 | organization.add_admin(admin) | 57 | organization.add_admin(admin) |
58 | 58 | ||
59 | login_as(admin.identifier) | 59 | login_as(admin.identifier) |
60 | - get :search_friend, :profile => organization.identifier, :q => '1234' | 60 | + get :search, :profile => organization.identifier, :q => '1234' |
61 | 61 | ||
62 | assert_equal [{"id" => person.id, "name" => person.name}].to_json, @response.body | 62 | assert_equal [{"id" => person.id, "name" => person.name}].to_json, @response.body |
63 | assert_response 200 | 63 | assert_response 200 |
plugins/sub_organizations/features/sub_organizations_display.feature
@@ -29,6 +29,7 @@ Feature: sub_organizations_display | @@ -29,6 +29,7 @@ Feature: sub_organizations_display | ||
29 | And I follow "Manage sub-groups" | 29 | And I follow "Manage sub-groups" |
30 | And I follow "Register a new sub-enterprise" | 30 | And I follow "Register a new sub-enterprise" |
31 | And I fill in "Name" with "Bart" | 31 | And I fill in "Name" with "Bart" |
32 | + And I fill in "Address" with "bart" | ||
32 | And I press "Next" | 33 | And I press "Next" |
33 | Then I should see "Enterprise registration completed" | 34 | Then I should see "Enterprise registration completed" |
34 | And I am logged in as admin | 35 | And I am logged in as admin |
plugins/sub_organizations/lib/ext/create_enterprise.rb
@@ -2,4 +2,5 @@ require_dependency 'create_enterprise' | @@ -2,4 +2,5 @@ require_dependency 'create_enterprise' | ||
2 | 2 | ||
3 | class CreateEnterprise | 3 | class CreateEnterprise |
4 | settings_items :sub_organizations_plugin_parent_to_be | 4 | settings_items :sub_organizations_plugin_parent_to_be |
5 | + DATA_FIELDS << 'sub_organizations_plugin_parent_to_be' | ||
5 | end | 6 | end |
po/fr/noosfero-doc.po
@@ -7,8 +7,8 @@ msgid "" | @@ -7,8 +7,8 @@ msgid "" | ||
7 | msgstr "" | 7 | msgstr "" |
8 | "Project-Id-Version: PACKAGE VERSION\n" | 8 | "Project-Id-Version: PACKAGE VERSION\n" |
9 | "POT-Creation-Date: 2013-12-10 15:48-0300\n" | 9 | "POT-Creation-Date: 2013-12-10 15:48-0300\n" |
10 | -"PO-Revision-Date: 2015-02-23 11:33+0200\n" | ||
11 | -"Last-Translator: Michal Čihař <michal@cihar.com>\n" | 10 | +"PO-Revision-Date: 2015-03-23 19:30+0200\n" |
11 | +"Last-Translator: Jérôme Jutteau <j.jutteau@gmail.com>\n" | ||
12 | "Language-Team: French " | 12 | "Language-Team: French " |
13 | "<https://hosted.weblate.org/projects/noosfero/documentation/fr/>\n" | 13 | "<https://hosted.weblate.org/projects/noosfero/documentation/fr/>\n" |
14 | "Language: fr\n" | 14 | "Language: fr\n" |
@@ -36,7 +36,7 @@ msgstr "" | @@ -36,7 +36,7 @@ msgstr "" | ||
36 | #: doc/noosfero/plugins/google_cse.en.xhtml:3 | 36 | #: doc/noosfero/plugins/google_cse.en.xhtml:3 |
37 | #: doc/noosfero/plugins/google_analytics.en.xhtml:3 | 37 | #: doc/noosfero/plugins/google_analytics.en.xhtml:3 |
38 | msgid "Usage" | 38 | msgid "Usage" |
39 | -msgstr "" | 39 | +msgstr "Utilisation" |
40 | 40 | ||
41 | # type: Content of: <ul><li> | 41 | # type: Content of: <ul><li> |
42 | #. type: Content of: <ul><li> | 42 | #. type: Content of: <ul><li> |
@@ -45,6 +45,8 @@ msgid "" | @@ -45,6 +45,8 @@ msgid "" | ||
45 | "Create a <span class=\"caps\">HTML</span> form using RawHTMLBlock or " | 45 | "Create a <span class=\"caps\">HTML</span> form using RawHTMLBlock or " |
46 | "RawHTMLArticle that invokes the {sendemail} action" | 46 | "RawHTMLArticle that invokes the {sendemail} action" |
47 | msgstr "" | 47 | msgstr "" |
48 | +"Créer un formulaire <span class=\"caps\">HTML</span> utilisant RawHTMLBlock " | ||
49 | +"ou RawHTMLArticle qui appel l'action {sendemail}" | ||
48 | 50 | ||
49 | # type: Content of: <ul><li> | 51 | # type: Content of: <ul><li> |
50 | #. type: Content of: <ul><li> | 52 | #. type: Content of: <ul><li> |
po/it/noosfero.po
@@ -7,7 +7,7 @@ msgid "" | @@ -7,7 +7,7 @@ msgid "" | ||
7 | msgstr "" | 7 | msgstr "" |
8 | "Project-Id-Version: 1.0-690-gcb6e853\n" | 8 | "Project-Id-Version: 1.0-690-gcb6e853\n" |
9 | "POT-Creation-Date: 2015-03-05 12:10-0300\n" | 9 | "POT-Creation-Date: 2015-03-05 12:10-0300\n" |
10 | -"PO-Revision-Date: 2015-03-16 23:06+0200\n" | 10 | +"PO-Revision-Date: 2015-03-23 22:59+0200\n" |
11 | "Last-Translator: TWS <tablettws@gmail.com>\n" | 11 | "Last-Translator: TWS <tablettws@gmail.com>\n" |
12 | "Language-Team: Italian " | 12 | "Language-Team: Italian " |
13 | "<https://hosted.weblate.org/projects/noosfero/noosfero/it/>\n" | 13 | "<https://hosted.weblate.org/projects/noosfero/noosfero/it/>\n" |
@@ -6093,9 +6093,8 @@ msgid "Offline" | @@ -6093,9 +6093,8 @@ msgid "Offline" | ||
6093 | msgstr "" | 6093 | msgstr "" |
6094 | 6094 | ||
6095 | #: app/views/shared/logged_in/xmpp_chat.html.erb:60 | 6095 | #: app/views/shared/logged_in/xmpp_chat.html.erb:60 |
6096 | -#, fuzzy | ||
6097 | msgid "Join room" | 6096 | msgid "Join room" |
6098 | -msgstr "Accedere" | 6097 | +msgstr "Accedere alla stanza" |
6099 | 6098 | ||
6100 | #: app/views/shared/logged_in/xmpp_chat.html.erb:61 | 6099 | #: app/views/shared/logged_in/xmpp_chat.html.erb:61 |
6101 | msgid "Leave room" | 6100 | msgid "Leave room" |
po/pt/noosfero.po
@@ -13,8 +13,8 @@ msgid "" | @@ -13,8 +13,8 @@ msgid "" | ||
13 | msgstr "" | 13 | msgstr "" |
14 | "Project-Id-Version: 1.0-690-gcb6e853\n" | 14 | "Project-Id-Version: 1.0-690-gcb6e853\n" |
15 | "POT-Creation-Date: 2015-03-05 12:10-0300\n" | 15 | "POT-Creation-Date: 2015-03-05 12:10-0300\n" |
16 | -"PO-Revision-Date: 2015-03-17 21:44+0200\n" | ||
17 | -"Last-Translator: Evandro Junior <evandrojr@gmail.com>\n" | 16 | +"PO-Revision-Date: 2015-03-29 01:47+0200\n" |
17 | +"Last-Translator: daniel <dtygel@eita.org.br>\n" | ||
18 | "Language-Team: Portuguese " | 18 | "Language-Team: Portuguese " |
19 | "<https://hosted.weblate.org/projects/noosfero/noosfero/pt/>\n" | 19 | "<https://hosted.weblate.org/projects/noosfero/noosfero/pt/>\n" |
20 | "Language: pt\n" | 20 | "Language: pt\n" |
@@ -7281,7 +7281,7 @@ msgstr "Seu nome" | @@ -7281,7 +7281,7 @@ msgstr "Seu nome" | ||
7281 | #: app/views/cms/_upload_file_form.html.erb:4 | 7281 | #: app/views/cms/_upload_file_form.html.erb:4 |
7282 | #: app/views/cms/_text_editor_sidebar.html.erb:16 | 7282 | #: app/views/cms/_text_editor_sidebar.html.erb:16 |
7283 | msgid "Choose folder to upload files:" | 7283 | msgid "Choose folder to upload files:" |
7284 | -msgstr "Escolha uma pasta para incluir arquivos:" | 7284 | +msgstr "O arquivo ficará na seguinte pasta:" |
7285 | 7285 | ||
7286 | #: app/views/cms/_upload_file_form.html.erb:16 | 7286 | #: app/views/cms/_upload_file_form.html.erb:16 |
7287 | msgid "More files" | 7287 | msgid "More files" |
@@ -7535,7 +7535,7 @@ msgstr "Houve problemas com os seguintes arquivos:" | @@ -7535,7 +7535,7 @@ msgstr "Houve problemas com os seguintes arquivos:" | ||
7535 | 7535 | ||
7536 | #: app/views/cms/upload_files.html.erb:15 | 7536 | #: app/views/cms/upload_files.html.erb:15 |
7537 | msgid "Publish media" | 7537 | msgid "Publish media" |
7538 | -msgstr "Publicar mídia" | 7538 | +msgstr "Publicar imagem ou documento" |
7539 | 7539 | ||
7540 | #: app/views/cms/upload_files.html.erb:17 | 7540 | #: app/views/cms/upload_files.html.erb:17 |
7541 | msgid "Select the files you want to upload (max size %s):" | 7541 | msgid "Select the files you want to upload (max size %s):" |
@@ -7551,7 +7551,7 @@ msgstr "Enviando arquivos para %s" | @@ -7551,7 +7551,7 @@ msgstr "Enviando arquivos para %s" | ||
7551 | 7551 | ||
7552 | #: app/views/cms/_text_editor_sidebar.html.erb:8 | 7552 | #: app/views/cms/_text_editor_sidebar.html.erb:8 |
7553 | msgid "Insert media" | 7553 | msgid "Insert media" |
7554 | -msgstr "Adicionar mídia" | 7554 | +msgstr "Adicionar imagem ou documento" |
7555 | 7555 | ||
7556 | #: app/views/cms/_text_editor_sidebar.html.erb:8 | 7556 | #: app/views/cms/_text_editor_sidebar.html.erb:8 |
7557 | msgid "Show/Hide" | 7557 | msgid "Show/Hide" |
@@ -7559,7 +7559,7 @@ msgstr "Mostrar/Ocultar" | @@ -7559,7 +7559,7 @@ msgstr "Mostrar/Ocultar" | ||
7559 | 7559 | ||
7560 | #: app/views/cms/_text_editor_sidebar.html.erb:21 | 7560 | #: app/views/cms/_text_editor_sidebar.html.erb:21 |
7561 | msgid "New folder" | 7561 | msgid "New folder" |
7562 | -msgstr "Nova pasta" | 7562 | +msgstr "Criar pasta" |
7563 | 7563 | ||
7564 | #: app/views/cms/_text_editor_sidebar.html.erb:26 | 7564 | #: app/views/cms/_text_editor_sidebar.html.erb:26 |
7565 | msgid "Hide all uploads" | 7565 | msgid "Hide all uploads" |
public/javascripts/manage-fields.js
@@ -57,7 +57,7 @@ jQuery(document).ready(function(){ | @@ -57,7 +57,7 @@ jQuery(document).ready(function(){ | ||
57 | } | 57 | } |
58 | 58 | ||
59 | var checkbox = jQuery(checkboxes[i+3]).attr("id").split("_") | 59 | var checkbox = jQuery(checkboxes[i+3]).attr("id").split("_") |
60 | - jQuery("#" + checkbox.first() + "_" + checkbox.last()).attr("checked", allchecked) | 60 | + jQuery("#" + checkbox[0] + "_" + checkbox[checkbox.length-1]).attr("checked", allchecked) |
61 | } | 61 | } |
62 | } | 62 | } |
63 | 63 | ||
@@ -74,10 +74,10 @@ jQuery(document).ready(function(){ | @@ -74,10 +74,10 @@ jQuery(document).ready(function(){ | ||
74 | 74 | ||
75 | jQuery("input[type='checkbox']").click(function (){ | 75 | jQuery("input[type='checkbox']").click(function (){ |
76 | var checkbox = jQuery(this).attr("id").split("_") | 76 | var checkbox = jQuery(this).attr("id").split("_") |
77 | - verify_checked(checkbox.first()) | 77 | + verify_checked(checkbox[0]) |
78 | 78 | ||
79 | if(this.checked == false) { | 79 | if(this.checked == false) { |
80 | - jQuery("#" + checkbox.first() + "_" + checkbox.last()).attr("checked", false) | 80 | + jQuery("#" + checkbox[0] + "_" + checkbox[checkbox.length-1]).attr("checked", false) |
81 | } | 81 | } |
82 | }) | 82 | }) |
83 | }) | 83 | }) |
script/production
@@ -85,7 +85,7 @@ environments_loop() { | @@ -85,7 +85,7 @@ environments_loop() { | ||
85 | } | 85 | } |
86 | 86 | ||
87 | do_running() { | 87 | do_running() { |
88 | - pids=$(cat tmp/pids/thin.*.pid 2>/dev/null || true) | 88 | + pids=$(sed "s/.*/& /" tmp/pids/thin.*.pid | tr -d '\n' 2>/dev/null || true) |
89 | # passes if any of $pids exist, fails otherwise | 89 | # passes if any of $pids exist, fails otherwise |
90 | kill -0 $pids > /dev/null 2>&1 | 90 | kill -0 $pids > /dev/null 2>&1 |
91 | } | 91 | } |
script/quick-start
@@ -114,7 +114,9 @@ else | @@ -114,7 +114,9 @@ else | ||
114 | rails runner 'Environment.default.enable("skip_new_user_email_confirmation")' | 114 | rails runner 'Environment.default.enable("skip_new_user_email_confirmation")' |
115 | fi | 115 | fi |
116 | 116 | ||
117 | -run quiet rake noosfero:translations:compile | 117 | +if [ ! -d locale ]; then |
118 | + run quiet rake noosfero:translations:compile | ||
119 | +fi | ||
118 | 120 | ||
119 | # create needed directory | 121 | # create needed directory |
120 | mkdir -p tmp/pids | 122 | mkdir -p tmp/pids |
test/functional/cms_controller_test.rb
@@ -699,7 +699,7 @@ class CmsControllerTest < ActionController::TestCase | @@ -699,7 +699,7 @@ class CmsControllerTest < ActionController::TestCase | ||
699 | xhr :get, :update_categories, :profile => profile.identifier, :category_id => top.id | 699 | xhr :get, :update_categories, :profile => profile.identifier, :category_id => top.id |
700 | assert_template 'shared/update_categories' | 700 | assert_template 'shared/update_categories' |
701 | assert_equal top, assigns(:current_category) | 701 | assert_equal top, assigns(:current_category) |
702 | - assert_equal [c1, c2], assigns(:categories) | 702 | + assert_equivalent [c1, c2], assigns(:categories) |
703 | end | 703 | end |
704 | 704 | ||
705 | should 'record when coming from public view on edit' do | 705 | should 'record when coming from public view on edit' do |
test/functional/contact_controller_test.rb
@@ -131,7 +131,7 @@ class ContactControllerTest < ActionController::TestCase | @@ -131,7 +131,7 @@ class ContactControllerTest < ActionController::TestCase | ||
131 | post :new, :profile => community.identifier | 131 | post :new, :profile => community.identifier |
132 | 132 | ||
133 | assert_response :forbidden | 133 | assert_response :forbidden |
134 | - assert_template :access_denied | 134 | + assert_template :private_profile |
135 | end | 135 | end |
136 | 136 | ||
137 | should 'not show send e-mail page to non members of invisible community' do | 137 | should 'not show send e-mail page to non members of invisible community' do |
test/functional/events_controller_test.rb
@@ -60,7 +60,7 @@ class EventsControllerTest < ActionController::TestCase | @@ -60,7 +60,7 @@ class EventsControllerTest < ActionController::TestCase | ||
60 | post :events, :profile => community.identifier | 60 | post :events, :profile => community.identifier |
61 | 61 | ||
62 | assert_response :forbidden | 62 | assert_response :forbidden |
63 | - assert_template :access_denied | 63 | + assert_template :private_profile |
64 | end | 64 | end |
65 | 65 | ||
66 | should 'not show events page to non members of invisible community' do | 66 | should 'not show events page to non members of invisible community' do |
test/functional/search_controller_test.rb
@@ -204,7 +204,7 @@ class SearchControllerTest < ActionController::TestCase | @@ -204,7 +204,7 @@ class SearchControllerTest < ActionController::TestCase | ||
204 | end | 204 | end |
205 | 205 | ||
206 | should 'paginate enterprise listing' do | 206 | should 'paginate enterprise listing' do |
207 | - @controller.expects(:limit).returns(1) | 207 | + @controller.expects(:limit).returns(1).at_least_once |
208 | ent1 = create_profile_with_optional_category(Enterprise, 'teste 1') | 208 | ent1 = create_profile_with_optional_category(Enterprise, 'teste 1') |
209 | ent2 = create_profile_with_optional_category(Enterprise, 'teste 2') | 209 | ent2 = create_profile_with_optional_category(Enterprise, 'teste 2') |
210 | 210 |
test/integration/categories_menu_test.rb
@@ -1,41 +0,0 @@ | @@ -1,41 +0,0 @@ | ||
1 | -require_relative "../test_helper" | ||
2 | - | ||
3 | -class CategoriesMenuTest < ActionController::IntegrationTest | ||
4 | - | ||
5 | - def setup | ||
6 | - HomeController.any_instance.stubs(:get_layout).returns('application') | ||
7 | - SearchController.any_instance.stubs(:get_layout).returns('application') | ||
8 | - | ||
9 | - Category.delete_all | ||
10 | - @cat1 = Category.create!(:display_in_menu => true, :name => 'Food', :environment => Environment.default, :display_color => '#888a85') | ||
11 | - @cat2 = Category.create!(:display_in_menu => true, :name => 'Vegetables', :environment => Environment.default, :parent => @cat1) | ||
12 | - | ||
13 | - # all categories must be shown for these tests | ||
14 | - Category.any_instance.stubs(:display_in_menu?).returns(true) | ||
15 | - end | ||
16 | - | ||
17 | - should 'display link to categories' do | ||
18 | - get '/' | ||
19 | - assert_tag :attributes => { :id => 'cat_menu' }, :descendant => { :tag => 'a', :attributes => { :href => '/cat/food/vegetables' } } | ||
20 | - end | ||
21 | - | ||
22 | - should 'display link to sub-categories' do | ||
23 | - get '/cat/food' | ||
24 | - # there must be a link to the subcategory | ||
25 | - assert_tag :attributes => { :id => 'cat_menu' }, :descendant => { :tag => 'a', :attributes => { :href => '/cat/food/vegetables' } } | ||
26 | - end | ||
27 | - | ||
28 | - should "always link to category's initial page in category menu" do | ||
29 | - get '/search/products/food/vegetables' | ||
30 | - assert_tag :attributes => { :id => 'cat_menu' }, :descendant => { :tag => 'a', :attributes => { :href => '/cat/food/vegetables' } } | ||
31 | - assert_no_tag :attributes => { :id => 'cat_menu' }, :descendant => { :tag => 'a', :attributes => { :href => '/searchh/products/food/vegetables' } } | ||
32 | - end | ||
33 | - | ||
34 | - should 'cache the categories menu' do | ||
35 | - ActionController::Base.perform_caching = true | ||
36 | - HomeController.any_instance.stubs(:fragment_cache_key).with(Environment.default.id.to_s + "_categories_menu").returns('dir') | ||
37 | - get '/' | ||
38 | - ActionController::Base.perform_caching = false | ||
39 | - end | ||
40 | - | ||
41 | -end |
test/unit/boxes_helper_test.rb
@@ -3,6 +3,7 @@ require 'boxes_helper' | @@ -3,6 +3,7 @@ require 'boxes_helper' | ||
3 | 3 | ||
4 | class BoxesHelperTest < ActionView::TestCase | 4 | class BoxesHelperTest < ActionView::TestCase |
5 | 5 | ||
6 | + include ApplicationHelper | ||
6 | include BoxesHelper | 7 | include BoxesHelper |
7 | include ActionView::Helpers::TagHelper | 8 | include ActionView::Helpers::TagHelper |
8 | 9 | ||
@@ -181,4 +182,20 @@ class BoxesHelperTest < ActionView::TestCase | @@ -181,4 +182,20 @@ class BoxesHelperTest < ActionView::TestCase | ||
181 | display_box_content(box, '') | 182 | display_box_content(box, '') |
182 | end | 183 | end |
183 | 184 | ||
185 | + should 'display embed button when a block is embedable' do | ||
186 | + box = create(Box, position: 1, owner: fast_create(Profile)) | ||
187 | + block = Block.create!(:box => box) | ||
188 | + block.stubs(:embedable?).returns(true) | ||
189 | + stubs(:url_for).returns('') | ||
190 | + assert_tag_in_string block_edit_buttons(block), :tag => 'a', :attributes => {:class => 'button icon-button icon-embed '} | ||
191 | + end | ||
192 | + | ||
193 | + should 'not display embed button when a block is not embedable' do | ||
194 | + box = create(Box, position: 1, owner: fast_create(Profile)) | ||
195 | + block = Block.create!(:box => box) | ||
196 | + block.stubs(:embedable?).returns(false) | ||
197 | + stubs(:url_for).returns('') | ||
198 | + assert_no_tag_in_string block_edit_buttons(block), :tag => 'a', :attributes => {:class => 'button icon-button icon-embed '} | ||
199 | + end | ||
200 | + | ||
184 | end | 201 | end |
test/unit/profile_test.rb
@@ -110,6 +110,16 @@ class ProfileTest < ActiveSupport::TestCase | @@ -110,6 +110,16 @@ class ProfileTest < ActiveSupport::TestCase | ||
110 | assert_equal total - mine, Article.count | 110 | assert_equal total - mine, Article.count |
111 | end | 111 | end |
112 | 112 | ||
113 | + should 'remove images when removing profile' do | ||
114 | + profile = build(Profile, :image_builder => {:uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')}) | ||
115 | + image = profile.image | ||
116 | + image.save! | ||
117 | + profile.destroy | ||
118 | + assert_raise ActiveRecord::RecordNotFound do | ||
119 | + image.reload | ||
120 | + end | ||
121 | + end | ||
122 | + | ||
113 | def test_should_avoid_reserved_identifiers | 123 | def test_should_avoid_reserved_identifiers |
114 | Profile::RESERVED_IDENTIFIERS.each do |identifier| | 124 | Profile::RESERVED_IDENTIFIERS.each do |identifier| |
115 | assert_invalid_identifier identifier | 125 | assert_invalid_identifier identifier |