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 50 end
51 51  
52 52 # At this point the page will be showed
53   - @page.hit
  53 + @page.hit unless user_is_a_bot?
54 54  
55 55 @page = FilePresenter.for @page
56 56  
... ... @@ -183,4 +183,13 @@ class ContentViewerController < ApplicationController
183 183 allowed
184 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 195 end
... ...
app/controllers/public/events_controller.rb
... ... @@ -21,7 +21,7 @@ class EventsController < PublicController
21 21  
22 22 def events_by_day
23 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 25 render :partial => 'events'
26 26 end
27 27  
... ...
features/balloon.feature
... ... @@ -8,6 +8,7 @@ Feature: balloon
8 8 And the following communities
9 9 | identifier | name |
10 10 | sample | Sample |
  11 + And I am logged in as "joaosilva"
11 12  
12 13 @selenium
13 14 Scenario: I should not see trigger if not enabled
... ...
features/categories_block.feature
... ... @@ -24,16 +24,12 @@ Feature: categories_block
24 24 | owner | type |
25 25 | environment | CategoriesBlock |
26 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 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 33 And I check "Product"
38 34 When I press "Save"
39 35 Then I should see "Food"
... ... @@ -42,11 +38,9 @@ Feature: categories_block
42 38 And "Steak" should not be visible within "span#category-name"
43 39 And "Fiction" should not be visible within "span#category-name"
44 40  
45   - @selenium @ignore-hidden-elements
  41 + @selenium
46 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 44 And I check "Product"
51 45 And I press "Save"
52 46 Then I should see "Food"
... ... @@ -61,11 +55,9 @@ Feature: categories_block
61 55 And I should see "Steak"
62 56 And I should not see "Fiction"
63 57  
64   - @selenium @ignore-hidden-elements
  58 + @selenium
65 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 61 And I check "Product"
70 62 And I press "Save"
71 63 Then I should see "Book"
... ... @@ -73,20 +65,16 @@ Feature: categories_block
73 65 When I follow "block_2_category_2"
74 66 Then I should see "Literature"
75 67  
76   - @selenium @ignore-hidden-elements
  68 + @selenium
77 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 71 And I check "Generic category"
82 72 When I press "Save"
83 73 Then I should see "Wood"
84 74  
85   - @selenium @ignore-hidden-elements
  75 + @selenium
86 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 78 And I check "Region"
91 79 When I press "Save"
92 80 Then I should see "Bahia"
... ...
features/comment.feature
... ... @@ -39,7 +39,7 @@ Feature: comment
39 39 When I press "Post comment"
40 40 Then I should see "Hey ho, let's go"
41 41  
42   - @selenium
  42 + @selenium-fixme
43 43 Scenario: redirect to right place after comment a picture
44 44 Given the following files
45 45 | owner | file | mime |
... ... @@ -134,4 +134,4 @@ Feature: comment
134 134 | Post one | joaosilva | Hello | Hello |
135 135 When I go to /joaosilva/forum/post-one
136 136 And I select "Oldest first" from "comment_order" within ".comment-order"
137   - Then I should see "Hi all" within ".article-comment"
138 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   -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 51 end
52 52  
53 53 def process(container)
54   - RAILS_DEFAULT_LOGGER.info("Processing %s with id = %d" % [container.class.name, container.id])
55 54 begin
56 55 container.class.transaction do
57 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 50 nil
51 51 end
52 52  
  53 + def download?(view=nil)
  54 + false
  55 + end
  56 +
