Commit 66ec5b45594482074ba649bd1f31b88eabd597b0
1 parent
7170c4c4
Exists in
master
and in
29 other branches
rails3: fix functional tests
Showing
11 changed files
with
32 additions
and
38 deletions
Show diff stats
app/controllers/embed_controller.rb
@@ -4,10 +4,10 @@ class EmbedController < ApplicationController | @@ -4,10 +4,10 @@ class EmbedController < ApplicationController | ||
4 | def block | 4 | def block |
5 | @block = Block.find(params[:id]) | 5 | @block = Block.find(params[:id]) |
6 | if !@block.embedable? || !@block.visible? | 6 | if !@block.embedable? || !@block.visible? |
7 | - render 'unavailable.rhtml', :status => 403 | 7 | + render 'unavailable', :status => 403 |
8 | end | 8 | end |
9 | rescue ActiveRecord::RecordNotFound | 9 | rescue ActiveRecord::RecordNotFound |
10 | - render 'not_found.rhtml', :status => 404 | 10 | + render 'not_found', :status => 404 |
11 | end | 11 | end |
12 | 12 | ||
13 | end | 13 | end |
app/helpers/categories_helper.rb
@@ -50,8 +50,9 @@ module CategoriesHelper | @@ -50,8 +50,9 @@ module CategoriesHelper | ||
50 | 50 | ||
51 | #FIXME make this test | 51 | #FIXME make this test |
52 | def selected_category_link(cat) | 52 | def selected_category_link(cat) |
53 | - content_tag('div', button_to_function_without_text(:remove, _('Remove'), nil) {|page| page["selected-category-#{cat.id}"].remove} + | ||
54 | - link_to_function(cat.full_name(' → '), nil, :id => "remove-selected-category-#{cat.id}-button", :class => 'select-subcategory-link') {|page| page["selected-category-#{cat.id}"].remove}, | 53 | + js_remove = j("jQuery('#selected-category-#{cat.id}').remove();") |
54 | + content_tag('div', button_to_function_without_text(:remove, _('Remove'), js_remove) + | ||
55 | + link_to_function(cat.full_name(' → '), js_remove, :id => "remove-selected-category-#{cat.id}-button", :class => 'select-subcategory-link'), | ||
55 | :class => 'selected-category' | 56 | :class => 'selected-category' |
56 | ) | 57 | ) |
57 | end | 58 | end |
app/models/block.rb
1 | class Block < ActiveRecord::Base | 1 | class Block < ActiveRecord::Base |
2 | 2 | ||
3 | - attr_accessible :title, :display, :limit, :box_id, :posts_per_page, :visualization_format, :language | 3 | + attr_accessible :title, :display, :limit, :box_id, :posts_per_page, :visualization_format, :language, :display_user |
4 | 4 | ||
5 | # to be able to generate HTML | 5 | # to be able to generate HTML |
6 | include ActionView::Helpers::UrlHelper | 6 | include ActionView::Helpers::UrlHelper |
@@ -24,7 +24,7 @@ class Block < ActiveRecord::Base | @@ -24,7 +24,7 @@ class Block < ActiveRecord::Base | ||
24 | 24 | ||
25 | def embed_code | 25 | def embed_code |
26 | me = self | 26 | me = self |
27 | - lambda do | 27 | + proc do |
28 | content_tag('iframe', '', | 28 | content_tag('iframe', '', |
29 | :src => url_for(:controller => 'embed', :action => 'block', :id => me.id, :only_path => false), | 29 | :src => url_for(:controller => 'embed', :action => 'block', :id => me.id, :only_path => false), |
30 | :frameborder => 0, | 30 | :frameborder => 0, |
@@ -214,9 +214,9 @@ class Block < ActiveRecord::Base | @@ -214,9 +214,9 @@ class Block < ActiveRecord::Base | ||
214 | 214 | ||
215 | def display_user_options | 215 | def display_user_options |
216 | @display_user_options ||= { | 216 | @display_user_options ||= { |
217 | - 'all' => __('All users'), | ||
218 | - 'logged' => __('Logged'), | ||
219 | - 'not_logged' => __('Not logged'), | 217 | + 'all' => _('All users'), |
218 | + 'logged' => _('Logged'), | ||
219 | + 'not_logged' => _('Not logged'), | ||
220 | } | 220 | } |
221 | end | 221 | end |
222 | 222 |
app/views/shared/_select_subcategories.html.erb
@@ -7,7 +7,7 @@ | @@ -7,7 +7,7 @@ | ||
7 | <%= link_to_remote category.name, | 7 | <%= link_to_remote category.name, |
8 | { :update => "select-categories", | 8 | { :update => "select-categories", |
9 | :url => { :action => "update_categories", :category_id => category.id, :id => @object}, | 9 | :url => { :action => "update_categories", :category_id => category.id, :id => @object}, |
10 | - :loaded => visual_effect(:highlight, "select-categories") | 10 | + :loaded => j(visual_effect(:highlight, "select-categories")) |
11 | }, | 11 | }, |
12 | :class => 'select-subcategory-link', | 12 | :class => 'select-subcategory-link', |
13 | :id => "select-category-#{category.id}-link" | 13 | :id => "select-category-#{category.id}-link" |
app/views/users/_users_list.html.erb
1 | <div class="environment-users-results-header"> | 1 | <div class="environment-users-results-header"> |
2 | - <div id='environment-users-filter-title'><%= filter_title(@filter) %></div> | 2 | + <div id='environment-users-filter-title'><%= users_filter_title(@filter) %></div> |
3 | <%= filter_selector(@filter) %> | 3 | <%= filter_selector(@filter) %> |
4 | <div style="clear: both"></div> | 4 | <div style="clear: both"></div> |
5 | </div> | 5 | </div> |
lib/noosfero/plugin.rb
@@ -18,7 +18,7 @@ class Noosfero::Plugin | @@ -18,7 +18,7 @@ class Noosfero::Plugin | ||
18 | 18 | ||
19 | def initialize! | 19 | def initialize! |
20 | return if !should_load | 20 | return if !should_load |
21 | - enabled.each do |plugin_dir| | 21 | + available_plugins.each do |plugin_dir| |
22 | plugin_name = File.basename(plugin_dir) | 22 | plugin_name = File.basename(plugin_dir) |
23 | plugin = load_plugin(plugin_name) | 23 | plugin = load_plugin(plugin_name) |
24 | load_plugin_extensions(plugin_dir) | 24 | load_plugin_extensions(plugin_dir) |
@@ -28,7 +28,7 @@ class Noosfero::Plugin | @@ -28,7 +28,7 @@ class Noosfero::Plugin | ||
28 | 28 | ||
29 | def setup(config) | 29 | def setup(config) |
30 | return if !should_load | 30 | return if !should_load |
31 | - enabled.each do |dir| | 31 | + available_plugins.each do |dir| |
32 | setup_plugin(dir, config) | 32 | setup_plugin(dir, config) |
33 | end | 33 | end |
34 | end | 34 | end |
@@ -102,26 +102,19 @@ class Noosfero::Plugin | @@ -102,26 +102,19 @@ class Noosfero::Plugin | ||
102 | end | 102 | end |
103 | end | 103 | end |
104 | 104 | ||
105 | - def enabled | ||
106 | - @enabled ||= | ||
107 | - begin | ||
108 | - plugins = Dir.glob(Rails.root.join('config', 'plugins', '*')) | ||
109 | - if Rails.env.test? && !plugins.include?(Rails.root.join('config', 'plugins', 'foo')) | ||
110 | - plugins << Rails.root.join('plugins', 'foo') | ||
111 | - end | ||
112 | - plugins.select do |entry| | ||
113 | - File.directory?(entry) | ||
114 | - end | 105 | + def available_plugins |
106 | + unless @available_plugins | ||
107 | + path = File.join(Rails.root, 'config', 'plugins', '*') | ||
108 | + @available_plugins = Dir.glob(path).select{ |i| File.directory?(i) } | ||
109 | + if Rails.env.test? && !@available_plugins.include?(File.join(Rails.root, 'config', 'plugins', 'foo')) | ||
110 | + @available_plugins << File.join(Rails.root, 'plugins', 'foo') | ||
115 | end | 111 | end |
112 | + end | ||
113 | + @available_plugins | ||
116 | end | 114 | end |
117 | 115 | ||
118 | - | ||
119 | def all | 116 | def all |
120 | - @all ||= [] | ||
121 | - end | ||
122 | - | ||
123 | - def inherited(subclass) | ||
124 | - all << subclass.to_s unless all.include?(subclass.to_s) | 117 | + @all ||= available_plugins.map{ |dir| (File.basename(dir) + "_plugin").camelize } |
125 | end | 118 | end |
126 | 119 | ||
127 | def public_name | 120 | def public_name |
test/functional/content_viewer_controller_test.rb
@@ -1356,7 +1356,7 @@ class ContentViewerControllerTest < ActionController::TestCase | @@ -1356,7 +1356,7 @@ class ContentViewerControllerTest < ActionController::TestCase | ||
1356 | 1356 | ||
1357 | should 'not count hit from bots' do | 1357 | should 'not count hit from bots' do |
1358 | article = fast_create(Article, :profile_id => profile.id) | 1358 | article = fast_create(Article, :profile_id => profile.id) |
1359 | - assert_no_difference article, :hits do | 1359 | + assert_no_difference 'article.hits' do |
1360 | @request.env['HTTP_USER_AGENT'] = 'bot' | 1360 | @request.env['HTTP_USER_AGENT'] = 'bot' |
1361 | get 'view_page', :profile => profile.identifier, :page => article.path.split('/') | 1361 | get 'view_page', :profile => profile.identifier, :page => article.path.split('/') |
1362 | @request.env['HTTP_USER_AGENT'] = 'spider' | 1362 | @request.env['HTTP_USER_AGENT'] = 'spider' |
test/functional/environment_design_controller_test.rb
@@ -373,7 +373,7 @@ class EnvironmentDesignControllerTest < ActionController::TestCase | @@ -373,7 +373,7 @@ class EnvironmentDesignControllerTest < ActionController::TestCase | ||
373 | should 'clone a block' do | 373 | should 'clone a block' do |
374 | login_as(create_admin_user(Environment.default)) | 374 | login_as(create_admin_user(Environment.default)) |
375 | block = TagsBlock.create! | 375 | block = TagsBlock.create! |
376 | - assert_difference TagsBlock, :count, 1 do | 376 | + assert_difference 'TagsBlock.count', 1 do |
377 | post :clone_block, :id => block.id | 377 | post :clone_block, :id => block.id |
378 | assert_response :redirect | 378 | assert_response :redirect |
379 | end | 379 | end |
test/functional/events_controller_test.rb
@@ -43,7 +43,7 @@ class EventsControllerTest < ActionController::TestCase | @@ -43,7 +43,7 @@ class EventsControllerTest < ActionController::TestCase | ||
43 | profile.events << Event.new(:name => "Lesson #{i}", :start_date => Date.today) | 43 | profile.events << Event.new(:name => "Lesson #{i}", :start_date => Date.today) |
44 | end | 44 | end |
45 | get :events, :profile => profile.identifier | 45 | get :events, :profile => profile.identifier |
46 | - assert_equal 20, assigns(:events).count | 46 | + assert_equal 20, assigns(:events).size |
47 | end | 47 | end |
48 | 48 | ||
49 | should 'show events of specific day' do | 49 | should 'show events of specific day' do |
test/functional/search_controller_test.rb
@@ -382,7 +382,7 @@ class SearchControllerTest < ActionController::TestCase | @@ -382,7 +382,7 @@ class SearchControllerTest < ActionController::TestCase | ||
382 | create_event(person, :name => "Event #{i}", :start_date => Date.today) | 382 | create_event(person, :name => "Event #{i}", :start_date => Date.today) |
383 | end | 383 | end |
384 | get :events | 384 | get :events |
385 | - assert_equal 20, assigns(:events).count | 385 | + assert_equal 20, assigns(:events).size |
386 | end | 386 | end |
387 | 387 | ||
388 | %w[ people enterprises articles events communities products ].each do |asset| | 388 | %w[ people enterprises articles events communities products ].each do |asset| |
@@ -564,9 +564,9 @@ class SearchControllerTest < ActionController::TestCase | @@ -564,9 +564,9 @@ class SearchControllerTest < ActionController::TestCase | ||
564 | c2 = create(Community, :name => 'Testing community 2') | 564 | c2 = create(Community, :name => 'Testing community 2') |
565 | c3 = create(Community, :name => 'Testing community 3') | 565 | c3 = create(Community, :name => 'Testing community 3') |
566 | ActionTracker::Record.delete_all | 566 | ActionTracker::Record.delete_all |
567 | - ActionTracker::Record.create!(:target => c1, :user => person, :created_at => Time.now, :verb => 'leave_scrap') | ||
568 | - ActionTracker::Record.create!(:target => c2, :user => person, :created_at => Time.now, :verb => 'leave_scrap') | ||
569 | - ActionTracker::Record.create!(:target => c2, :user => person, :created_at => Time.now, :verb => 'leave_scrap') | 567 | + create(ActionTracker::Record, :target => c1, :user => person, :created_at => Time.now, :verb => 'leave_scrap') |
568 | + create(ActionTracker::Record, :target => c2, :user => person, :created_at => Time.now, :verb => 'leave_scrap') | ||
569 | + create(ActionTracker::Record, :target => c2, :user => person, :created_at => Time.now, :verb => 'leave_scrap') | ||
570 | get :communities, :filter => 'more_active' | 570 | get :communities, :filter => 'more_active' |
571 | assert_equal [c2,c1,c3] , assigns(:searches)[:communities][:results] | 571 | assert_equal [c2,c1,c3] , assigns(:searches)[:communities][:results] |
572 | end | 572 | end |
test/functional/users_controller_test.rb
@@ -135,7 +135,7 @@ class UsersControllerTest < ActionController::TestCase | @@ -135,7 +135,7 @@ class UsersControllerTest < ActionController::TestCase | ||
135 | 135 | ||
136 | should 'be able to remove a person' do | 136 | should 'be able to remove a person' do |
137 | person = fast_create(Person, :environment_id => environment.id) | 137 | person = fast_create(Person, :environment_id => environment.id) |
138 | - assert_difference Person, :count, -1 do | 138 | + assert_difference 'Person.count', -1 do |
139 | post :destroy_user, :id => person.id | 139 | post :destroy_user, :id => person.id |
140 | end | 140 | end |
141 | end | 141 | end |
@@ -143,7 +143,7 @@ class UsersControllerTest < ActionController::TestCase | @@ -143,7 +143,7 @@ class UsersControllerTest < ActionController::TestCase | ||
143 | should 'not crash if user does not exist' do | 143 | should 'not crash if user does not exist' do |
144 | person = fast_create(Person) | 144 | person = fast_create(Person) |
145 | 145 | ||
146 | - assert_no_difference Person, :count do | 146 | + assert_no_difference 'Person.count' do |
147 | post :destroy_user, :id => 99999 | 147 | post :destroy_user, :id => 99999 |
148 | end | 148 | end |
149 | assert_redirected_to :action => 'index' | 149 | assert_redirected_to :action => 'index' |