summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorMarkus Koller <markus-koller@gmx.ch>2017-09-18 17:07:38 +0200
committerMarkus Koller <markus.koller.ext@siemens.com>2017-11-06 10:51:50 +0100
commit1f773a8ef5a1f76166d0455c6a5e473278885c17 (patch)
treeed2d955865b49aa5d102ccb4b4f64868d4d12b77 /spec
parent6902848a9c54f9eb1bfd82fe173ad0d5d62fe2d5 (diff)
downloadgitlab-ce-1f773a8ef5a1f76166d0455c6a5e473278885c17.tar.gz
Support custom attributes on groups
Diffstat (limited to 'spec')
-rw-r--r--spec/factories/group_custom_attributes.rb7
-rw-r--r--spec/models/group_custom_attribute_spec.rb16
-rw-r--r--spec/models/group_spec.rb1
-rw-r--r--spec/requests/api/groups_spec.rb10
4 files changed, 34 insertions, 0 deletions
diff --git a/spec/factories/group_custom_attributes.rb b/spec/factories/group_custom_attributes.rb
new file mode 100644
index 00000000000..7ff5f376e8b
--- /dev/null
+++ b/spec/factories/group_custom_attributes.rb
@@ -0,0 +1,7 @@
+FactoryGirl.define do
+ factory :group_custom_attribute do
+ group
+ sequence(:key) { |n| "key#{n}" }
+ sequence(:value) { |n| "value#{n}" }
+ end
+end
diff --git a/spec/models/group_custom_attribute_spec.rb b/spec/models/group_custom_attribute_spec.rb
new file mode 100644
index 00000000000..7ecb2022567
--- /dev/null
+++ b/spec/models/group_custom_attribute_spec.rb
@@ -0,0 +1,16 @@
+require 'spec_helper'
+
+describe GroupCustomAttribute do
+ describe 'assocations' do
+ it { is_expected.to belong_to(:group) }
+ end
+
+ describe 'validations' do
+ subject { build :group_custom_attribute }
+
+ it { is_expected.to validate_presence_of(:group) }
+ it { is_expected.to validate_presence_of(:key) }
+ it { is_expected.to validate_presence_of(:value) }
+ it { is_expected.to validate_uniqueness_of(:key).scoped_to(:group_id) }
+ end
+end
diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb
index 0e1a7fdce0b..c8caa11b8b0 100644
--- a/spec/models/group_spec.rb
+++ b/spec/models/group_spec.rb
@@ -17,6 +17,7 @@ describe Group do
it { is_expected.to have_many(:variables).class_name('Ci::GroupVariable') }
it { is_expected.to have_many(:uploads).dependent(:destroy) }
it { is_expected.to have_one(:chat_team) }
+ it { is_expected.to have_many(:custom_attributes).class_name('GroupCustomAttribute') }
describe '#members & #requesters' do
let(:requester) { create(:user) }
diff --git a/spec/requests/api/groups_spec.rb b/spec/requests/api/groups_spec.rb
index 8ce9fcc80bf..780dbce6488 100644
--- a/spec/requests/api/groups_spec.rb
+++ b/spec/requests/api/groups_spec.rb
@@ -618,4 +618,14 @@ describe API::Groups do
end
end
end
+
+ it_behaves_like 'custom attributes endpoints', 'groups' do
+ let(:attributable) { group1 }
+ let(:other_attributable) { group2 }
+ let(:user) { user1 }
+
+ before do
+ group2.add_owner(user1)
+ end
+ end
end