summaryrefslogtreecommitdiff
path: root/spec/controllers
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2016-05-28 08:38:43 -0600
committermo khan <mo@mokhan.ca>2016-05-28 08:38:43 -0600
commit8be0dbbbafecb2065b2dbbb161dd6f31fe51ceb8 (patch)
tree3911765c72e06fe7401735f009985a8888e293d7 /spec/controllers
parentcd79878b91a6b2bffde89cf34774b62a0e4dbc62 (diff)
update gyms#create to create a gym using the yelp id.
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/gyms_controller_spec.rb22
-rw-r--r--spec/controllers/profiles_controller_spec.rb5
2 files changed, 24 insertions, 3 deletions
diff --git a/spec/controllers/gyms_controller_spec.rb b/spec/controllers/gyms_controller_spec.rb
index 34df58c..d3cac2f 100644
--- a/spec/controllers/gyms_controller_spec.rb
+++ b/spec/controllers/gyms_controller_spec.rb
@@ -82,6 +82,28 @@ describe GymsController do
expect(gym.location.country).to eql("CA")
expect(gym.location.postal_code).to eql("T2M 0L4")
end
+
+ end
+
+ context "with the yelp id" do
+ render_views
+
+ let(:yelp_id) { 'sait-campus-centre-calgary'}
+ let(:gym) { build(:gym, yelp_id: yelp_id) }
+
+ before :each do
+ allow(Gym).to receive(:create_from_yelp!).
+ with(yelp_id).
+ and_return(gym)
+ end
+
+ it 'returns a json response' do
+ xhr :post, :create, yelp_id: yelp_id
+ json = JSON.parse(response.body)
+ expect(json['yelp_id']).to eql(yelp_id)
+ expect(json['name']).to eql(gym.name)
+ expect(json['full_address']).to eql(gym.full_address)
+ end
end
context "invalid params" do
diff --git a/spec/controllers/profiles_controller_spec.rb b/spec/controllers/profiles_controller_spec.rb
index 0c9e57a..bc9d66d 100644
--- a/spec/controllers/profiles_controller_spec.rb
+++ b/spec/controllers/profiles_controller_spec.rb
@@ -52,11 +52,10 @@ describe ProfilesController do
end
it 'saves the users home gym' do
- gym = create(:gym, yelp_id: 'sait-campus-centre-calgary')
+ gym = create(:gym)
patch :update, id: user.to_param,
- profile: { time_zone: 'Alaska' },
- home_gym_yelp_id: gym.yelp_id
+ profile: { time_zone: 'Alaska', gym_id: gym.id }
expect(user.reload.profile.gym).to eql(gym)
end