mirror of
http://ghproxy.cn/https://github.com/multunus/onemdm-server
synced 2025-12-06 10:14:59 +00:00
Add GCM token field to device
This commit is contained in:
@@ -19,6 +19,6 @@ class DevicesController < ApplicationController
|
|||||||
private
|
private
|
||||||
|
|
||||||
def device_params
|
def device_params
|
||||||
params.require(:device).permit(:model, :unique_id, :imei_number)
|
params.require(:device).permit(:model, :unique_id, :imei_number,:gcm_token)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ class Device < ActiveRecord::Base
|
|||||||
|
|
||||||
attr_accessor :status
|
attr_accessor :status
|
||||||
|
|
||||||
validates :unique_id, :model, presence: true
|
validates :unique_id, :model, :gcm_token, presence: true
|
||||||
validates :unique_id, uniqueness: true
|
validates :unique_id, uniqueness: true
|
||||||
|
|
||||||
before_create :generate_access_token
|
before_create :generate_access_token
|
||||||
|
|||||||
5
db/migrate/20151113095735_add_gcm_token_to_devices.rb
Normal file
5
db/migrate/20151113095735_add_gcm_token_to_devices.rb
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
class AddGcmTokenToDevices < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :devices, :gcm_token, :string
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
#
|
#
|
||||||
# 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: 20151109072450) do
|
ActiveRecord::Schema.define(version: 20151113095735) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
@@ -58,6 +58,7 @@ ActiveRecord::Schema.define(version: 20151109072450) do
|
|||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
t.integer "heartbeats_count", default: 0
|
t.integer "heartbeats_count", default: 0
|
||||||
t.datetime "last_heartbeat_recd_time"
|
t.datetime "last_heartbeat_recd_time"
|
||||||
|
t.string "gcm_token"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "heartbeats", force: :cascade do |t|
|
create_table "heartbeats", force: :cascade do |t|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
FactoryGirl.define do
|
FactoryGirl.define do
|
||||||
factory :device do
|
factory :device do
|
||||||
model "Nexus 6"
|
model "LGE - Nexus 5"
|
||||||
unique_id "someuniqueid"
|
unique_id "aa55589dd10a8819"
|
||||||
imei_number "someimeinumber"
|
gcm_token "dAJukxHtV84iij0z5PJruUhcNnQSOl7NdeAWS9Y45UVhPoG1wRGp7i2Hp34SyrodDfdZieeDzbPusqYyFuEB_vAUl5EDyYqFdzMNF1JpN2ThkEl_dTawWP9F9rSsNadV1HZ"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ RSpec.describe Device, type: :model do
|
|||||||
|
|
||||||
it { should validate_presence_of :unique_id }
|
it { should validate_presence_of :unique_id }
|
||||||
it { should validate_presence_of :model }
|
it { should validate_presence_of :model }
|
||||||
|
it { should validate_presence_of :gcm_token }
|
||||||
it { should validate_uniqueness_of :unique_id }
|
it { should validate_uniqueness_of :unique_id }
|
||||||
|
|
||||||
describe "before create" do
|
describe "before create" do
|
||||||
|
|||||||
Reference in New Issue
Block a user