add missing specs

This commit is contained in:
Anton Chuchkalov 2016-01-20 14:49:30 +03:00
parent 80f39e4e54
commit df44b5b269
4 changed files with 31 additions and 5 deletions

View File

@ -22,6 +22,7 @@ module Devops
#define_hook :after_add_deploy_env #define_hook :after_add_deploy_env
attr_accessor :id, :deploy_envs, :type, :archived, :description, :run_list attr_accessor :id, :deploy_envs, :type, :archived, :description, :run_list
attr_accessor :components
MULTI_TYPE = "multi" MULTI_TYPE = "multi"

View File

@ -16,10 +16,6 @@ module Devops
super.merge(template_url: template_url) super.merge(template_url: template_url)
end end
def delete_template_file_from_storage
raise 'Implement me'
end
class << self class << self
def create(attrs) def create(attrs)

View File

@ -23,6 +23,23 @@ RSpec.describe Devops::Model::Project, type: :model do
project = build(:project, with_deploy_env_identifiers: ['foo', nil]) project = build(:project, with_deploy_env_identifiers: ['foo', nil])
expect(project).not_to be_valid expect(project).not_to be_valid
end end
describe 'components validation' do
it 'is valid with components with filenames' do
project.components = {'foo' => {'filename' => 'bar'}}
expect{project.validate_components}.not_to raise_error
end
it "isn't valid if components isn't a hash" do
project.components = []
expect{project.validate_components}.to raise_error InvalidRecord
end
it "raises InvalidRecord if one of componentsц hasn't filename" do
project.components = {'foo' => {}}
expect{project.validate_components}.to raise_error InvalidRecord
end
end
end end
describe '.fields' do describe '.fields' do

View File

@ -79,13 +79,25 @@ RSpec.describe Devops::Model::User, type: :model do
end end
end end
describe '.build_from_bson' do
it 'builds User model from given hash and assigns id' do
model = described_class.build_from_bson('_id' => 'foo', 'username' => 'not shown', 'email' => 'baz')
expect(model.id).to eq 'foo'
expect(model.email).to eq 'baz'
end
end
describe '#check_privileges' do describe '#check_privileges' do
it "raises InvalidPrivileges if user hasn't specified privilege" do it "raises InvalidPrivileges if user hasn't specified privilege" do
expect { user.check_privileges('key', 'w') }.to raise_error(InvalidPrivileges) expect { user.check_privileges('key', 'w') }.to raise_error(InvalidPrivileges)
end end
it 'does nothing is user has specified privilege' do it 'does nothing is user has specified privilege' do
user.check_privileges('key', 'r') expect{user.check_privileges('key', 'r')}.not_to raise_error
end
it 'raises InvalidPrivileges if given privelege is wrong' do
expect{user.check_privileges('key', 't')}.to raise_error InvalidPrivileges
end end
end end