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 | 136 | klass = @type.constantize |
137 | 137 | article_data = environment.enabled?('articles_dont_accept_comments_by_default') ? { :accept_comments => false } : {} |
138 | 138 | article_data.merge!(params[:article]) if params[:article] |
139 | + article_data.merge!(:profile => profile) if profile | |
139 | 140 | @article = klass.new(article_data) |
140 | 141 | |
141 | 142 | parent = check_parent(params[:parent_id]) |
... | ... | @@ -213,7 +214,7 @@ class CmsController < MyProfileController |
213 | 214 | if @errors.any? |
214 | 215 | render :action => 'upload_files', :parent_id => @parent_id |
215 | 216 | else |
216 | - session[:notice] = _('File(s) successfully uploaded') | |
217 | + session[:notice] = _('File(s) successfully uploaded') | |
217 | 218 | if @back_to |
218 | 219 | redirect_to @back_to |
219 | 220 | elsif @parent | ... | ... |
app/controllers/public/content_viewer_controller.rb
... | ... | @@ -17,7 +17,7 @@ class ContentViewerController < ApplicationController |
17 | 17 | @version = params[:version].to_i |
18 | 18 | |
19 | 19 | if path.blank? |
20 | - @page = profile.home_page | |
20 | + @page = profile.home_page | |
21 | 21 | return if redirected_to_profile_index |
22 | 22 | else |
23 | 23 | @page = profile.articles.find_by_path(path) |
... | ... | @@ -125,21 +125,23 @@ class ContentViewerController < ApplicationController |
125 | 125 | helper_method :pass_without_comment_captcha? |
126 | 126 | |
127 | 127 | def allow_access_to_page(path) |
128 | - allowed = true | |
129 | 128 | if @page.nil? # page not found, give error |
130 | 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 | 137 | private_profile_partial_parameters |
135 | 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 | 139 | end |
140 | + | |
141 | + return false | |
141 | 142 | end |
142 | - allowed | |
143 | + | |
144 | + return true | |
143 | 145 | end |
144 | 146 | |
145 | 147 | def user_is_a_bot? |
... | ... | @@ -184,7 +186,7 @@ class ContentViewerController < ApplicationController |
184 | 186 | if @page.forum? && @page.has_terms_of_use && terms_accepted == "true" |
185 | 187 | @page.add_agreed_user(user) |
186 | 188 | end |
187 | - end | |
189 | + end | |
188 | 190 | |
189 | 191 | def is_a_forum_topic? (page) |
190 | 192 | return (!@page.parent.nil? && @page.parent.forum?) | ... | ... |
app/controllers/public_controller.rb
app/helpers/tinymce_helper.rb
... | ... | @@ -20,7 +20,7 @@ module TinymceHelper |
20 | 20 | :image_advtab => true, |
21 | 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 | 24 | if options[:mode] == 'simple' |
25 | 25 | options[:menubar] = false |
26 | 26 | else | ... | ... |
app/mailers/task_mailer.rb
... | ... | @@ -5,7 +5,7 @@ class TaskMailer < ActionMailer::Base |
5 | 5 | @target = task.target.name |
6 | 6 | @environment = task.environment.name |
7 | 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 | 9 | @tasks_url = url_for_tasks_list |
10 | 10 | |
11 | 11 | mail( |
... | ... | @@ -56,7 +56,7 @@ class TaskMailer < ActionMailer::Base |
56 | 56 | end |
57 | 57 | |
58 | 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 | 60 | end |
61 | 61 | |
62 | 62 | end | ... | ... |
app/models/article.rb
... | ... | @@ -25,6 +25,16 @@ class Article < ActiveRecord::Base |
25 | 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 | 38 | def self.default_search_display |
29 | 39 | 'full' |
30 | 40 | end |
... | ... | @@ -501,11 +511,11 @@ class Article < ActiveRecord::Base |
501 | 511 | return [] if user.nil? || (profile && !profile.public? && !user.follows?(profile)) |
502 | 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 | 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 | 529 | |
520 | 530 | def display_to?(user = nil) |
521 | 531 | if published? |
522 | - profile.display_info_to?(user) | |
532 | + (profile.secret? || !profile.visible?) ? profile.display_info_to?(user) : true | |
523 | 533 | else |
524 | 534 | if !user |
525 | 535 | false | ... | ... |
app/models/environment.rb
... | ... | @@ -339,6 +339,16 @@ class Environment < ActiveRecord::Base |
339 | 339 | self.save! |
340 | 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 | 352 | # Disables a feature identified by its name |
343 | 353 | def disable(feature, must_save=true) |
344 | 354 | self.settings["#{feature}_enabled".to_sym] = false | ... | ... |
app/views/cms/_forum.html.erb
app/views/content_viewer/_article_toolbar.html.erb
1 | 1 | <div<%= user && " class='logged-in'" %>> |
2 | 2 | <div id="article-actions"> |
3 | + | |
3 | 4 | <%= fullscreen_buttons('#article') %> |
5 | + | |
4 | 6 | <% if @page.allow_edit?(user) && !remove_content_button(:edit, @page) %> |
5 | 7 | <% content = content_tag('span', label_for_edit_article(@page)) %> |
6 | 8 | <% url = profile.admin_url.merge({ :controller => 'cms', :action => 'edit', :id => @page.id }) %> |
7 | 9 | <%= expirable_button @page, :edit, content, url %> |
8 | 10 | <% end %> |
9 | - | |
11 | + | |
10 | 12 | <% if @page != profile.home_page && !@page.has_posts? && @page.allow_delete?(user) && !remove_content_button(:delete, @page)%> |
11 | 13 | <% content = content_tag( 'span', _('Delete') ) %> |
12 | 14 | <% url = profile.admin_url.merge({ :controller => 'cms', :action => 'destroy', :id => @page.id}) %> |
... | ... | @@ -50,6 +52,7 @@ |
50 | 52 | <% end %> |
51 | 53 | |
52 | 54 | <%= report_abuse(profile, :link, @page) %> |
55 | + | |
53 | 56 | </div> |
54 | 57 | <div id="article-header"> |
55 | 58 | <% if @page.blog? and !@page.image.nil? %> | ... | ... |
db/migrate/20150319114233_change_default_content_privacy.rb
0 → 100644
... | ... | @@ -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 | 11 | # |
12 | 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 | 16 | create_table "abuse_reports", :force => true do |t| |
17 | 17 | t.integer "reporter_id" |
... | ... | @@ -150,7 +150,7 @@ ActiveRecord::Schema.define(:version => 20150408231524) do |
150 | 150 | t.integer "spam_comments_count", :default => 0 |
151 | 151 | t.integer "author_id" |
152 | 152 | t.integer "created_by_id" |
153 | - t.boolean "show_to_followers", :default => false | |
153 | + t.boolean "show_to_followers", :default => true | |
154 | 154 | end |
155 | 155 | |
156 | 156 | add_index "articles", ["comments_count"], :name => "index_articles_on_comments_count" | ... | ... |
... | ... | @@ -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 | 80 | |
81 | 81 | Scenario: deny access to specific version when disabled, private and not logged |
82 | 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 | 85 | And I am not logged in |
86 | 86 | And I go to /joaosilva/edited-article?version=1 |
87 | 87 | Then I should see "Access denied" | ... | ... |
features/edit_article.feature
... | ... | @@ -41,6 +41,7 @@ Feature: edit article |
41 | 41 | When I follow "Folder" |
42 | 42 | And I fill in "Title" with "My Folder" |
43 | 43 | And I choose "article_published_false" |
44 | + And I uncheck "article_show_to_followers" | |
44 | 45 | And I press "Save" |
45 | 46 | And I log off |
46 | 47 | And I go to /freesoftware/my-folder |
... | ... | @@ -87,6 +88,7 @@ Feature: edit article |
87 | 88 | When I follow "Folder" |
88 | 89 | And I fill in "Title" with "My Folder" |
89 | 90 | And I choose "article_published_false" |
91 | + And I uncheck "article_show_to_followers" | |
90 | 92 | Then I should see "Fill in the search field to add the exception users to see this content" |
91 | 93 | |
92 | 94 | @selenium | ... | ... |
features/secret_community.feature
... | ... | @@ -33,7 +33,7 @@ Feature: Use a secret community |
33 | 33 | Scenario: Non members shouldn't see secret communit's content |
34 | 34 | Given I am logged in as "maria" |
35 | 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 | 37 | And I follow "Communities" |
38 | 38 | Then I should not see "My Community" |
39 | 39 | ... | ... |
... | ... | @@ -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 | 115 | .icon-set-admin-role { background-image: url(mod/16x16/apps/user.png) } |
116 | 116 | .icon-reset-admin-role { background-image: url(../../../images/icons-app/person-icon.png) } |
117 | 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 | 120 | /******************LARGE ICONS********************/ |
120 | 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 | 1217 | } |
1218 | 1218 | |
1219 | 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 | 131 | post :new, :profile => community.identifier |
132 | 132 | |
133 | 133 | assert_response :forbidden |
134 | - assert_template :private_profile | |
134 | + assert_template "profile/_private_profile" | |
135 | 135 | end |
136 | 136 | |
137 | 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 | 257 | end |
258 | 258 | |
259 | 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 | 261 | intranet = Folder.create!(:name => 'my_intranet', :profile => profile, :published => false) |
262 | 262 | |
263 | 263 | get :view_page, :profile => 'test_profile', :page => [ 'my-intranet' ] |
264 | 264 | |
265 | - assert_template 'access_denied' | |
265 | + assert_template "profile/_private_profile" | |
266 | 266 | end |
267 | 267 | |
268 | 268 | should 'not give access to private articles if logged in but not member' do |
269 | 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 | 271 | intranet = Folder.create!(:name => 'my_intranet', :profile => profile, :published => false) |
272 | 272 | |
273 | 273 | get :view_page, :profile => 'test_profile', :page => [ 'my-intranet' ] |
274 | 274 | |
275 | - assert_template 'access_denied' | |
275 | + assert_template "profile/_private_profile" | |
276 | 276 | end |
277 | 277 | |
278 | 278 | should 'not give access to private articles if logged in and only member' do |
... | ... | @@ -1428,7 +1428,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
1428 | 1428 | |
1429 | 1429 | article = TinyMceArticle.create(:name => 'Article to be shared with images', |
1430 | 1430 | :body => 'This article should be shared with all social networks', |
1431 | - :profile => @profile, | |
1431 | + :profile => community, | |
1432 | 1432 | :published => false, |
1433 | 1433 | :show_to_followers => true) |
1434 | 1434 | article.parent = blog | ... | ... |
test/functional/events_controller_test.rb
... | ... | @@ -60,7 +60,7 @@ class EventsControllerTest < ActionController::TestCase |
60 | 60 | post :events, :profile => community.identifier |
61 | 61 | |
62 | 62 | assert_response :forbidden |
63 | - assert_template :private_profile | |
63 | + assert_template "profile/_private_profile" | |
64 | 64 | end |
65 | 65 | |
66 | 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 | 85 | |
86 | 86 | test 'private community content should not return cache headers' do |
87 | 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 | 90 | get "/the-community/test-page" |
91 | 91 | assert_response 403 |
... | ... | @@ -139,4 +139,3 @@ class HttpCachingTest < ActionController::IntegrationTest |
139 | 139 | end |
140 | 140 | |
141 | 141 | end |
142 | - | ... | ... |
test/unit/application_helper_test.rb
... | ... | @@ -1002,6 +1002,13 @@ class ApplicationHelperTest < ActionView::TestCase |
1002 | 1002 | assert_equal file, from_theme_include('atheme', 'afile')[:file] # exists? = true |
1003 | 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 | 1012 | protected |
1006 | 1013 | include NoosferoTestHelper |
1007 | 1014 | ... | ... |
test/unit/article_test.rb
... | ... | @@ -484,7 +484,7 @@ class ArticleTest < ActiveSupport::TestCase |
484 | 484 | |
485 | 485 | should 'say that member user can not see private article' do |
486 | 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 | 488 | person = create_user('test_user').person |
489 | 489 | profile.affiliate(person, Profile::Roles.member(profile.environment.id)) |
490 | 490 | |
... | ... | @@ -509,15 +509,15 @@ class ArticleTest < ActiveSupport::TestCase |
509 | 509 | assert article.display_to?(person) |
510 | 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 | 513 | profile = fast_create(Profile, :name => 'test profile', :identifier => 'test_profile', :public_profile => false) |
514 | 514 | article = fast_create(Article, :name => 'test article', :profile_id => profile.id, :published => true) |
515 | 515 | person1 = create_user('test_user1').person |
516 | 516 | profile.affiliate(person1, Profile::Roles.member(profile.environment.id)) |
517 | 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 | 521 | assert article.display_to?(person1) |
522 | 522 | end |
523 | 523 | |
... | ... | @@ -543,7 +543,7 @@ class ArticleTest < ActiveSupport::TestCase |
543 | 543 | |
544 | 544 | should 'not allow friends of private person see the article' do |
545 | 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 | 547 | friend = create_user('test_friend').person |
548 | 548 | person.add_friend(friend) |
549 | 549 | person.save! |
... | ... | @@ -1686,7 +1686,7 @@ class ArticleTest < ActiveSupport::TestCase |
1686 | 1686 | a.allow_members_to_edit = true |
1687 | 1687 | assert !a.allow_edit?(nil) |
1688 | 1688 | end |
1689 | - | |
1689 | + | |
1690 | 1690 | should 'allow author to edit topic' do |
1691 | 1691 | community = fast_create(Community) |
1692 | 1692 | admin = fast_create(Person) |
... | ... | @@ -1905,7 +1905,7 @@ class ArticleTest < ActiveSupport::TestCase |
1905 | 1905 | end |
1906 | 1906 | |
1907 | 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 | 1909 | Article.delete_all |
1910 | 1910 | a = fast_create(Article, :published => true, :profile_id => p.id) |
1911 | 1911 | fast_create(Article, :published => false, :profile_id => p.id) |
... | ... | @@ -1915,7 +1915,7 @@ class ArticleTest < ActiveSupport::TestCase |
1915 | 1915 | |
1916 | 1916 | should 'display_filter display public articles for users' do |
1917 | 1917 | user = create_user('someuser').person |
1918 | - p = fast_create(Person) | |
1918 | + p = fast_create(Person) | |
1919 | 1919 | user.stubs(:has_permission?).with(:view_private_content, p).returns(false) |
1920 | 1920 | Article.delete_all |
1921 | 1921 | a = fast_create(Article, :published => true, :profile_id => p.id) |
... | ... | @@ -1926,7 +1926,7 @@ class ArticleTest < ActiveSupport::TestCase |
1926 | 1926 | |
1927 | 1927 | should 'display_filter display private article last changed by user' do |
1928 | 1928 | user = create_user('someuser').person |
1929 | - p = fast_create(Person) | |
1929 | + p = fast_create(Person) | |
1930 | 1930 | user.stubs(:has_permission?).with(:view_private_content, p).returns(false) |
1931 | 1931 | Article.delete_all |
1932 | 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 | 1938 | should 'display_filter display user private article of his own profile' do |
1939 | 1939 | user = create_user('someuser').person |
1940 | 1940 | user.stubs(:has_permission?).with(:view_private_content, user).returns(false) |
1941 | - p = fast_create(Person) | |
1941 | + p = fast_create(Person) | |
1942 | 1942 | Article.delete_all |
1943 | 1943 | a = fast_create(Article, :published => false, :profile_id => user.id) |
1944 | 1944 | fast_create(Article, :published => false, :profile_id => p.id) |
... | ... | @@ -1948,7 +1948,7 @@ class ArticleTest < ActiveSupport::TestCase |
1948 | 1948 | |
1949 | 1949 | should 'display_filter show profile private content if the user has view_private_content permission' do |
1950 | 1950 | user = create_user('someuser').person |
1951 | - p = fast_create(Person) | |
1951 | + p = fast_create(Person) | |
1952 | 1952 | Article.delete_all |
1953 | 1953 | user.stubs(:has_permission?).with(:view_private_content, p).returns(false) |
1954 | 1954 | a = fast_create(Article, :published => false, :profile_id => p.id) |
... | ... | @@ -1965,8 +1965,8 @@ class ArticleTest < ActiveSupport::TestCase |
1965 | 1965 | user.stubs(:has_permission?).with(:view_private_content, p).returns(false) |
1966 | 1966 | Article.delete_all |
1967 | 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 | 1970 | assert_equal [a], Article.display_filter(user, p) |
1971 | 1971 | end |
1972 | 1972 | |
... | ... | @@ -1977,8 +1977,8 @@ class ArticleTest < ActiveSupport::TestCase |
1977 | 1977 | user.stubs(:has_permission?).with(:view_private_content, p).returns(false) |
1978 | 1978 | Article.delete_all |
1979 | 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 | 1982 | assert_equal [a], Article.display_filter(user, p) |
1983 | 1983 | end |
1984 | 1984 | |
... | ... | @@ -2040,6 +2040,17 @@ class ArticleTest < ActiveSupport::TestCase |
2040 | 2040 | assert_equal [], Article.display_filter(user, nil) |
2041 | 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 | 2054 | should 'display_filter do not show community private content to non members passing nil as profile parameter' do |
2044 | 2055 | user = create_user('someuser').person |
2045 | 2056 | p = fast_create(Community) |
... | ... | @@ -2049,6 +2060,16 @@ class ArticleTest < ActiveSupport::TestCase |
2049 | 2060 | assert_equal [], Article.display_filter(user, nil) |
2050 | 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 | 2073 | should 'display_filter show community public content of private community for user members' do |
2053 | 2074 | user = create_user('someuser').person |
2054 | 2075 | p = fast_create(Community, :public_profile => false) |
... | ... | @@ -2057,8 +2078,8 @@ class ArticleTest < ActiveSupport::TestCase |
2057 | 2078 | user.stubs(:has_permission?).with(:view_private_content, p).returns(false) |
2058 | 2079 | Article.delete_all |
2059 | 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 | 2083 | assert_equal [a], Article.display_filter(user, p) |
2063 | 2084 | end |
2064 | 2085 | |
... | ... | @@ -2088,7 +2109,7 @@ class ArticleTest < ActiveSupport::TestCase |
2088 | 2109 | a1 = fast_create(Article, :published => true, :profile_id => user.id) |
2089 | 2110 | a2 = fast_create(Article, :published => true, :profile_id => p.id) |
2090 | 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 | 2113 | end |
2093 | 2114 | |
2094 | 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 | 2120 | user.stubs(:has_permission?).with(:view_private_content, p).returns(false) |
2100 | 2121 | Article.delete_all |
2101 | 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 | 2125 | assert_equal [a], Article.display_filter(user, p) |
2105 | 2126 | end |
2106 | 2127 | |
... | ... | @@ -2130,7 +2151,7 @@ class ArticleTest < ActiveSupport::TestCase |
2130 | 2151 | a1 = fast_create(Article, :published => true, :profile_id => user.id) |
2131 | 2152 | a2 = fast_create(Article, :published => true, :profile_id => p.id) |
2132 | 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 | 2155 | end |
2135 | 2156 | |
2136 | 2157 | should 'update hit attribute of article array' do | ... | ... |
test/unit/environment_test.rb
... | ... | @@ -524,7 +524,7 @@ class EnvironmentTest < ActiveSupport::TestCase |
524 | 524 | p1= fast_create(Person, :is_template => true, :environment_id => e.id) |
525 | 525 | p2 = fast_create(Person, :environment_id => e.id) |
526 | 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 | 528 | end |
529 | 529 | |
530 | 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 | 532 | |
533 | 533 | fast_create(Person, :environment_id => e.id) |
534 | 534 | fast_create(Person, :environment_id => e.id) |
535 | - assert_equivalent [], e.person_templates | |
535 | + assert_equivalent [], e.person_templates | |
536 | 536 | end |
537 | 537 | |
538 | 538 | should 'person_default_template return the template defined as default' do |
... | ... | @@ -585,7 +585,7 @@ class EnvironmentTest < ActiveSupport::TestCase |
585 | 585 | c1= fast_create(Community, :is_template => true, :environment_id => e.id) |
586 | 586 | c2 = fast_create(Community, :environment_id => e.id) |
587 | 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 | 589 | end |
590 | 590 | |
591 | 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 | 646 | e1= fast_create(Enterprise, :is_template => true, :environment_id => env.id) |
647 | 647 | e2 = fast_create(Enterprise, :environment_id => env.id) |
648 | 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 | 650 | end |
651 | 651 | |
652 | 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 | 654 | |
655 | 655 | fast_create(Enterprise, :environment_id => env.id) |
656 | 656 | fast_create(Enterprise, :environment_id => env.id) |
657 | - assert_equivalent [], env.enterprise_templates | |
657 | + assert_equivalent [], env.enterprise_templates | |
658 | 658 | end |
659 | 659 | |
660 | 660 | should 'enterprise_default_template return the template defined as default' do |
... | ... | @@ -1428,6 +1428,36 @@ class EnvironmentTest < ActiveSupport::TestCase |
1428 | 1428 | assert !environment.plugin_enabled?(Plugin) |
1429 | 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 | 1461 | should 'have production costs' do |
1432 | 1462 | assert_respond_to Environment.default, :production_costs |
1433 | 1463 | end | ... | ... |
test/unit/folder_helper_test.rb
... | ... | @@ -68,7 +68,7 @@ class FolderHelperTest < ActionView::TestCase |
68 | 68 | profile.public_profile = false |
69 | 69 | profile.save! |
70 | 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 | 72 | article = fast_create(Article, {:parent_id => folder.id, :profile_id => profile.id}) |
73 | 73 | |
74 | 74 | result = available_articles(folder.children, profile2) | ... | ... |
test/unit/task_mailer_test.rb
... | ... | @@ -119,7 +119,7 @@ class TaskMailerTest < ActiveSupport::TestCase |
119 | 119 | assert_match(/#{task.target_notification_description}/, mail.subject) |
120 | 120 | |
121 | 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 | 123 | mail.deliver |
124 | 124 | assert !ActionMailer::Base.deliveries.empty? |
125 | 125 | end |
... | ... | @@ -135,6 +135,36 @@ class TaskMailerTest < ActiveSupport::TestCase |
135 | 135 | assert_equal 'My name <email@example.com>', TaskMailer.generate_from(task) |
136 | 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 | 169 | private |
140 | 170 | def read_fixture(action) | ... | ... |