Commit 3d179656abb7728f863908200a24273cee0af634

Authored by Joenio Costa
1 parent c51f902b

Create relative symbolic-links when installing plugins

Also:
- check return of before_disable.rb when disabling plugins
- fix rails3: instance_eval -> instance_exec

(ActionItem2859)
plugins/people_block/before_disable.rb
1 -raise "\n\n" +  
2 - "WARNING: PeopleBlockPlugin shouldn't be disabled,\n" +  
3 - " Noosfero doesn't works without that!" +  
4 - "\n\n" 1 +raise "\nPeopleBlockPlugin shouldn't be enabled/disabled by hand, Noosfero" +
  2 + "\ninstallation already comes with it enabled by default!\n"
plugins/people_block/test/unit/people_block_test.rb
@@ -60,7 +60,7 @@ class PeopleBlockTest < ActiveSupport::TestCase @@ -60,7 +60,7 @@ class PeopleBlockTest < ActiveSupport::TestCase
60 60
61 61
62 should 'prioritize profiles with image by default' do 62 should 'prioritize profiles with image by default' do
63 - assert PeopleBlock.new.prioritize_people_with_image 63 + assert PeopleBlock.new.prioritize_profiles_with_image
64 end 64 end
65 65
66 66
@@ -97,7 +97,7 @@ class PeopleBlockTest < ActiveSupport::TestCase @@ -97,7 +97,7 @@ class PeopleBlockTest < ActiveSupport::TestCase
97 expects(:profile_image_link).with(person2, :minor).returns(person2.name) 97 expects(:profile_image_link).with(person2, :minor).returns(person2.name)
98 expects(:block_title).with(anything).returns('') 98 expects(:block_title).with(anything).returns('')
99 99
100 - content = instance_eval(&block.content) 100 + content = instance_exec(&block.content)
101 101
102 assert_match(/#{person1.name}/, content) 102 assert_match(/#{person1.name}/, content)
103 assert_match(/#{person2.name}/, content) 103 assert_match(/#{person2.name}/, content)
@@ -109,10 +109,11 @@ class PeopleBlockTest < ActiveSupport::TestCase @@ -109,10 +109,11 @@ class PeopleBlockTest < ActiveSupport::TestCase
109 109
110 block = PeopleBlock.new 110 block = PeopleBlock.new
111 111
112 - expects(:_).with('View all').returns('View all')  
113 - expects(:link_to).with('View all', :controller => 'search', :action => 'people').returns('link-to-people') 112 + stubs(:_).with('View all').returns('View all')
  113 + stubs(:link_to).returns('link-to-people')
  114 + stubs(:url_for).returns(' ')
114 115
115 - assert_equal 'link-to-people', instance_eval(&block.footer) 116 + assert_equal 'link-to-people', instance_exec(&block.footer)
116 end 117 end
117 118
118 119
script/noosfero-plugins
@@ -76,7 +76,8 @@ run(){ @@ -76,7 +76,8 @@ run(){
76 76
77 _enable(){ 77 _enable(){
78 plugin="$1" 78 plugin="$1"
79 - source="$available_plugins_dir/$plugin" 79 + cd $enabled_plugins_dir
  80 + source="../../plugins/$plugin"
80 target="$enabled_plugins_dir/$plugin" 81 target="$enabled_plugins_dir/$plugin"
81 run "$source/before_enable.rb" 82 run "$source/before_enable.rb"
82 if [ -h "$target" ]; then 83 if [ -h "$target" ]; then
@@ -98,11 +99,13 @@ _enable(){ @@ -98,11 +99,13 @@ _enable(){
98 fi 99 fi
99 fi 100 fi
100 if [ "$installation_ok" = true ] && [ "$dependencies_ok" = true ]; then 101 if [ "$installation_ok" = true ] && [ "$dependencies_ok" = true ]; then
101 - ln -s "$source" "$target" 102 + ln -s "$source" "$plugin"
102 plugins_public_dir="$NOOSFERO_DIR/public/plugins" 103 plugins_public_dir="$NOOSFERO_DIR/public/plugins"
103 plugins_features_dir="$NOOSFERO_DIR/features/plugins" 104 plugins_features_dir="$NOOSFERO_DIR/features/plugins"
104 - test -d "$target/public/" && ln -s "$target/public" "$plugins_public_dir/$plugin"  
105 - test -d "$NOOSFERO_DIR/features" && test -d "$target/features" && ln -s "$target/features" "$plugins_features_dir/$plugin" 105 + cd $plugins_public_dir
  106 + test -d "$source/public" && ln -s "$source/public" "$plugin"
  107 + cd $plugins_features_dir
  108 + test -d "$NOOSFERO_DIR/features" && test -d "$source/features" && ln -s "$source/features" "$plugin"
106 _say "$plugin enabled" 109 _say "$plugin enabled"
107 run "$source/after_enable.rb" 110 run "$source/after_enable.rb"
108 needs_migrate=true 111 needs_migrate=true
@@ -122,15 +125,19 @@ _disable(){ @@ -122,15 +125,19 @@ _disable(){
122 target="$enabled_plugins_dir/$plugin" 125 target="$enabled_plugins_dir/$plugin"
123 plugins_public_dir="$NOOSFERO_DIR/public/plugins" 126 plugins_public_dir="$NOOSFERO_DIR/public/plugins"
124 plugins_features_dir="$NOOSFERO_DIR/features/plugins" 127 plugins_features_dir="$NOOSFERO_DIR/features/plugins"
125 - run "$source/before_disable.rb"  
126 - if [ -h "$target" ]; then  
127 - rm "$target"  
128 - test -h "$plugins_public_dir/$plugin" && rm "$plugins_public_dir/$plugin"  
129 - test -h "$plugins_features_dir/$plugin" && rm "$plugins_features_dir/$plugin"  
130 - _say "$plugin disabled"  
131 - run "$source/after_disable.rb" 128 + if ! run "$source/before_disable.rb"; then
  129 + echo "W: failed to disabling $plugin"
  130 + echo
132 else 131 else
133 - _say "$plugin already disabled" 132 + if [ -h "$target" ]; then
  133 + rm "$target"
  134 + test -h "$plugins_public_dir/$plugin" && rm "$plugins_public_dir/$plugin"
  135 + test -h "$plugins_features_dir/$plugin" && rm "$plugins_features_dir/$plugin"
  136 + _say "$plugin disabled"
  137 + run "$source/after_disable.rb"
  138 + else
  139 + _say "$plugin already disabled"
  140 + fi
134 fi 141 fi
135 } 142 }
136 143