53 57 def short_description
54 58 file_type = if content_type.present?
55 59 content_type.sub(/^application\//, '').sub(/^x-/, '').sub(/^image\//, '')
... ...
lib/tasks/plugins_tests.rake
... ... @@ -25,51 +25,87 @@ def plugin_disabled_warning(plugin)
25 25 puts "E: you should enable #{plugin} plugin before running it's tests!"
26 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 37 else
33   - sh 'testrb', '-Itest', *files
  38 + return 'default'
34 39 end
35 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 68 else
42   - sh 'xvfb-run', 'ruby', '-S', 'cucumber', '--profile', profile.to_s, '--format', ENV['CUCUMBER_FORMAT'] || 'progress' , *files
  69 + run_testrb files
43 70 end
44 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 88 end
  89 + when :by_plugin
54 90 end
55 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 101 end
66 102 end
67 103  
68   -def plugin_selenium_task(name, plugin, files_glob)
  104 +def plugin_test_task(name, plugin, run=:individually)
69 105 desc "Run #{name} tests for #{plugin_name(plugin)}"
70 106 task name => 'db:test:plugins:prepare' do |t|
71 107 if plugin_enabled?(plugin)
72   - run_cucumber t.name, "#{plugin}_selenium", files_glob
  108 + run_tests(name, plugin, run)
73 109 else
74 110 plugin_disabled_warning(plugin)
75 111 end
... ... @@ -98,28 +134,28 @@ namespace :test do
98 134 namespace :noosfero_plugins do
99 135 all_plugins.each do |plugin|
100 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 142 end
107 143  
108 144 test_sequence_task(plugin, plugin, "#{plugin}:units", "#{plugin}:functionals", "#{plugin}:integration", "#{plugin}:cucumber", "#{plugin}:selenium")
109 145 end
110 146  
111   - { :units => :unit , :functionals => :functional , :integration => :integration }.each do |taskname,folder|
  147 + [:units, :functionals, :integration].each do |taskname|
112 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 150 end
115 151 end
116 152  
117 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 155 end
120 156  
121 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 159 end
124 160  
125 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 2 include Rakismet::Model
3 3  
4 4 @@wrappers = []
  5 + cattr_accessor :wrappers
5 6  
6 7 def self.wrap(object)
7   - wrapper = @@wrappers.find { |wrapper| wrapper.wraps?(object) }
  8 + wrapper = wrappers.find { |wrapper| wrapper.wraps?(object) }
8 9 wrapper ? wrapper.new(object) : object
9 10 end
10 11  
... ... @@ -13,6 +14,10 @@ class AntiSpamPlugin::Wrapper &lt; SimpleDelegator
13 14 end
14 15  
15 16 def self.inherited(child)
16   - @@wrappers << child
  17 + wrappers << child
17 18 end
18 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 36 end
37 37  
38 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 43 xhr :get, :view_comments, :profile => @profile.identifier, :article_id => article.id, :group_id => 0
44 44 assert_match /firstpage 1/, @response.body
45 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 10 class ContentViewerControllerTest < ActionController::TestCase
11 11  
12 12 def setup
13   - @profile = fast_create(Community)
  13 + @profile = Community.create!(:name => 'Sample community', :identifier => 'sample-community')
14 14 @track = create_track('track', @profile)
15 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 87 end
88 88  
89 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 91 get :view_page, @step.url
94 92 assert_tag :tag => 'div', :attributes => { :class => 'track_list', :id => "track_list_#{@block.id}" }
95 93 end
96 94  
97 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 97 get :view_page, @step.url
102 98 assert_tag :tag => 'div', :attributes => { :class => 'track_list', :id => "track_list_#{@block.id}" }
103 99 end
104 100  
105 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 103 get :view_page, @step.url
  104 + file = File.open('result.html', 'w+')
  105 + file.write(@response.body)
  106 + file.close
110 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 108 end
112 109  
113 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 112 get :view_page, @step.url
118 113 assert_tag :tag => 'div', :attributes => { :class => "item_card category_#{@track.category_name}" }, :descendant => { :tag => 'div', :attributes => { :class => 'track_content' } }
119 114 assert_tag :tag => 'div', :attributes => { :class => "item_card category_#{@track.category_name}" }, :descendant => { :tag => 'div', :attributes => { :class => 'track_stats' } }
120 115 end
121 116  
122 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 119 (@block.limit+1).times { |i| create_track("track#{i}", @profile) }
128 120  
129 121 get :view_page, @step.url
... ... @@ -131,9 +123,7 @@ class ContentViewerControllerTest &lt; ActionController::TestCase
131 123 end
132 124  
133 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 127 @block.more_another_page = true
138 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 61  
62 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 68 block = RecentContentBlock.new
69 69 block.stubs(:holder).returns(profile)
... ...
test/functional/content_viewer_controller_test.rb
... ... @@ -72,9 +72,7 @@ class ContentViewerControllerTest &lt; ActionController::TestCase
72 72 get :view_page, :profile => 'someone', :page => [ '500.html' ]
73 73  
74 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 76 end
79 77  
80 78 should 'produce a download-link when article is not text/html' do
... ... @@ -577,14 +575,6 @@ class ContentViewerControllerTest &lt; ActionController::TestCase
577 575 assert_template 'view_page'
578 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 578 should "display 'Upload files' when create children of image gallery" do
589 579 login_as(profile.identifier)
590 580 f = Gallery.create!(:name => 'gallery', :profile => profile)
... ... @@ -1360,8 +1350,23 @@ class ContentViewerControllerTest &lt; ActionController::TestCase
1360 1350  
1361 1351 should 'display link to download of non-recognized file types on its page' do
1362 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 1370 end
1366 1371  
1367 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 46 assert_equal 20, assigns(:events).count
47 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 57 end
... ...
test/functional/search_controller_test.rb
... ... @@ -373,7 +373,7 @@ class SearchControllerTest &lt; ActionController::TestCase
373 373 end
374 374  
375 375 should 'see the events paginated' do
376   - person = create_user('pagination').person
  376 + person = create_user('testuser').person
377 377 30.times do |i|
378 378 create_event(person, :name => "Event #{i}", :start_date => Date.today)
379 379 end
... ...
test/unit/profile_test.rb
... ... @@ -363,7 +363,7 @@ class ProfileTest &lt; ActiveSupport::TestCase
363 363 t2 = c.tasks.build; t2.save!; t2.finish
364 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 367 end
368 368  
369 369 should 'responds to categories' do
... ...
test/unit/tags_helper_test.rb
... ... @@ -20,12 +20,14 @@ class TagsHelperTest &lt; ActiveSupport::TestCase
20 20  
21 21 should 'order tags alphabetically with special characters' do
22 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 25 :id,
26 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 31 end
30 32  
31 33 end
... ...
test/unit/uploaded_file_test.rb
... ... @@ -324,13 +324,11 @@ class UploadedFileTest &lt; ActiveSupport::TestCase
324 324 should 'group trackers activity of image\'s upload' do
325 325 ActionTracker::Record.delete_all
326 326 gallery = fast_create(Gallery, :profile_id => profile.id)
327   - count = ActionTracker::Record.find_all_by_verb('upload_image').count
328 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 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 332 end
335 333  
336 334 {
... ...