Commit 7d5483f1ef483174fe1899b281006ca750e5dda2

Authored by Victor Costa
2 parents 71b7f7a9 3f489bc4

Merge branch 'master' into rails3_stable

Conflicts:
	app/helpers/layout_helper.rb
	db/schema.rb
Gemfile
... ... @@ -18,7 +18,6 @@ gem 'rake', :require => false
18 18 gem 'grape', '0.2.1'
19 19 gem 'rest-client'
20 20 gem 'exception_notification'
21   -gem 'gettext_rails'
22 21  
23 22 # FIXME list here all actual dependencies (i.e. the ones in debian/control),
24 23 # with their GEM names (not the Debian package names)
... ...
Gemfile.lock
... ... @@ -67,15 +67,6 @@ GEM
67 67 activesupport (>= 3.0.4)
68 68 fast_gettext (0.6.8)
69 69 ffi (1.0.11)
70   - gettext (2.2.1)
71   - locale
72   - gettext_activerecord (2.1.0)
73   - activerecord (>= 2.3.2)
74   - gettext (>= 2.1.0)
75   - gettext_rails (2.1.0)
76   - gettext_activerecord (>= 2.1.0)
77   - locale_rails (>= 2.0.5)
78   - rails (>= 2.3.2)
79 70 gherkin (2.4.21)
80 71 json (>= 1.4.6)
81 72 hike (1.2.1)
... ... @@ -83,9 +74,6 @@ GEM
83 74 i18n (0.6.0)
84 75 journey (1.0.3)
85 76 json (1.7.3)
86   - locale (2.0.5)
87   - locale_rails (2.0.5)
88   - locale (>= 2.0.5)
89 77 mail (2.4.4)
90 78 i18n (>= 0.4.0)
91 79 mime-types (~> 1.16)
... ... @@ -184,7 +172,6 @@ DEPENDENCIES
184 172 database_cleaner
185 173 exception_notification
186 174 fast_gettext
187   - gettext_rails
188 175 hpricot
189 176 mocha
190 177 nokogiri
... ...
app/controllers/admin/environment_design_controller.rb
... ... @@ -9,9 +9,7 @@ class EnvironmentDesignController < BoxOrganizerController
9 9 end
10 10  
11 11 def available_blocks
12   - # TODO EnvironmentStatisticsBlock is DEPRECATED and will be removed from
13   - # the Noosfero core soon, see ActionItem3045
14   - @available_blocks ||= [ ArticleBlock, LoginBlock, EnvironmentStatisticsBlock, RecentDocumentsBlock, EnterprisesBlock, CommunitiesBlock, SellersSearchBlock, LinkListBlock, FeedReaderBlock, SlideshowBlock, HighlightsBlock, FeaturedProductsBlock, CategoriesBlock, RawHTMLBlock, TagsBlock ]
  12 + @available_blocks ||= [ ArticleBlock, LoginBlock, RecentDocumentsBlock, EnterprisesBlock, CommunitiesBlock, SellersSearchBlock, LinkListBlock, FeedReaderBlock, SlideshowBlock, HighlightsBlock, FeaturedProductsBlock, CategoriesBlock, RawHTMLBlock, TagsBlock ]
15 13 @available_blocks += plugins.dispatch(:extra_blocks, :type => Environment)
16 14 end
17 15  
... ...
app/controllers/my_profile/cms_controller.rb
... ... @@ -7,7 +7,7 @@ class CmsController < MyProfileController
7 7 def search_tags
8 8 arg = params[:term].downcase
9 9 result = ActsAsTaggableOn::Tag.find(:all, :conditions => ['LOWER(name) LIKE ?', "%#{arg}%"])
10   - render :text => prepare_to_token_input2(result).to_json
  10 + render :text => prepare_to_token_input_by_label(result).to_json, :content_type => 'application/json'
11 11 end
12 12  
13 13 def self.protect_if(*args)
... ...
app/helpers/article_helper.rb
... ... @@ -83,7 +83,7 @@ module ArticleHelper
83 83 array.map { |object| {:id => object.id, :name => object.name} }
84 84 end
85 85  
86   - def prepare_to_token_input2(array)
  86 + def prepare_to_token_input_by_label(array)
