This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'spec_helper' | |
| describe User do | |
| before(:each) do | |
| @attr = { :name => "Example User", | |
| :email => "user@example.com", | |
| :password => "secret" | |
| #:password_confirmation => "secret" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class User < ActiveRecord::Base | |
| has_secure_password | |
| attr_accessible :name, :email, :password, :password_confirmation | |
| email_regex = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i | |
| validates :name, :presence => true, | |
| :length => { :maximum => 50 } | |
| validates :email, :presence => true, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ rspec spec | |
| ........................true | |
| #<User id: 1, name: "Example User", email: "user@example.com", created_at: "2011-07-25 09:17:10", updated_at: "2011-07-25 09:17:10", password_digest: "$2a$10$8rSXunwrcXG7jgn2e6WrE.LaJK3UzyZr5AUjVu1qfg3R..."> | |
| .true | |
| #<User id: 1, name: "Example User", email: "user@example.com", created_at: "2011-07-25 09:17:10", updated_at: "2011-07-25 09:17:10", password_digest: "$2a$10$nniZHkVQFHvXlhEeqnSL8.ocNWck/uWpC/5NYheOv/O9..."> | |
| . | |
| Finished in 1.86 seconds | |
| 26 examples, 0 failures |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| e 'spec_helper' | |
| describe UsersController do | |
| render_views | |
| describe "GET 'new'" do | |
| it "should be successful" do | |
| get 'new' | |
| response.should be_success | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'spec_helper' | |
| describe User do | |
| # Password encryption tests | |
| describe "password encryption" do | |
| before(:each) do | |
| @attr = { :name => "Example User", | |
| :email => "user@example.com", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Started GET "/" for 127.0.0.1 at 2011-08-03 21:46:53 -0700 | |
| ActionView::MissingTemplate (Missing template pages/welcome, application/welcome with {:handlers=>[:erb, :builder], :formats=>[:html], :locale=>[:en, :en]}. Searched in: | |
| ): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sessions controller action: | |
| def create | |
| user = User.find_by_email(params[:email]) | |
| if user && user.authenticate(params[:password]) | |
| session[:user_id] = user.id | |
| redirect_to root_url, :notice => "Successfully signed in." | |
| else | |
| flash.now.alert = "Invalid email or password." | |
| @title = "Sign In" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| user views: | |
| NEW ACTION | |
| <section> | |
| <article class="content"> | |
| <h1>Sign Up</h1> | |
| <%= form_for(@user) do |f| %> | |
| <%= render 'shared/error_messages' %> | |
| <div class="field"> | |
| <%= f.label :first_name, "First Name:" %><br /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class CreateUsers < ActiveRecord::Migration | |
| def change | |
| create_table :users do |t| | |
| t.string :first_name | |
| t.string :last_name | |
| t.string :email | |
| t.string :password_digest | |
| t.string :auth_token | |
| t.timestamps |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <section class="signup box"> | |
| <h1>Sign Up</h1> | |
| <%= form_for(@user) do |f| %> | |
| <%= render 'shared/error_messages', :object => f.object %> | |
| <div class="field"> | |
| <%= f.label :first_name, "First Name:" %><br /> | |
| <%= f.text_field :first_name %> | |
| </div> | |
| <div class="field"> | |
| <%= f.label :last_name, "Last Name:" %><br /> |
OlderNewer