fix errors related to filter tests
This commit is contained in:
parent
bffab7564d
commit
22e207c9cc
|
|
@ -156,7 +156,7 @@ class ApiSearchController < ApiController
|
|||
sobj = MusicianSearch.user_search_filter(current_user)
|
||||
@search = sobj.search_results_page(filter_params, page, user_ids)
|
||||
|
||||
respond_with @search, responder: ApiResponder, status: 201, template: 'api_search/index'
|
||||
respond_with @search, responder: ApiResponder, status: 201, template: 'api_search/filter'
|
||||
|
||||
rescue => exception
|
||||
logger.debug("Latency exception: #{exception.message}")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,81 @@
|
|||
object @search
|
||||
|
||||
node :page_count do |foo|
|
||||
@search.page_count
|
||||
end
|
||||
|
||||
node :my_audio_latency do |user|
|
||||
current_user.last_jam_audio_latency.round if current_user.last_jam_audio_latency
|
||||
end
|
||||
|
||||
node :filter_json do |foo|
|
||||
@search.to_json
|
||||
end
|
||||
|
||||
# node :description do |foo|
|
||||
# @search.description
|
||||
# end
|
||||
|
||||
node :is_blank_filter do |foo|
|
||||
@search.is_blank?
|
||||
end
|
||||
|
||||
child(:results => :musicians) {
|
||||
attributes :id, :first_name, :last_name, :name, :city, :state, :country, :online, :musician, :photo_url, :biography, :regionname, :score, :full_score
|
||||
|
||||
node :is_friend do |musician|
|
||||
@search.is_friend?(musician)
|
||||
end
|
||||
|
||||
node :is_following do |musician|
|
||||
@search.is_follower?(musician)
|
||||
end
|
||||
|
||||
node :pending_friend_request do |musician|
|
||||
musician.pending_friend_request?(current_user)
|
||||
end
|
||||
|
||||
node :biography do |musician|
|
||||
musician.biography.nil? ? "" : musician.biography
|
||||
end
|
||||
|
||||
child :musician_instruments => :instruments do
|
||||
attributes :instrument_id, :description, :proficiency_level, :priority
|
||||
end
|
||||
|
||||
child :top_followings => :followings do |uf|
|
||||
node :user_id do |uu| uu.id end
|
||||
node :photo_url do |uu| uu.photo_url end
|
||||
node :name do |uu| uu.name end
|
||||
end
|
||||
|
||||
node :friend_count do |musician| @search.friend_count(musician) end
|
||||
node :follow_count do |musician| @search.follow_count(musician) end
|
||||
node :recording_count do |musician| @search.record_count(musician) end
|
||||
node :session_count do |musician| @search.session_count(musician) end
|
||||
|
||||
node :audio_latency do |musician|
|
||||
last_jam_audio_latency(musician)
|
||||
end
|
||||
|
||||
node :latency_data do |musician|
|
||||
|
||||
if latency = @latency_data.detect{|l_data| l_data[:user_id] == musician.id }
|
||||
{
|
||||
audio_latency: latency[:audio_latency],
|
||||
ars_internet_latency: latency[:ars_internet_latency],
|
||||
ars_total_latency: latency[:ars_total_latency]
|
||||
}
|
||||
end if @latency_data
|
||||
end
|
||||
|
||||
node :last_active_timestamp do |musician|
|
||||
if musician.updated_at || musician.last_jam_updated_at
|
||||
[musician.updated_at, musician.last_jam_updated_at].compact.max.to_i
|
||||
end
|
||||
end
|
||||
|
||||
child :genres => :genres do
|
||||
attributes :genre_id, :description
|
||||
end
|
||||
}
|
||||
|
|
@ -15,9 +15,9 @@ if @search.is_a?(BaseSearch)
|
|||
end
|
||||
|
||||
if @search.is_a? MusicianSearch
|
||||
node :description do |foo|
|
||||
@search.description
|
||||
end
|
||||
# node :description do |foo|
|
||||
# @search.description
|
||||
# end
|
||||
|
||||
node :is_blank_filter do |foo|
|
||||
@search.is_blank?
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ describe ApiSearchController, type: :controller do
|
|||
|
||||
response.should be_success
|
||||
expect(response.content_type).to eq("application/json")
|
||||
expect(response).to render_template(:index)
|
||||
expect(response).to render_template(:filter)
|
||||
expect(response).to have_http_status(:created)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ describe "Musician Filter API", type: :request do
|
|||
it "filter GOOD latency users" do
|
||||
post '/api/filter.json', { latency_good: true, latency_fair: false, latency_high: false }
|
||||
expect(response.content_type).to eq("application/json")
|
||||
expect(response).to render_template(:index)
|
||||
expect(response).to render_template(:filter)
|
||||
expect(response).to have_http_status(:created)
|
||||
expect(JSON.parse(response.body)["musicians"].size).to eq(2)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue