Commit 430e082

mo khan <mo@mokhan.ca>
2016-05-28 16:49:31
hound happy.
1 parent 75ca729
app/controllers/gyms_controller.rb
@@ -46,9 +46,9 @@ class GymsController < ApplicationController
 
   def build_gym
     if params[:yelp_id].present?
-      @gym = Gym.create_from_yelp!(params[:yelp_id])
+      Gym.create_from_yelp!(params[:yelp_id])
     else
-      @gym = Gym.new(secure_params)
+      Gym.new(secure_params)
     end
   end
 end
app/controllers/profiles_controller.rb
@@ -20,6 +20,11 @@ class ProfilesController < ApplicationController
   private
 
   def profile_params
-    params.require(:profile).permit(:gender, :social_tolerance, :time_zone, :gym_id)
+    params.require(:profile).permit(
+      :gender,
+      :gym_id,
+      :social_tolerance,
+      :time_zone,
+    )
   end
 end
app/models/gym.rb
@@ -65,7 +65,8 @@ class Gym < ActiveRecord::Base
   end
 
   def self.create_from_yelp!(id)
-    Gym.find_by(yelp_id: id) || Gym.map_from(::Yelp.client.business(id).business)
+    Gym.find_by(yelp_id: id) ||
+      Gym.map_from(::Yelp.client.business(id).business)
   end
 
   def self.import(city, pages: 5)
@@ -77,7 +78,8 @@ class Gym < ActiveRecord::Base
   end
 
   def map_url
-    "https://maps.google.com/maps/place/#{name}/@#{location.latitude},#{location.longitude},12z"
+    params = [location.latitude, location.longitude, "12z"].join(",")
+    "https://maps.google.com/maps/place/#{name}/@#{params}"
   end
 
   def duplicate?(distance: 0.1)
spec/controllers/gyms_controller_spec.rb
@@ -82,13 +82,12 @@ 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(:yelp_id) { "sait-campus-centre-calgary" }
       let(:gym) { build(:gym, yelp_id: yelp_id) }
 
       before :each do
@@ -97,12 +96,12 @@ describe GymsController do
           and_return(gym)
       end
 
-      it 'returns a json response' do
+      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)
+        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
 
spec/controllers/profiles_controller_spec.rb
@@ -54,8 +54,7 @@ describe ProfilesController do
       it 'saves the users home gym' do
         gym = create(:gym)
 
-        patch :update, id: user.to_param,
-          profile: { time_zone: 'Alaska', gym_id: gym.id }
+        patch :update, id: user.to_param, profile: { gym_id: gym.id }
 
         expect(user.reload.profile.gym).to eql(gym)
       end
spec/features/profiles_spec.rb
@@ -44,13 +44,13 @@ feature "Profiles", type: :feature do
 
       link_text = I18n.translate("profiles.edit.choose_home_gym")
       subject.click_link(link_text)
-      within('#gym-search form') do
-        fill_in 'q', with: 'sait'
-        fill_in 'city', with: 'calgary'
+      within("#gym-search form") do
+        fill_in "q", with: "sait"
+        fill_in "city", with: "calgary"
         click_button("Search")
       end
       subject.wait_for_ajax
-      subject.click_button('Mine')
+      subject.click_button("Mine")
       subject.wait_for_ajax
       subject.save_changes
       expect(page).to have_content(gym.name)
spec/models/training_history_spec.rb
@@ -25,13 +25,13 @@ describe TrainingHistory do
 
   describe "#completed_any" do
     describe "when this exercise has never been performed" do
-      it 'returns false' do
+      it "returns false" do
         expect(subject.completed_any?).to be_falsey
       end
     end
 
     describe "when the exercise has been performed at least once" do
-      it 'returns true' do
+      it "returns true" do
         session = user.begin_workout(workout_a, DateTime.now, 225)
         session.train(squat, 310, [5, 5, 5])
         expect(subject.completed_any?).to be_truthy