Commit a3c6ba2

mo khan <mo@mokhan.ca>
2015-05-30 18:03:20
create a profiles controller to display a users profile.
1 parent 371ad0e
Changed files (4)
app/controllers/profiles_controller.rb
@@ -0,0 +1,5 @@
+class ProfilesController < PublicController
+  def show
+    @user = User.find_by(username: params[:id])
+  end
+end
app/views/profiles/show.html.erb
config/routes.rb
@@ -8,6 +8,7 @@ Rails.application.routes.draw do
     end
   end
   resources :programs, only: [:show]
+  resources :profiles, only: [:show]
   get "/dashboard" => "training_sessions#index", as: :dashboard
   get "/terms" => "static_pages#terms"
 end
spec/controllers/profiles_controller_spec.rb
@@ -0,0 +1,12 @@
+require "rails_helper"
+
+describe ProfilesController do
+  describe "#show" do
+    let(:user) { create(:user) }
+
+    it "loads the users profile" do
+      get :show, id: user.username
+      expect(assigns(:user)).to eql(user)
+    end
+  end
+end