Commit 1ef72f36f9f804a5f03347116faf24f2e49e6a6b

Authored by Daniela Feitosa
2 parents 7cdb436f 1c2bcef6

Merge branch 'stable' into rails235

Conflicts:
	app/controllers/public/content_viewer_controller.rb
	features/categories_block.feature
	test/functional/search_controller_test.rb
app/controllers/public/content_viewer_controller.rb
@@ -50,7 +50,7 @@ class ContentViewerController < ApplicationController @@ -50,7 +50,7 @@ class ContentViewerController < ApplicationController
50 end 50 end
51 51
52 # At this point the page will be showed 52 # At this point the page will be showed
53 - @page.hit 53 + @page.hit unless user_is_a_bot?
54 54
55 @page = FilePresenter.for @page 55 @page = FilePresenter.for @page
56 56
@@ -183,4 +183,13 @@ class ContentViewerController < ApplicationController @@ -183,4 +183,13 @@ class ContentViewerController < ApplicationController
183 allowed 183 allowed
184 end 184 end
185 185
  186 + def user_is_a_bot?
  187 + user_agent= request.env["HTTP_USER_AGENT"]
  188 + user_agent.blank? ||
  189 + user_agent.match(/bot/) ||
  190 + user_agent.match(/spider/) ||
  191 + user_agent.match(/crawler/) ||
  192 + user_agent.match(/\(.*https?:\/\/.*\)/)
  193 + end
  194 +
186 end 195 end
app/controllers/public/events_controller.rb
@@ -21,7 +21,7 @@ class EventsController < PublicController @@ -21,7 +21,7 @@ class EventsController < PublicController
21 21
22 def events_by_day 22 def events_by_day
23 @date = build_date(params[:year], params[:month], params[:day]) 23 @date = build_date(params[:year], params[:month], params[:day])
24 - @events = profile.events.by_day(@date) 24 + @events = profile.events.by_day(@date).paginate(:per_page => per_page, :page => params[:page])
25 render :partial => 'events' 25 render :partial => 'events'
26 end 26 end
27 27
features/balloon.feature
@@ -8,6 +8,7 @@ Feature: balloon @@ -8,6 +8,7 @@ Feature: balloon
8 And the following communities 8 And the following communities
9 | identifier | name | 9 | identifier | name |
10 | sample | Sample | 10 | sample | Sample |
  11 + And I am logged in as "joaosilva"
11 12
12 @selenium 13 @selenium
13 Scenario: I should not see trigger if not enabled 14 Scenario: I should not see trigger if not enabled
features/categories_block.feature
@@ -24,16 +24,12 @@ Feature: categories_block @@ -24,16 +24,12 @@ Feature: categories_block
24 | owner | type | 24 | owner | type |
25 | environment | CategoriesBlock | 25 | environment | CategoriesBlock |
26 And I am logged in as admin 26 And I am logged in as admin
  27 + And I go to /admin/environment_design
  28 + And display ".button-bar"
