diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 10:34:06 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 10:34:06 +0000 |
commit | 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch) | |
tree | d7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /spec/models/terraform/state_spec.rb | |
parent | 446d496a6d000c73a304be52587cd9bbc7493136 (diff) | |
download | gitlab-ce-13.9.0-rc42.tar.gz |
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'spec/models/terraform/state_spec.rb')
-rw-r--r-- | spec/models/terraform/state_spec.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/spec/models/terraform/state_spec.rb b/spec/models/terraform/state_spec.rb index ed311314086..1319e2adb03 100644 --- a/spec/models/terraform/state_spec.rb +++ b/spec/models/terraform/state_spec.rb @@ -8,8 +8,11 @@ RSpec.describe Terraform::State do it { is_expected.to belong_to(:project) } it { is_expected.to belong_to(:locked_by_user).class_name('User') } + it { is_expected.to validate_presence_of(:name) } it { is_expected.to validate_presence_of(:project_id) } + it { is_expected.to validate_uniqueness_of(:name).scoped_to(:project_id) } + describe 'scopes' do describe '.ordered_by_name' do let_it_be(:project) { create(:project) } @@ -25,6 +28,15 @@ RSpec.describe Terraform::State do it { expect(subject.map(&:name)).to eq(names.sort) } end + + describe '.with_name' do + let_it_be(:matching_name) { create(:terraform_state, name: 'matching-name') } + let_it_be(:other_name) { create(:terraform_state, name: 'other-name') } + + subject { described_class.with_name(matching_name.name) } + + it { is_expected.to contain_exactly(matching_name) } + end end describe '#destroy' do |