Commit f8a595c3c3cd91049e28b548bf7d10a863b08064
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
Merge branch 'master' into production
Conflicts: app/views/content_viewer/_article_toolbar.html.erb
Showing
28 changed files
with
265 additions
and
64 deletions
Show diff stats
app/controllers/my_profile/cms_controller.rb
@@ -136,6 +136,7 @@ class CmsController < MyProfileController | @@ -136,6 +136,7 @@ class CmsController < MyProfileController | ||
136 | klass = @type.constantize | 136 | klass = @type.constantize |
137 | article_data = environment.enabled?('articles_dont_accept_comments_by_default') ? { :accept_comments => false } : {} | 137 | article_data = environment.enabled?('articles_dont_accept_comments_by_default') ? { :accept_comments => false } : {} |
138 | article_data.merge!(params[:article]) if params[:article] | 138 | article_data.merge!(params[:article]) if params[:article] |
139 | + article_data.merge!(:profile => profile) if profile | ||
139 | @article = klass.new(article_data) | 140 | @article = klass.new(article_data) |
140 | 141 | ||
141 | parent = check_parent(params[:parent_id]) | 142 | parent = check_parent(params[:parent_id]) |
@@ -213,7 +214,7 @@ class CmsController < MyProfileController | @@ -213,7 +214,7 @@ class CmsController < MyProfileController | ||
213 | if @errors.any? | 214 | if @errors.any? |
214 | render :action => 'upload_files', :parent_id => @parent_id | 215 | render :action => 'upload_files', :parent_id => @parent_id |
215 | else | 216 | else |
216 | - session[:notice] = _('File(s) successfully uploaded') | 217 | + session[:notice] = _('File(s) successfully uploaded') |
217 | if @back_to | 218 | if @back_to |
218 | redirect_to @back_to | 219 | redirect_to @back_to |
219 | elsif @parent | 220 | elsif @parent |
app/controllers/public/content_viewer_controller.rb
@@ -17,7 +17,7 @@ class ContentViewerController < ApplicationController | @@ -17,7 +17,7 @@ class ContentViewerController < ApplicationController | ||
17 | @version = params[:version].to_i | 17 | @version = params[:version].to_i |
18 | 18 | ||
19 | if path.blank? | 19 | if path.blank? |
20 | - @page = profile.home_page | 20 | + @page = profile.home_page |
21 | return if redirected_to_profile_index | 21 | return if redirected_to_profile_index |
22 | else | 22 | else |
23 | @page = profile.articles.find_by_path(path) | 23 | @page = profile.articles.find_by_path(path) |
@@ -125,21 +125,23 @@ class ContentViewerController < ApplicationController | @@ -125,21 +125,23 @@ class ContentViewerController < ApplicationController | ||
125 | helper_method :pass_without_comment_captcha? | 125 | helper_method :pass_without_comment_captcha? |
126 | 126 | ||
127 | def allow_access_to_page(path) | 127 | def allow_access_to_page(path) |
128 | - allowed = true | ||
129 | if @page.nil? # page not found, give error | 128 | if @page.nil? # page not found, give error |
130 | render_not_found(path) | 129 | render_not_found(path) |
131 | - allowed = false | ||
132 | - elsif !@page.display_to?(user) | ||
133 | - if !profile.public? | 130 | + return false |
131 | + end | ||
132 | + | ||
133 | + unless @page.display_to?(user) | ||
134 | + if !profile.visible? || profile.secret? || (user && user.follows?(profile)) | ||
135 | + render_access_denied | ||
136 | + else #!profile.public? | ||
134 | private_profile_partial_parameters | 137 | private_profile_partial_parameters |
135 | render :template => 'profile/_private_profile', :status => 403, :formats => [:html] | 138 | render :template => 'profile/_private_profile', :status => 403, :formats => [:html] |
136 | - allowed = false | ||
137 | - else #if !profile.visible? | ||
138 | - render_access_denied | ||
139 | - allowed = false | ||
140 | end | 139 | end |
140 | + | ||
141 | + return false | ||
141 | end | 142 | end |
142 | - allowed | 143 | + |
144 | + return true | ||
143 | end | 145 | end |
144 | 146 | ||
145 | def user_is_a_bot? | 147 | def user_is_a_bot? |
@@ -184,7 +186,7 @@ class ContentViewerController < ApplicationController | @@ -184,7 +186,7 @@ class ContentViewerController < ApplicationController | ||
184 | if @page.forum? && @page.has_terms_of_use && terms_accepted == "true" | 186 | if @page.forum? && @page.has_terms_of_use && terms_accepted == "true" |
185 | @page.add_agreed_user(user) | 187 | @page.add_agreed_user(user) |
186 | end | 188 | end |
187 | - end | 189 | + end |
188 | 190 | ||
189 | def is_a_forum_topic? (page) | 191 | def is_a_forum_topic? (page) |
190 | return (!@page.parent.nil? && @page.parent.forum?) | 192 | return (!@page.parent.nil? && @page.parent.forum?) |
app/controllers/public_controller.rb
@@ -3,7 +3,7 @@ class PublicController < ApplicationController | @@ -3,7 +3,7 @@ class PublicController < ApplicationController | ||
3 | 3 | ||
4 | def allow_access_to_page | 4 | def allow_access_to_page |
5 | unless profile.display_info_to?(user) | 5 | unless profile.display_info_to?(user) |
6 | - if profile.visible? | 6 | + if profile.visible? && !profile.secret |
7 | private_profile | 7 | private_profile |
8 | else | 8 | else |
9 | invisible_profile | 9 | invisible_profile |
app/helpers/tinymce_helper.rb
@@ -20,7 +20,7 @@ module TinymceHelper | @@ -20,7 +20,7 @@ module TinymceHelper | ||
20 | :image_advtab => true, | 20 | :image_advtab => true, |
21 | :language => tinymce_language | 21 | :language => tinymce_language |
22 | 22 | ||
23 | - options[:toolbar1] = "insertfile undo redo | copy paste | bold italic underline | styleselect fontsizeselect | forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image" | 23 | + options[:toolbar1] = "fullscreen | insertfile undo redo | copy paste | bold italic underline | styleselect fontsizeselect | forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image" |
24 | if options[:mode] == 'simple' | 24 | if options[:mode] == 'simple' |
25 | options[:menubar] = false | 25 | options[:menubar] = false |
26 | else | 26 | else |
app/mailers/task_mailer.rb
@@ -5,7 +5,7 @@ class TaskMailer < ActionMailer::Base | @@ -5,7 +5,7 @@ class TaskMailer < ActionMailer::Base | ||
5 | @target = task.target.name | 5 | @target = task.target.name |
6 | @environment = task.environment.name | 6 | @environment = task.environment.name |
7 | @url = generate_environment_url(task, :controller => 'home') | 7 | @url = generate_environment_url(task, :controller => 'home') |
8 | - url_for_tasks_list = task.target.kind_of?(Environment) ? '' : url_for(task.target.tasks_url) | 8 | + url_for_tasks_list = task.target.kind_of?(Environment) ? '' : url_for(task.target.tasks_url.merge(:script_name => Noosfero.root('/'))) |
9 | @tasks_url = url_for_tasks_list | 9 | @tasks_url = url_for_tasks_list |
10 | 10 | ||
11 | mail( | 11 | mail( |
@@ -56,7 +56,7 @@ class TaskMailer < ActionMailer::Base | @@ -56,7 +56,7 @@ class TaskMailer < ActionMailer::Base | ||
56 | end | 56 | end |
57 | 57 | ||
58 | def generate_environment_url(task, url = {}) | 58 | def generate_environment_url(task, url = {}) |
59 | - url_for(Noosfero.url_options.merge(:host => task.environment.default_hostname).merge(url)) | 59 | + url_for(Noosfero.url_options.merge(:host => task.environment.default_hostname).merge(url).merge(:script_name => Noosfero.root('/'))) |
60 | end | 60 | end |
61 | 61 | ||
62 | end | 62 | end |
app/models/article.rb
@@ -25,6 +25,16 @@ class Article < ActiveRecord::Base | @@ -25,6 +25,16 @@ class Article < ActiveRecord::Base | ||
25 | :display => %w[full] | 25 | :display => %w[full] |
26 | } | 26 | } |
27 | 27 | ||
28 | + def initialize(*params) | ||
29 | + super | ||
30 | + | ||
31 | + if !params.blank? && params.first.has_key?(:profile) | ||
32 | + profile = params.first[:profile] | ||
33 | + self.published = false unless profile.public? | ||
34 | + end | ||
35 | + | ||
36 | + end | ||
37 | + | ||
28 | def self.default_search_display | 38 | def self.default_search_display |
29 | 'full' | 39 | 'full' |
30 | end | 40 | end |
@@ -501,11 +511,11 @@ class Article < ActiveRecord::Base | @@ -501,11 +511,11 @@ class Article < ActiveRecord::Base | ||
501 | return [] if user.nil? || (profile && !profile.public? && !user.follows?(profile)) | 511 | return [] if user.nil? || (profile && !profile.public? && !user.follows?(profile)) |
502 | where( | 512 | where( |
503 | [ | 513 | [ |
504 | - "published = ? OR last_changed_by_id = ? OR profile_id = ? OR ? | ||
505 | - OR (show_to_followers = ? AND ?)", true, user.id, user.id, | 514 | + "published = ? OR last_changed_by_id = ? OR profile_id = ? OR ? |
515 | + OR (show_to_followers = ? AND ? AND profile_id = ?)", true, user.id, user.id, | ||
506 | profile.nil? ? false : user.has_permission?(:view_private_content, profile), | 516 | profile.nil? ? false : user.has_permission?(:view_private_content, profile), |
507 | - true, user.follows?(profile) | ||
508 | - ] | 517 | + true, user.follows?(profile), (profile.nil? ? nil : profile.id) |
518 | + ] | ||
509 | ) | 519 | ) |
510 | } | 520 | } |
511 | 521 | ||
@@ -519,7 +529,7 @@ class Article < ActiveRecord::Base | @@ -519,7 +529,7 @@ class Article < ActiveRecord::Base | ||
519 | 529 | ||
520 | def display_to?(user = nil) | 530 | def display_to?(user = nil) |
521 | if published? | 531 | if published? |
522 | - profile.display_info_to?(user) | 532 | + (profile.secret? || !profile.visible?) ? profile.display_info_to?(user) : true |
523 | else | 533 | else |
524 | if !user | 534 | if !user |
525 | false | 535 | false |
app/models/environment.rb
@@ -339,6 +339,16 @@ class Environment < ActiveRecord::Base | @@ -339,6 +339,16 @@ class Environment < ActiveRecord::Base | ||
339 | self.save! | 339 | self.save! |
340 | end | 340 | end |
341 | 341 | ||
342 | + def enable_all_plugins | ||
343 | + Noosfero::Plugin.available_plugin_names.each do |plugin| | ||
344 | + plugin_name = plugin.to_s + "Plugin" | ||
345 | + unless self.enabled_plugins.include?(plugin_name) | ||
346 | + self.enabled_plugins += [plugin_name] | ||
347 | + end | ||
348 | + end | ||
349 | + self.save! | ||
350 | + end | ||
351 | + | ||
342 | # Disables a feature identified by its name | 352 | # Disables a feature identified by its name |
343 | def disable(feature, must_save=true) | 353 | def disable(feature, must_save=true) |
344 | self.settings["#{feature}_enabled".to_sym] = false | 354 | self.settings["#{feature}_enabled".to_sym] = false |
app/views/cms/_forum.html.erb
@@ -2,6 +2,8 @@ | @@ -2,6 +2,8 @@ | ||
2 | 2 | ||
3 | <h1><%= _('My Forum') %></h1> | 3 | <h1><%= _('My Forum') %></h1> |
4 | 4 | ||
5 | +<%= required_fields_message %> | ||
6 | + | ||
5 | <%= render :file => 'shared/tiny_mce' %> | 7 | <%= render :file => 'shared/tiny_mce' %> |
6 | 8 | ||
7 | <%= required f.text_field(:name, :size => '64', :maxlength => 150, :onchange => "updateUrlField(this, 'article_slug')") %> | 9 | <%= required f.text_field(:name, :size => '64', :maxlength => 150, :onchange => "updateUrlField(this, 'article_slug')") %> |
app/views/content_viewer/_article_toolbar.html.erb
1 | <div<%= user && " class='logged-in'" %>> | 1 | <div<%= user && " class='logged-in'" %>> |
2 | <div id="article-actions"> | 2 | <div id="article-actions"> |
3 | + | ||
3 | <%= fullscreen_buttons('#article') %> | 4 | <%= fullscreen_buttons('#article') %> |
5 | + | ||
4 | <% if @page.allow_edit?(user) && !remove_content_button(:edit, @page) %> | 6 | <% if @page.allow_edit?(user) && !remove_content_button(:edit, @page) %> |
5 | <% content = content_tag('span', label_for_edit_article(@page)) %> | 7 | <% content = content_tag('span', label_for_edit_article(@page)) %> |
6 | <% url = profile.admin_url.merge({ :controller => 'cms', :action => 'edit', :id => @page.id }) %> | 8 | <% url = profile.admin_url.merge({ :controller => 'cms', :action => 'edit', :id => @page.id }) %> |
7 | <%= expirable_button @page, :edit, content, url %> | 9 | <%= expirable_button @page, :edit, content, url %> |
8 | <% end %> | 10 | <% end %> |
9 | - | 11 | + |
10 | <% if @page != profile.home_page && !@page.has_posts? && @page.allow_delete?(user) && !remove_content_button(:delete, @page)%> | 12 | <% if @page != profile.home_page && !@page.has_posts? && @page.allow_delete?(user) && !remove_content_button(:delete, @page)%> |
11 | <% content = content_tag( 'span', _('Delete') ) %> | 13 | <% content = content_tag( 'span', _('Delete') ) %> |
12 | <% url = profile.admin_url.merge({ :controller => 'cms', :action => 'destroy', :id => @page.id}) %> | 14 | <% url = profile.admin_url.merge({ :controller => 'cms', :action => 'destroy', :id => @page.id}) %> |
@@ -50,6 +52,7 @@ | @@ -50,6 +52,7 @@ | ||
50 | <% end %> | 52 | <% end %> |
51 | 53 | ||
52 | <%= report_abuse(profile, :link, @page) %> | 54 | <%= report_abuse(profile, :link, @page) %> |
55 | + | ||
53 | </div> | 56 | </div> |
54 | <div id="article-header"> | 57 | <div id="article-header"> |
55 | <% if @page.blog? and !@page.image.nil? %> | 58 | <% if @page.blog? and !@page.image.nil? %> |
db/migrate/20150319114233_change_default_content_privacy.rb
0 → 100644
@@ -0,0 +1,19 @@ | @@ -0,0 +1,19 @@ | ||
1 | +class ChangeDefaultContentPrivacy < ActiveRecord::Migration | ||
2 | + def up | ||
3 | + update_sql('UPDATE articles SET published = (1>2), show_to_followers = (1=1) | ||
4 | + FROM profiles WHERE articles.profile_id = profiles.id AND | ||
5 | + NOT profiles.public_profile AND articles.published = (1=1)') | ||
6 | + | ||
7 | + Block.select('blocks.*').joins("INNER JOIN boxes ON blocks.box_id = boxes.id | ||
8 | + INNER JOIN profiles ON boxes.owner_id = profiles.id AND boxes.owner_type = 'Profile'"). | ||
9 | + where("NOT profiles.public_profile AND blocks.type != 'MainBlock'").find_each do |block| | ||
10 | + block.display_user = 'followers' | ||
11 | + block.save | ||
12 | + end | ||
13 | + change_column :articles, :show_to_followers, :boolean, :default => true | ||
14 | + end | ||
15 | + | ||
16 | + def down | ||
17 | + say "this migration can't be reverted" | ||
18 | + end | ||
19 | +end |
db/schema.rb
@@ -11,7 +11,7 @@ | @@ -11,7 +11,7 @@ | ||
11 | # | 11 | # |
12 | # It's strongly recommended to check this file into your version control system. | 12 | # It's strongly recommended to check this file into your version control system. |
13 | 13 | ||
14 | -ActiveRecord::Schema.define(:version => 20150408231524) do | 14 | +ActiveRecord::Schema.define(:version => 20150423144533) do |
15 | 15 | ||
16 | create_table "abuse_reports", :force => true do |t| | 16 | create_table "abuse_reports", :force => true do |t| |
17 | t.integer "reporter_id" | 17 | t.integer "reporter_id" |
@@ -150,7 +150,7 @@ ActiveRecord::Schema.define(:version => 20150408231524) do | @@ -150,7 +150,7 @@ ActiveRecord::Schema.define(:version => 20150408231524) do | ||
150 | t.integer "spam_comments_count", :default => 0 | 150 | t.integer "spam_comments_count", :default => 0 |
151 | t.integer "author_id" | 151 | t.integer "author_id" |
152 | t.integer "created_by_id" | 152 | t.integer "created_by_id" |
153 | - t.boolean "show_to_followers", :default => false | 153 | + t.boolean "show_to_followers", :default => true |
154 | end | 154 | end |
155 | 155 | ||
156 | add_index "articles", ["comments_count"], :name => "index_articles_on_comments_count" | 156 | add_index "articles", ["comments_count"], :name => "index_articles_on_comments_count" |
@@ -0,0 +1,14 @@ | @@ -0,0 +1,14 @@ | ||
1 | +# This file should contain all the record creation needed to seed the database with its default values. | ||
2 | +# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). | ||
3 | +# | ||
4 | +# Examples: | ||
5 | +# | ||
6 | +# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) | ||
7 | +# Mayor.create(name: 'Emanuel', city: cities.first) | ||
8 | + | ||
9 | +ENV['RAILS_ENV'] ||= 'development' | ||
10 | + | ||
11 | +# This is for plugins that wants to use seeds.rb | ||
12 | +# Check for example on the Foo plugin | ||
13 | +plugin_seed_dirs = Dir.glob(Rails.root.join('{baseplugins,config/plugins}', '*', 'db', 'seeds.rb')) | ||
14 | +plugin_seed_dirs.each { |path| load path } |
features/article_versioning.feature
@@ -80,8 +80,8 @@ Feature: article versioning | @@ -80,8 +80,8 @@ Feature: article versioning | ||
80 | 80 | ||
81 | Scenario: deny access to specific version when disabled, private and not logged | 81 | Scenario: deny access to specific version when disabled, private and not logged |
82 | Given the article "Edited Article" is updated with | 82 | Given the article "Edited Article" is updated with |
83 | - | display_versions | published | | ||
84 | - | false | false | | 83 | + | display_versions | published | show_to_followers | |
84 | + | false | false | false | | ||
85 | And I am not logged in | 85 | And I am not logged in |
86 | And I go to /joaosilva/edited-article?version=1 | 86 | And I go to /joaosilva/edited-article?version=1 |
87 | Then I should see "Access denied" | 87 | Then I should see "Access denied" |
features/edit_article.feature
@@ -41,6 +41,7 @@ Feature: edit article | @@ -41,6 +41,7 @@ Feature: edit article | ||
41 | When I follow "Folder" | 41 | When I follow "Folder" |
42 | And I fill in "Title" with "My Folder" | 42 | And I fill in "Title" with "My Folder" |
43 | And I choose "article_published_false" | 43 | And I choose "article_published_false" |
44 | + And I uncheck "article_show_to_followers" | ||
44 | And I press "Save" | 45 | And I press "Save" |
45 | And I log off | 46 | And I log off |
46 | And I go to /freesoftware/my-folder | 47 | And I go to /freesoftware/my-folder |
@@ -87,6 +88,7 @@ Feature: edit article | @@ -87,6 +88,7 @@ Feature: edit article | ||
87 | When I follow "Folder" | 88 | When I follow "Folder" |
88 | And I fill in "Title" with "My Folder" | 89 | And I fill in "Title" with "My Folder" |
89 | And I choose "article_published_false" | 90 | And I choose "article_published_false" |
91 | + And I uncheck "article_show_to_followers" | ||
90 | Then I should see "Fill in the search field to add the exception users to see this content" | 92 | Then I should see "Fill in the search field to add the exception users to see this content" |
91 | 93 | ||
92 | @selenium | 94 | @selenium |
features/secret_community.feature
@@ -33,7 +33,7 @@ Feature: Use a secret community | @@ -33,7 +33,7 @@ Feature: Use a secret community | ||
33 | Scenario: Non members shouldn't see secret communit's content | 33 | Scenario: Non members shouldn't see secret communit's content |
34 | Given I am logged in as "maria" | 34 | Given I am logged in as "maria" |
35 | And I go to mycommunity's homepage | 35 | And I go to mycommunity's homepage |
36 | - And I should see "Access denied" | 36 | + And I should see "Oops ... you cannot go ahead here" |
37 | And I follow "Communities" | 37 | And I follow "Communities" |
38 | Then I should not see "My Community" | 38 | Then I should not see "My Community" |
39 | 39 |
@@ -0,0 +1,9 @@ | @@ -0,0 +1,9 @@ | ||
1 | +# This file should contain all the record creation needed to seed the database with its default values. | ||
2 | +# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). | ||
3 | +# | ||
4 | +# Examples: | ||
5 | +# | ||
6 | +# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) | ||
7 | +# Mayor.create(name: 'Emanuel', city: cities.first) | ||
8 | + | ||
9 | +FooPlugin::Bar.create() |
public/designs/icons/tango/style.css
@@ -115,6 +115,7 @@ | @@ -115,6 +115,7 @@ | ||
115 | .icon-set-admin-role { background-image: url(mod/16x16/apps/user.png) } | 115 | .icon-set-admin-role { background-image: url(mod/16x16/apps/user.png) } |
116 | .icon-reset-admin-role { background-image: url(../../../images/icons-app/person-icon.png) } | 116 | .icon-reset-admin-role { background-image: url(../../../images/icons-app/person-icon.png) } |
117 | .icon-clock { background-image: url(Tango/16x16/actions/appointment.png) } | 117 | .icon-clock { background-image: url(Tango/16x16/actions/appointment.png) } |
118 | +.icon-fullscreen { background-image: url(Tango/16x16/actions/view-fullscreen.png) } | ||
118 | 119 | ||
119 | /******************LARGE ICONS********************/ | 120 | /******************LARGE ICONS********************/ |
120 | .image-gallery-item .folder { background-image: url(mod/96x96/places/folder.png) } | 121 | .image-gallery-item .folder { background-image: url(mod/96x96/places/folder.png) } |
public/javascripts/application.js
@@ -1217,3 +1217,35 @@ function add_new_file_fields() { | @@ -1217,3 +1217,35 @@ function add_new_file_fields() { | ||
1217 | } | 1217 | } |
1218 | 1218 | ||
1219 | window.isHidden = function isHidden() { return (typeof(document.hidden) != 'undefined') ? document.hidden : !document.hasFocus() }; | 1219 | window.isHidden = function isHidden() { return (typeof(document.hidden) != 'undefined') ? document.hidden : !document.hasFocus() }; |
1220 | + | ||
1221 | +function $_GET(id){ | ||
1222 | + var a = new RegExp(id+"=([^&#=]*)"); | ||
1223 | + return decodeURIComponent(a.exec(window.location.search)[1]); | ||
1224 | +} | ||
1225 | + | ||
1226 | +var fullwidth=false; | ||
1227 | +function toggle_fullwidth(itemId){ | ||
1228 | + if(fullwidth){ | ||
1229 | + jQuery(itemId).removeClass("fullwidth"); | ||
1230 | + jQuery("#fullscreen-btn").show() | ||
1231 | + jQuery("#exit-fullscreen-btn").hide() | ||
1232 | + fullwidth = false; | ||
1233 | + } | ||
1234 | + else{ | ||
1235 | + jQuery(itemId).addClass("fullwidth"); | ||
1236 | + jQuery("#exit-fullscreen-btn").show() | ||
1237 | + jQuery("#fullscreen-btn").hide() | ||
1238 | + fullwidth = true; | ||
1239 | + } | ||
1240 | + jQuery(window).trigger("toggleFullwidth", fullwidth); | ||
1241 | +} | ||
1242 | + | ||
1243 | +function fullscreenPageLoad(itemId){ | ||
1244 | + jQuery(document).ready(function(){ | ||
1245 | + | ||
1246 | + if ($_GET('fullscreen') == 1){ | ||
1247 | + toggle_fullwidth(itemId); | ||
1248 | + } | ||
1249 | + }); | ||
1250 | +} | ||
1251 | + |
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 :private_profile | 134 | + assert_template "profile/_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/content_viewer_controller_test.rb
@@ -257,22 +257,22 @@ class ContentViewerControllerTest < ActionController::TestCase | @@ -257,22 +257,22 @@ class ContentViewerControllerTest < ActionController::TestCase | ||
257 | end | 257 | end |
258 | 258 | ||
259 | should 'not give access to private articles if logged off' do | 259 | should 'not give access to private articles if logged off' do |
260 | - profile = Profile.create!(:name => 'test profile', :identifier => 'test_profile') | 260 | + profile = Community.create!(:name => 'test profile', :identifier => 'test_profile') |
261 | intranet = Folder.create!(:name => 'my_intranet', :profile => profile, :published => false) | 261 | intranet = Folder.create!(:name => 'my_intranet', :profile => profile, :published => false) |
262 | 262 | ||
263 | get :view_page, :profile => 'test_profile', :page => [ 'my-intranet' ] | 263 | get :view_page, :profile => 'test_profile', :page => [ 'my-intranet' ] |
264 | 264 | ||
265 | - assert_template 'access_denied' | 265 | + assert_template "profile/_private_profile" |
266 | end | 266 | end |
267 | 267 | ||
268 | should 'not give access to private articles if logged in but not member' do | 268 | should 'not give access to private articles if logged in but not member' do |
269 | login_as('testinguser') | 269 | login_as('testinguser') |
270 | - profile = Profile.create!(:name => 'test profile', :identifier => 'test_profile') | 270 | + profile = Community.create!(:name => 'test profile', :identifier => 'test_profile') |
271 | intranet = Folder.create!(:name => 'my_intranet', :profile => profile, :published => false) | 271 | intranet = Folder.create!(:name => 'my_intranet', :profile => profile, :published => false) |
272 | 272 | ||
273 | get :view_page, :profile => 'test_profile', :page => [ 'my-intranet' ] | 273 | get :view_page, :profile => 'test_profile', :page => [ 'my-intranet' ] |
274 | 274 | ||
275 | - assert_template 'access_denied' | 275 | + assert_template "profile/_private_profile" |
276 | end | 276 | end |
277 | 277 | ||
278 | should 'not give access to private articles if logged in and only member' do | 278 | should 'not give access to private articles if logged in and only member' do |
@@ -1428,7 +1428,7 @@ class ContentViewerControllerTest < ActionController::TestCase | @@ -1428,7 +1428,7 @@ class ContentViewerControllerTest < ActionController::TestCase | ||
1428 | 1428 | ||
1429 | article = TinyMceArticle.create(:name => 'Article to be shared with images', | 1429 | article = TinyMceArticle.create(:name => 'Article to be shared with images', |
1430 | :body => 'This article should be shared with all social networks', | 1430 | :body => 'This article should be shared with all social networks', |
1431 | - :profile => @profile, | 1431 | + :profile => community, |
1432 | :published => false, | 1432 | :published => false, |
1433 | :show_to_followers => true) | 1433 | :show_to_followers => true) |
1434 | article.parent = blog | 1434 | article.parent = blog |
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 :private_profile | 63 | + assert_template "profile/_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/integration/http_caching_test.rb
@@ -85,7 +85,7 @@ class HttpCachingTest < ActionController::IntegrationTest | @@ -85,7 +85,7 @@ class HttpCachingTest < ActionController::IntegrationTest | ||
85 | 85 | ||
86 | test 'private community content should not return cache headers' do | 86 | test 'private community content should not return cache headers' do |
87 | community = create_private_community('the-community') | 87 | community = create_private_community('the-community') |
88 | - create(Article, profile_id: community.id, name: 'Test page') | 88 | + create(Article, profile_id: community.id, name: 'Test page', published: false) |
89 | 89 | ||
90 | get "/the-community/test-page" | 90 | get "/the-community/test-page" |
91 | assert_response 403 | 91 | assert_response 403 |
@@ -139,4 +139,3 @@ class HttpCachingTest < ActionController::IntegrationTest | @@ -139,4 +139,3 @@ class HttpCachingTest < ActionController::IntegrationTest | ||
139 | end | 139 | end |
140 | 140 | ||
141 | end | 141 | end |
142 | - |
test/unit/application_helper_test.rb
@@ -1002,6 +1002,13 @@ class ApplicationHelperTest < ActionView::TestCase | @@ -1002,6 +1002,13 @@ class ApplicationHelperTest < ActionView::TestCase | ||
1002 | assert_equal file, from_theme_include('atheme', 'afile')[:file] # exists? = true | 1002 | assert_equal file, from_theme_include('atheme', 'afile')[:file] # exists? = true |
1003 | end | 1003 | end |
1004 | 1004 | ||
1005 | + should 'enable fullscreen buttons' do | ||
1006 | + html = fullscreen_buttons("#article") | ||
1007 | + assert html.include?("<script>fullscreenPageLoad('#article')</script>") | ||
1008 | + assert html.include?("class=\"button with-text icon-fullscreen\"") | ||
1009 | + assert html.include?("onClick=\"toggle_fullwidth('#article')\"") | ||
1010 | + end | ||
1011 | + | ||
1005 | protected | 1012 | protected |
1006 | include NoosferoTestHelper | 1013 | include NoosferoTestHelper |
1007 | 1014 |
test/unit/article_test.rb
@@ -484,7 +484,7 @@ class ArticleTest < ActiveSupport::TestCase | @@ -484,7 +484,7 @@ class ArticleTest < ActiveSupport::TestCase | ||
484 | 484 | ||
485 | should 'say that member user can not see private article' do | 485 | should 'say that member user can not see private article' do |
486 | profile = fast_create(Profile, :name => 'test profile', :identifier => 'test_profile') | 486 | profile = fast_create(Profile, :name => 'test profile', :identifier => 'test_profile') |
487 | - article = fast_create(Article, :name => 'test article', :profile_id => profile.id, :published => false) | 487 | + article = fast_create(Article, :name => 'test article', :profile_id => profile.id, :published => false, :show_to_followers => false) |
488 | person = create_user('test_user').person | 488 | person = create_user('test_user').person |
489 | profile.affiliate(person, Profile::Roles.member(profile.environment.id)) | 489 | profile.affiliate(person, Profile::Roles.member(profile.environment.id)) |
490 | 490 | ||
@@ -509,15 +509,15 @@ class ArticleTest < ActiveSupport::TestCase | @@ -509,15 +509,15 @@ class ArticleTest < ActiveSupport::TestCase | ||
509 | assert article.display_to?(person) | 509 | assert article.display_to?(person) |
510 | end | 510 | end |
511 | 511 | ||
512 | - should 'not show article to non member if article public but profile private' do | 512 | + should 'show article to non member if article public but profile private' do |
513 | profile = fast_create(Profile, :name => 'test profile', :identifier => 'test_profile', :public_profile => false) | 513 | profile = fast_create(Profile, :name => 'test profile', :identifier => 'test_profile', :public_profile => false) |
514 | article = fast_create(Article, :name => 'test article', :profile_id => profile.id, :published => true) | 514 | article = fast_create(Article, :name => 'test article', :profile_id => profile.id, :published => true) |
515 | person1 = create_user('test_user1').person | 515 | person1 = create_user('test_user1').person |
516 | profile.affiliate(person1, Profile::Roles.member(profile.environment.id)) | 516 | profile.affiliate(person1, Profile::Roles.member(profile.environment.id)) |
517 | person2 = create_user('test_user2').person | 517 | person2 = create_user('test_user2').person |
518 | 518 | ||
519 | - assert !article.display_to?(nil) | ||
520 | - assert !article.display_to?(person2) | 519 | + assert article.display_to?(nil) |
520 | + assert article.display_to?(person2) | ||
521 | assert article.display_to?(person1) | 521 | assert article.display_to?(person1) |
522 | end | 522 | end |
523 | 523 | ||
@@ -543,7 +543,7 @@ class ArticleTest < ActiveSupport::TestCase | @@ -543,7 +543,7 @@ class ArticleTest < ActiveSupport::TestCase | ||
543 | 543 | ||
544 | should 'not allow friends of private person see the article' do | 544 | should 'not allow friends of private person see the article' do |
545 | person = create_user('test_user').person | 545 | person = create_user('test_user').person |
546 | - article = create(Article, :name => 'test article', :profile => person, :published => false) | 546 | + article = create(Article, :name => 'test article', :profile => person, :published => false, :show_to_followers => false) |
547 | friend = create_user('test_friend').person | 547 | friend = create_user('test_friend').person |
548 | person.add_friend(friend) | 548 | person.add_friend(friend) |
549 | person.save! | 549 | person.save! |
@@ -1686,7 +1686,7 @@ class ArticleTest < ActiveSupport::TestCase | @@ -1686,7 +1686,7 @@ class ArticleTest < ActiveSupport::TestCase | ||
1686 | a.allow_members_to_edit = true | 1686 | a.allow_members_to_edit = true |
1687 | assert !a.allow_edit?(nil) | 1687 | assert !a.allow_edit?(nil) |
1688 | end | 1688 | end |
1689 | - | 1689 | + |
1690 | should 'allow author to edit topic' do | 1690 | should 'allow author to edit topic' do |
1691 | community = fast_create(Community) | 1691 | community = fast_create(Community) |
1692 | admin = fast_create(Person) | 1692 | admin = fast_create(Person) |
@@ -1905,7 +1905,7 @@ class ArticleTest < ActiveSupport::TestCase | @@ -1905,7 +1905,7 @@ class ArticleTest < ActiveSupport::TestCase | ||
1905 | end | 1905 | end |
1906 | 1906 | ||
1907 | should 'display_filter display only public articles if there is no user' do | 1907 | should 'display_filter display only public articles if there is no user' do |
1908 | - p = fast_create(Person) | 1908 | + p = fast_create(Person) |
1909 | Article.delete_all | 1909 | Article.delete_all |
1910 | a = fast_create(Article, :published => true, :profile_id => p.id) | 1910 | a = fast_create(Article, :published => true, :profile_id => p.id) |
1911 | fast_create(Article, :published => false, :profile_id => p.id) | 1911 | fast_create(Article, :published => false, :profile_id => p.id) |
@@ -1915,7 +1915,7 @@ class ArticleTest < ActiveSupport::TestCase | @@ -1915,7 +1915,7 @@ class ArticleTest < ActiveSupport::TestCase | ||
1915 | 1915 | ||
1916 | should 'display_filter display public articles for users' do | 1916 | should 'display_filter display public articles for users' do |
1917 | user = create_user('someuser').person | 1917 | user = create_user('someuser').person |
1918 | - p = fast_create(Person) | 1918 | + p = fast_create(Person) |
1919 | user.stubs(:has_permission?).with(:view_private_content, p).returns(false) | 1919 | user.stubs(:has_permission?).with(:view_private_content, p).returns(false) |
1920 | Article.delete_all | 1920 | Article.delete_all |
1921 | a = fast_create(Article, :published => true, :profile_id => p.id) | 1921 | a = fast_create(Article, :published => true, :profile_id => p.id) |
@@ -1926,7 +1926,7 @@ class ArticleTest < ActiveSupport::TestCase | @@ -1926,7 +1926,7 @@ class ArticleTest < ActiveSupport::TestCase | ||
1926 | 1926 | ||
1927 | should 'display_filter display private article last changed by user' do | 1927 | should 'display_filter display private article last changed by user' do |
1928 | user = create_user('someuser').person | 1928 | user = create_user('someuser').person |
1929 | - p = fast_create(Person) | 1929 | + p = fast_create(Person) |
1930 | user.stubs(:has_permission?).with(:view_private_content, p).returns(false) | 1930 | user.stubs(:has_permission?).with(:view_private_content, p).returns(false) |
1931 | Article.delete_all | 1931 | Article.delete_all |
1932 | a = fast_create(Article, :published => false, :last_changed_by_id => user.id, :profile_id => p.id) | 1932 | a = fast_create(Article, :published => false, :last_changed_by_id => user.id, :profile_id => p.id) |
@@ -1938,7 +1938,7 @@ class ArticleTest < ActiveSupport::TestCase | @@ -1938,7 +1938,7 @@ class ArticleTest < ActiveSupport::TestCase | ||
1938 | should 'display_filter display user private article of his own profile' do | 1938 | should 'display_filter display user private article of his own profile' do |
1939 | user = create_user('someuser').person | 1939 | user = create_user('someuser').person |
1940 | user.stubs(:has_permission?).with(:view_private_content, user).returns(false) | 1940 | user.stubs(:has_permission?).with(:view_private_content, user).returns(false) |
1941 | - p = fast_create(Person) | 1941 | + p = fast_create(Person) |
1942 | Article.delete_all | 1942 | Article.delete_all |
1943 | a = fast_create(Article, :published => false, :profile_id => user.id) | 1943 | a = fast_create(Article, :published => false, :profile_id => user.id) |
1944 | fast_create(Article, :published => false, :profile_id => p.id) | 1944 | fast_create(Article, :published => false, :profile_id => p.id) |
@@ -1948,7 +1948,7 @@ class ArticleTest < ActiveSupport::TestCase | @@ -1948,7 +1948,7 @@ class ArticleTest < ActiveSupport::TestCase | ||
1948 | 1948 | ||
1949 | should 'display_filter show profile private content if the user has view_private_content permission' do | 1949 | should 'display_filter show profile private content if the user has view_private_content permission' do |
1950 | user = create_user('someuser').person | 1950 | user = create_user('someuser').person |
1951 | - p = fast_create(Person) | 1951 | + p = fast_create(Person) |
1952 | Article.delete_all | 1952 | Article.delete_all |
1953 | user.stubs(:has_permission?).with(:view_private_content, p).returns(false) | 1953 | user.stubs(:has_permission?).with(:view_private_content, p).returns(false) |
1954 | a = fast_create(Article, :published => false, :profile_id => p.id) | 1954 | a = fast_create(Article, :published => false, :profile_id => p.id) |
@@ -1965,8 +1965,8 @@ class ArticleTest < ActiveSupport::TestCase | @@ -1965,8 +1965,8 @@ class ArticleTest < ActiveSupport::TestCase | ||
1965 | user.stubs(:has_permission?).with(:view_private_content, p).returns(false) | 1965 | user.stubs(:has_permission?).with(:view_private_content, p).returns(false) |
1966 | Article.delete_all | 1966 | Article.delete_all |
1967 | a = fast_create(Article, :published => false, :show_to_followers => true, :profile_id => p.id) | 1967 | a = fast_create(Article, :published => false, :show_to_followers => true, :profile_id => p.id) |
1968 | - fast_create(Article, :published => false, :profile_id => p.id) | ||
1969 | - fast_create(Article, :published => false, :profile_id => p.id) | 1968 | + fast_create(Article, :published => false, :show_to_followers => false, :profile_id => p.id) |
1969 | + fast_create(Article, :published => false, :show_to_followers => false, :profile_id => p.id) | ||
1970 | assert_equal [a], Article.display_filter(user, p) | 1970 | assert_equal [a], Article.display_filter(user, p) |
1971 | end | 1971 | end |
1972 | 1972 | ||
@@ -1977,8 +1977,8 @@ class ArticleTest < ActiveSupport::TestCase | @@ -1977,8 +1977,8 @@ class ArticleTest < ActiveSupport::TestCase | ||
1977 | user.stubs(:has_permission?).with(:view_private_content, p).returns(false) | 1977 | user.stubs(:has_permission?).with(:view_private_content, p).returns(false) |
1978 | Article.delete_all | 1978 | Article.delete_all |
1979 | a = fast_create(Article, :published => false, :show_to_followers => true, :profile_id => p.id) | 1979 | a = fast_create(Article, :published => false, :show_to_followers => true, :profile_id => p.id) |
1980 | - fast_create(Article, :published => false, :profile_id => p.id) | ||
1981 | - fast_create(Article, :published => false, :profile_id => p.id) | 1980 | + fast_create(Article, :published => false, :show_to_followers => false, :profile_id => p.id) |
1981 | + fast_create(Article, :published => false, :show_to_followers => false, :profile_id => p.id) | ||
1982 | assert_equal [a], Article.display_filter(user, p) | 1982 | assert_equal [a], Article.display_filter(user, p) |
1983 | end | 1983 | end |
1984 | 1984 | ||
@@ -2040,6 +2040,17 @@ class ArticleTest < ActiveSupport::TestCase | @@ -2040,6 +2040,17 @@ class ArticleTest < ActiveSupport::TestCase | ||
2040 | assert_equal [], Article.display_filter(user, nil) | 2040 | assert_equal [], Article.display_filter(user, nil) |
2041 | end | 2041 | end |
2042 | 2042 | ||
2043 | + should 'display_filter show person public content to non friends passing nil as profile parameter' do | ||
2044 | + user = create_user('someuser').person | ||
2045 | + p = fast_create(Person) | ||
2046 | + assert !p.is_a_friend?(user) | ||
2047 | + assert !user.is_admin? | ||
2048 | + Article.delete_all | ||
2049 | + a1 = fast_create(Article, :profile_id => p.id) | ||
2050 | + a2 = fast_create(Article) | ||
2051 | + assert_equivalent [a1,a2], Article.display_filter(user, nil) | ||
2052 | + end | ||
2053 | + | ||
2043 | should 'display_filter do not show community private content to non members passing nil as profile parameter' do | 2054 | should 'display_filter do not show community private content to non members passing nil as profile parameter' do |
2044 | user = create_user('someuser').person | 2055 | user = create_user('someuser').person |
2045 | p = fast_create(Community) | 2056 | p = fast_create(Community) |
@@ -2049,6 +2060,16 @@ class ArticleTest < ActiveSupport::TestCase | @@ -2049,6 +2060,16 @@ class ArticleTest < ActiveSupport::TestCase | ||
2049 | assert_equal [], Article.display_filter(user, nil) | 2060 | assert_equal [], Article.display_filter(user, nil) |
2050 | end | 2061 | end |
2051 | 2062 | ||
2063 | + should 'display_filter show community public content to non members passing nil as profile parameter' do | ||
2064 | + user = create_user('someuser').person | ||
2065 | + p = fast_create(Community) | ||
2066 | + assert !user.is_member_of?(p) | ||
2067 | + Article.delete_all | ||
2068 | + a1 = fast_create(Article, :profile_id => p.id) | ||
2069 | + a2 = fast_create(Article) | ||
2070 | + assert_equivalent [a1,a2], Article.display_filter(user, nil) | ||
2071 | + end | ||
2072 | + | ||
2052 | should 'display_filter show community public content of private community for user members' do | 2073 | should 'display_filter show community public content of private community for user members' do |
2053 | user = create_user('someuser').person | 2074 | user = create_user('someuser').person |
2054 | p = fast_create(Community, :public_profile => false) | 2075 | p = fast_create(Community, :public_profile => false) |
@@ -2057,8 +2078,8 @@ class ArticleTest < ActiveSupport::TestCase | @@ -2057,8 +2078,8 @@ class ArticleTest < ActiveSupport::TestCase | ||
2057 | user.stubs(:has_permission?).with(:view_private_content, p).returns(false) | 2078 | user.stubs(:has_permission?).with(:view_private_content, p).returns(false) |
2058 | Article.delete_all | 2079 | Article.delete_all |
2059 | a = fast_create(Article, :published => true, :profile_id => p.id) | 2080 | a = fast_create(Article, :published => true, :profile_id => p.id) |
2060 | - fast_create(Article, :published => false, :profile_id => p.id) | ||
2061 | - fast_create(Article, :published => false, :profile_id => p.id) | 2081 | + fast_create(Article, :published => false, :show_to_followers => false, :profile_id => p.id) |
2082 | + fast_create(Article, :published => false, :show_to_followers => false, :profile_id => p.id) | ||
2062 | assert_equal [a], Article.display_filter(user, p) | 2083 | assert_equal [a], Article.display_filter(user, p) |
2063 | end | 2084 | end |
2064 | 2085 | ||
@@ -2088,7 +2109,7 @@ class ArticleTest < ActiveSupport::TestCase | @@ -2088,7 +2109,7 @@ class ArticleTest < ActiveSupport::TestCase | ||
2088 | a1 = fast_create(Article, :published => true, :profile_id => user.id) | 2109 | a1 = fast_create(Article, :published => true, :profile_id => user.id) |
2089 | a2 = fast_create(Article, :published => true, :profile_id => p.id) | 2110 | a2 = fast_create(Article, :published => true, :profile_id => p.id) |
2090 | fast_create(Article, :published => false, :profile_id => p.id) | 2111 | fast_create(Article, :published => false, :profile_id => p.id) |
2091 | - assert_equivalent [a1,a2], Article.display_filter(user, nil) | 2112 | + assert_equivalent [a1,a2], Article.display_filter(nil, user) |
2092 | end | 2113 | end |
2093 | 2114 | ||
2094 | should 'display_filter show person public content of private person profile for user friends' do | 2115 | should 'display_filter show person public content of private person profile for user friends' do |
@@ -2099,8 +2120,8 @@ class ArticleTest < ActiveSupport::TestCase | @@ -2099,8 +2120,8 @@ class ArticleTest < ActiveSupport::TestCase | ||
2099 | user.stubs(:has_permission?).with(:view_private_content, p).returns(false) | 2120 | user.stubs(:has_permission?).with(:view_private_content, p).returns(false) |
2100 | Article.delete_all | 2121 | Article.delete_all |
2101 | a = fast_create(Article, :published => true, :profile_id => p.id) | 2122 | a = fast_create(Article, :published => true, :profile_id => p.id) |
2102 | - fast_create(Article, :published => false, :profile_id => p.id) | ||
2103 | - fast_create(Article, :published => false, :profile_id => p.id) | 2123 | + fast_create(Article, :published => false, :show_to_followers => false, :profile_id => p.id) |
2124 | + fast_create(Article, :published => false, :show_to_followers => false, :profile_id => p.id) | ||
2104 | assert_equal [a], Article.display_filter(user, p) | 2125 | assert_equal [a], Article.display_filter(user, p) |
2105 | end | 2126 | end |
2106 | 2127 | ||
@@ -2130,7 +2151,7 @@ class ArticleTest < ActiveSupport::TestCase | @@ -2130,7 +2151,7 @@ class ArticleTest < ActiveSupport::TestCase | ||
2130 | a1 = fast_create(Article, :published => true, :profile_id => user.id) | 2151 | a1 = fast_create(Article, :published => true, :profile_id => user.id) |
2131 | a2 = fast_create(Article, :published => true, :profile_id => p.id) | 2152 | a2 = fast_create(Article, :published => true, :profile_id => p.id) |
2132 | fast_create(Article, :published => false, :profile_id => p.id) | 2153 | fast_create(Article, :published => false, :profile_id => p.id) |
2133 | - assert_equivalent [a1,a2], Article.display_filter(user, nil) | 2154 | + assert_equivalent [a1,a2], Article.display_filter(nil, user) |
2134 | end | 2155 | end |
2135 | 2156 | ||
2136 | should 'update hit attribute of article array' do | 2157 | should 'update hit attribute of article array' do |
test/unit/environment_test.rb
@@ -524,7 +524,7 @@ class EnvironmentTest < ActiveSupport::TestCase | @@ -524,7 +524,7 @@ class EnvironmentTest < ActiveSupport::TestCase | ||
524 | p1= fast_create(Person, :is_template => true, :environment_id => e.id) | 524 | p1= fast_create(Person, :is_template => true, :environment_id => e.id) |
525 | p2 = fast_create(Person, :environment_id => e.id) | 525 | p2 = fast_create(Person, :environment_id => e.id) |
526 | p3 = fast_create(Person, :is_template => true, :environment_id => e.id) | 526 | p3 = fast_create(Person, :is_template => true, :environment_id => e.id) |
527 | - assert_equivalent [p1,p3], e.person_templates | 527 | + assert_equivalent [p1,p3], e.person_templates |
528 | end | 528 | end |
529 | 529 | ||
530 | should 'person_templates return an empty array if there is no templates of person' do | 530 | should 'person_templates return an empty array if there is no templates of person' do |
@@ -532,7 +532,7 @@ class EnvironmentTest < ActiveSupport::TestCase | @@ -532,7 +532,7 @@ class EnvironmentTest < ActiveSupport::TestCase | ||
532 | 532 | ||
533 | fast_create(Person, :environment_id => e.id) | 533 | fast_create(Person, :environment_id => e.id) |
534 | fast_create(Person, :environment_id => e.id) | 534 | fast_create(Person, :environment_id => e.id) |
535 | - assert_equivalent [], e.person_templates | 535 | + assert_equivalent [], e.person_templates |
536 | end | 536 | end |
537 | 537 | ||
538 | should 'person_default_template return the template defined as default' do | 538 | should 'person_default_template return the template defined as default' do |
@@ -585,7 +585,7 @@ class EnvironmentTest < ActiveSupport::TestCase | @@ -585,7 +585,7 @@ class EnvironmentTest < ActiveSupport::TestCase | ||
585 | c1= fast_create(Community, :is_template => true, :environment_id => e.id) | 585 | c1= fast_create(Community, :is_template => true, :environment_id => e.id) |
586 | c2 = fast_create(Community, :environment_id => e.id) | 586 | c2 = fast_create(Community, :environment_id => e.id) |
587 | c3 = fast_create(Community, :is_template => true, :environment_id => e.id) | 587 | c3 = fast_create(Community, :is_template => true, :environment_id => e.id) |
588 | - assert_equivalent [c1,c3], e.community_templates | 588 | + assert_equivalent [c1,c3], e.community_templates |
589 | end | 589 | end |
590 | 590 | ||
591 | should 'community_templates return an empty array if there is no templates of community' do | 591 | should 'community_templates return an empty array if there is no templates of community' do |
@@ -646,7 +646,7 @@ class EnvironmentTest < ActiveSupport::TestCase | @@ -646,7 +646,7 @@ class EnvironmentTest < ActiveSupport::TestCase | ||
646 | e1= fast_create(Enterprise, :is_template => true, :environment_id => env.id) | 646 | e1= fast_create(Enterprise, :is_template => true, :environment_id => env.id) |
647 | e2 = fast_create(Enterprise, :environment_id => env.id) | 647 | e2 = fast_create(Enterprise, :environment_id => env.id) |
648 | e3 = fast_create(Enterprise, :is_template => true, :environment_id => env.id) | 648 | e3 = fast_create(Enterprise, :is_template => true, :environment_id => env.id) |
649 | - assert_equivalent [e1,e3], env.enterprise_templates | 649 | + assert_equivalent [e1,e3], env.enterprise_templates |
650 | end | 650 | end |
651 | 651 | ||
652 | should 'enterprise_templates return an empty array if there is no templates of enterprise' do | 652 | should 'enterprise_templates return an empty array if there is no templates of enterprise' do |
@@ -654,7 +654,7 @@ class EnvironmentTest < ActiveSupport::TestCase | @@ -654,7 +654,7 @@ class EnvironmentTest < ActiveSupport::TestCase | ||
654 | 654 | ||
655 | fast_create(Enterprise, :environment_id => env.id) | 655 | fast_create(Enterprise, :environment_id => env.id) |
656 | fast_create(Enterprise, :environment_id => env.id) | 656 | fast_create(Enterprise, :environment_id => env.id) |
657 | - assert_equivalent [], env.enterprise_templates | 657 | + assert_equivalent [], env.enterprise_templates |
658 | end | 658 | end |
659 | 659 | ||
660 | should 'enterprise_default_template return the template defined as default' do | 660 | should 'enterprise_default_template return the template defined as default' do |
@@ -1428,6 +1428,36 @@ class EnvironmentTest < ActiveSupport::TestCase | @@ -1428,6 +1428,36 @@ class EnvironmentTest < ActiveSupport::TestCase | ||
1428 | assert !environment.plugin_enabled?(Plugin) | 1428 | assert !environment.plugin_enabled?(Plugin) |
1429 | end | 1429 | end |
1430 | 1430 | ||
1431 | + should 'activate on database all available plugins' do | ||
1432 | + plugins_enable = ["Statistics", "Foo", "PeopleBlock"] | ||
1433 | + Noosfero::Plugins.stubs(:available_plugin_names).returns(plugins_enable) | ||
1434 | + env1 = Environment.create(:name => "Test") | ||
1435 | + env2 = Environment.create(:name => "Test 2") | ||
1436 | + | ||
1437 | + env1.enable_all_plugins | ||
1438 | + env2.enable_all_plugins | ||
1439 | + | ||
1440 | + plugins = ["PeopleBlockPlugin", "StatisticsPlugin", "FooPlugin"] | ||
1441 | + plugins.each do |plugin| | ||
1442 | + assert env1.enabled_plugins.include?(plugin) | ||
1443 | + assert env2.enabled_plugins.include?(plugin) | ||
1444 | + end | ||
1445 | + end | ||
1446 | + | ||
1447 | + should 'dont activate plugins that are not available' do | ||
1448 | + env1 = Environment.create(:name => "Test") | ||
1449 | + env2 = Environment.create(:name => "Test 2") | ||
1450 | + | ||
1451 | + env1.enable_all_plugins | ||
1452 | + env2.enable_all_plugins | ||
1453 | + | ||
1454 | + plugins = ["SomePlugin", "OtherPlugin", "ThirdPlugin"] | ||
1455 | + plugins.each do |plugin| | ||
1456 | + assert_equal false, env1.enabled_plugins.include?(plugin) | ||
1457 | + assert_equal false, env2.enabled_plugins.include?(plugin) | ||
1458 | + end | ||
1459 | + end | ||
1460 | + | ||
1431 | should 'have production costs' do | 1461 | should 'have production costs' do |
1432 | assert_respond_to Environment.default, :production_costs | 1462 | assert_respond_to Environment.default, :production_costs |
1433 | end | 1463 | end |
test/unit/folder_helper_test.rb
@@ -68,7 +68,7 @@ class FolderHelperTest < ActionView::TestCase | @@ -68,7 +68,7 @@ class FolderHelperTest < ActionView::TestCase | ||
68 | profile.public_profile = false | 68 | profile.public_profile = false |
69 | profile.save! | 69 | profile.save! |
70 | profile2 = create_user('Folder Viwer').person | 70 | profile2 = create_user('Folder Viwer').person |
71 | - folder = fast_create(Folder, :profile_id => profile.id) | 71 | + folder = fast_create(Folder, :profile_id => profile.id, :published => false) |
72 | article = fast_create(Article, {:parent_id => folder.id, :profile_id => profile.id}) | 72 | article = fast_create(Article, {:parent_id => folder.id, :profile_id => profile.id}) |
73 | 73 | ||
74 | result = available_articles(folder.children, profile2) | 74 | result = available_articles(folder.children, profile2) |
test/unit/task_mailer_test.rb
@@ -119,7 +119,7 @@ class TaskMailerTest < ActiveSupport::TestCase | @@ -119,7 +119,7 @@ class TaskMailerTest < ActiveSupport::TestCase | ||
119 | assert_match(/#{task.target_notification_description}/, mail.subject) | 119 | assert_match(/#{task.target_notification_description}/, mail.subject) |
120 | 120 | ||
121 | assert_equal "Hello friend name, my name invite you, please follow this link: http://example.com/account/signup?invitation_code=123456", mail.body.to_s | 121 | assert_equal "Hello friend name, my name invite you, please follow this link: http://example.com/account/signup?invitation_code=123456", mail.body.to_s |
122 | - | 122 | + |
123 | mail.deliver | 123 | mail.deliver |
124 | assert !ActionMailer::Base.deliveries.empty? | 124 | assert !ActionMailer::Base.deliveries.empty? |
125 | end | 125 | end |
@@ -135,6 +135,36 @@ class TaskMailerTest < ActiveSupport::TestCase | @@ -135,6 +135,36 @@ class TaskMailerTest < ActiveSupport::TestCase | ||
135 | assert_equal 'My name <email@example.com>', TaskMailer.generate_from(task) | 135 | assert_equal 'My name <email@example.com>', TaskMailer.generate_from(task) |
136 | end | 136 | end |
137 | 137 | ||
138 | + should 'return the email with the subdirectory defined' do | ||
139 | + Noosfero.stubs(:root).returns('/subdir') | ||
140 | + | ||
141 | + task = InviteFriend.new | ||
142 | + task.expects(:code).returns('123456') | ||
143 | + | ||
144 | + task.stubs(:message).returns('Hello <friend>, <user> invite you, please follow this link: <url>') | ||
145 | + task.expects(:friend_email).returns('friend@exemple.com') | ||
146 | + task.expects(:friend_name).returns('friend name').at_least_once | ||
147 | + | ||
148 | + requestor = mock() | ||
149 | + requestor.stubs(:name).returns('my name') | ||
150 | + requestor.stubs(:public_profile_url).returns('requestor_path') | ||
151 | + | ||
152 | + environment = mock() | ||
153 | + environment.expects(:noreply_email).returns('sender@example.com') | ||
154 | + environment.expects(:default_hostname).returns('example.com') | ||
155 | + environment.expects(:name).returns('example').at_least_once | ||
156 | + | ||
157 | + task.expects(:requestor).returns(requestor).at_least_once | ||
158 | + task.expects(:person).returns(requestor).at_least_once | ||
159 | + requestor.expects(:environment).returns(environment).at_least_once | ||
160 | + task.expects(:environment).returns(environment).at_least_once | ||
161 | + | ||
162 | + mail = TaskMailer.invitation_notification(task) | ||
163 | + | ||
164 | + url_to_compare = "/subdir/account/signup" | ||
165 | + | ||
166 | + assert_match(/#{url_to_compare}/, mail.body.to_s) | ||
167 | + end | ||
138 | 168 | ||
139 | private | 169 | private |
140 | def read_fixture(action) | 170 | def read_fixture(action) |