87 87 array.map { |object| {:label => object.name, :value => object.name} }
88 88 end
89 89  
... ...
app/helpers/layout_helper.rb
... ... @@ -27,6 +27,7 @@ module LayoutHelper
27 27 'thickbox',
28 28 'lightbox',
29 29 'colorbox',
  30 + 'inputosaurus',
30 31 'chat',
31 32 pngfix_stylesheet_path,
32 33 ] + tokeninput_stylesheets
... ...
app/models/box.rb
... ... @@ -28,9 +28,6 @@ class Box < ActiveRecord::Base
28 28 CategoriesBlock,
29 29 CommunitiesBlock,
30 30 EnterprisesBlock,
31   - # TODO EnvironmentStatisticsBlock is DEPRECATED and will be removed from
32   - # the Noosfero core soon, see ActionItem3045
33   - EnvironmentStatisticsBlock,
34 31 FansBlock,
35 32 FavoriteEnterprisesBlock,
36 33 FeedReaderBlock,
... ... @@ -53,9 +50,6 @@ class Box < ActiveRecord::Base
53 50 CommunitiesBlock,
54 51 DisabledEnterpriseMessageBlock,
55 52 EnterprisesBlock,
56   - # TODO EnvironmentStatisticsBlock is DEPRECATED and will be removed from
57   - # the Noosfero core soon, see ActionItem3045
58   - EnvironmentStatisticsBlock,
59 53 FansBlock,
60 54 FavoriteEnterprisesBlock,
61 55 FeaturedProductsBlock,
... ...
app/models/environment.rb
... ... @@ -177,9 +177,6 @@ class Environment < ActiveRecord::Base
177 177  
178 178 # "left" area
179 179 env.boxes[1].blocks << LoginBlock.new
180   - # TODO EnvironmentStatisticsBlock is DEPRECATED and will be removed from
181   - # the Noosfero core soon, see ActionItem3045
182   - env.boxes[1].blocks << EnvironmentStatisticsBlock.new
183 180 env.boxes[1].blocks << RecentDocumentsBlock.new
184 181  
185 182 # "right" area
... ...
app/models/environment_statistics_block.rb
... ... @@ -1,33 +0,0 @@
1   -# TODO EnvironmentStatisticsBlock is DEPRECATED and will be removed from
2   -# the Noosfero core soon, see ActionItem3045
3   -
4   -class EnvironmentStatisticsBlock < Block
5   -
6   - def self.description
7   - _('Environment stastistics (DEPRECATED)')
8   - end
9   -
10   - def default_title
11   - _('Statistics for %s') % owner.name
12   - end
13   -
14   - def help
15   - _('This block presents some statistics about your environment.')
16   - end
17   -
18   - def content(args={})
19   - users = owner.people.visible.count
20   - enterprises = owner.enterprises.visible.count
21   - communities = owner.communities.visible.count
22   -
23   - info = []
24   - info << (n_('One user', '%{num} users', users) % { :num => users })
25   - unless owner.enabled?('disable_asset_enterprises')
26   - info << (n_('One enterprise', '%{num} enterprises', enterprises) % { :num => enterprises })
27   - end
28   - info << (n_('One community', '%{num} communities', communities) % { :num => communities })
29   -
30   - block_title(title) + content_tag('ul', info.map {|item| content_tag('li', item) }.join("\n"))
31   - end
32   -
33   -end
app/sweepers/profile_sweeper.rb
... ... @@ -8,9 +8,6 @@ class ProfileSweeper # &lt; ActiveRecord::Observer
8 8 end
9 9  
10 10 def after_create(profile)
11   - # TODO EnvironmentStatisticsBlock is DEPRECATED and will be removed from
12   - # the Noosfero core soon, see ActionItem3045
13   - expire_statistics_block_cache(profile)
14 11 end
15 12  
16 13 protected
... ... @@ -31,13 +28,6 @@ protected
31 28 expire_blogs(profile) if profile.organization?
32 29 end
33 30  
34   - # TODO EnvironmentStatisticsBlock is DEPRECATED and will be removed from
35   - # the Noosfero core soon, see ActionItem3045
36   - def expire_statistics_block_cache(profile)
37   - blocks = profile.environment.blocks.select { |b| b.kind_of?(EnvironmentStatisticsBlock) }
38   - BlockSweeper.expire_blocks(blocks)
39   - end
40   -
41 31 def expire_blogs(profile)
42 32 profile.blogs.select{|b| !b.empty?}.each do |blog|
43 33 pages = blog.posts.count / blog.posts_per_page + 1
... ...
app/views/cms/edit.html.erb
... ... @@ -33,9 +33,8 @@
33 33  
34 34 <br />
35 35  
36   - <%= stylesheet_link_tag('inputosaurus') %>
37   -
38 36 <%= f.text_field('tag_list', :size => 64) %>
  37 + <%= content_tag( 'small', _('Separate tags with commas') ) %>
