mirror of
http://ghproxy.cn/https://github.com/multunus/onemdm-server
synced 2025-12-06 02:04:57 +00:00
Added Models App, Installation Batch Installation
This commit is contained in:
7
spec/factories/app.rb
Normal file
7
spec/factories/app.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
FactoryGirl.define do
|
||||
factory :app do
|
||||
name "My Ultimate Application"
|
||||
package_name "my.ultimate.application"
|
||||
end
|
||||
|
||||
end
|
||||
6
spec/factories/batch_installations.rb
Normal file
6
spec/factories/batch_installations.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
FactoryGirl.define do
|
||||
factory :batch_installation do
|
||||
app_id 1
|
||||
end
|
||||
|
||||
end
|
||||
8
spec/factories/installations.rb
Normal file
8
spec/factories/installations.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
FactoryGirl.define do
|
||||
factory :installation do
|
||||
device_id 1
|
||||
batch_installation_id 1
|
||||
status 1
|
||||
end
|
||||
|
||||
end
|
||||
11
spec/models/app.rb
Normal file
11
spec/models/app.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe App, type: :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
|
||||
let!(:app) { create(:app) }
|
||||
|
||||
it { should validate_presence_of :name }
|
||||
it { should validate_presence_of :package_name }
|
||||
|
||||
end
|
||||
5
spec/models/batch_installation_spec.rb
Normal file
5
spec/models/batch_installation_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe BatchInstallation, type: :model do
|
||||
it {should belong_to(:app)}
|
||||
end
|
||||
32
spec/models/installation_spec.rb
Normal file
32
spec/models/installation_spec.rb
Normal file
@@ -0,0 +1,32 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Installation, type: :model do
|
||||
it { should belong_to(:device) }
|
||||
it { should belong_to(:batch_installation) }
|
||||
|
||||
|
||||
|
||||
# Create Installation Model [Device ID, batch installation ID, status(Pushed, Downloaded, Cancelled, Installed)]
|
||||
describe "Installation status" do
|
||||
let!(:installation){FactoryGirl.create(:installation)}
|
||||
it "Pushed" do
|
||||
installation.pushed!
|
||||
expect(installation.status).to eql Installation.statuses.keys[0]
|
||||
end
|
||||
it "Downloaded" do
|
||||
installation.downloaded!
|
||||
expect(installation.status).to eql Installation.statuses.keys[1]
|
||||
end
|
||||
it "Cancelled" do
|
||||
installation.cancelled!
|
||||
expect(installation.status).to eql Installation.statuses.keys[2]
|
||||
end
|
||||
|
||||
it "Installed" do
|
||||
installation.installed!
|
||||
expect(installation.status).to eql Installation.statuses.keys[3]
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user