Permalink
Browse files

signup initial version

  • Loading branch information...
1 parent 29628e1 commit 757600ff418110a9aedf8d0691b307f0957f8138 Hakim Hanif committed May 19, 2014
View
@@ -18,6 +18,7 @@ end
group :test do
gem 'selenium-webdriver', '2.35.1'
gem 'capybara', '2.1.0'
+ gem 'factory_girl_rails', '4.2.1'
end
gem 'sass-rails', '4.0.3'
View
@@ -54,6 +54,11 @@ GEM
diff-lcs (1.2.5)
erubis (2.7.0)
execjs (2.0.2)
+ factory_girl (4.2.0)
+ activesupport (>= 3.0.0)
+ factory_girl_rails (4.2.1)
+ factory_girl (~> 4.2.0)
+ railties (>= 3.0.0)
ffi (1.9.3)
formatador (0.2.4)
guard (2.6.1)
@@ -193,6 +198,7 @@ DEPENDENCIES
bootstrap-sass (= 3.1.1)
capybara (= 2.1.0)
coffee-rails (= 4.0.1)
+ factory_girl_rails (= 4.2.1)
guard-rspec (= 2.5.0)
jbuilder (= 1.0.2)
jquery-rails (= 3.0.4)
@@ -5,6 +5,13 @@
$grayMediumLight: #eaeaea;
$grayLight: #999;
+@mixin box_sizing {
+ -moz-box-sizing: border-box;
+ -webkit-box-sizing: border-box;
+ box-sizing: border-box;
+}
+
+
/* universal */
html {
@@ -100,4 +107,47 @@ footer {
margin-left: 10px;
}
}
-}
+}
+
+
+
+/* miscellaneous */
+
+.debug_dump {
+ clear: both;
+ float: left;
+ width: 100%;
+ margin-top: 45px;
+ @include box_sizing;
+}
+
+/* sidebar */
+
+aside {
+ section {
+ padding: 10px 0;
+ border-top: 1px solid $grayLight;
+ &: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;
+}
+
@@ -1,4 +1,8 @@
class UsersController < ApplicationController
def new
end
+
+ def show
+ @user = User.find( params[:id] )
+ end
end
@@ -1,2 +1,8 @@
module UsersHelper
+ # Returns the Gravatar (http://gravatar.com/) for the given user.
+ 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
@@ -13,6 +13,7 @@
<div class="container">
<%= yield %>
<%= render 'layouts/footer' %>
+ <%= debug(params) if Rails.env.development? %>
</div>
</body>
</html>
@@ -0,0 +1,12 @@
+<% provide(:title, @user.name) %>
+
+<div class="row">
+ <aside class="span4">
+ <section>
+ <h1>
+ <%= gravatar_for @user %>
+ <%= @user.name %>
+ </h1>
+ </section>
+ </aside>
+</div>
@@ -33,4 +33,7 @@
# Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr
+
+ # Speed up tests by lowering bcrypt's cost function.
+ ActiveModel::SecurePassword.min_cost = true
end
View
@@ -1,5 +1,5 @@
SampleApp::Application.routes.draw do
- get "users/new"
+ resources :users
root 'static_pages#home'
match '/help', to: 'static_pages#help', via: 'get'
match '/about', to: 'static_pages#aboutus', via: 'get'
View
@@ -18,7 +18,6 @@
t.string "email"
t.datetime "created_at"
t.datetime "updated_at"
- t.string "passord_digest"
t.string "password_digest"
end
View
@@ -0,0 +1,8 @@
+FactoryGirl.define do
+ factory :user do
+ name "Hakim Hanif"
+ email "haha@haha.com"
+ password "test"
+ password_confirmation "test"
+ end
+end
@@ -12,4 +12,33 @@
it { should have_title('Sign up') }
end
+
+ describe "user profile" do
+ let (:user ) { FactoryGirl.create(:user) }
+ before { visit user_path (user) }
+
+ it { should have_content( user.name ) }
+ it { should have_title( user.name ) }
+ end
+
+ describe "signup" do
+ before { visit signup_path}
+
+ describe "with invalid information" do
+ expect { click_button "Create my account"}.not_to change(User, :count)
+ end
+
+ describe "with valid information" do
+ before do
+ fill_in "Name", with: "Example user"
+ fill_in "Email", with: "user@example.com"
+ fill_in "Password", with: "test"
+ fill_in "Confirmation", with: "test"
+ end
+ it "should create a user" do
+ expect { click_button submit }.to change(User, :count).by(1)
+ end
+ end
+ end
+
end

0 comments on commit 757600f

Please sign in to comment.