Commit c3c5d2d13d0cbe1cd88d3a6343a0d2c135db5ca4

Authored by Victor Costa
1 parent 5f40b80d
Exists in staging and in 1 other branch production

Revert "api: accept order param in search endpoint"

This reverts commit 2027742cb860eb3a9dacfb1cb25224abcc415dd2.
lib/noosfero/api/v1/search.rb
@@ -19,14 +19,10 @@ module Noosfero @@ -19,14 +19,10 @@ module Noosfero
19 scope = scope.where(make_conditions_with_parameter(params)) 19 scope = scope.where(make_conditions_with_parameter(params))
20 scope = scope.joins(:categories).where(:categories => {:id => params[:category_ids]}) if params[:category_ids].present? 20 scope = scope.joins(:categories).where(:categories => {:id => params[:category_ids]}) if params[:category_ids].present?
21 scope = scope.where('articles.children_count > 0') if params[:has_children].present? 21 scope = scope.where('articles.children_count > 0') if params[:has_children].present?
22 -  
23 - order = make_order_with_parameters(profile || environment, :articles, params)  
24 - scope = scope.reorder(order)  
25 -  
26 query = params[:query] || "" 22 query = params[:query] || ""
27 - search_order = "more_recent" 23 + order = "more_recent"
28 24
29 - options = {:filter => search_order, :template_id => params[:template_id]} 25 + options = {:filter => order, :template_id => params[:template_id]}
30 26
31 search_result = find_by_contents(asset, context, scope, query, {:page => 1}, options) 27 search_result = find_by_contents(asset, context, scope, query, {:page => 1}, options)
32 28
test/api/search_test.rb
@@ -155,12 +155,4 @@ class SearchTest < ActiveSupport::TestCase @@ -155,12 +155,4 @@ class SearchTest < ActiveSupport::TestCase
155 assert_equal [article2.id], json['articles'].map {|a| a['id']} 155 assert_equal [article2.id], json['articles'].map {|a| a['id']}
156 end 156 end
157 157
158 - should 'list articles with order' do  
159 - article1 = fast_create(Article, :profile_id => person.id, created_at: Time.now - 1.day)  
160 - article2 = fast_create(Article, :profile_id => person.id, created_at: Time.now)  
161 - params = {order: 'created_at DESC'}  
162 - get "/api/v1/search/article?#{params.to_query}"  
163 - json = JSON.parse(last_response.body)  
164 - assert_equal [article2.id, article1.id], json['articles'].map {|a| a['id']}  
165 - end  
166 end 158 end