Commit 5356d953547a420ec7bbfd6f18fb15dec3b934c1

Authored by Leandro Santos
2 parents 192dec3e 02d5269c

merging with master

@@ -19,13 +19,6 @@ addons: @@ -19,13 +19,6 @@ addons:
19 - libsqlite3-dev 19 - libsqlite3-dev
20 - libxslt1-dev 20 - libxslt1-dev
21 21
22 -before_install:  
23 -# FIXME: workaround while https://github.com/travis-ci/travis-ci/issues/4210 is open  
24 - - rm config/initializers/default_icon_theme.rb  
25 -# selenium support  
26 - - export DISPLAY=:99.0  
27 - - sh -e /etc/init.d/xvfb start  
28 -  
29 before_script: 22 before_script:
30 - mkdir -p tmp/pids log 23 - mkdir -p tmp/pids log
31 - bundle check || bundle install 24 - bundle check || bundle install
@@ -19,17 +19,16 @@ gem 'gettext', '~> 2.2.1', :require => false @@ -19,17 +19,16 @@ gem 'gettext', '~> 2.2.1', :require => false
19 gem 'locale', '~> 2.0.5' 19 gem 'locale', '~> 2.0.5'
20 gem 'whenever', :require => false 20 gem 'whenever', :require => false
21 gem 'eita-jrails', '~> 0.9.5', require: 'jrails' 21 gem 'eita-jrails', '~> 0.9.5', require: 'jrails'
22 -gem 'grape', '~> 0.11.0' 22 +
  23 +# API dependencies
  24 +gem 'grape', '~> 0.12'
23 gem 'grape-entity' 25 gem 'grape-entity'
24 -gem 'grape-swagger'  
25 -gem 'grape_logging'  
26 -gem 'api-pagination', '~> 4.1.1' 26 +#FIXME Get the Grape Loggin from master yo solve this issue https://github.com/intridea/grape/issues/1059
  27 +#We have to remove this commit referenve code when update the next release of grape_logging. Actualy we are using (1.1.2)
  28 +gem 'grape_logging', :git => 'https://github.com/aceunreal/grape_logging.git', :ref => '100091b'
27 gem 'rack-cors' 29 gem 'rack-cors'
28 gem 'rack-contrib' 30 gem 'rack-contrib'
29 31
30 -# FIXME list here all actual dependencies (i.e. the ones in debian/control),  
31 -# with their GEM names (not the Debian package names)  
32 -  
33 # asset pipeline 32 # asset pipeline
34 gem 'uglifier', '>= 1.0.3' 33 gem 'uglifier', '>= 1.0.3'
35 gem 'sass-rails' 34 gem 'sass-rails'
app/models/article.rb
@@ -510,9 +510,9 @@ class Article < ActiveRecord::Base @@ -510,9 +510,9 @@ class Article < ActiveRecord::Base
510 where( 510 where(
511 [ 511 [
512 "published = ? OR last_changed_by_id = ? OR profile_id = ? OR ? 512 "published = ? OR last_changed_by_id = ? OR profile_id = ? OR ?
513 - OR (show_to_followers = ? AND ? AND profile_id = ?)", true, user.id, user.id, 513 + OR (show_to_followers = ? AND ? AND profile_id IN (?))", true, user.id, user.id,
514 profile.nil? ? false : user.has_permission?(:view_private_content, profile), 514 profile.nil? ? false : user.has_permission?(:view_private_content, profile),
515 - true, user.follows?(profile), (profile.nil? ? nil : profile.id) 515 + true, (profile.nil? ? true : user.follows?(profile)), ( profile.nil? ? (user.friends.select('profiles.id')) : [profile.id])
516 ] 516 ]
517 ) 517 )
518 } 518 }
app/models/highlights_block.rb
@@ -12,6 +12,7 @@ class HighlightsBlock < Block @@ -12,6 +12,7 @@ class HighlightsBlock < Block
12 block.images.each do |i| 12 block.images.each do |i|
13 i[:image_id] = i[:image_id].to_i 13 i[:image_id] = i[:image_id].to_i
14 i[:position] = i[:position].to_i 14 i[:position] = i[:position].to_i
  15 + i[:address] = Noosfero.root + i[:address] unless Noosfero.root.nil?
15 begin 16 begin
16 file = UploadedFile.find(i[:image_id]) 17 file = UploadedFile.find(i[:image_id])
17 i[:image_src] = file.public_filename 18 i[:image_src] = file.public_filename
plugins/event/lib/event_plugin/event_block.rb
@@ -26,8 +26,8 @@ class EventPlugin::EventBlock < Block @@ -26,8 +26,8 @@ class EventPlugin::EventBlock < Block
26 end 26 end
27 27
28 def events(user = nil) 28 def events(user = nil)
29 - events = events_source.events  
30 - events = events.published.order('start_date') 29 + events = events_source.events.order('start_date')
  30 + events = user.nil? ? events.public : events.display_filter(user,nil)
