[Git][noosfero/noosfero][api] 10 commits: Highlight block fix
Rodrigo Souto
gitlab at gitlab.com
Mon Jul 20 14:55:00 BRT 2015
Rodrigo Souto pushed to branch api at Noosfero / noosfero
Commits:
26f01247 by Tallys Martins at 2015-07-16T16:17:38Z
Highlight block fix
- Hightlight block links no longer break when noosfero is under a subdir
Signed-off-by: Andre Bernardes <andrebsguedes at gmail.com>
Signed-off-by: Tallys Martins <tallysmartins at yahoo.com.br>
- - - - -
84003a1c by Antonio Terceiro at 2015-07-16T16:18:08Z
Merge branch 'softwarepublico/noosfero-highlight_block_fix'
Closes merge request !623
- - - - -
4812b285 by Gabriela Navarro at 2015-07-16T13:24:24Z
Fix JS behaviour to show categories when noosfero is in a subdir environment
Signed-off-by: Fabio Teixeira <fabio1079 at gmail.com>
Signed-off-by: Gabriela Navarro <navarro1703 at gmail.com>
- - - - -
2238acd5 by Antonio Terceiro at 2015-07-16T19:19:22Z
Merge branch 'fix_javascript_categories' into 'master'
Fix JS behaviour to show categories when noosfero is in a subdir environment
The admin page to edit or remove a category breaks when noosfero is a subdir app. We are using the method to get the Noosfero.root to add to the address
See merge request !624
- - - - -
3dc4f1e6 by Joenio Costa at 2015-07-17T23:15:28Z
allow run the "quick-start" script from everywhere
change current directory to the noosfero's root at the beginning of
the script execution
- - - - -
549bf1dc by Antonio Terceiro at 2015-07-18T12:04:48Z
Merge branch 'quick-start-out-of-noosfero-dir' into 'master'
allow run the "quick-start" script from everywhere
change current directory to the noosfero's root at the beginning of
the script execution
See merge request !627
- - - - -
33eb3f78 by Braulio Bhavamitra at 2015-07-19T20:49:13Z
travis: remove workaround and fix selenium concurrent run
- - - - -
1a1eab27 by Braulio Bhavamitra at 2015-07-19T20:49:14Z
sub_organizations: add missed timestamps (fix unit tests)
- - - - -
e833fc77 by Leandro Nunes dos Santos at 2015-07-20T14:11:23Z
refactoring display_filter to filter all article of friends marked as show_to_followers
- - - - -
02d5269c by Rodrigo Souto at 2015-07-20T14:48:59Z
Merge branch 'master' into api
- - - - -
12 changed files:
- .travis.yml
- app/models/article.rb
- app/models/highlights_block.rb
- plugins/event/lib/event_plugin/event_block.rb
- + plugins/event/test/test_helper.rb
- plugins/event/test/unit/event_block_test.rb
- plugins/event/test/unit/event_plugin_test.rb
- plugins/sub_organizations/db/migrate/20150508153119_add_timestamp_to_relation.rb
- public/javascripts/manage-categories.js
- script/quick-start
- test/unit/article_test.rb
- test/unit/highlights_block_test.rb
Changes:
=====================================
.travis.yml
=====================================
--- a/.travis.yml
+++ b/.travis.yml
@@ -19,13 +19,6 @@ addons:
- libsqlite3-dev
- libxslt1-dev
-before_install:
-# FIXME: workaround while https://github.com/travis-ci/travis-ci/issues/4210 is open
- - rm config/initializers/default_icon_theme.rb
-# selenium support
- - export DISPLAY=:99.0
- - sh -e /etc/init.d/xvfb start
-
before_script:
- mkdir -p tmp/pids log
- bundle check || bundle install
=====================================
app/models/article.rb
=====================================
--- a/app/models/article.rb
+++ b/app/models/article.rb
@@ -506,9 +506,9 @@ class Article < ActiveRecord::Base
where(
[
"published = ? OR last_changed_by_id = ? OR profile_id = ? OR ?
- OR (show_to_followers = ? AND ? AND profile_id = ?)", true, user.id, user.id,
+ OR (show_to_followers = ? AND ? AND profile_id IN (?))", true, user.id, user.id,
profile.nil? ? false : user.has_permission?(:view_private_content, profile),
- true, user.follows?(profile), (profile.nil? ? nil : profile.id)
+ true, (profile.nil? ? true : user.follows?(profile)), ( profile.nil? ? (user.friends.select('profiles.id')) : [profile.id])
]
)
}
=====================================
app/models/highlights_block.rb
=====================================
--- a/app/models/highlights_block.rb
+++ b/app/models/highlights_block.rb
@@ -12,6 +12,7 @@ class HighlightsBlock < Block
block.images.each do |i|
i[:image_id] = i[:image_id].to_i
i[:position] = i[:position].to_i
+ i[:address] = Noosfero.root + i[:address] unless Noosfero.root.nil?
begin
file = UploadedFile.find(i[:image_id])
i[:image_src] = file.public_filename
=====================================
plugins/event/lib/event_plugin/event_block.rb
=====================================
--- a/plugins/event/lib/event_plugin/event_block.rb
+++ b/plugins/event/lib/event_plugin/event_block.rb
@@ -26,8 +26,8 @@ class EventPlugin::EventBlock < Block
end
def events(user = nil)
- events = events_source.events
- events = events.published.order('start_date')
+ events = events_source.events.order('start_date')
+ events = user.nil? ? events.public : events.display_filter(user,nil)
if future_only
events = events.where('start_date >= ?', Date.today)
=====================================
plugins/event/test/test_helper.rb
=====================================
--- /dev/null
+++ b/plugins/event/test/test_helper.rb
@@ -0,0 +1 @@
+require_relative '../../../test/test_helper'
=====================================
plugins/event/test/unit/event_block_test.rb
=====================================
--- a/plugins/event/test/unit/event_block_test.rb
+++ b/plugins/event/test/unit/event_block_test.rb
@@ -1,6 +1,6 @@
-require File.dirname(__FILE__) + '/../../../../test/test_helper'
+require_relative '../test_helper'
-class EventPlugin::EventBlockTest < ActiveSupport::TestCase
+class EventBlockTest < ActiveSupport::TestCase
def setup
@env = Environment.default
@@ -165,7 +165,7 @@ class EventPlugin::EventBlockTest < ActiveSupport::TestCase
def visibility_content_test_from_a_profile(profile)
@block.box.owner = @env
- ev = fast_create Event, :name => '2 de Julho', :profile_id => profile.id
+ ev = Event.create!(:name => '2 de Julho', :profile => profile)
@block.all_env_events = true
# Do not list event from private profile for non logged visitor
=====================================
plugins/event/test/unit/event_plugin_test.rb
=====================================
--- a/plugins/event/test/unit/event_plugin_test.rb
+++ b/plugins/event/test/unit/event_plugin_test.rb
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../../../../test/test_helper'
+require_relative '../test_helper'
class EventPluginTest < ActiveSupport::TestCase
=====================================
plugins/sub_organizations/db/migrate/20150508153119_add_timestamp_to_relation.rb
=====================================
--- a/plugins/sub_organizations/db/migrate/20150508153119_add_timestamp_to_relation.rb
+++ b/plugins/sub_organizations/db/migrate/20150508153119_add_timestamp_to_relation.rb
@@ -2,5 +2,7 @@ class AddTimestampToRelation < ActiveRecord::Migration
def change
add_column :sub_organizations_plugin_relations, :created_at, :datetime
add_column :sub_organizations_plugin_relations, :updated_at, :datetime
+ add_column :sub_organizations_plugin_approve_paternity_relations, :created_at, :datetime
+ add_column :sub_organizations_plugin_approve_paternity_relations, :updated_at, :datetime
end
end
=====================================
public/javascripts/manage-categories.js
=====================================
--- a/public/javascripts/manage-categories.js
+++ b/public/javascripts/manage-categories.js
@@ -2,7 +2,7 @@
fetch_sub_items = function(sub_items, category){
loading_for_button($("#category-loading-"+category)[0]);
$.ajax({
- url: "/admin/categories/get_children",
+ url: noosfero_root() + "/admin/categories/get_children",
dataType: "html",
data: {id: category},
success: function(data, st, ajax){
=====================================
script/quick-start
=====================================
--- a/script/quick-start
+++ b/script/quick-start
@@ -61,6 +61,8 @@ setup_rubygems_path() {
fi
}
+# change current directory to the noosfero's root
+cd "$(dirname $0)/../"
force_install=false
if test "$1" = '--force-install'; then
=====================================
test/unit/article_test.rb
=====================================
--- a/test/unit/article_test.rb
+++ b/test/unit/article_test.rb
@@ -1971,6 +1971,19 @@ class ArticleTest < ActiveSupport::TestCase
assert_equal [a], Article.display_filter(user, p)
end
+ should 'display_filter show person private content to friends when no profile is passed as parameter' do
+ user = create_user('someuser').person
+ p = fast_create(Person)
+ user.add_friend(p)
+ user.stubs(:has_permission?).with(:view_private_content, p).returns(false)
+ Article.delete_all
+ a = fast_create(Article, :published => false, :show_to_followers => true, :profile_id => p.id)
+ fast_create(Article, :published => false, :show_to_followers => false, :profile_id => p.id)
+ fast_create(Article, :published => false, :show_to_followers => false, :profile_id => p.id)
+ assert_equal [a], Article.display_filter(user, nil)
+ end
+
+
should 'display_filter show community private content to members' do
user = create_user('someuser').person
p = fast_create(Community)
=====================================
test/unit/highlights_block_test.rb
=====================================
--- a/test/unit/highlights_block_test.rb
+++ b/test/unit/highlights_block_test.rb
@@ -119,6 +119,19 @@ class HighlightsBlockTest < ActiveSupport::TestCase
block.featured_images
end
+ should 'return correct sub-dir address' do
+ Noosfero.stubs(:root).returns("/social")
+ f1 = mock()
+ f1.expects(:public_filename).returns('address')
+ UploadedFile.expects(:find).with(1).returns(f1)
+ block = HighlightsBlock.new
+ i1 = {:image_id => 1, :address => '/address', :position => 3, :title => 'address'}
+ block.images = [i1]
+ block.save!
+ block.reload
+ assert_equal block.images.first[:address], "/social/address"
+ end
+
[Environment, Profile].each do |klass|
should "choose between owner galleries when owner is #{klass.name}" do
owner = fast_create(klass)
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/95efd89f36ff0a5c14ebe94232cac43e871ae835...02d5269c396935cf2ed39aeb9efe34ae2a1aa23e
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20150720/2df2fa2d/attachment-0001.html>
More information about the Noosfero-dev
mailing list