diff options
author | Shinya Maeda <shinya@gitlab.com> | 2017-06-28 10:16:19 +0300 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2017-06-28 10:16:19 +0300 |
commit | bbb3babf8a17c719fa5cd2c56dd24f00d842fed1 (patch) | |
tree | 9fb84a266322c4996c0eaa5d162287bc08e7854f /spec | |
parent | 90610c2a45a892f9f2797a9c23f856135fa76e52 (diff) | |
parent | de893b19c30acf83ce43dd42376783505d704763 (diff) |
Merged HasVariable
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/ci/project_variable_spec.rb | 23 | ||||
-rw-r--r-- | spec/models/concerns/has_variable_spec.rb (renamed from spec/models/ci/variable_spec.rb) | 31 |
2 files changed, 26 insertions, 28 deletions
diff --git a/spec/models/ci/project_variable_spec.rb b/spec/models/ci/project_variable_spec.rb index 2c72c401f04..3c2d6a19cf5 100644 --- a/spec/models/ci/project_variable_spec.rb +++ b/spec/models/ci/project_variable_spec.rb @@ -3,5 +3,28 @@ require 'spec_helper' describe Ci::ProjectVariable, models: true do subject { build(:ci_project_variable) } + it { is_expected.to include_module(HasVariable) } it { is_expected.to validate_uniqueness_of(:key).scoped_to(:project_id) } + + describe '.unprotected' do + subject { described_class.unprotected } + + context 'when variable is protected' do + before do + create(:ci_variable, :protected) + end + + it 'returns nothing' do + is_expected.to be_empty + end + end + + context 'when variable is not protected' do + let(:variable) { create(:ci_variable, protected: false) } + + it 'returns the variable' do + is_expected.to contain_exactly(variable) + end + end + end end diff --git a/spec/models/ci/variable_spec.rb b/spec/models/concerns/has_variable_spec.rb index 3f18681a56a..f4b24e6d1d9 100644 --- a/spec/models/ci/variable_spec.rb +++ b/spec/models/concerns/has_variable_spec.rb @@ -1,10 +1,7 @@ require 'spec_helper' -describe Ci::Variable, models: true do - set(:project) { create(:empty_project) } - let(:secret_value) { 'secret' } - - subject { build(:ci_variable, project_id: project.id) } +describe HasVariable do + subject { build(:ci_variable) } it { is_expected.to validate_presence_of(:key) } it { is_expected.to validate_length_of(:key).is_at_most(255) } @@ -12,31 +9,9 @@ describe Ci::Variable, models: true do it { is_expected.not_to allow_value('foo bar').for(:key) } it { is_expected.not_to allow_value('foo/bar').for(:key) } - describe '.unprotected' do - subject { described_class.unprotected } - - context 'when variable is protected' do - before do - create(:ci_variable, :protected) - end - - it 'returns nothing' do - is_expected.to be_empty - end - end - - context 'when variable is not protected' do - let(:variable) { create(:ci_variable, protected: false) } - - it 'returns the variable' do - is_expected.to contain_exactly(variable) - end - end - end - describe '#value' do before do - subject.value = secret_value + subject.value = 'secret' end it 'stores the encrypted value' do |