31 31
32 if future_only 32 if future_only
33 events = events.where('start_date >= ?', Date.today) 33 events = events.where('start_date >= ?', Date.today)
plugins/event/test/test_helper.rb 0 → 100644
@@ -0,0 +1 @@ @@ -0,0 +1 @@
  1 +require_relative '../../../test/test_helper'
plugins/event/test/unit/event_block_test.rb
1 -require File.dirname(__FILE__) + '/../../../../test/test_helper' 1 +require_relative '../test_helper'
2 2
3 -class EventPlugin::EventBlockTest < ActiveSupport::TestCase 3 +class EventBlockTest < ActiveSupport::TestCase
4 4
5 def setup 5 def setup
6 @env = Environment.default 6 @env = Environment.default
@@ -165,7 +165,7 @@ class EventPlugin::EventBlockTest &lt; ActiveSupport::TestCase @@ -165,7 +165,7 @@ class EventPlugin::EventBlockTest &lt; ActiveSupport::TestCase
165 165
166 def visibility_content_test_from_a_profile(profile) 166 def visibility_content_test_from_a_profile(profile)
167 @block.box.owner = @env 167 @block.box.owner = @env
168 - ev = fast_create Event, :name => '2 de Julho', :profile_id => profile.id 168 + ev = Event.create!(:name => '2 de Julho', :profile => profile)
169 @block.all_env_events = true 169 @block.all_env_events = true
170 170
171 # Do not list event from private profile for non logged visitor 171 # Do not list event from private profile for non logged visitor
plugins/event/test/unit/event_plugin_test.rb
1 -require File.dirname(__FILE__) + '/../../../../test/test_helper' 1 +require_relative '../test_helper'
2 2
3 class EventPluginTest < ActiveSupport::TestCase 3 class EventPluginTest < ActiveSupport::TestCase
4 4
plugins/people_block/lib/friends_block.rb
@@ -17,7 +17,7 @@ class FriendsBlock &lt; PeopleBlockBase @@ -17,7 +17,7 @@ class FriendsBlock &lt; PeopleBlockBase
17 end 17 end
18 18
19 def suggestions 19 def suggestions
20 - owner.profile_suggestions.of_person.enabled.limit(3).includes(:suggestion) 20 + owner.suggested_profiles.of_person.enabled.limit(3).includes(:suggestion)
21 end 21 end
22 22
23 def footer 23 def footer
plugins/people_block/test/functional/profile_controller_test.rb
@@ -17,8 +17,8 @@ class ProfileControllerTest &lt; ActionController::TestCase @@ -17,8 +17,8 @@ class ProfileControllerTest &lt; ActionController::TestCase
17 login_as(user.login) 17 login_as(user.login)
18 owner = user.person 18 owner = user.person
19 19
20 - suggestion1 = owner.profile_suggestions.create(:suggestion => fast_create(Person))  
21 - suggestion2 = owner.profile_suggestions.create(:suggestion => fast_create(Person)) 20 + suggestion1 = ProfileSuggestion.create!(:suggestion => fast_create(Person), :person => owner)
  21 + suggestion2 = ProfileSuggestion.create!(:suggestion => fast_create(Person), :person => owner)
22 22
23 FriendsBlock.delete_all 23 FriendsBlock.delete_all
24 block = FriendsBlock.new 24 block = FriendsBlock.new
plugins/people_block/test/unit/friends_block_test.rb
@@ -138,8 +138,8 @@ class FriendsBlockTest &lt; ActionView::TestCase @@ -138,8 +138,8 @@ class FriendsBlockTest &lt; ActionView::TestCase
138 138
139 should 'list owner\'s friends suggestions' do 139 should 'list owner\'s friends suggestions' do
140 owner = fast_create(Person) 140 owner = fast_create(Person)
141 - suggestion1 = owner.profile_suggestions.create(:suggestion => fast_create(Person))  
142 - suggestion2 = owner.profile_suggestions.create(:suggestion => fast_create(Person)) 141 + suggestion1 = ProfileSuggestion.create!(:suggestion => fast_create(Person), :person => owner)
  142 + suggestion2 = ProfileSuggestion.create!(:suggestion => fast_create(Person), :person => owner)
