Skip to content

Instantly share code, notes, and snippets.

@maletor
Created January 10, 2011 21:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save maletor/1171c4e2954b93ae01ab to your computer and use it in GitHub Desktop.
Save maletor/1171c4e2954b93ae01ab to your computer and use it in GitHub Desktop.
1) Error:
test_can_call_search_with_search_results_for_text(VideosControllerTest):
FakeWeb::NetConnectNotAllowedError: Real HTTP connections are disabled. Unregistered request: GET http://api.brightcove.com/services/library?token=0Z2dtxTdJAxtbZ-d0U7Bhio2V1Rhr5Iafl5FFtDPY8E.&page_size=16&all=doritos%20combine&page_number=0&get_item_count=true&command=search_videos
app/controllers/application_controller.rb:32:in `call_brightcove'
app/controllers/application_controller.rb:31:in `call_brightcove'
app/controllers/videos_controller.rb:48:in `search'
/test/functional/videos_controller_test.rb:135:in `test_can_call_search_with_search_results_for_text'
test "can call search with search results for text" do
FakeWeb.register_uri(:get,
'http://api.brightcove.com/services/library?text=doritos%20combine&page_number=0&token=0Z2dtxTdJAxtbZ-d0U7Bhio2V1Rhr5Iafl5FFtDPY8E.&page_size=16&command=find_videos_by_text&get_item_count=true',
:body => File.join(File.dirname(__FILE__), 'fakeweb', 'find_videos_by_text_response.json'),
:content_type => "application/json")
FakeWeb.register_uri(:get,
'http://api.brightcove.com/services/library?playlist_id=275170418001&token=0Z2dtxTdJAxtbZ-d0U7Bhio2V1Rhr5Iafl5FFtDPY8E.&command=find_playlist_by_id',
:body => File.join(File.dirname(__FILE__), 'fakeweb', 'find_playlist_by_id_response.json'),
:content_type => "application/json")
playlist = Factory.create(:playlist, :name => 'Featured', :external_id => 275170418001)
get :search, :q => 'doritos combine'
assert_equal "max-age=#{CACHE_CONTROL_EXPIRATION}, public", @response.headers["Cache-Control"]
assert_response :success
assert assigns(:featured_playlist)
assert assigns(:featured_playlist_information)
assert assigns(:playlist_search_results)
assert_equal 5, @controller.instance_variable_get(:@featured_playlist_information)['videos'].size
assert_equal 12, @controller.instance_variable_get(:@playlist_search_results)['items'].size
end
def search
if params[:q].nil? || params[:q].empty? || params[:q] == "Enter Search Term"
redirect_to :action => :latest and return
end
sanitize_page_number_for_brightcove
if params[:q].include?(',') || !params[:tag_search].blank?
search_tags = params[:q].split(',').collect{ |item| item.strip }.select{ |item| !item.blank? }
@playlist_search_results = call_brightcove('find_videos_by_tags', {:sort_by => 'PUBLISH_DATE', :sort_order => 'DESC', :and_tags => search_tags.join(','), :page_size => APPLICATION_CONFIGURATION[:default_page_size_search], :page_number => @page_number, :get_item_count => true})
else
@playlist_search_results = call_brightcove('search_videos', {:all => params[:q], :page_size => APPLICATION_CONFIGURATION[:default_page_size_search], :page_number => @page_number, :get_item_count => true})
end
unless @playlist_search_results.nil?
@paginated_search_results = @playlist_search_results['items'].paginate(:page => @page_number + 1, :per_page => APPLICATION_CONFIGURATION[:default_page_size_search], :total_entries => @playlist_search_results['total_count'])
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment