diff options
-rw-r--r-- | app/controllers/users_controller.rb | 2 | ||||
-rw-r--r-- | app/views/users/_form.html.erb | 8 | ||||
-rw-r--r-- | app/views/users/index.html.erb | 4 | ||||
-rw-r--r-- | app/views/users/index.json.jbuilder | 2 | ||||
-rw-r--r-- | app/views/users/show.html.erb | 10 | ||||
-rw-r--r-- | app/views/users/show.json.jbuilder | 2 | ||||
-rw-r--r-- | db/migrate/20140306024707_create_servers.rb (renamed from db/migrate/20140306022626_create_servers.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140306024709_create_tournaments.rb (renamed from db/migrate/20140306022628_create_tournaments.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140306024711_create_matches.rb (renamed from db/migrate/20140306022631_create_matches.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140306024713_create_teams.rb (renamed from db/migrate/20140306022633_create_teams.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140306024715_create_alerts.rb (renamed from db/migrate/20140306022635_create_alerts.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140306024718_create_pms.rb (renamed from db/migrate/20140306022638_create_pms.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140306024720_create_games.rb (renamed from db/migrate/20140306022640_create_games.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140306024722_create_users.rb (renamed from db/migrate/20140306022642_create_users.rb) | 2 | ||||
-rw-r--r-- | db/migrate/20140306024724_create_sessions.rb (renamed from db/migrate/20140306022644_create_sessions.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140306024727_create_game_attributes.rb (renamed from db/migrate/20140306022647_create_game_attributes.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140306024729_create_server_settings.rb (renamed from db/migrate/20140306022649_create_server_settings.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140306024731_create_user_team_pairs.rb (renamed from db/migrate/20140306022651_create_user_team_pairs.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140306024733_create_team_match_pairs.rb (renamed from db/migrate/20140306022653_create_team_match_pairs.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140306024735_create_tournament_options.rb (renamed from db/migrate/20140306022702_create_tournament_options.rb) | 0 | ||||
-rw-r--r-- | db/migrate/20140306024744_add_hidden_attrs_to_user.rb | 8 | ||||
-rw-r--r-- | db/schema.rb | 8 | ||||
-rwxr-xr-x | generate.sh | 9 | ||||
-rw-r--r-- | test/controllers/users_controller_test.rb | 4 | ||||
-rw-r--r-- | test/fixtures/users.yml | 4 |
25 files changed, 25 insertions, 38 deletions
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 989ef76..b18efed 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -69,6 +69,6 @@ class UsersController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def user_params - params.require(:user).permit(:name, :email, :user_name, :password_digest, :remember_token) + params.require(:user).permit(:name, :email, :user_name) end end diff --git a/app/views/users/_form.html.erb b/app/views/users/_form.html.erb index ad89f47..4d28738 100644 --- a/app/views/users/_form.html.erb +++ b/app/views/users/_form.html.erb @@ -23,14 +23,6 @@ <%= f.label :user_name %><br> <%= f.text_field :user_name %> </div> - <div class="field"> - <%= f.label :password_digest %><br> - <%= f.text_field :password_digest %> - </div> - <div class="field"> - <%= f.label :remember_token %><br> - <%= f.text_field :remember_token %> - </div> <div class="actions"> <%= f.submit %> </div> diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index c0d52a0..3692112 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -6,8 +6,6 @@ <th>Name</th> <th>Email</th> <th>User name</th> - <th>Password digest</th> - <th>Remember token</th> <th></th> <th></th> <th></th> @@ -20,8 +18,6 @@ <td><%= user.name %></td> <td><%= user.email %></td> <td><%= user.user_name %></td> - <td><%= user.password_digest %></td> - <td><%= user.remember_token %></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> diff --git a/app/views/users/index.json.jbuilder b/app/views/users/index.json.jbuilder index cf21a4a..42d8b72 100644 --- a/app/views/users/index.json.jbuilder +++ b/app/views/users/index.json.jbuilder @@ -1,4 +1,4 @@ json.array!(@users) do |user| - json.extract! user, :id, :name, :email, :user_name, :password_digest, :remember_token + json.extract! user, :id, :name, :email, :user_name json.url user_url(user, format: :json) end diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index a0fa94c..9455a3c 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -15,15 +15,5 @@ <%= @user.user_name %> </p> -<p> - <strong>Password digest:</strong> - <%= @user.password_digest %> -</p> - -<p> - <strong>Remember token:</strong> - <%= @user.remember_token %> -</p> - <%= link_to 'Edit', edit_user_path(@user) %> | <%= link_to 'Back', users_path %> diff --git a/app/views/users/show.json.jbuilder b/app/views/users/show.json.jbuilder index 11b0784..4919af3 100644 --- a/app/views/users/show.json.jbuilder +++ b/app/views/users/show.json.jbuilder @@ -1 +1 @@ -json.extract! @user, :id, :name, :email, :user_name, :password_digest, :remember_token, :created_at, :updated_at +json.extract! @user, :id, :name, :email, :user_name, :created_at, :updated_at diff --git a/db/migrate/20140306022626_create_servers.rb b/db/migrate/20140306024707_create_servers.rb index f33241a..f33241a 100644 --- a/db/migrate/20140306022626_create_servers.rb +++ b/db/migrate/20140306024707_create_servers.rb diff --git a/db/migrate/20140306022628_create_tournaments.rb b/db/migrate/20140306024709_create_tournaments.rb index 36fcf7e..36fcf7e 100644 --- a/db/migrate/20140306022628_create_tournaments.rb +++ b/db/migrate/20140306024709_create_tournaments.rb diff --git a/db/migrate/20140306022631_create_matches.rb b/db/migrate/20140306024711_create_matches.rb index 325863d..325863d 100644 --- a/db/migrate/20140306022631_create_matches.rb +++ b/db/migrate/20140306024711_create_matches.rb diff --git a/db/migrate/20140306022633_create_teams.rb b/db/migrate/20140306024713_create_teams.rb index dd8397d..dd8397d 100644 --- a/db/migrate/20140306022633_create_teams.rb +++ b/db/migrate/20140306024713_create_teams.rb diff --git a/db/migrate/20140306022635_create_alerts.rb b/db/migrate/20140306024715_create_alerts.rb index 68a8e10..68a8e10 100644 --- a/db/migrate/20140306022635_create_alerts.rb +++ b/db/migrate/20140306024715_create_alerts.rb diff --git a/db/migrate/20140306022638_create_pms.rb b/db/migrate/20140306024718_create_pms.rb index 93bb5c6..93bb5c6 100644 --- a/db/migrate/20140306022638_create_pms.rb +++ b/db/migrate/20140306024718_create_pms.rb diff --git a/db/migrate/20140306022640_create_games.rb b/db/migrate/20140306024720_create_games.rb index 59d4ef0..59d4ef0 100644 --- a/db/migrate/20140306022640_create_games.rb +++ b/db/migrate/20140306024720_create_games.rb diff --git a/db/migrate/20140306022642_create_users.rb b/db/migrate/20140306024722_create_users.rb index f416771..8032870 100644 --- a/db/migrate/20140306022642_create_users.rb +++ b/db/migrate/20140306024722_create_users.rb @@ -4,8 +4,6 @@ class CreateUsers < ActiveRecord::Migration t.string :name t.string :email t.string :user_name - t.string :password_digest - t.string :remember_token t.timestamps end diff --git a/db/migrate/20140306022644_create_sessions.rb b/db/migrate/20140306024724_create_sessions.rb index fe25bf2..fe25bf2 100644 --- a/db/migrate/20140306022644_create_sessions.rb +++ b/db/migrate/20140306024724_create_sessions.rb diff --git a/db/migrate/20140306022647_create_game_attributes.rb b/db/migrate/20140306024727_create_game_attributes.rb index b63f134..b63f134 100644 --- a/db/migrate/20140306022647_create_game_attributes.rb +++ b/db/migrate/20140306024727_create_game_attributes.rb diff --git a/db/migrate/20140306022649_create_server_settings.rb b/db/migrate/20140306024729_create_server_settings.rb index dfdd91b..dfdd91b 100644 --- a/db/migrate/20140306022649_create_server_settings.rb +++ b/db/migrate/20140306024729_create_server_settings.rb diff --git a/db/migrate/20140306022651_create_user_team_pairs.rb b/db/migrate/20140306024731_create_user_team_pairs.rb index 2c492ac..2c492ac 100644 --- a/db/migrate/20140306022651_create_user_team_pairs.rb +++ b/db/migrate/20140306024731_create_user_team_pairs.rb diff --git a/db/migrate/20140306022653_create_team_match_pairs.rb b/db/migrate/20140306024733_create_team_match_pairs.rb index 8fac07e..8fac07e 100644 --- a/db/migrate/20140306022653_create_team_match_pairs.rb +++ b/db/migrate/20140306024733_create_team_match_pairs.rb diff --git a/db/migrate/20140306022702_create_tournament_options.rb b/db/migrate/20140306024735_create_tournament_options.rb index d2df22e..d2df22e 100644 --- a/db/migrate/20140306022702_create_tournament_options.rb +++ b/db/migrate/20140306024735_create_tournament_options.rb diff --git a/db/migrate/20140306024744_add_hidden_attrs_to_user.rb b/db/migrate/20140306024744_add_hidden_attrs_to_user.rb new file mode 100644 index 0000000..2f1b0b2 --- /dev/null +++ b/db/migrate/20140306024744_add_hidden_attrs_to_user.rb @@ -0,0 +1,8 @@ +class AddHiddenAttrsToUser < ActiveRecord::Migration + def change + add_column :users, :password_digest, :string + add_column :users, :remember_token, :string + add_index :users, :remember_token, unique: true + add_column :users, :groups, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index ca583d1..b0d0766 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20140306022702) do +ActiveRecord::Schema.define(version: 20140306024744) do create_table "alerts", force: true do |t| t.integer "author_id" @@ -122,13 +122,15 @@ ActiveRecord::Schema.define(version: 20140306022702) do t.string "name" t.string "email" t.string "user_name" - t.string "password_digest" - t.string "remember_token" t.datetime "created_at" t.datetime "updated_at" + t.string "password_digest" + t.string "remember_token" + t.integer "groups" end add_index "users", ["email"], name: "index_users_on_email", unique: true + add_index "users", ["remember_token"], name: "index_users_on_remember_token", unique: true add_index "users", ["user_name"], name: "index_users_on_user_name", unique: true end diff --git a/generate.sh b/generate.sh index da55bca..fcd962f 100755 --- a/generate.sh +++ b/generate.sh @@ -24,7 +24,7 @@ bundle exec rails generate scaffold team $NOTEST bundle exec rails generate scaffold alert author:references message:text $NOTEST bundle exec rails generate scaffold pm author:references recipient:references message:text $NOTEST bundle exec rails generate scaffold game name:text players_per_team:integer teams_per_match:integer set_rounds:integer randomized_teams:integer --force $NOTEST -bundle exec rails generate scaffold user name:string email:string:uniq user_name:string:uniq password_digest:string remember_token:string +bundle exec rails generate scaffold user name:string email:string:uniq user_name:string:uniq bundle exec rails generate scaffold session user:references # Just models @@ -32,14 +32,19 @@ bundle exec rails generate model game_attribute game:references key:text type:in bundle exec rails generate model server_settings $NOTEST bundle exec rails generate model user_team_pair user:references team:references $NOTEST bundle exec rails generate model team_match_pair team:references match:references $NOTEST +bundle exec rails generate model tournament_option $NOTEST # Just controllers bundle exec rails generate controller search $NOTEST bundle exec rails generate controller main $NOTEST bundle exec rails generate controller static $NOTEST +# Migrations +# By having these separate from the original 'generate', it makes it +# not stick these in the views or anything. +bundle exec rails generate migration AddHiddenAttrsToUser password_digest:string remember_token:string:uniq groups:integer + #for the tournament controller to generate options -bundle exec rails generate model tournament_option $NOTEST #bundle exec rails generate scaffold bundle exec rake db:drop RAILS_ENV=development diff --git a/test/controllers/users_controller_test.rb b/test/controllers/users_controller_test.rb index fc06f63..79a5700 100644 --- a/test/controllers/users_controller_test.rb +++ b/test/controllers/users_controller_test.rb @@ -18,7 +18,7 @@ class UsersControllerTest < ActionController::TestCase test "should create user" do assert_difference('User.count') do - post :create, user: { email: @user.email, name: @user.name, password_digest: @user.password_digest, remember_token: @user.remember_token, user_name: @user.user_name } + post :create, user: { email: @user.email, name: @user.name, user_name: @user.user_name } end assert_redirected_to user_path(assigns(:user)) @@ -35,7 +35,7 @@ class UsersControllerTest < ActionController::TestCase end test "should update user" do - patch :update, id: @user, user: { email: @user.email, name: @user.name, password_digest: @user.password_digest, remember_token: @user.remember_token, user_name: @user.user_name } + patch :update, id: @user, user: { email: @user.email, name: @user.name, user_name: @user.user_name } assert_redirected_to user_path(assigns(:user)) end diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml index cf39694..ea3e874 100644 --- a/test/fixtures/users.yml +++ b/test/fixtures/users.yml @@ -4,12 +4,8 @@ one: name: MyString email: MyString user_name: MyString - password_digest: MyString - remember_token: MyString two: name: MyString email: MyString user_name: MyString - password_digest: MyString - remember_token: MyString |