27 29
28 - # Note that this @ignore-hidden-elements only works for seeing hidden  
29 - # elements. It actually doesn't work for following hidden link or pressing  
30 - # hidden buttons. That's why it's necessary to use this display hack to show  
31 - # the link.  
32 - @selenium @ignore-hidden-elements 30 + @selenium
33 Scenario: List just product categories 31 Scenario: List just product categories
34 - Given I go to /admin/environment_design  
35 - And display ".categories-block .button-bar"  
36 - And I follow "Edit" within ".categories-block" 32 + Given I follow "Edit" within ".categories-block"
37 And I check "Product" 33 And I check "Product"
38 When I press "Save" 34 When I press "Save"
39 Then I should see "Food" 35 Then I should see "Food"
@@ -42,11 +38,9 @@ Feature: categories_block @@ -42,11 +38,9 @@ Feature: categories_block
42 And "Steak" should not be visible within "span#category-name" 38 And "Steak" should not be visible within "span#category-name"
43 And "Fiction" should not be visible within "span#category-name" 39 And "Fiction" should not be visible within "span#category-name"
44 40
45 - @selenium @ignore-hidden-elements 41 + @selenium
46 Scenario: Show submenu if it exists 42 Scenario: Show submenu if it exists
47 - Given I go to /admin/environment_design  
48 - And display ".categories-block .button-bar"  
49 - And I follow "Edit" within ".categories-block" 43 + Given I follow "Edit" within ".categories-block"
50 And I check "Product" 44 And I check "Product"
51 And I press "Save" 45 And I press "Save"
52 Then I should see "Food" 46 Then I should see "Food"
@@ -61,11 +55,9 @@ Feature: categories_block @@ -61,11 +55,9 @@ Feature: categories_block
61 And I should see "Steak" 55 And I should see "Steak"
62 And I should not see "Fiction" 56 And I should not see "Fiction"
63 57
64 - @selenium @ignore-hidden-elements 58 + @selenium
65 Scenario: Show only one submenu per time 59 Scenario: Show only one submenu per time
66 - Given I go to /admin/environment_design  
67 - And display ".categories-block .button-bar"  
68 - And I follow "Edit" within ".categories-block" 60 + Given I follow "Edit" within ".categories-block"
69 And I check "Product" 61 And I check "Product"
70 And I press "Save" 62 And I press "Save"
71 Then I should see "Book" 63 Then I should see "Book"
@@ -73,20 +65,16 @@ Feature: categories_block @@ -73,20 +65,16 @@ Feature: categories_block
73 When I follow "block_2_category_2" 65 When I follow "block_2_category_2"
74 Then I should see "Literature" 66 Then I should see "Literature"
75 67
76 - @selenium @ignore-hidden-elements 68 + @selenium
77 Scenario: List just general categories 69 Scenario: List just general categories
78 - Given I go to /admin/environment_design  
79 - And display ".categories-block .button-bar"  
80 - And I follow "Edit" within ".categories-block" 70 + Given I follow "Edit" within ".categories-block"
81 And I check "Generic category" 71 And I check "Generic category"
82 When I press "Save" 72 When I press "Save"
83 Then I should see "Wood" 73 Then I should see "Wood"
84 74
85 - @selenium @ignore-hidden-elements 75 + @selenium
86 Scenario: List just regions 76 Scenario: List just regions
87 - Given I go to /admin/environment_design  
88 - And display ".categories-block .button-bar"  
89 - And I follow "Edit" within ".categories-block" 77 + Given I follow "Edit" within ".categories-block"
90 And I check "Region" 78 And I check "Region"
91 When I press "Save" 79 When I press "Save"
92 Then I should see "Bahia" 80 Then I should see "Bahia"
features/comment.feature
@@ -39,7 +39,7 @@ Feature: comment @@ -39,7 +39,7 @@ Feature: comment
39 When I press "Post comment" 39 When I press "Post comment"
40 Then I should see "Hey ho, let's go" 40 Then I should see "Hey ho, let's go"
41 41
42 - @selenium 42 + @selenium-fixme
43 Scenario: redirect to right place after comment a picture 43 Scenario: redirect to right place after comment a picture
44 Given the following files 44 Given the following files
45 | owner | file | mime | 45 | owner | file | mime |
@@ -134,4 +134,4 @@ Feature: comment @@ -134,4 +134,4 @@ Feature: comment
134 | Post one | joaosilva | Hello | Hello | 134 | Post one | joaosilva | Hello | Hello |
135 When I go to /joaosilva/forum/post-one 135 When I go to /joaosilva/forum/post-one
136 And I select "Oldest first" from "comment_order" within ".comment-order" 136 And I select "Oldest first" from "comment_order" within ".comment-order"
137 - Then I should see "Hi all" within ".article-comment"  
138 \ No newline at end of file 137 \ No newline at end of file
  138 + Then I should see "Hi all" within ".article-comment"
features/short_filename.feature
@@ -1,21 +0,0 @@ @@ -1,21 +0,0 @@
1 -Feature: sitemap  
2 - As a noosfero user  
3 - I want to list articles  
4 -  
5 - Background:  
6 - Given I am on the homepage  
7 - And the following users  
8 - | login | name |  
9 - | joaosilva | Joao Silva |  
10 - And the following files  
11 - | owner | file | mime |  
12 - | joaosilva | AGENDA_CULTURA_-_FESTA_DE_VAQUEIROS_PONTO_DE_SERRA_PRETA_BAIXA.txt | text/plain |  
13 -  
14 - Scenario: view a folder page  
15 - When I am on /profile/joaosilva/sitemap  
16 - Then I should see "AGENDA_CULTURA_-_FESTA_DE_VAQUEIRO(...).txt"  
17 -  
18 - Scenario: view the CMS  
19 - Given I am logged in as "joaosilva"  
20 - When I am on /myprofile/joaosilva/cms  
21 - Then I should see "AGENDA_CULTURA_-_FESTA_DE_VAQUEIROS_PONTO_DE_SERRA_(...).txt"  
lib/feed_handler.rb
@@ -51,7 +51,6 @@ class FeedHandler @@ -51,7 +51,6 @@ class FeedHandler
51 end 51 end
52 52
53 def process(container) 53 def process(container)
54 - RAILS_DEFAULT_LOGGER.info("Processing %s with id = %d" % [container.class.name, container.id])  
55 begin 54 begin
56 container.class.transaction do 55 container.class.transaction do
57 if container.update_errors > FeedHandler.max_errors && container.fetched_at < (Time.now - FeedHandler.disabled_period) 56 if container.update_errors > FeedHandler.max_errors && container.fetched_at < (Time.now - FeedHandler.disabled_period)
lib/file_presenter.rb
@@ -50,6 +50,10 @@ class FilePresenter @@ -50,6 +50,10 @@ class FilePresenter
50 nil 50 nil
51 end 51 end
52 52
  53 + def download?(view=nil)
  54 + false
  55 + end
  56 +