39 38  
40 39 <script>
41 40 jQuery('#article_tag_list').inputosaurus({
... ...
baseplugins/statistics 0 → 120000
... ... @@ -0,0 +1 @@
  1 +../plugins/statistics
0 2 \ No newline at end of file
... ...
db/migrate/20140827191326_remove_environment_statistics_block.rb 0 → 100644
... ... @@ -0,0 +1,9 @@
  1 +class RemoveEnvironmentStatisticsBlock < ActiveRecord::Migration
  2 + def self.up
  3 + update("UPDATE blocks SET type = 'StatisticsBlock' WHERE type = 'EnvironmentStatisticsBlock'")
  4 + end
  5 +
  6 + def self.down
  7 + say("Nothing to undo (cannot recover the data)")
  8 + end
  9 +end
... ...
db/schema.rb
... ... @@ -11,11 +11,7 @@
11 11 #
12 12 # It's strongly recommended to check this file into your version control system.
13 13  
14   -<<<<<<< HEAD
15   -ActiveRecord::Schema.define(:version => 20140807134625) do
16   -=======
17   -ActiveRecord::Schema.define(:version => 20140808185510) do
18   ->>>>>>> rails3
  14 +ActiveRecord::Schema.define(:version => 20140827191326) do
19 15  
20 16 create_table "abuse_reports", :force => true do |t|
21 17 t.integer "reporter_id"
... ...
debian/control
... ... @@ -7,7 +7,6 @@ Build-Depends:
7 7 debhelper (>= 7.0.50~),
8 8 po4a,
9 9 ruby-gettext,
10   - ruby-gettext-rails,
11 10 ruby-sqlite3,
12 11 rake,
13 12 rails3 (>= 3.2.6-1~),
... ...
script/noosfero-plugins
... ... @@ -77,8 +77,7 @@ run(){
77 77  
78 78 _enable(){
79 79 plugin="$1"
80   - cd $enabled_plugins_dir
81   - source="../../plugins/$plugin"
  80 + source="$available_plugins_dir/$plugin"
82 81 target="$enabled_plugins_dir/$plugin"
83 82 base="$base_plugins_dir/$plugin"
84 83 run "$source/before_enable.rb"
... ... @@ -101,15 +100,11 @@ _enable(){
101 100 fi
102 101 fi
103 102 if [ "$installation_ok" = true ] && [ "$dependencies_ok" = true ]; then
104   - ln -s "$source" "$plugin"
  103 + ln -s "$source" "$target"
105 104 plugins_public_dir="$NOOSFERO_DIR/public/plugins"
106 105 plugins_features_dir="$NOOSFERO_DIR/features/plugins"
107   - cd $plugins_public_dir
108   - test -d "$source/public" && ln -s "$source/public" "$plugin"
109   - if [ -d "$NOOSFERO_DIR/features" ]; then
110   - cd $plugins_features_dir
111   - test -d "$source/features" && ln -s "$source/features" "$plugin"
112   - fi
  106 + test -d "$target/public" && ln -s "$target/public" "$plugins_public_dir/$plugin"
  107 + test -d "$NOOSFERO_DIR/features" && test -d "$target/features" && ln -s "$target/features" "$plugins_features_dir/$plugin"
113 108 _say "$plugin enabled"
114 109 run "$source/after_enable.rb"
115 110 needs_migrate=true
... ...
script/quick-start
... ... @@ -85,7 +85,7 @@ fi
85 85 run rake db:schema:load
86 86 run rake db:data:minimal
87 87 run rake db:test:prepare
88   -run rails runner 'Environment.default.enable("skip_new_user_email_confirmation")'
  88 +rails runner 'Environment.default.enable("skip_new_user_email_confirmation")'
89 89  
90 90 # FIXME compile translations depends on ruby-gettext-rails, please see debian/control
91 91 # run rake noosfero:translations:compile
... ...
test/functional/cms_controller_test.rb
... ... @@ -1807,6 +1807,23 @@ class CmsControllerTest &lt; ActionController::TestCase
1807 1807 assert_template 'cms/publish'
1808 1808 end
1809 1809  
  1810 + should 'response of search_tags be json' do
  1811 + get :search_tags, :profile => profile.identifier, :term => 'linux'
  1812 + assert_equal 'application/json', @response.content_type
  1813 + end
  1814 +
  1815 + should 'return empty json if does not find tag' do
  1816 + get :search_tags, :profile => profile.identifier, :term => 'linux'
  1817 + assert_equal "[]", @response.body
  1818 + end
  1819 +
  1820 + should 'return tags found' do
  1821 + tag = mock; tag.stubs(:name).returns('linux')
  1822 + ActsAsTaggableOn::Tag.stubs(:find).returns([tag])
  1823 + get :search_tags, :profile => profile.identifier, :term => 'linux'
  1824 + assert_equal '[{"label":"linux","value":"linux"}]', @response.body
  1825 + end
  1826 +
1810 1827 protected
1811 1828  
1812 1829 # FIXME this is to avoid adding an extra dependency for a proper JSON parser.
... ...
test/functional/environment_design_controller_test.rb
... ... @@ -6,9 +6,7 @@ class EnvironmentDesignController; def rescue_action(e) raise e end; end
6 6  
7 7 class EnvironmentDesignControllerTest < ActionController::TestCase
8 8  
9   - # TODO EnvironmentStatisticsBlock is DEPRECATED and will be removed from
10   - # the Noosfero core soon, see ActionItem3045
11   - ALL_BLOCKS = [ArticleBlock, LoginBlock, EnvironmentStatisticsBlock, RecentDocumentsBlock, EnterprisesBlock, CommunitiesBlock, SellersSearchBlock, LinkListBlock, FeedReaderBlock, SlideshowBlock, HighlightsBlock, FeaturedProductsBlock, CategoriesBlock, RawHTMLBlock, TagsBlock ]
  9 + ALL_BLOCKS = [ArticleBlock, LoginBlock, RecentDocumentsBlock, EnterprisesBlock, CommunitiesBlock, SellersSearchBlock, LinkListBlock, FeedReaderBlock, SlideshowBlock, HighlightsBlock, FeaturedProductsBlock, CategoriesBlock, RawHTMLBlock, TagsBlock ]
12 10  
13 11 def setup
14 12 @controller = EnvironmentDesignController.new
... ... @@ -77,18 +75,6 @@ class EnvironmentDesignControllerTest &lt; ActionController::TestCase
77 75 assert_tag :tag => 'p', :attributes => { :id => 'no_portal_community' }
78 76 end
79 77  
80   - # TODO EnvironmentStatisticsBlock is DEPRECATED and will be removed from
81   - # the Noosfero core soon, see ActionItem3045
82   - should 'be able to edit EnvironmentStatisticsBlock' do
83   - login_as(create_admin_user(Environment.default))
84   - b = EnvironmentStatisticsBlock.create!
85   - e = Environment.default
86   - e.boxes.create!
87   - e.boxes.first.blocks << b
88   - get :edit, :id => b.id
89   - assert_tag :tag => 'input', :attributes => { :id => 'block_title' }
90   - end
91   -
92 78 should 'be able to edit EnterprisesBlock' do
93 79 login_as(create_admin_user(Environment.default))
94 80 b = EnterprisesBlock.create!
... ...
test/unit/box_test.rb
... ... @@ -33,9 +33,6 @@ class BoxTest &lt; ActiveSupport::TestCase
33 33 assert blocks.include?('categories-block')
34 34 assert blocks.include?('communities-block')
35 35 assert blocks.include?('enterprises-block')
36   - # TODO EnvironmentStatisticsBlock is DEPRECATED and will be removed from
37   - # the Noosfero core soon, see ActionItem3045
38   - assert blocks.include?('environment-statistics-block')
39 36 assert blocks.include?('fans-block')
40 37 assert blocks.include?('favorite-enterprises-block')
41 38 assert blocks.include?('feed-reader-block')
... ... @@ -64,9 +61,6 @@ class BoxTest &lt; ActiveSupport::TestCase
64 61 assert blocks.include?('communities-block')
65 62 assert blocks.include?('disabled-enterprise-message-block')
66 63 assert blocks.include?('enterprises-block')
67   - # TODO EnvironmentStatisticsBlock is DEPRECATED and will be removed from
68   - # the Noosfero core soon, see ActionItem3045
69   - assert blocks.include?('environment-statistics-block')
70 64 assert blocks.include?('fans-block')
71 65 assert blocks.include?('favorite-enterprises-block')
72 66 assert blocks.include?('featured-products-block')
... ...
test/unit/environment_statistics_block_test.rb
... ... @@ -1,99 +0,0 @@
1   -# TODO EnvironmentStatisticsBlock is DEPRECATED and will be removed from
2   -# the Noosfero core soon, see ActionItem3045
3   -
4   -require File.dirname(__FILE__) + '/../test_helper'
5   -
6   -class EnvironmentStatisticsBlockTest < ActiveSupport::TestCase
7   -
8   - should 'inherit from Block' do
9   - assert_kind_of Block, EnvironmentStatisticsBlock.new
10   - end
11   -
12   - should 'describe itself' do
13   - assert_not_equal Block.description, EnvironmentStatisticsBlock.description
14   - end
15   -
16   - should 'provide a default title' do
17   - owner = mock
18   - owner.expects(:name).returns('my environment')
19   -
20   - block = EnvironmentStatisticsBlock.new
21   - block.expects(:owner).returns(owner)
22   - assert_equal 'Statistics for my environment', block.title
23   - end
24   -
25   - should 'generate statistics' do
26   - env = create(Environment)
27   - user1 = create_user('testuser1', :environment_id => env.id)
28   - user2 = create_user('testuser2', :environment_id => env.id)
29   -
30   - fast_create(Enterprise, :environment_id => env.id)
31   - fast_create(Community, :environment_id => env.id)
32   -
33   - block = EnvironmentStatisticsBlock.new
34   - env.boxes.first.blocks << block
35   -
36   - content = block.content
37   -
38   - assert_match(/One enterprise/, content)
39   - assert_match(/2 users/, content)
40   - assert_match(/One community/, content)
41   - end
42   -
43   - should 'generate statistics including private profiles' do
44   - env = create(Environment)
45   - user1 = create_user('testuser1', :environment_id => env.id)
46   - user2 = create_user('testuser2', :environment_id => env.id)
47   - user3 = create_user('testuser3', :environment_id => env.id)
48   - p = user3.person; p.public_profile = false; p.save!
49   -
50   - fast_create(Enterprise, :environment_id => env.id)
51   - fast_create(Enterprise, :environment_id => env.id, :public_profile => false)
52   -
53   - fast_create(Community, :environment_id => env.id)
54   - fast_create(Community, :environment_id => env.id, :public_profile => false)
55   -
56   - block = EnvironmentStatisticsBlock.new
57   - env.boxes.first.blocks << block
58   -
59   - content = block.content
60   -
61   - assert_match /2 enterprises/, content
62   - assert_match /3 users/, content
63   - assert_match /2 communities/, content
64   - end
65   -
66   - should 'generate statistics but not for not visible profiles' do
67   - env = create(Environment)
68   - user1 = create_user('testuser1', :environment_id => env.id)
69   - user2 = create_user('testuser2', :environment_id => env.id)
70   - user3 = create_user('testuser3', :environment_id => env.id)
71   - p = user3.person; p.visible = false; p.save!
72   -
73   - fast_create(Enterprise, :environment_id => env.id)
74   - fast_create(Enterprise, :environment_id => env.id, :visible => false)
75   -
76   - fast_create(Community, :environment_id => env.id)
77   - fast_create(Community, :environment_id => env.id, :visible => false)
78   -
79   - block = EnvironmentStatisticsBlock.new
80   - env.boxes.first.blocks << block
81   -
82   - content = block.content
83   -
84   - assert_match /One enterprise/, content
85   - assert_match /2 users/, content
86   - assert_match /One community/, content
87   - end
88   -
89   - should 'not display enterprises if disabled' do
90   - env = fast_create(Environment)
91   - env.enable('disable_asset_enterprises', false)
92   -
93   - block = EnvironmentStatisticsBlock.new
94   - block.stubs(:owner).returns(env)
95   -
96   - assert_no_match /enterprises/i, block.content
97   - end
98   -
99   -end