Add AndroidDeviceRegistrationToken model belonging to user
This commit is contained in:
parent
a727dfb1dd
commit
cf5c02626d
6 changed files with 34 additions and 1 deletions
3
app/models/android_device_registration_token.rb
Normal file
3
app/models/android_device_registration_token.rb
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
class AndroidDeviceRegistrationToken < ActiveRecord::Base
|
||||||
|
belongs_to :user
|
||||||
|
end
|
|
@ -23,6 +23,7 @@ class User < ActiveRecord::Base
|
||||||
has_many :outgoing_requests,
|
has_many :outgoing_requests,
|
||||||
class_name: 'Request', foreign_key: 'creditor_id'
|
class_name: 'Request', foreign_key: 'creditor_id'
|
||||||
has_many :notifications
|
has_many :notifications
|
||||||
|
has_many :android_device_registration_tokens, class_name: 'AndroidDeviceRegistrationToken', foreign_key: 'user_id'
|
||||||
|
|
||||||
has_many :issued_transactions, as: :issuer, class_name: 'Transaction'
|
has_many :issued_transactions, as: :issuer, class_name: 'Transaction'
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
class CreateAndroidDeviceRegistrationTokens < ActiveRecord::Migration[5.2]
|
||||||
|
def change
|
||||||
|
create_table :android_device_registration_tokens do |t|
|
||||||
|
t.string :token
|
||||||
|
t.belongs_to :user, foreign_key: true
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
10
db/schema.rb
10
db/schema.rb
|
@ -10,7 +10,15 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 2018_06_20_161021) do
|
ActiveRecord::Schema.define(version: 2019_05_08_192738) do
|
||||||
|
|
||||||
|
create_table "android_device_registration_tokens", force: :cascade do |t|
|
||||||
|
t.string "token"
|
||||||
|
t.integer "user_id"
|
||||||
|
t.datetime "created_at", null: false
|
||||||
|
t.datetime "updated_at", null: false
|
||||||
|
t.index ["user_id"], name: "index_android_device_registration_tokens_on_user_id"
|
||||||
|
end
|
||||||
|
|
||||||
create_table "clients", force: :cascade do |t|
|
create_table "clients", force: :cascade do |t|
|
||||||
t.string "name", null: false
|
t.string "name", null: false
|
||||||
|
|
6
spec/factories/android_device_registration_tokens.rb
Normal file
6
spec/factories/android_device_registration_tokens.rb
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
FactoryGirl.define do
|
||||||
|
factory :android_device_registration_token do
|
||||||
|
token "MyString"
|
||||||
|
user nil
|
||||||
|
end
|
||||||
|
end
|
5
spec/models/android_device_registration_token_spec.rb
Normal file
5
spec/models/android_device_registration_token_spec.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe AndroidDeviceRegistrationToken, type: :model do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
Loading…
Reference in a new issue