diff options
| author | mo khan <mo@mokhan.ca> | 2016-05-03 12:26:37 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2016-05-03 12:26:37 -0600 |
| commit | c9b35df01922631815d79afb6bf496d40dfd932f (patch) | |
| tree | 1888dae00b621447571fa97740750afdfa8b7c74 /spec/controllers | |
| parent | 882a106a9730778fa9bdf3e634097a674ced47e2 (diff) | |
allow adding new gyms by searching the yelp api.
Diffstat (limited to 'spec/controllers')
| -rw-r--r-- | spec/controllers/gyms_controller_spec.rb | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/spec/controllers/gyms_controller_spec.rb b/spec/controllers/gyms_controller_spec.rb index cbfe366..77dcd15 100644 --- a/spec/controllers/gyms_controller_spec.rb +++ b/spec/controllers/gyms_controller_spec.rb @@ -2,14 +2,16 @@ require 'rails_helper' describe GymsController do let(:user) { create(:user) } + let(:user_session) { create(:user_session, location: portland, user: user) } + let(:portland) { create(:portland) } before :each do - http_login(user) + http_login(user, user_session) end describe "#index" do - let!(:sait) { create(:gym, name: 'sait') } - let!(:world_health) { create(:gym, name: 'world health') } + let!(:sait) { create(:gym, name: 'sait', location: create(:portland)) } + let!(:world_health) { create(:gym, name: 'world health', location: create(:portland)) } it 'returns a list of gyms' do get :index @@ -24,6 +26,17 @@ describe GymsController do expect(assigns(:gyms)).to match_array([sait]) expect(response).to be_ok end + + it 'returns matches from yelp' do + yelp_gym = double + allow(Gym).to receive(:search_yelp). + with(term: 'sait', city: portland.city). + and_return([yelp_gym]) + get :index, q: 'sait', source: 'yelp' + + expect(assigns(:gyms)).to match_array([yelp_gym]) + expect(response).to be_ok + end end describe "#new" do |