143 143
144 block = FriendsBlock.new 144 block = FriendsBlock.new
145 block.stubs(:owner).returns(owner) 145 block.stubs(:owner).returns(owner)
plugins/statistics/lib/statistics_block.rb
@@ -61,7 +61,7 @@ class StatisticsBlock &lt; Block @@ -61,7 +61,7 @@ class StatisticsBlock &lt; Block
61 end 61 end
62 62
63 def templates 63 def templates
64 - Community.templates(environment) 64 + self.environment.community_templates
65 end 65 end
66 66
67 def is_template_counter_active? template_id 67 def is_template_counter_active? template_id
plugins/sub_organizations/db/migrate/20150508153119_add_timestamp_to_relation.rb
@@ -2,5 +2,7 @@ class AddTimestampToRelation &lt; ActiveRecord::Migration @@ -2,5 +2,7 @@ class AddTimestampToRelation &lt; ActiveRecord::Migration
2 def change 2 def change
3 add_column :sub_organizations_plugin_relations, :created_at, :datetime 3 add_column :sub_organizations_plugin_relations, :created_at, :datetime
4 add_column :sub_organizations_plugin_relations, :updated_at, :datetime 4 add_column :sub_organizations_plugin_relations, :updated_at, :datetime
  5 + add_column :sub_organizations_plugin_approve_paternity_relations, :created_at, :datetime
  6 + add_column :sub_organizations_plugin_approve_paternity_relations, :updated_at, :datetime
5 end 7 end
6 end 8 end
public/javascripts/manage-categories.js
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 fetch_sub_items = function(sub_items, category){ 2 fetch_sub_items = function(sub_items, category){
3 loading_for_button($("#category-loading-"+category)[0]); 3 loading_for_button($("#category-loading-"+category)[0]);
4 $.ajax({ 4 $.ajax({
5 - url: "/admin/categories/get_children", 5 + url: noosfero_root() + "/admin/categories/get_children",
6 dataType: "html", 6 dataType: "html",
7 data: {id: category}, 7 data: {id: category},
8 success: function(data, st, ajax){ 8 success: function(data, st, ajax){
script/quick-start
@@ -61,6 +61,8 @@ setup_rubygems_path() { @@ -61,6 +61,8 @@ setup_rubygems_path() {
61 fi 61 fi
62 } 62 }
63 63
  64 +# change current directory to the noosfero's root
  65 +cd "$(dirname $0)/../"
64 66
65 force_install=false 67 force_install=false
66 if test "$1" = '--force-install'; then 68 if test "$1" = '--force-install'; then
test/unit/article_test.rb
@@ -1971,6 +1971,19 @@ class ArticleTest &lt; ActiveSupport::TestCase @@ -1971,6 +1971,19 @@ class ArticleTest &lt; ActiveSupport::TestCase
1971 assert_equal [a], Article.display_filter(user, p) 1971 assert_equal [a], Article.display_filter(user, p)
1972 end 1972 end
1973 1973
  1974 + should 'display_filter show person private content to friends when no profile is passed as parameter' do
  1975 + user = create_user('someuser').person
  1976 + p = fast_create(Person)
  1977 + user.add_friend(p)
  1978 + user.stubs(:has_permission?).with(:view_private_content, p).returns(false)
  1979 + Article.delete_all
  1980 + a = fast_create(Article, :published => false, :show_to_followers => true, :profile_id => p.id)
  1981 + fast_create(Article, :published => false, :show_to_followers => false, :profile_id => p.id)
  1982 + fast_create(Article, :published => false, :show_to_followers => false, :profile_id => p.id)
  1983 + assert_equal [a], Article.display_filter(user, nil)
  1984 + end
  1985 +
  1986 +
1974 should 'display_filter show community private content to members' do 1987 should 'display_filter show community private content to members' do
1975 user = create_user('someuser').person 1988 user = create_user('someuser').person
1976 p = fast_create(Community) 1989 p = fast_create(Community)
test/unit/highlights_block_test.rb
@@ -119,6 +119,19 @@ class HighlightsBlockTest &lt; ActiveSupport::TestCase @@ -119,6 +119,19 @@ class HighlightsBlockTest &lt; ActiveSupport::TestCase
119 block.featured_images 119 block.featured_images
120 end 120 end
121 121
  122 + should 'return correct sub-dir address' do
  123 + Noosfero.stubs(:root).returns("/social")
  124 + f1 = mock()
  125 + f1.expects(:public_filename).returns('address')
  126 + UploadedFile.expects(:find).with(1).returns(f1)
  127 + block = HighlightsBlock.new
  128 + i1 = {:image_id => 1, :address => '/address', :position => 3, :title => 'address'}
  129 + block.images = [i1]
  130 + block.save!
  131 + block.reload
  132 + assert_equal block.images.first[:address], "/social/address"
  133 + end
  134 +
122 [Environment, Profile].each do |klass| 135 [Environment, Profile].each do |klass|
123 should "choose between owner galleries when owner is #{klass.name}" do 136 should "choose between owner galleries when owner is #{klass.name}" do
124 owner = fast_create(klass) 137 owner = fast_create(klass)