Commit d6340a1464f256f73285a68f0f12d768cc89638e
1 parent
92d8b7be
Exists in
master
and in
20 other branches
rails4: fix plugins tests
Showing
9 changed files
with
26 additions
and
19 deletions
Show diff stats
plugins/analytics/lib/analytics_plugin/base.rb
| ... | ... | @@ -27,9 +27,7 @@ class AnalyticsPlugin::Base < Noosfero::Plugin |
| 27 | 27 | request_started_at: request_started_at, request_finished_at: request_finished_at |
| 28 | 28 | |
| 29 | 29 | unless profile.analytics_anonymous? |
| 30 | - # FIXME: use session.id in Rails 4 | |
| 31 | - session_id = Marshal.load(Base64.decode64 request['_session_id'])['session_id'] rescue nil | |
| 32 | - #session_id = request.session_options[:id] | |
| 30 | + session_id = session.id | |
| 33 | 31 | page_view.user = user |
| 34 | 32 | page_view.session_id = session_id |
| 35 | 33 | end | ... | ... |
plugins/analytics/test/functional/content_viewer_controller_test.rb
| ... | ... | @@ -24,7 +24,7 @@ class ContentViewerControllerTest < ActionController::TestCase |
| 24 | 24 | |
| 25 | 25 | should 'register page view correctly' do |
| 26 | 26 | @request.env['HTTP_REFERER'] = 'http://google.com' |
| 27 | - first_url = 'http://test.host' | |
| 27 | + first_url = 'http://test.host/testcomm' | |
| 28 | 28 | get :view_page, profile: @community.identifier, page: [] |
| 29 | 29 | assert_equal 1, @community.page_views.count |
| 30 | 30 | assert_equal 1, @community.visits.count | ... | ... |
plugins/recent_content/lib/recent_content_block.rb
plugins/relevant_content/lib/ext/article.rb
| ... | ... | @@ -16,7 +16,7 @@ class Article |
| 16 | 16 | |
| 17 | 17 | def self.most_commented_relevant_content(owner, limit) |
| 18 | 18 | conditions = owner.kind_of?(Environment) ? ["comments_count > 0"] : ["profile_id = ? and comments_count > 0", owner.id] |
| 19 | - result = Article.relevant_content.all.order('comments_count desc').limit(limit).where(conditions) | |
| 19 | + result = Article.relevant_content.order('comments_count desc').limit(limit).where(conditions) | |
| 20 | 20 | result.paginate({:page => 1, :per_page => limit}) |
| 21 | 21 | end |
| 22 | 22 | ... | ... |
plugins/shopping_cart/controllers/shopping_cart_plugin_controller.rb
| ... | ... | @@ -303,11 +303,13 @@ class ShoppingCartPluginController < PublicController |
| 303 | 303 | after_filter :save_cookie |
| 304 | 304 | def save_cookie |
| 305 | 305 | if @cart.nil? |
| 306 | - cookies.delete(cookie_key, :path => '/plugin/shopping_cart') | |
| 306 | + # cookie.delete does not work, set to empty value | |
| 307 | + cookies[cookie_key] = {value: '', path: '/plugin/shopping_cart', expires: Time.at(0)} | |
| 307 | 308 | else |
| 308 | 309 | cookies[cookie_key] = { |
| 309 | - :value => Base64.encode64(@cart.to_yaml), | |
| 310 | - :path => "/plugin/shopping_cart" | |
| 310 | + value: Base64.encode64(@cart.to_yaml), | |
| 311 | + path: "/plugin/shopping_cart", | |
| 312 | + expires: Time.at(0), | |
| 311 | 313 | } |
| 312 | 314 | end |
| 313 | 315 | end | ... | ... |
plugins/shopping_cart/lib/shopping_cart_plugin/purchase_order.rb
| ... | ... | @@ -9,7 +9,7 @@ class ShoppingCartPlugin::PurchaseOrder < ActiveRecord::Base |
| 9 | 9 | |
| 10 | 10 | acts_as_having_settings :field => :data |
| 11 | 11 | |
| 12 | - settings_items :products_list, :type => Array, :default => {} | |
| 12 | + settings_items :products_list, :type => Hash, :default => {} | |
| 13 | 13 | settings_items :customer_name, :type => String |
| 14 | 14 | settings_items :customer_email, :type => String |
| 15 | 15 | settings_items :customer_contact_phone, :type => String | ... | ... |
plugins/shopping_cart/test/functional/shopping_cart_plugin_controller_test.rb
| ... | ... | @@ -15,8 +15,12 @@ class ShoppingCartPluginControllerTest < ActionController::TestCase |
| 15 | 15 | attr_reader :product |
| 16 | 16 | |
| 17 | 17 | should 'force cookie expiration with explicit path for an empty cart' do |
| 18 | - get :get | |
| 19 | - assert @response.headers['Set-Cookie'] =~ /_noosfero_plugin_shopping_cart=; path=\/plugin\/shopping_cart; expires=.*-1970/ | |
| 18 | + get :get, id: product.id | |
| 19 | + assert @response.headers['Set-Cookie'] =~ /_noosfero_plugin_shopping_cart=; path=\/plugin\/shopping_cart; expires=.*1970.*/ | |
| 20 | + | |
| 21 | + get :add, id: product.id | |
| 22 | + get :remove, id: product.id | |
| 23 | + assert @response.headers['Set-Cookie'] =~ /_noosfero_plugin_shopping_cart=; path=\/plugin\/shopping_cart; expires=.*1970.*/ | |
| 20 | 24 | end |
| 21 | 25 | |
| 22 | 26 | should 'add a new product to cart' do | ... | ... |
plugins/sniffer/controllers/sniffer_plugin_myprofile_controller.rb
| ... | ... | @@ -109,7 +109,7 @@ class SnifferPluginMyprofileController < MyProfileController |
| 109 | 109 | profiles = Profile.all :conditions => {:id => products.map { |p| target_profile_id(p) }} |
| 110 | 110 | profiles_by_id = {} |
| 111 | 111 | profiles.each do |p| |
| 112 | - p[:sniffer_plugin_distance] = distance_between_profiles(@profile, p) | |
| 112 | + p.sniffer_plugin_distance = distance_between_profiles(@profile, p) | |
| 113 | 113 | profiles_by_id[p.id] ||= p |
| 114 | 114 | end |
| 115 | 115 | profiles_by_id | ... | ... |
plugins/sniffer/test/integration/sniffer_map_test.rb
| ... | ... | @@ -95,8 +95,9 @@ class SnifferMapTest < ActionDispatch::IntegrationTest |
| 95 | 95 | assert_response 200 |
| 96 | 96 | assert_tag :tag => 'a', :attributes => { :href => '/profile/ent2'}, :content => @e[2].name |
| 97 | 97 | assert_tag :tag => 'a', :attributes => { :href => url_for(@p[3].url) }, :content => @p[3].name |
| 98 | - assert_select '.consumer-products', nil, 'consumer-products must to exist' | |
| 99 | - assert_select '.consumer-products *', 0, 'consumer-products must to be empty for @c1 on @e2' | |
| 98 | + doc = Nokogiri::HTML @response.body | |
| 99 | + assert_select doc, '.consumer-products', nil, 'consumer-products must to exist' | |
| 100 | + assert_select doc, '.consumer-products *', 0, 'consumer-products must to be empty for @c1 on @e2' | |
| 100 | 101 | end |
| 101 | 102 | |
| 102 | 103 | should 'create balloon on map for a consumer' do |
| ... | ... | @@ -114,8 +115,9 @@ class SnifferMapTest < ActionDispatch::IntegrationTest |
| 114 | 115 | assert_response 200 |
| 115 | 116 | assert_tag :tag => 'a', :attributes => { :href => '/profile/ent4'}, :content => @e[4].name |
| 116 | 117 | assert_tag :tag => 'a', :attributes => { :href => url_for(@p[2].url) }, :content => @p[2].name |
| 117 | - assert_select '.suppliers-products', nil, 'suppliers-products must to exist' | |
| 118 | - assert_select '.suppliers-products *', 0, 'suppliers-products must to be empty for @c2 on @e4' | |
| 118 | + doc = Nokogiri::HTML @response.body | |
| 119 | + assert_select doc, '.suppliers-products', nil, 'suppliers-products must to exist' | |
| 120 | + assert_select doc, '.suppliers-products *', 0, 'suppliers-products must to be empty for @c2 on @e4' | |
| 119 | 121 | end |
| 120 | 122 | |
| 121 | 123 | should 'create balloon on map for a supplier and consumer' do |
| ... | ... | @@ -138,9 +140,10 @@ class SnifferMapTest < ActionDispatch::IntegrationTest |
| 138 | 140 | } |
| 139 | 141 | assert_response 200 |
| 140 | 142 | assert_tag :tag => 'a', :attributes => { :href => '/profile/ent3'}, :content => @e[3].name |
| 141 | - assert_select ".suppliers-products a[href=#{url_for(@p[6].url)}]", @p[6].name, | |
| 143 | + doc = Nokogiri::HTML @response.body | |
| 144 | + assert_select doc, ".suppliers-products a[href=#{url_for(@p[6].url)}]", @p[6].name, | |
| 142 | 145 | "Can't find link to @p6 (#{@p[6].name})." |
| 143 | - assert_select ".consumer-products a[href=#{url_for(@p[2].url)}]", @p[2].name, | |
| 146 | + assert_select doc, ".consumer-products a[href=#{url_for(@p[2].url)}]", @p[2].name, | |
| 144 | 147 | "Can't find link to @p2 (#{@p[2].name})." |
| 145 | 148 | end |
| 146 | 149 | ... | ... |