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 | 4 | def block |
5 | 5 | @block = Block.find(params[:id]) |
6 | 6 | if !@block.embedable? || !@block.visible? |
7 | - render 'unavailable.rhtml', :status => 403 | |
7 | + render 'unavailable', :status => 403 | |
8 | 8 | end |
9 | 9 | rescue ActiveRecord::RecordNotFound |
10 | - render 'not_found.rhtml', :status => 404 | |
10 | + render 'not_found', :status => 404 | |
11 | 11 | end |
12 | 12 | |
13 | 13 | end | ... | ... |
app/helpers/categories_helper.rb
... | ... | @@ -50,8 +50,9 @@ module CategoriesHelper |
50 | 50 | |
51 | 51 | #FIXME make this test |
52 | 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 | 56 | :class => 'selected-category' |
56 | 57 | ) |
57 | 58 | end | ... | ... |
app/models/block.rb
1 | 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 | 5 | # to be able to generate HTML |
6 | 6 | include ActionView::Helpers::UrlHelper |
... | ... | @@ -24,7 +24,7 @@ class Block < ActiveRecord::Base |
24 | 24 | |
25 | 25 | def embed_code |
26 | 26 | me = self |
27 | - lambda do | |
27 | + proc do | |
28 | 28 | content_tag('iframe', '', |
29 | 29 | :src => url_for(:controller => 'embed', :action => 'block', :id => me.id, :only_path => false), |
30 | 30 | :frameborder => 0, |
... | ... | @@ -214,9 +214,9 @@ class Block < ActiveRecord::Base |
214 | 214 | |
215 | 215 | def display_user_options |
216 | 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 | 221 | end |
222 | 222 | ... | ... |
app/views/shared/_select_subcategories.html.erb
... | ... | @@ -7,7 +7,7 @@ |
7 | 7 | <%= link_to_remote category.name, |
8 | 8 | { :update => "select-categories", |
9 | 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 | 12 | :class => 'select-subcategory-link', |
13 | 13 | :id => "select-category-#{category.id}-link" | ... | ... |
app/views/users/_users_list.html.erb
1 | 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 | 3 | <%= filter_selector(@filter) %> |
4 | 4 | <div style="clear: both"></div> |
5 | 5 | </div> | ... | ... |
lib/noosfero/plugin.rb
... | ... | @@ -18,7 +18,7 @@ class Noosfero::Plugin |
18 | 18 | |
19 | 19 | def initialize! |
20 | 20 | return if !should_load |
21 | - enabled.each do |plugin_dir| | |
21 | + available_plugins.each do |plugin_dir| | |
22 | 22 | plugin_name = File.basename(plugin_dir) |
23 | 23 | plugin = load_plugin(plugin_name) |
24 | 24 | load_plugin_extensions(plugin_dir) |
... | ... | @@ -28,7 +28,7 @@ class Noosfero::Plugin |
28 | 28 | |
29 | 29 | def setup(config) |
30 | 30 | return if !should_load |
31 | - enabled.each do |dir| | |
31 | + available_plugins.each do |dir| | |
32 | 32 | setup_plugin(dir, config) |
33 | 33 | end |
34 | 34 | end |
... | ... | @@ -102,26 +102,19 @@ class Noosfero::Plugin |
102 | 102 | end |
103 | 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 | 111 | end |
112 | + end | |
113 | + @available_plugins | |
116 | 114 | end |
117 | 115 | |
118 | - | |
119 | 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 | 118 | end |
126 | 119 | |
127 | 120 | def public_name | ... | ... |
test/functional/content_viewer_controller_test.rb
... | ... | @@ -1356,7 +1356,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
1356 | 1356 | |
1357 | 1357 | should 'not count hit from bots' do |
1358 | 1358 | article = fast_create(Article, :profile_id => profile.id) |
1359 | - assert_no_difference article, :hits do | |
1359 | + assert_no_difference 'article.hits' do | |
1360 | 1360 | @request.env['HTTP_USER_AGENT'] = 'bot' |
1361 | 1361 | get 'view_page', :profile => profile.identifier, :page => article.path.split('/') |
1362 | 1362 | @request.env['HTTP_USER_AGENT'] = 'spider' | ... | ... |
test/functional/environment_design_controller_test.rb
... | ... | @@ -373,7 +373,7 @@ class EnvironmentDesignControllerTest < ActionController::TestCase |
373 | 373 | should 'clone a block' do |
374 | 374 | login_as(create_admin_user(Environment.default)) |
375 | 375 | block = TagsBlock.create! |
376 | - assert_difference TagsBlock, :count, 1 do | |
376 | + assert_difference 'TagsBlock.count', 1 do | |
377 | 377 | post :clone_block, :id => block.id |
378 | 378 | assert_response :redirect |
379 | 379 | end | ... | ... |
test/functional/events_controller_test.rb
... | ... | @@ -43,7 +43,7 @@ class EventsControllerTest < ActionController::TestCase |
43 | 43 | profile.events << Event.new(:name => "Lesson #{i}", :start_date => Date.today) |
44 | 44 | end |
45 | 45 | get :events, :profile => profile.identifier |
46 | - assert_equal 20, assigns(:events).count | |
46 | + assert_equal 20, assigns(:events).size | |
47 | 47 | end |
48 | 48 | |
49 | 49 | should 'show events of specific day' do | ... | ... |
test/functional/search_controller_test.rb
... | ... | @@ -382,7 +382,7 @@ class SearchControllerTest < ActionController::TestCase |
382 | 382 | create_event(person, :name => "Event #{i}", :start_date => Date.today) |
383 | 383 | end |
384 | 384 | get :events |
385 | - assert_equal 20, assigns(:events).count | |
385 | + assert_equal 20, assigns(:events).size | |
386 | 386 | end |
387 | 387 | |
388 | 388 | %w[ people enterprises articles events communities products ].each do |asset| |
... | ... | @@ -564,9 +564,9 @@ class SearchControllerTest < ActionController::TestCase |
564 | 564 | c2 = create(Community, :name => 'Testing community 2') |
565 | 565 | c3 = create(Community, :name => 'Testing community 3') |
566 | 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 | 570 | get :communities, :filter => 'more_active' |
571 | 571 | assert_equal [c2,c1,c3] , assigns(:searches)[:communities][:results] |
572 | 572 | end | ... | ... |
test/functional/users_controller_test.rb
... | ... | @@ -135,7 +135,7 @@ class UsersControllerTest < ActionController::TestCase |
135 | 135 | |
136 | 136 | should 'be able to remove a person' do |
137 | 137 | person = fast_create(Person, :environment_id => environment.id) |
138 | - assert_difference Person, :count, -1 do | |
138 | + assert_difference 'Person.count', -1 do | |
139 | 139 | post :destroy_user, :id => person.id |
140 | 140 | end |
141 | 141 | end |
... | ... | @@ -143,7 +143,7 @@ class UsersControllerTest < ActionController::TestCase |
143 | 143 | should 'not crash if user does not exist' do |
144 | 144 | person = fast_create(Person) |
145 | 145 | |
146 | - assert_no_difference Person, :count do | |
146 | + assert_no_difference 'Person.count' do | |
147 | 147 | post :destroy_user, :id => 99999 |
148 | 148 | end |
149 | 149 | assert_redirected_to :action => 'index' | ... | ... |