Permalink
Browse files

remove User scaffold

  • Loading branch information...
1 parent dd835bd commit 7431a0b8b15a9a93b08648c064d21f81835afae0 @FuriKuri committed Nov 6, 2012
View
@@ -4,6 +4,7 @@ gem 'rails', '3.2.8'
gem 'pg'
gem 'mysql2'
+gem 'bcrypt-ruby'
group :development, :test do
gem 'sqlite3'
View
@@ -29,6 +29,7 @@ GEM
i18n (~> 0.6)
multi_json (~> 1.0)
arel (3.0.2)
+ bcrypt-ruby (3.0.1-x86-mingw32)
builder (3.0.3)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
@@ -112,6 +113,7 @@ PLATFORMS
x86-mingw32
DEPENDENCIES
+ bcrypt-ruby
coffee-rails (~> 3.2.1)
jquery-rails
mysql2
@@ -1,3 +0,0 @@
-# Place all the behaviors and hooks related to the matching controller here.
-# All this logic will automatically be available in application.js.
-# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
@@ -1,3 +0,0 @@
-// Place all the styles related to the Users controller here.
-// They will automatically be included in application.css.
-// You can use Sass (SCSS) here: http://sass-lang.com/
@@ -1,83 +0,0 @@
-class UsersController < ApplicationController
- # GET /users
- # GET /users.json
- def index
- @users = User.all
-
- respond_to do |format|
- format.html # index.html.erb
- format.json { render json: @users }
- end
- end
-
- # GET /users/1
- # GET /users/1.json
- def show
- @user = User.find(params[:id])
-
- respond_to do |format|
- format.html # show.html.erb
- format.json { render json: @user }
- end
- end
-
- # GET /users/new
- # GET /users/new.json
- def new
- @user = User.new
-
- respond_to do |format|
- format.html # new.html.erb
- format.json { render json: @user }
- end
- end
-
- # GET /users/1/edit
- def edit
- @user = User.find(params[:id])
- end
-
- # POST /users
- # POST /users.json
- def create
- @user = User.new(params[:user])
-
- respond_to do |format|
- if @user.save
- format.html { redirect_to @user, notice: 'User was successfully created.' }
- format.json { render json: @user, status: :created, location: @user }
- else
- format.html { render action: "new" }
- format.json { render json: @user.errors, status: :unprocessable_entity }
- end
- end
- end
-
- # PUT /users/1
- # PUT /users/1.json
- def update
- @user = User.find(params[:id])
-
- respond_to do |format|
- if @user.update_attributes(params[:user])
- format.html { redirect_to @user, notice: 'User was successfully updated.' }
- format.json { head :no_content }
- else
- format.html { render action: "edit" }
- format.json { render json: @user.errors, status: :unprocessable_entity }
- end
- end
- end
-
- # DELETE /users/1
- # DELETE /users/1.json
- def destroy
- @user = User.find(params[:id])
- @user.destroy
-
- respond_to do |format|
- format.html { redirect_to users_url }
- format.json { head :no_content }
- end
- end
-end
@@ -1,2 +0,0 @@
-module UsersHelper
-end
View
@@ -1,8 +0,0 @@
-class User < ActiveRecord::Base
- attr_accessible :email, :name, :password
- validates_presence_of :email, :name, :password
- validates_length_of :name, :within => 3..40
- validates_length_of :password, :within => 5..40
- validates_format_of :email, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i, :message => "Invalid email"
- validates_uniqueness_of :email, :name
-end
@@ -1,29 +0,0 @@
-<%= form_for(@user) do |f| %>
- <% if @user.errors.any? %>
- <div id="error_explanation">
- <h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2>
-
- <ul>
- <% @user.errors.full_messages.each do |msg| %>
- <li><%= msg %></li>
- <% end %>
- </ul>
- </div>
- <% end %>
-
- <div class="field">
- <%= f.label :name %><br />
- <%= f.text_field :name %>
- </div>
- <div class="field">
- <%= f.label :password %><br />
- <%= f.text_field :password %>
- </div>
- <div class="field">
- <%= f.label :email %><br />
- <%= f.text_field :email %>
- </div>
- <div class="actions">
- <%= f.submit %>
- </div>
-<% end %>
@@ -1,6 +0,0 @@
-<h1>Editing user</h1>
-
-<%= render 'form' %>
-
-<%= link_to 'Show', @user %> |
-<%= link_to 'Back', users_path %>
@@ -1,27 +0,0 @@
-<h1>Listing users</h1>
-
-<table>
- <tr>
- <th>Name</th>
- <th>Password</th>
- <th>Email</th>
- <th></th>
- <th></th>
- <th></th>
- </tr>
-
-<% @users.each do |user| %>
- <tr>
- <td><%= user.name %></td>
- <td><%= user.password %></td>
- <td><%= user.email %></td>
- <td><%= link_to 'Show', user %></td>
- <td><%= link_to 'Edit', edit_user_path(user) %></td>
- <td><%= link_to 'Destroy', user, method: :delete, data: { confirm: 'Are you sure?' } %></td>
- </tr>
-<% end %>
-</table>
-
-<br />
-
-<%= link_to 'New User', new_user_path %>
@@ -1,5 +0,0 @@
-<h1>New user</h1>
-
-<%= render 'form' %>
-
-<%= link_to 'Back', users_path %>
@@ -1,20 +0,0 @@
-<p id="notice"><%= notice %></p>
-
-<p>
- <b>Name:</b>
- <%= @user.name %>
-</p>
-
-<p>
- <b>Password:</b>
- <%= @user.password %>
-</p>
-
-<p>
- <b>Email:</b>
- <%= @user.email %>
-</p>
-
-
-<%= link_to 'Edit', edit_user_path(@user) %> |
-<%= link_to 'Back', users_path %>
@@ -1,11 +0,0 @@
-class CreateUsers < ActiveRecord::Migration
- def change
- create_table :users do |t|
- t.string :name
- t.string :password
- t.string :email
-
- t.timestamps
- end
- end
-end
View
@@ -1,11 +0,0 @@
-# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
-
-tim:
- name: tim
- password: secret
- email: tim@email.com
-
-daniel:
- name: damiel
- password: secert
- email: daniel@email.com
@@ -1,49 +0,0 @@
-require 'test_helper'
-
-class UsersControllerTest < ActionController::TestCase
- setup do
- @user = users(:tim)
- end
-
- test "should get index" do
- get :index
- assert_response :success
- assert_not_nil assigns(:users)
- end
-
- test "should get new" do
- get :new
- assert_response :success
- end
-
- test "should create user" do
- assert_difference('User.count') do
- post :create, user: { email: 'new_user@email.com', name: 'user3', password: 'secret' }
- end
-
- assert_redirected_to user_path(assigns(:user))
- end
-
- test "should show user" do
- get :show, id: @user
- assert_response :success
- end
-
- test "should get edit" do
- get :edit, id: @user
- assert_response :success
- end
-
- test "should update user" do
- put :update, id: @user, user: { email: @user.email, name: @user.name, password: @user.password }
- assert_redirected_to user_path(assigns(:user))
- end
-
- test "should destroy user" do
- assert_difference('User.count', -1) do
- delete :destroy, id: @user
- end
-
- assert_redirected_to users_path
- end
-end
@@ -1,4 +0,0 @@
-require 'test_helper'
-
-class UsersHelperTest < ActionView::TestCase
-end
View
@@ -1,95 +0,0 @@
-require 'test_helper'
-
-class UserTest < ActiveSupport::TestCase
- fixtures :users
-
- test "should save user" do
- user = User.new
- user.name = 'hans'
- user.password = 'secret'
- user.email = 'hans@email.com'
- assert user.valid?
- end
-
- test "should not save user with no name" do
- user = User.new
- user.password = 'secret'
- user.email = 'user@email.com'
- assert user.invalid?
- end
-
- test "should not save user with no password" do
- user = User.new
- user.name = 'hans'
- user.email = 'user@email.com'
- assert user.invalid?
- end
-
- test "should not save user with no email" do
- user = User.new
- user.name = 'hans'
- user.password = 'secret'
- assert user.invalid?
- end
-
- test "should not save user with too short name" do
- user = User.new
- user.name = 'u'
- user.password = 'secret'
- user.email = 'user@email.com'
- assert user.invalid?
- end
-
-
- test "should not save user with too long name" do
- user = User.new
- name = ''
- 41.times {name += 'u'}
- user.name = name
- user.password = 'secret'
- user.email = 'user@email.com'
- assert user.invalid?
- end
-
- test "should not save user with too short password" do
- user = User.new
- user.name = 'hans'
- user.password = 'pw'
- user.email = 'user@email.com'
- assert user.invalid?
- end
-
- test "should not save user with too long password" do
- user = User.new
- user.name = 'hans'
- pw = ''
- 41.times {pw += 'p'}
- user.password = pw
- user.email = 'user@email.com'
- assert user.invalid?
- end
-
- test "should not save user with a wrong email format" do
- user = User.new
- user.name = 'hans'
- user.password = 'secret'
- user.email = 'email.com'
- assert user.invalid?
- end
-
- test "should not save user with an existing name" do
- user = User.new
- user.name = 'tim'
- user.password = 'secret'
- user.email = 'user@email.com'
- assert user.invalid?
- end
-
- test "should not save user with an existing email" do
- user = User.new
- user.name = 'hans'
- user.password = 'secret'
- user.email = 'tim@email.com'
- assert user.invalid?
- end
-end

0 comments on commit 7431a0b

Please sign in to comment.