Added Models App, Installation Batch Installation

This commit is contained in:
Ernest Sankeshwar
2015-11-13 15:03:29 +00:00
parent cffea0c31d
commit 5a81168161
15 changed files with 147 additions and 1 deletions

7
spec/factories/app.rb Normal file
View File

@@ -0,0 +1,7 @@
FactoryGirl.define do
factory :app do
name "My Ultimate Application"
package_name "my.ultimate.application"
end
end

View File

@@ -0,0 +1,6 @@
FactoryGirl.define do
factory :batch_installation do
app_id 1
end
end

View 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
View 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

View File

@@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe BatchInstallation, type: :model do
it {should belong_to(:app)}
end

View 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