diff --git a/app/models/key.rb b/app/models/key.rb new file mode 100644 index 00000000..fa699610 --- /dev/null +++ b/app/models/key.rb @@ -0,0 +1,3 @@ +class Key < ActiveRecord::Base + belongs_to :user +end diff --git a/app/models/user.rb b/app/models/user.rb index 9b0ff817..5c67c493 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -25,6 +25,8 @@ class User < ActiveRecord::Base has_many :member_projects, through: :project_members, source: :member_project has_many :issues + # authorization of ssh access + has_many :keys VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i diff --git a/db/migrate/20150718043105_create_keys.rb b/db/migrate/20150718043105_create_keys.rb new file mode 100644 index 00000000..af4a86d9 --- /dev/null +++ b/db/migrate/20150718043105_create_keys.rb @@ -0,0 +1,14 @@ +class CreateKeys < ActiveRecord::Migration + def change + create_table :keys do |t| + t.integer :user_id + t.text :key + t.string :title + t.string :fingerprint + + t.timestamps + end + + add_index :keys, [:user_id], name: 'index_keys_on_user_id' + end +end diff --git a/db/schema.rb b/db/schema.rb index 5ec0315b..f399e35a 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: 20150623095804) do +ActiveRecord::Schema.define(version: 20150718043105) do create_table "comments", force: true do |t| t.text "body" @@ -67,6 +67,17 @@ t.datetime "updated_at" end + create_table "keys", force: true do |t| + t.integer "user_id" + t.text "key" + t.string "title" + t.string "fingerprint" + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "keys", ["user_id"], name: "index_keys_on_user_id" + create_table "notification_statuses", force: true do |t| t.integer "victim_id" t.integer "notification_id" diff --git a/spec/factories/keys.rb b/spec/factories/keys.rb new file mode 100644 index 00000000..900101e6 --- /dev/null +++ b/spec/factories/keys.rb @@ -0,0 +1,7 @@ +FactoryGirl.define do + factory :key do + key 'MyText' + title 'MyString' + fingerprint 'MyString' + end +end diff --git a/spec/models/key_spec.rb b/spec/models/key_spec.rb new file mode 100644 index 00000000..eb9ec971 --- /dev/null +++ b/spec/models/key_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +RSpec.describe Key, type: :model do + pending 'add some examples to (or delete) #{__FILE__}' +end