Commit ba2d73ae94a362721071e0bb5a2847b32ce617c0
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
Merge branch 'master' into production
Showing
19 changed files
with
143 additions
and
57 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/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 |
| ... | ... | @@ -498,14 +508,14 @@ class Article < ActiveRecord::Base |
| 498 | 508 | |
| 499 | 509 | scope :display_filter, lambda {|user, profile| |
| 500 | 510 | return published if (user.nil? && profile && profile.public?) |
| 501 | - return [] if user.nil? || (profile && !profile.public? && !user.follows?(profile)) | |
| 511 | + return [] if user.nil? || profile.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.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 | ... | ... |
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
| ... | ... | @@ -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() | ... | ... |
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/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 | |
| ... | ... | @@ -2057,8 +2057,8 @@ class ArticleTest < ActiveSupport::TestCase |
| 2057 | 2057 | user.stubs(:has_permission?).with(:view_private_content, p).returns(false) |
| 2058 | 2058 | Article.delete_all |
| 2059 | 2059 | 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) | |
| 2060 | + fast_create(Article, :published => false, :show_to_followers => false, :profile_id => p.id) | |
| 2061 | + fast_create(Article, :published => false, :show_to_followers => false, :profile_id => p.id) | |
| 2062 | 2062 | assert_equal [a], Article.display_filter(user, p) |
| 2063 | 2063 | end |
| 2064 | 2064 | |
| ... | ... | @@ -2088,7 +2088,7 @@ class ArticleTest < ActiveSupport::TestCase |
| 2088 | 2088 | a1 = fast_create(Article, :published => true, :profile_id => user.id) |
| 2089 | 2089 | a2 = fast_create(Article, :published => true, :profile_id => p.id) |
| 2090 | 2090 | fast_create(Article, :published => false, :profile_id => p.id) |
| 2091 | - assert_equivalent [a1,a2], Article.display_filter(user, nil) | |
| 2091 | + assert_equivalent [a1,a2], Article.display_filter(nil, user) | |
| 2092 | 2092 | end |
| 2093 | 2093 | |
| 2094 | 2094 | should 'display_filter show person public content of private person profile for user friends' do |
| ... | ... | @@ -2099,8 +2099,8 @@ class ArticleTest < ActiveSupport::TestCase |
| 2099 | 2099 | user.stubs(:has_permission?).with(:view_private_content, p).returns(false) |
| 2100 | 2100 | Article.delete_all |
| 2101 | 2101 | 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) | |
| 2102 | + fast_create(Article, :published => false, :show_to_followers => false, :profile_id => p.id) | |
| 2103 | + fast_create(Article, :published => false, :show_to_followers => false, :profile_id => p.id) | |
| 2104 | 2104 | assert_equal [a], Article.display_filter(user, p) |
| 2105 | 2105 | end |
| 2106 | 2106 | |
| ... | ... | @@ -2130,7 +2130,7 @@ class ArticleTest < ActiveSupport::TestCase |
| 2130 | 2130 | a1 = fast_create(Article, :published => true, :profile_id => user.id) |
| 2131 | 2131 | a2 = fast_create(Article, :published => true, :profile_id => p.id) |
| 2132 | 2132 | fast_create(Article, :published => false, :profile_id => p.id) |
| 2133 | - assert_equivalent [a1,a2], Article.display_filter(user, nil) | |
| 2133 | + assert_equivalent [a1,a2], Article.display_filter(nil, user) | |
| 2134 | 2134 | end |
| 2135 | 2135 | |
| 2136 | 2136 | should 'update hit attribute of article array' do | ... | ... |
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) | ... | ... |