From c47d2aed69edf1c507bca445be6862d9ffbafee4 Mon Sep 17 00:00:00 2001 From: Seth Call Date: Sun, 13 Jan 2013 22:51:15 -0600 Subject: [PATCH] * VRFS-217 making sure REST API is stil the same --- Gemfile | 1 - app/controllers/api_users_controller.rb | 2 +- config/application.rb | 6 ------ config/initializers/tire.rb | 16 ---------------- spec/requests/search_api_spec.rb | 24 +++++++----------------- 5 files changed, 8 insertions(+), 41 deletions(-) delete mode 100644 config/initializers/tire.rb diff --git a/Gemfile b/Gemfile index d4147ede1..285e27dce 100644 --- a/Gemfile +++ b/Gemfile @@ -36,7 +36,6 @@ gem 'gon' # for passthrough of Ruby variables to Javascript variables gem 'eventmachine', '1.0.0' gem 'amqp', '0.9.8' gem 'logging-rails', :require => 'logging/rails' -gem 'tire', '0.5.1' gem 'omniauth', '1.1.1' gem 'omniauth-facebook', '1.4.1' gem 'fb_graph', '2.5.9' diff --git a/app/controllers/api_users_controller.rb b/app/controllers/api_users_controller.rb index 6e6239f72..92d7e924d 100644 --- a/app/controllers/api_users_controller.rb +++ b/app/controllers/api_users_controller.rb @@ -73,7 +73,7 @@ class ApiUsersController < ApiController end def delete - @user.destroy # required to make 'tire' integration work + @user.destroy respond_with responder: ApiResponder, :status => 204 end diff --git a/config/application.rb b/config/application.rb index f72fe8c7c..cad01c184 100644 --- a/config/application.rb +++ b/config/application.rb @@ -73,12 +73,6 @@ module SampleApp config.rabbitmq_host = "localhost" config.rabbitmq_port = 5672 - # where is elasticsearch? - config.elasticsearch_uri = "http://localhost:9200" - # or 'verify' or 'none'. 'autorepair will automatically rebuild the elasticsearch index on startup of rails, - # if an inconsistency is detected' - config.elasticsearch_verify_mode = "autorepair" - # API key for filepicker.io gem config.filepicker_rails.api_key = "AhUoVoBZSLirP3esyCl7Zz" diff --git a/config/initializers/tire.rb b/config/initializers/tire.rb deleted file mode 100644 index 7bc8c9ef5..000000000 --- a/config/initializers/tire.rb +++ /dev/null @@ -1,16 +0,0 @@ -Tire.configure do - logger Rails.root + "log/tire_#{Rails.env}.log" - url Rails.application.config.elasticsearch_uri -end - -User.create_search_index unless User.search_index.exists? -Band.create_search_index unless Band.search_index.exists? - -# Verify elasticsearch integrity -if Rails.application.config.elasticsearch_verify_mode == "autorepair" - unless TireTasks.verify - TireTasks.rebuild_indexes - end -elsif Rails.application.config.elasticsearch_verify_mode == "verify" - TireTasks.verify -end \ No newline at end of file diff --git a/spec/requests/search_api_spec.rb b/spec/requests/search_api_spec.rb index 690fa75fb..b7db88af6 100644 --- a/spec/requests/search_api_spec.rb +++ b/spec/requests/search_api_spec.rb @@ -9,11 +9,6 @@ describe "Search API", :type => :api do let(:user) { FactoryGirl.create(:user) } before(:each) do - Band.delete_search_index - Band.create_search_index - User.delete_search_index - User.create_search_index - post '/sessions', "session[email]" => user.email, "session[password]" => user.password rack_mock_session.cookie_jar["remember_token"].should == user.remember_token end @@ -25,16 +20,11 @@ describe "Search API", :type => :api do end it "simple search" do - User.delete_search_index # so that the user created before the test and logged in doesn't show up - User.create_search_index @musician = FactoryGirl.create(:user, first_name: "Peach", last_name: "Nothing", email: "user@example.com", musician: true) @fan = FactoryGirl.create(:user, first_name: "Peach Peach", last_name: "Grovery", email: "fan@example.com", musician: false) @band = Band.save(nil, "Peach pit", "www.bands.com", "zomg we rock", "Apex", "NC", "USA", ["hip hop"], user.id, nil, nil) @band2 = Band.save(nil, "Peach", "www.bands2.com", "zomg we rock", "Apex", "NC", "USA", ["hip hop"], user.id, nil, nil) - User.search_index.refresh - Band.search_index.refresh - - + get '/api/search.json?query=peach' last_response.status.should == 200 response = JSON.parse(last_response.body) @@ -48,13 +38,13 @@ describe "Search API", :type => :api do fan["id"].should == @fan.id response["bands"].length.should == 2 - band = response["bands"][0] - band["id"].should == @band2.id - band = response["bands"][1] - band["id"].should == @band.id - + bands = response["bands"] + bands = [bands[0]["id"], bands[1]["id"]] + bands.should include(@band.id) + bands.should include(@band2.id) + response["recordings"].length.should == 0 - band = response["recordings"][0] + recording = response["recordings"][0] end end end