53 def short_description 57 def short_description
54 file_type = if content_type.present? 58 file_type = if content_type.present?
55 content_type.sub(/^application\//, '').sub(/^x-/, '').sub(/^image\//, '') 59 content_type.sub(/^application\//, '').sub(/^x-/, '').sub(/^image\//, '')
lib/tasks/plugins_tests.rake
@@ -25,51 +25,87 @@ def plugin_disabled_warning(plugin) @@ -25,51 +25,87 @@ def plugin_disabled_warning(plugin)
25 puts "E: you should enable #{plugin} plugin before running it's tests!" 25 puts "E: you should enable #{plugin} plugin before running it's tests!"
26 end 26 end
27 27
28 -def run_tests(name, files_glob)  
29 - files = Dir.glob(files_glob)  
30 - if files.empty?  
31 - puts "I: no tests to run (#{name})" 28 +def task2ext(task)
  29 + (task == :selenium || task == :cucumber) ? :feature : :rb
  30 +end
  31 +
  32 +def task2profile(task, plugin)
  33 + if task == :cucumber
  34 + return plugin
  35 + elsif task == :selenium
  36 + return "#{plugin}_selenium"
32 else 37 else
33 - sh 'testrb', '-Itest', *files 38 + return 'default'
34 end 39 end
35 end 40 end
36 41
37 -def run_cucumber(name, profile, files_glob)  
38 - files = Dir.glob(files_glob)  
39 - if files.empty?  
40 - puts "I: no tests to run #{name}" 42 +def filename2plugin(filename)
  43 + filename.split('/')[1]
  44 +end
  45 +
  46 +def task2folder(task)
  47 + result = case task.to_sym
  48 + when :units
  49 + :unit
  50 + when :functionals
  51 + :functional
  52 + when :integration
  53 + :integration
  54 + when :cucumber
  55 + :features
  56 + when :selenium
  57 + :features
  58 + end
  59 +
  60 + return result
  61 +end
  62 +
  63 +def run_test(name, files)
  64 + files = Array(files)
  65 + plugin = filename2plugin(files.first)
  66 + if name == :cucumber || name == :selenium
  67 + run_cucumber task2_profile(name, plugin), files
41 else 68 else
42 - sh 'xvfb-run', 'ruby', '-S', 'cucumber', '--profile', profile.to_s, '--format', ENV['CUCUMBER_FORMAT'] || 'progress' , *files 69 + run_testrb files
43 end 70 end
44 end 71 end
45 72
46 -def plugin_test_task(name, plugin, files_glob)  
47 - desc "Run #{name} tests for #{plugin_name(plugin)}"  
48 - task name => 'db:test:plugins:prepare' do |t|  
49 - if plugin_enabled?(plugin)  
50 - run_tests t.name, files_glob  
51 - else  
52 - plugin_disabled_warning(plugin) 73 +def run_testrb(files)
  74 + sh 'testrb', '-Itest', *files
  75 +end
  76 +
  77 +def run_cucumber(profile, files)
  78 + sh 'xvfb-run', 'ruby', '-S', 'cucumber', '--profile', profile.to_s, '--format', ENV['CUCUMBER_FORMAT'] || 'progress' , *files
  79 +end
  80 +
  81 +def custom_run(name, files, run=:individually)
  82 + case run
  83 + when :all
  84 + run_test name, files
  85 + when :individually
  86 + files.each do |file|
  87 + run_test name, file
53 end 88 end
  89 + when :by_plugin
54 end 90 end
55 end 91 end
56 92
57 -def plugin_cucumber_task(name, plugin, files_glob)  
58 - desc "Run #{name} tests for #{plugin_name(plugin)}"  
59 - task name => 'db:test:plugins:prepare' do |t|  
60 - if plugin_enabled?(plugin)  
61 - run_cucumber t.name, plugin, files_glob  
62 - else  
63 - plugin_disabled_warning(plugin)  
64 - end 93 +def run_tests(name, plugins, run=:individually)
  94 + plugins = Array(plugins)
  95 + glob = "plugins/{#{plugins.join(',')}}/test/#{task2folder(name)}/**/*.#{task2ext(name)}"
  96 + files = Dir.glob(glob)
  97 + if files.empty?
  98 + puts "I: no tests to run #{name}"
  99 + else
  100 + custom_run(name, files, run)
65 end 101 end
66 end 102 end
67 103
68 -def plugin_selenium_task(name, plugin, files_glob) 104 +def plugin_test_task(name, plugin, run=:individually)
69 desc "Run #{name} tests for #{plugin_name(plugin)}" 105 desc "Run #{name} tests for #{plugin_name(plugin)}"
70 task name => 'db:test:plugins:prepare' do |t| 106 task name => 'db:test:plugins:prepare' do |t|
71 if plugin_enabled?(plugin) 107 if plugin_enabled?(plugin)
72 - run_cucumber t.name, "#{plugin}_selenium", files_glob 108 + run_tests(name, plugin, run)
73 else 109 else
74 plugin_disabled_warning(plugin) 110 plugin_disabled_warning(plugin)
75 end 111 end
@@ -98,28 +134,28 @@ namespace :test do @@ -98,28 +134,28 @@ namespace :test do
98 namespace :noosfero_plugins do 134 namespace :noosfero_plugins do
99 all_plugins.each do |plugin| 135 all_plugins.each do |plugin|
100 namespace plugin do 136 namespace plugin do
101 - plugin_test_task :units, plugin, "plugins/#{plugin}/test/unit/**/*.rb"  
102 - plugin_test_task :functionals, plugin, "plugins/#{plugin}/test/functional/**/*.rb"  
103 - plugin_test_task :integration, plugin, "plugins/#{plugin}/test/integration/**/*.rb"  
104 - plugin_cucumber_task :cucumber, plugin, "plugins/#{plugin}/features/**/*.feature"  
105 - plugin_selenium_task :selenium, plugin, "plugins/#{plugin}/features/**/*.feature" 137 + plugin_test_task :units, plugin
  138 + plugin_test_task :functionals, plugin
  139 + plugin_test_task :integration, plugin
  140 + plugin_test_task :cucumber, plugin
  141 + plugin_test_task :selenium, plugin
106 end 142 end
107 143
108 test_sequence_task(plugin, plugin, "#{plugin}:units", "#{plugin}:functionals", "#{plugin}:integration", "#{plugin}:cucumber", "#{plugin}:selenium") 144 test_sequence_task(plugin, plugin, "#{plugin}:units", "#{plugin}:functionals", "#{plugin}:integration", "#{plugin}:cucumber", "#{plugin}:selenium")
109 end 145 end
110 146
111 - { :units => :unit , :functionals => :functional , :integration => :integration }.each do |taskname,folder| 147 + [:units, :functionals, :integration].each do |taskname|
112 task taskname => 'db:test:plugins:prepare' do |t| 148 task taskname => 'db:test:plugins:prepare' do |t|
113 - run_tests t.name, "plugins/{#{enabled_plugins.join(',')}}/test/#{folder}/**/*.rb" 149 + run_tests taskname, enabled_plugins
114 end 150 end
115 end 151 end
116 152
117 task :cucumber => 'db:test:plugins:prepare' do |t| 153 task :cucumber => 'db:test:plugins:prepare' do |t|
118 - run_cucumber t.name, :default, "plugins/{#{enabled_plugins.join(',')}}/test/features/**/*.features" 154 + run_tests :cucumber, enabled_plugins
119 end 155 end
120 156
121 task :selenium => 'db:test:plugins:prepare' do |t| 157 task :selenium => 'db:test:plugins:prepare' do |t|
122 - run_cucumber t.name, :selenium, "plugins/{#{enabled_plugins.join(',')}}/test/features/**/*.features" 158 + run_tests :selenium, enabled_plugins
123 end 159 end
124 160
125 task :temp_enable_all_plugins do 161 task :temp_enable_all_plugins do
plugins/anti_spam/lib/anti_spam_plugin/wrapper.rb
@@ -2,9 +2,10 @@ class AntiSpamPlugin::Wrapper &lt; SimpleDelegator @@ -2,9 +2,10 @@ class AntiSpamPlugin::Wrapper &lt; SimpleDelegator
2 include Rakismet::Model 2 include Rakismet::Model
3 3
4 @@wrappers = [] 4 @@wrappers = []
  5 + cattr_accessor :wrappers
5 6
6 def self.wrap(object) 7 def self.wrap(object)
7 - wrapper = @@wrappers.find { |wrapper| wrapper.wraps?(object) } 8 + wrapper = wrappers.find { |wrapper| wrapper.wraps?(object) }
8 wrapper ? wrapper.new(object) : object 9 wrapper ? wrapper.new(object) : object
9 end 10 end
10 11
@@ -13,6 +14,10 @@ class AntiSpamPlugin::Wrapper &lt; SimpleDelegator @@ -13,6 +14,10 @@ class AntiSpamPlugin::Wrapper &lt; SimpleDelegator
13 end 14 end
14 15
15 def self.inherited(child) 16 def self.inherited(child)
16 - @@wrappers << child 17 + wrappers << child
17 end 18 end
18 end 19 end
  20 +
  21 +Dir.glob(File.join(AntiSpamPlugin.root_path, 'lib', 'anti_spam_plugin', '*_wrapper.rb')) do |file|
  22 + load(file)
  23 +end
plugins/comment_group/test/functional/comment_group_plugin_profile_controller_test.rb
@@ -36,10 +36,10 @@ class CommentGroupPluginProfileControllerTest &lt; ActionController::TestCase @@ -36,10 +36,10 @@ class CommentGroupPluginProfileControllerTest &lt; ActionController::TestCase
36 end 36 end
37 37
38 should 'show first page comments only' do 38 should 'show first page comments only' do
39 - comment1 = fast_create(Comment, :source_id => article, :author_id => profile, :title => 'a comment', :body => 'secondpage', :group_id => 0)  
40 - comment2 = fast_create(Comment, :source_id => article, :author_id => profile, :title => 'a comment', :body => 'firstpage 1', :group_id => 0)  
41 - comment3 = fast_create(Comment, :source_id => article, :author_id => profile, :title => 'a comment', :body => 'firstpage 2', :group_id => 0)  
42 - comment4 = fast_create(Comment, :source_id => article, :author_id => profile, :title => 'a comment', :body => 'firstpage 3', :group_id => 0) 39 + comment1 = fast_create(Comment, :source_id => article, :author_id => profile, :title => 'a comment', :created_at => Time.now, :body => 'secondpage', :group_id => 0)
  40 + comment2 = fast_create(Comment, :source_id => article, :author_id => profile, :title => 'a comment', :created_at => Time.now - 1.day, :body => 'firstpage 1', :group_id => 0)
  41 + comment3 = fast_create(Comment, :source_id => article, :author_id => profile, :title => 'a comment', :created_at => Time.now - 2.days, :body => 'firstpage 2', :group_id => 0)
  42 + comment4 = fast_create(Comment, :source_id => article, :author_id => profile, :title => 'a comment', :created_at => Time.now - 3.days, :body => 'firstpage 3', :group_id => 0)
43 xhr :get, :view_comments, :profile => @profile.identifier, :article_id => article.id, :group_id => 0 43 xhr :get, :view_comments, :profile => @profile.identifier, :article_id => article.id, :group_id => 0
44 assert_match /firstpage 1/, @response.body 44 assert_match /firstpage 1/, @response.body
45 assert_match /firstpage 2/, @response.body 45 assert_match /firstpage 2/, @response.body
plugins/community_track/test/functional/community_track_plugin_content_viewer_controller_test.rb
@@ -10,7 +10,7 @@ end @@ -10,7 +10,7 @@ end
10 class ContentViewerControllerTest < ActionController::TestCase 10 class ContentViewerControllerTest < ActionController::TestCase
11 11
12 def setup 12 def setup
13 - @profile = fast_create(Community) 13 + @profile = Community.create!(:name => 'Sample community', :identifier => 'sample-community')
14 @track = create_track('track', @profile) 14 @track = create_track('track', @profile)
15 @step = CommunityTrackPlugin::Step.create!(:name => 'step1', :body => 'body', :profile => @profile, :parent => @track, :published => false, :end_date => Date.today, :start_date => Date.today, :tool_type => TinyMceArticle.name) 15 @step = CommunityTrackPlugin::Step.create!(:name => 'step1', :body => 'body', :profile => @profile, :parent => @track, :published => false, :end_date => Date.today, :start_date => Date.today, :tool_type => TinyMceArticle.name)
16 16
@@ -87,43 +87,35 @@ class ContentViewerControllerTest &lt; ActionController::TestCase @@ -87,43 +87,35 @@ class ContentViewerControllerTest &lt; ActionController::TestCase
87 end 87 end
88 88
89 should 'render a div with block id for track list block' do 89 should 'render a div with block id for track list block' do
90 - box = fast_create(Box, :owner_id => @profile.id, :owner_type => @profile.class.name)  
91 - @block = CommunityTrackPlugin::TrackListBlock.create!(:box => box)  
92 - @profile.boxes << box 90 + @block = CommunityTrackPlugin::TrackListBlock.create!(:box => @profile.boxes.last)
93 get :view_page, @step.url 91 get :view_page, @step.url
94 assert_tag :tag => 'div', :attributes => { :class => 'track_list', :id => "track_list_#{@block.id}" } 92 assert_tag :tag => 'div', :attributes => { :class => 'track_list', :id => "track_list_#{@block.id}" }
95 end 93 end
96 94
97 should 'render a div with block id for track card list block' do 95 should 'render a div with block id for track card list block' do
98 - box = fast_create(Box, :owner_id => @profile.id, :owner_type => @profile.class.name)  
99 - @block = CommunityTrackPlugin::TrackCardListBlock.create!(:box => box)  
100 - @profile.boxes << box 96 + @block = CommunityTrackPlugin::TrackCardListBlock.create!(:box => @profile.boxes.last)
101 get :view_page, @step.url 97 get :view_page, @step.url
102 assert_tag :tag => 'div', :attributes => { :class => 'track_list', :id => "track_list_#{@block.id}" } 98 assert_tag :tag => 'div', :attributes => { :class => 'track_list', :id => "track_list_#{@block.id}" }
103 end 99 end
104 100
105 should 'render tracks in track list block' do 101 should 'render tracks in track list block' do
106 - box = fast_create(Box, :owner_id => @profile.id, :owner_type => @profile.class.name)  
107 - @block = CommunityTrackPlugin::TrackListBlock.create!(:box => box)  
108 - @profile.boxes << box 102 + @block = CommunityTrackPlugin::TrackListBlock.create!(:box => @profile.boxes.last)
109 get :view_page, @step.url 103 get :view_page, @step.url
  104 + file = File.open('result.html', 'w+')
  105 + file.write(@response.body)
  106 + file.close
110 assert_tag :tag => 'div', :attributes => { :class => "item category_#{@track.category_name}" }, :descendant => { :tag => 'div', :attributes => { :class => 'steps' }, :descendant => { :tag => 'span', :attributes => { :class => "step #{@block.status_class(@step)}" } } } 107 assert_tag :tag => 'div', :attributes => { :class => "item category_#{@track.category_name}" }, :descendant => { :tag => 'div', :attributes => { :class => 'steps' }, :descendant => { :tag => 'span', :attributes => { :class => "step #{@block.status_class(@step)}" } } }
111 end 108 end
112 109
113 should 'render tracks in track card list block' do 110 should 'render tracks in track card list block' do
114 - box = fast_create(Box, :owner_id => @profile.id, :owner_type => @profile.class.name)  
115 - @block = CommunityTrackPlugin::TrackCardListBlock.create!(:box => box)  
116 - @profile.boxes << box 111 + @block = CommunityTrackPlugin::TrackCardListBlock.create!(:box => @profile.boxes.last)
117 get :view_page, @step.url 112 get :view_page, @step.url
118 assert_tag :tag => 'div', :attributes => { :class => "item_card category_#{@track.category_name}" }, :descendant => { :tag => 'div', :attributes => { :class => 'track_content' } } 113 assert_tag :tag => 'div', :attributes => { :class => "item_card category_#{@track.category_name}" }, :descendant => { :tag => 'div', :attributes => { :class => 'track_content' } }
119 assert_tag :tag => 'div', :attributes => { :class => "item_card category_#{@track.category_name}" }, :descendant => { :tag => 'div', :attributes => { :class => 'track_stats' } } 114 assert_tag :tag => 'div', :attributes => { :class => "item_card category_#{@track.category_name}" }, :descendant => { :tag => 'div', :attributes => { :class => 'track_stats' } }
120 end 115 end
121 116
122 should 'render link to display more tracks in track list block' do 117 should 'render link to display more tracks in track list block' do
123 - box = fast_create(Box, :owner_id => @profile.id, :owner_type => @profile.class.name)  
124 - @block = CommunityTrackPlugin::TrackCardListBlock.create!(:box => box)  
125 - @profile.boxes << box  
126 - 118 + @block = CommunityTrackPlugin::TrackCardListBlock.create!(:box => @profile.boxes.last)
127 (@block.limit+1).times { |i| create_track("track#{i}", @profile) } 119 (@block.limit+1).times { |i| create_track("track#{i}", @profile) }
128 120
129 get :view_page, @step.url 121 get :view_page, @step.url
@@ -131,9 +123,7 @@ class ContentViewerControllerTest &lt; ActionController::TestCase @@ -131,9 +123,7 @@ class ContentViewerControllerTest &lt; ActionController::TestCase
131 end 123 end
132 124
133 should 'render link to show all tracks in track list block' do 125 should 'render link to show all tracks in track list block' do
134 - box = fast_create(Box, :owner_id => @profile.id, :owner_type => @profile.class.name)  
135 - @block = CommunityTrackPlugin::TrackCardListBlock.create!(:box => box)  
136 - @profile.boxes << box 126 + @block = CommunityTrackPlugin::TrackCardListBlock.create!(:box => @profile.boxes.last)
137 @block.more_another_page = true 127 @block.more_another_page = true
138 @block.save! 128 @block.save!
139 129
plugins/recent_content/test/unit/recent_content_block_test.rb
@@ -61,9 +61,9 @@ class RecentContentBlockTest &lt; ActiveSupport::TestCase @@ -61,9 +61,9 @@ class RecentContentBlockTest &lt; ActiveSupport::TestCase
61 61
62 root = fast_create(Blog, :name => 'test-blog', :profile_id => profile.id) 62 root = fast_create(Blog, :name => 'test-blog', :profile_id => profile.id)
63 63
64 - a1 = fast_create(TextileArticle, :name => 'article #1', :profile_id => profile.id, :parent_id => root.id)  
65 - a2 = fast_create(TextileArticle, :name => 'article #2', :profile_id => profile.id, :parent_id => root.id)  
66 - a3 = fast_create(TextileArticle, :name => 'article #3', :profile_id => profile.id, :parent_id => root.id) 64 + a1 = fast_create(TextileArticle, :name => 'article #1', :profile_id => profile.id, :parent_id => root.id, :created_at => Time.now - 2.days)
  65 + a2 = fast_create(TextileArticle, :name => 'article #2', :profile_id => profile.id, :parent_id => root.id, :created_at => Time.now - 1.days)
  66 + a3 = fast_create(TextileArticle, :name => 'article #3', :profile_id => profile.id, :parent_id => root.id, :created_at => Time.now)
67 67
68 block = RecentContentBlock.new 68 block = RecentContentBlock.new
69 block.stubs(:holder).returns(profile) 69 block.stubs(:holder).returns(profile)
test/functional/content_viewer_controller_test.rb
@@ -72,9 +72,7 @@ class ContentViewerControllerTest &lt; ActionController::TestCase @@ -72,9 +72,7 @@ class ContentViewerControllerTest &lt; ActionController::TestCase
72 get :view_page, :profile => 'someone', :page => [ '500.html' ] 72 get :view_page, :profile => 'someone', :page => [ '500.html' ]
73 73
74 assert_response :success 74 assert_response :success
75 - assert_match /^text\/html/, @response.headers['Content-Type']  
76 - assert @response.headers['Content-Disposition'].present?  
77 - assert_match /attachment/, @response.headers['Content-Disposition'] 75 + assert_match /#{html.public_filename}/, @response.body
78 end 76 end
79 77
80 should 'produce a download-link when article is not text/html' do 78 should 'produce a download-link when article is not text/html' do
@@ -577,14 +575,6 @@ class ContentViewerControllerTest &lt; ActionController::TestCase @@ -577,14 +575,6 @@ class ContentViewerControllerTest &lt; ActionController::TestCase
577 assert_template 'view_page' 575 assert_template 'view_page'
578 end 576 end
579 577
580 - should 'download data for image when not view' do  
581 - file = UploadedFile.create!(:uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :profile => profile)  
582 - get :view_page, :profile => profile.identifier, :page => file.explode_path  
583 -  
584 - assert_response :success  
585 - assert_template nil  
586 - end  
587 -  
588 should "display 'Upload files' when create children of image gallery" do 578 should "display 'Upload files' when create children of image gallery" do
589 login_as(profile.identifier) 579 login_as(profile.identifier)
590 f = Gallery.create!(:name => 'gallery', :profile => profile) 580 f = Gallery.create!(:name => 'gallery', :profile => profile)
@@ -1360,8 +1350,23 @@ class ContentViewerControllerTest &lt; ActionController::TestCase @@ -1360,8 +1350,23 @@ class ContentViewerControllerTest &lt; ActionController::TestCase
1360 1350
1361 should 'display link to download of non-recognized file types on its page' do 1351 should 'display link to download of non-recognized file types on its page' do
1362 file = UploadedFile.create!(:uploaded_data => fixture_file_upload('/files/test.txt', 'bin/unknown'), :profile => profile) 1352 file = UploadedFile.create!(:uploaded_data => fixture_file_upload('/files/test.txt', 'bin/unknown'), :profile => profile)
1363 - get :view_page, file.url.merge(:view=>:true)  
1364 - assert_match /this is a sample text file/, @response.body 1353 + get :view_page, file.url
  1354 + assert_match /#{file.public_filename}/, @response.body
  1355 + end
  1356 +
  1357 + should 'not count hit from bots' do
  1358 + article = fast_create(Article, :profile_id => profile.id)
  1359 + assert_no_difference article, :hits do
  1360 + @request.env['HTTP_USER_AGENT'] = 'bot'
  1361 + get 'view_page', :profile => profile.identifier, :page => article.path.split('/')
  1362 + @request.env['HTTP_USER_AGENT'] = 'spider'
  1363 + get 'view_page', :profile => profile.identifier, :page => article.path.split('/')
  1364 + @request.env['HTTP_USER_AGENT'] = 'crawler'
  1365 + get 'view_page', :profile => profile.identifier, :page => article.path.split('/')
  1366 + @request.env['HTTP_USER_AGENT'] = '(http://some-crawler.com)'
  1367 + get 'view_page', :profile => profile.identifier, :page => article.path.split('/')
  1368 + article.reload
  1369 + end
1365 end 1370 end
1366 1371
1367 should 'add meta tags with article info' do 1372 should 'add meta tags with article info' do
test/functional/events_controller_test.rb
@@ -46,4 +46,12 @@ class EventsControllerTest &lt; ActionController::TestCase @@ -46,4 +46,12 @@ class EventsControllerTest &lt; ActionController::TestCase
46 assert_equal 20, assigns(:events).count 46 assert_equal 20, assigns(:events).count
47 end 47 end
48 48
  49 + should 'show events of specific day' do
  50 + profile.events << Event.new(:name => 'Joao Birthday', :start_date => Date.new(2009, 10, 28))
  51 +
  52 + get :events_by_day, :profile => profile.identifier, :year => 2009, :month => 10, :day => 28
  53 +
  54 + assert_tag :tag => 'a', :content => /Joao Birthday/
  55 + end
  56 +
49 end 57 end
test/functional/search_controller_test.rb
@@ -373,7 +373,7 @@ class SearchControllerTest &lt; ActionController::TestCase @@ -373,7 +373,7 @@ class SearchControllerTest &lt; ActionController::TestCase
373 end 373 end
374 374
375 should 'see the events paginated' do 375 should 'see the events paginated' do
376 - person = create_user('pagination').person 376 + person = create_user('testuser').person
377 30.times do |i| 377 30.times do |i|
378 create_event(person, :name => "Event #{i}", :start_date => Date.today) 378 create_event(person, :name => "Event #{i}", :start_date => Date.today)
379 end 379 end
test/unit/profile_test.rb
@@ -363,7 +363,7 @@ class ProfileTest &lt; ActiveSupport::TestCase @@ -363,7 +363,7 @@ class ProfileTest &lt; ActiveSupport::TestCase
363 t2 = c.tasks.build; t2.save!; t2.finish 363 t2 = c.tasks.build; t2.save!; t2.finish
364 t3 = c.tasks.build; t3.save!; t3.finish 364 t3 = c.tasks.build; t3.save!; t3.finish
365 365
366 - assert_equal [t2, t3], c.tasks.finished 366 + assert_equivalent [t2, t3], c.tasks.finished
367 end 367 end
368 368
369 should 'responds to categories' do 369 should 'responds to categories' do
test/unit/tags_helper_test.rb
@@ -20,12 +20,14 @@ class TagsHelperTest &lt; ActiveSupport::TestCase @@ -20,12 +20,14 @@ class TagsHelperTest &lt; ActiveSupport::TestCase
20 20
21 should 'order tags alphabetically with special characters' do 21 should 'order tags alphabetically with special characters' do
22 result = tag_cloud( 22 result = tag_cloud(
23 - { 'aula'=>9, 'área'=>2, 'area'=>2, 'avião'=>2, 'armário'=>2,  
24 - 'A'=>1, 'Á'=>1, 'AB'=>1, 'ÁA'=>1 }, 23 + { 'area'=>9, 'área'=>2, 'base'=>2, 'báse' => 3,
  24 + 'A'=>1, 'Á'=>1, 'zebra'=>1, 'zebrá'=>1 },
25 :id, 25 :id,
26 { :host=>'noosfero.org', :controller=>'test', :action=>'tag' } 26 { :host=>'noosfero.org', :controller=>'test', :action=>'tag' }
27 ) 27 )
28 - assert_equal %w(A Á ÁA AB area área armário aula avião).join("\n"), result 28 + result = result.split("\n")
  29 + assert_order ['Á', 'área', 'báse', 'zebrá'], result
  30 + assert_order ['A', 'area', 'base', 'zebra'], result
29 end 31 end
30 32
31 end 33 end
test/unit/uploaded_file_test.rb
@@ -324,13 +324,11 @@ class UploadedFileTest &lt; ActiveSupport::TestCase @@ -324,13 +324,11 @@ class UploadedFileTest &lt; ActiveSupport::TestCase
324 should 'group trackers activity of image\'s upload' do 324 should 'group trackers activity of image\'s upload' do
325 ActionTracker::Record.delete_all 325 ActionTracker::Record.delete_all
326 gallery = fast_create(Gallery, :profile_id => profile.id) 326 gallery = fast_create(Gallery, :profile_id => profile.id)
327 - count = ActionTracker::Record.find_all_by_verb('upload_image').count  
328 image1 = UploadedFile.create!(:uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :parent => gallery, :profile => profile) 327 image1 = UploadedFile.create!(:uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :parent => gallery, :profile => profile)
329 - count += 1  
330 - assert_equal count, ActionTracker::Record.find_all_by_verb('upload_image').count 328 + assert_equal 1, ActionTracker::Record.find_all_by_verb('upload_image').count
331 329
332 image2 = UploadedFile.create!(:uploaded_data => fixture_file_upload('/files/other-pic.jpg', 'image/jpg'), :parent => gallery, :profile => profile) 330 image2 = UploadedFile.create!(:uploaded_data => fixture_file_upload('/files/other-pic.jpg', 'image/jpg'), :parent => gallery, :profile => profile)
333 - assert_equal count, ActionTracker::Record.find_all_by_verb('upload_image').count 331 + assert_equal 1, ActionTracker::Record.find_all_by_verb('upload_image').count
334 end 332 end
335 333
336 { 334 {