summaryrefslogtreecommitdiff
path: root/spec/models
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-04-13 15:47:18 +0200
committerKamil Trzcinski <ayufan@ayufan.eu>2016-04-13 15:47:18 +0200
commit4af0968c43d517a3d702658749b5117ba4b9e11a (patch)
treed62a15cbcae8e1d1af00208c28fd1b09d01140f1 /spec/models
parent872bbb9fe2a5fbb5195aa448b615191baae960d7 (diff)
parentf026e53c4df5b0b3bb7435c05d3c8662afe45881 (diff)
downloadgitlab-ce-4af0968c43d517a3d702658749b5117ba4b9e11a.tar.gz
Merge remote-tracking branch 'origin/master' into ci-commit-as-pipeline
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/notification_setting_spec.rb17
-rw-r--r--spec/models/repository_spec.rb2
2 files changed, 19 insertions, 0 deletions
diff --git a/spec/models/notification_setting_spec.rb b/spec/models/notification_setting_spec.rb
new file mode 100644
index 00000000000..295081e9da1
--- /dev/null
+++ b/spec/models/notification_setting_spec.rb
@@ -0,0 +1,17 @@
+require 'rails_helper'
+
+RSpec.describe NotificationSetting, type: :model do
+ describe "Associations" do
+ it { is_expected.to belong_to(:user) }
+ it { is_expected.to belong_to(:source) }
+ end
+
+ describe "Validation" do
+ subject { NotificationSetting.new(source_id: 1, source_type: 'Project') }
+
+ it { is_expected.to validate_presence_of(:user) }
+ it { is_expected.to validate_presence_of(:source) }
+ it { is_expected.to validate_presence_of(:level) }
+ it { is_expected.to validate_uniqueness_of(:user_id).scoped_to([:source_id, :source_type]).with_message(/already exists in source/) }
+ end
+end
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb
index 4e49c413f23..c3a4016fa49 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -393,6 +393,8 @@ describe Repository, models: true do
describe '#expire_cache' do
it 'expires all caches' do
expect(repository).to receive(:expire_branch_cache)
+ expect(repository).to receive(:expire_branch_count_cache)
+ expect(repository).to receive(:expire_tag_count_cache)
repository.expire_cache
end