Skip to content

Commit

Permalink
fix user pages
Browse files Browse the repository at this point in the history
  • Loading branch information
thirotan committed Nov 28, 2015
1 parent 181eda8 commit 8206e8e
Show file tree
Hide file tree
Showing 11 changed files with 97 additions and 2 deletions.
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -14,6 +14,7 @@ end
group :test do
gem 'selenium-webdriver'
gem 'capybara'
gem 'factory_girl_rails'
end

gem 'sass-rails', '~> 5.0'
Expand Down
6 changes: 6 additions & 0 deletions Gemfile.lock
Expand Up @@ -65,6 +65,11 @@ GEM
diff-lcs (1.2.5)
erubis (2.7.0)
execjs (2.6.0)
factory_girl (4.5.0)
activesupport (>= 3.0.0)
factory_girl_rails (4.5.0)
factory_girl (~> 4.5.0)
railties (>= 3.0.0)
ffi (1.9.10)
globalid (0.3.6)
activesupport (>= 4.1.0)
Expand Down Expand Up @@ -189,6 +194,7 @@ DEPENDENCIES
bootstrap-sass
capybara
coffee-rails (~> 4.1.0)
factory_girl_rails
jbuilder (~> 2.0)
jquery-rails
pg
Expand Down
48 changes: 48 additions & 0 deletions app/assets/stylesheets/custom.css.scss
@@ -1,8 +1,16 @@
@import "bootstrap";

/* mixins variables, etc */

$gray-light: #999;
$grayMediumLight: #eaeaea;

@mixin box_sizing {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}

/* universal */

html {
Expand Down Expand Up @@ -100,3 +108,43 @@ footer {
}
}
}

/* miscellaneous */
.debug_dump {
clear: both;
floot: left;
width: 100%;
margin-top: 45px;
@include box_sizing;
}


/* sidebar */

aside {
section {
padding: 10px 0;
border-top: 1px solid $gray-light;
&:first-child {
border: 0;
padding-top: 0;
}
span {
display: block;
margin-bottom: 3px;
line-height: 1;
}
h1 {
font-size: 1.4em;
text-align: left;
letter-spacing: -1px;
margin-bottom: 3px;
margin-top: 0px;
}
}
}

.gravatar {
float: left;
margin-right: 10px;
}
5 changes: 5 additions & 0 deletions app/controllers/users_controller.rb
@@ -1,4 +1,9 @@
class UsersController < ApplicationController

def show
@user = User.find(params[:id])
end

def new
end
end
5 changes: 5 additions & 0 deletions app/helpers/users_helper.rb
@@ -1,2 +1,7 @@
module UsersHelper
def gravatar_for(user)
gravatar_id = Digest::MD5::hexdigest(user.email.downcase)
gravatar_url = "https://secure.gravatar.com/avatar/#{gravatar_id}"
image_tag(gravatar_url, alt: user.name, class: "gravatar")
end
end
1 change: 1 addition & 0 deletions app/views/layouts/application.html.erb
Expand Up @@ -13,6 +13,7 @@
<div class="container">
<%= yield %>
<%= render 'layouts/footer' %>
<%= debug(params) if Rails.env.development? %>
</div>
</body>
</html>
11 changes: 11 additions & 0 deletions app/views/users/show.html.erb
@@ -0,0 +1,11 @@
<% provide(:title, @user.name) %>
<div class="row">
<aside class="span4">
<section>
<h1>
<%= gravatar_for @user %>
<%= @user.name %>
</h1>
</section>
</aside>
</div>
2 changes: 2 additions & 0 deletions config/environments/test.rb
Expand Up @@ -39,4 +39,6 @@

# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
#
ActiveModel::SecurePassword.min_cost = true
end
3 changes: 1 addition & 2 deletions config/routes.rb
@@ -1,6 +1,5 @@
Rails.application.routes.draw do
get 'users/new'

resources :users
root 'static_pages#home'
match '/signup', to: 'users#new', via: 'get'
match '/help', to: 'static_pages#help', via: 'get'
Expand Down
8 changes: 8 additions & 0 deletions spec/factories.rb
@@ -0,0 +1,8 @@
FactoryGirl.define do
factory :user do
name "Michael Hartl"
email "michael@example.com"
password "foobar"
password_confirmation "foobar"
end
end
9 changes: 9 additions & 0 deletions spec/requests/user_pages_spec.rb
Expand Up @@ -3,10 +3,19 @@
RSpec.describe "UserPages", type: :request do
subject { page }

describe "profile page" do
let(:user) { FactoryGirl.create(:user) }
before { visit user_path(user) }

it { is_expected.to have_content(user.name) }
it { is_expected.to have_title(user.name) }
end

describe "signup page" do
before { visit signup_path }

it { is_expected.to have_content('Sign up') }
it { is_expected.to have_title(full_title('Sign up')) }
end

end

0 comments on commit 8206e8e

Please sign in to comment.