Skip to content

Commit ff4a0ba

Browse files
author
Ryan Bigg
committed
Section 7.1.1: Added admin flag to user
1 parent fcf008b commit ff4a0ba

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddAdminToUsers < ActiveRecord::Migration
2+
def change
3+
add_column :users, :admin, :boolean, default: false
4+
end
5+
end

ticketee/db/schema.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#
1212
# It's strongly recommended that you check this file into your version control system.
1313

14-
ActiveRecord::Schema.define(version: 20141130094135) do
14+
ActiveRecord::Schema.define(version: 20141206010551) do
1515

1616
create_table "projects", force: true do |t|
1717
t.string "name"
@@ -32,18 +32,19 @@
3232
add_index "tickets", ["project_id"], name: "index_tickets_on_project_id"
3333

3434
create_table "users", force: true do |t|
35-
t.string "email", default: "", null: false
36-
t.string "encrypted_password", default: "", null: false
35+
t.string "email", default: "", null: false
36+
t.string "encrypted_password", default: "", null: false
3737
t.string "reset_password_token"
3838
t.datetime "reset_password_sent_at"
3939
t.datetime "remember_created_at"
40-
t.integer "sign_in_count", default: 0, null: false
40+
t.integer "sign_in_count", default: 0, null: false
4141
t.datetime "current_sign_in_at"
4242
t.datetime "last_sign_in_at"
4343
t.string "current_sign_in_ip"
4444
t.string "last_sign_in_ip"
4545
t.datetime "created_at"
4646
t.datetime "updated_at"
47+
t.boolean "admin", default: false
4748
end
4849

4950
add_index "users", ["email"], name: "index_users_on_email", unique: true

ticketee/spec/factories/user_factory.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,9 @@
22
factory :user do
33
sequence(:email) { |n| "test#{n}@example.com" }
44
password "password"
5+
6+
trait :admin do
7+
admin true
8+
end
59
end
610
end

ticketee/spec/features/creating_projects_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
feature 'Creating Projects' do
44
before do
5+
login_as(FactoryGirl.create(:user, :admin))
56
visit '/'
67

78
click_link 'New Project'

0 commit comments

Comments
 (0)