Permalink
Browse files

User model with password, user show page

  • Loading branch information...
1 parent 2c23d8f commit e67731da868fe8ac37b629202506b8be5a8a3a84 @ryanmaclear committed Mar 1, 2011
View
@@ -1,11 +1,11 @@
source 'http://rubygems.org'
-gem 'rails', '3.0.1'
-
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
+gem 'rails', '3.0.1'
gem 'sqlite3-ruby', '1.3.1', :require => 'sqlite3'
+gem 'gravatar_image_tag', '0.1.0'
group :development do
gem 'rspec-rails', '2.0.1'
@@ -15,6 +15,7 @@ end
group :test do
gem 'rspec', '2.0.1'
gem 'webrat', '0.7.1'
+ gem 'factory_girl_rails', '1.0'
end
# Use unicorn as the web server
View
@@ -35,6 +35,11 @@ GEM
diff-lcs (1.1.2)
erubis (2.6.6)
abstract (>= 1.0.0)
+ factory_girl (1.3.3)
+ factory_girl_rails (1.0)
+ factory_girl (~> 1.3)
+ rails (>= 3.0.0.beta4)
+ gravatar_image_tag (0.1.0)
i18n (0.4.2)
mail (2.2.15)
activesupport (>= 2.3.6)
@@ -90,6 +95,8 @@ PLATFORMS
DEPENDENCIES
annotate-models (= 1.0.4)
+ factory_girl_rails (= 1.0)
+ gravatar_image_tag (= 0.1.0)
rails (= 3.0.1)
rspec (= 2.0.1)
rspec-rails (= 2.0.1)
@@ -2,6 +2,7 @@ class UsersController < ApplicationController
def show
@user = User.find(params[:id])
+ @title = @user.name
end
def new
@@ -1,2 +1,8 @@
module UsersHelper
+
+ def gravatar_for(user, options = { :size => 50 })
+ gravatar_image_tag(user.email.downcase, :alt => user.name,
+ :class => 'gravatar',
+ :gravatar => options)
+ end
end
@@ -1 +1,15 @@
-<%= @user.name %>, <%= @user.email %>
+<table class="profile" summary="Profile information">
+ <tr>
+ <td class="main">
+ <h1>
+ <%= gravatar_for @user %>
+ <%= @user.name %>
+ </h1>
+ </td>
+ <td class="sidebar round">
+ <strong>Name</strong> <%= @user.name %><br/>
+ <strong>URL</strong> <%= link_to user_path(@user), @user %>
+ </td>
+ </tr>
+</table>
+
@@ -103,4 +103,27 @@ footer {
}
footer nav {
float: none;
-}
+}
+
+/* User show pages */
+table.profile {
+ width: 100%;
+ margin-bottom: 0;
+}
+
+td.main {
+ width: 70%;
+ padding: 1em;
+}
+
+td.sidebar {
+ width: 30%;
+ padding: 1em;
+ vertical-align: top;
+ background: #ffc;
+}
+
+.profile img.gravatar {
+ border: 1px solid #999;
+ margin-bottom: -15px;
+}
@@ -3,6 +3,39 @@
describe UsersController do
render_views
+ describe "GET 'show'" do
+
+ before(:each) do
+ @user = Factory(:user)
+ end
+
+ it "should be successful" do
+ get :show, :id => @user
+ response.should be_success
+ end
+
+ it "should find the right user" do
+ get :show, :id => @user
+ assigns(:user).should == @user
+ end
+
+ it "should have the right title" do
+ get :show, :id => @user
+ response.should have_selector("title", :content => @user.name)
+ end
+
+ it "should contain the user's name" do
+ get :show, :id => @user
+ response.should have_selector("h1", :content => @user.name)
+ end
+
+ it "should have a profile image" do
+ get :show, :id => @user
+ response.should have_selector("h1>img", :class => "gravatar")
+ end
+
+ end
+
describe "GET 'new'" do
it "should be successful" do
get 'new'
View
@@ -0,0 +1,8 @@
+# By using the symbol ':user', we get Factory Girl to simulate the User model.
+Factory.define :user do |user|
+ user.name "Ryan Maclear"
+ user.email "ryan.maclear@gmail.com"
+ user.password "password"
+ user.password_confirmation "password"
+end
+

0 comments on commit e67731d

Please sign in to comment.