summaryrefslogtreecommitdiff
path: root/spec/models
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-09-18 14:02:45 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-09-18 14:02:45 +0000
commit80f61b4035607d7cd87de993b8f5e996bde3481f (patch)
tree06b12f51e97d87192e3dd0e05edf55143645b894 /spec/models
parent4ab54c2233e91f60a80e5b6fa2181e6899fdcc3e (diff)
downloadgitlab-ce-80f61b4035607d7cd87de993b8f5e996bde3481f.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/clusters/applications/ingress_spec.rb37
-rw-r--r--spec/models/concerns/issuable_states_spec.rb2
-rw-r--r--spec/models/milestone_spec.rb6
-rw-r--r--spec/models/note_spec.rb8
-rw-r--r--spec/models/project_services/bugzilla_service_spec.rb2
-rw-r--r--spec/models/project_services/custom_issue_tracker_service_spec.rb2
-rw-r--r--spec/models/project_services/gitlab_issue_tracker_service_spec.rb2
-rw-r--r--spec/models/project_services/jira_service_spec.rb4
-rw-r--r--spec/models/project_services/redmine_service_spec.rb2
-rw-r--r--spec/models/project_services/youtrack_service_spec.rb2
-rw-r--r--spec/models/repository_spec.rb49
-rw-r--r--spec/models/todo_spec.rb16
-rw-r--r--spec/models/user_spec.rb2
13 files changed, 72 insertions, 62 deletions
diff --git a/spec/models/clusters/applications/ingress_spec.rb b/spec/models/clusters/applications/ingress_spec.rb
index f984f6ba0ce..d9461ee8581 100644
--- a/spec/models/clusters/applications/ingress_spec.rb
+++ b/spec/models/clusters/applications/ingress_spec.rb
@@ -131,4 +131,41 @@ describe Clusters::Applications::Ingress do
expect(values).to include('podAnnotations')
end
end
+
+ describe '#values' do
+ let(:project) { build(:project) }
+ let(:cluster) { build(:cluster, projects: [project]) }
+
+ context 'when ingress_modsecurity is enabled' do
+ before do
+ stub_feature_flags(ingress_modsecurity: true)
+
+ allow(subject).to receive(:cluster).and_return(cluster)
+ end
+
+ it 'includes modsecurity module enablement' do
+ expect(subject.values).to include("enable-modsecurity: 'true'")
+ end
+
+ it 'includes modsecurity core ruleset enablement' do
+ expect(subject.values).to include("enable-owasp-modsecurity-crs: 'true'")
+ end
+ end
+
+ context 'when ingress_modsecurity is disabled' do
+ before do
+ stub_feature_flags(ingress_modsecurity: false)
+
+ allow(subject).to receive(:cluster).and_return(cluster)
+ end
+
+ it 'excludes modsecurity module enablement' do
+ expect(subject.values).not_to include('enable-modsecurity')
+ end
+
+ it 'excludes modsecurity core ruleset enablement' do
+ expect(subject.values).not_to include('enable-owasp-modsecurity-crs')
+ end
+ end
+ end
end
diff --git a/spec/models/concerns/issuable_states_spec.rb b/spec/models/concerns/issuable_states_spec.rb
index 70450159cc0..a5e19cdfc4f 100644
--- a/spec/models/concerns/issuable_states_spec.rb
+++ b/spec/models/concerns/issuable_states_spec.rb
@@ -4,7 +4,7 @@ require 'spec_helper'
# This spec checks if state_id column of issues and merge requests
# are being synced on every save.
-# It can be removed in the next release. Check https://gitlab.com/gitlab-org/gitlab-ce/issues/51789 for more information.
+# It can be removed in the next release. Check https://gitlab.com/gitlab-org/gitlab-foss/issues/51789 for more information.
describe IssuableStates do
[Issue, MergeRequest].each do |klass|
it "syncs state_id column when #{klass.model_name.human} gets created" do
diff --git a/spec/models/milestone_spec.rb b/spec/models/milestone_spec.rb
index 0c4952eebd7..2ecbe548520 100644
--- a/spec/models/milestone_spec.rb
+++ b/spec/models/milestone_spec.rb
@@ -530,9 +530,9 @@ describe Milestone do
describe '.link_reference_pattern' do
subject { described_class.link_reference_pattern }
- it { is_expected.to match("#{Gitlab.config.gitlab.url}/gitlab-org/gitlab-ce/milestones/123") }
- it { is_expected.to match("#{Gitlab.config.gitlab.url}/gitlab-org/gitlab-ce/-/milestones/123") }
- it { is_expected.not_to match("#{Gitlab.config.gitlab.url}/gitlab-org/gitlab-ce/issues/123") }
+ it { is_expected.to match("#{Gitlab.config.gitlab.url}/gitlab-org/gitlab-foss/milestones/123") }
+ it { is_expected.to match("#{Gitlab.config.gitlab.url}/gitlab-org/gitlab-foss/-/milestones/123") }
+ it { is_expected.not_to match("#{Gitlab.config.gitlab.url}/gitlab-org/gitlab-foss/issues/123") }
it { is_expected.not_to match("gitlab-org/gitlab-ce/milestones/123") }
end
end
diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb
index 927fbdb93d8..66e3c6d5e9d 100644
--- a/spec/models/note_spec.rb
+++ b/spec/models/note_spec.rb
@@ -73,6 +73,10 @@ describe Note do
end
describe "Commit notes" do
+ before do
+ allow(Gitlab::Git::KeepAround).to receive(:execute).and_call_original
+ end
+
let!(:note) { create(:note_on_commit, note: "+1 from me") }
let!(:commit) { note.noteable }
@@ -92,7 +96,9 @@ describe Note do
end
it "keeps the commit around" do
- expect(note.project.repository.kept_around?(commit.id)).to be_truthy
+ repo = note.project.repository
+
+ expect(repo.ref_exists?("refs/keep-around/#{commit.id}")).to be_truthy
end
it 'does not generate N+1 queries for participants', :request_store do
diff --git a/spec/models/project_services/bugzilla_service_spec.rb b/spec/models/project_services/bugzilla_service_spec.rb
index e25d87f61d6..66481a461ca 100644
--- a/spec/models/project_services/bugzilla_service_spec.rb
+++ b/spec/models/project_services/bugzilla_service_spec.rb
@@ -41,7 +41,7 @@ describe BugzillaService do
{ project_url: url, issues_url: url, new_issue_url: url }
end
- # this will be removed as part of https://gitlab.com/gitlab-org/gitlab-ce/issues/63084
+ # this will be removed as part of https://gitlab.com/gitlab-org/gitlab-foss/issues/63084
context 'when data are stored in properties' do
let(:properties) { access_params.merge(title: title, description: description) }
let(:service) do
diff --git a/spec/models/project_services/custom_issue_tracker_service_spec.rb b/spec/models/project_services/custom_issue_tracker_service_spec.rb
index 8359bc6807a..50bf15cfc8c 100644
--- a/spec/models/project_services/custom_issue_tracker_service_spec.rb
+++ b/spec/models/project_services/custom_issue_tracker_service_spec.rb
@@ -55,7 +55,7 @@ describe CustomIssueTrackerService do
{ project_url: url, issues_url: url, new_issue_url: url }
end
- # this will be removed as part of https://gitlab.com/gitlab-org/gitlab-ce/issues/63084
+ # this will be removed as part of https://gitlab.com/gitlab-org/gitlab-foss/issues/63084
context 'when data are stored in properties' do
let(:properties) { access_params.merge(title: title, description: description) }
let(:service) do
diff --git a/spec/models/project_services/gitlab_issue_tracker_service_spec.rb b/spec/models/project_services/gitlab_issue_tracker_service_spec.rb
index 4f3736ca65b..2dc0b67239c 100644
--- a/spec/models/project_services/gitlab_issue_tracker_service_spec.rb
+++ b/spec/models/project_services/gitlab_issue_tracker_service_spec.rb
@@ -58,7 +58,7 @@ describe GitlabIssueTrackerService do
{ project_url: url, issues_url: url, new_issue_url: url }
end
- # this will be removed as part of https://gitlab.com/gitlab-org/gitlab-ce/issues/63084
+ # this will be removed as part of https://gitlab.com/gitlab-org/gitlab-foss/issues/63084
context 'when data are stored in properties' do
let(:properties) { access_params.merge(title: title, description: description) }
let(:service) do
diff --git a/spec/models/project_services/jira_service_spec.rb b/spec/models/project_services/jira_service_spec.rb
index a976745023b..39c1176f238 100644
--- a/spec/models/project_services/jira_service_spec.rb
+++ b/spec/models/project_services/jira_service_spec.rb
@@ -278,7 +278,7 @@ describe JiraService do
end
end
- # this will be removed as part of https://gitlab.com/gitlab-org/gitlab-ce/issues/63084
+ # this will be removed as part of https://gitlab.com/gitlab-org/gitlab-foss/issues/63084
context 'when data are stored in properties' do
let(:properties) { data_params.merge(title: title, description: description) }
let!(:service) do
@@ -650,7 +650,7 @@ describe JiraService do
end
end
- describe 'favicon urls', :request_store do
+ describe 'favicon urls' do
it 'includes the standard favicon' do
props = described_class.new.send(:build_remote_link_props, url: 'http://example.com', title: 'title')
expect(props[:object][:icon][:url16x16]).to match %r{^http://localhost/assets/favicon(?:-\h+).png$}
diff --git a/spec/models/project_services/redmine_service_spec.rb b/spec/models/project_services/redmine_service_spec.rb
index 4ef4064d069..2339c5a8421 100644
--- a/spec/models/project_services/redmine_service_spec.rb
+++ b/spec/models/project_services/redmine_service_spec.rb
@@ -57,7 +57,7 @@ describe RedmineService do
{ project_url: url, issues_url: url, new_issue_url: url }
end
- # this will be removed as part of https://gitlab.com/gitlab-org/gitlab-ce/issues/63084
+ # this will be removed as part of https://gitlab.com/gitlab-org/gitlab-foss/issues/63084
context 'when data are stored in properties' do
let(:properties) { access_params.merge(title: title, description: description) }
let(:service) do
diff --git a/spec/models/project_services/youtrack_service_spec.rb b/spec/models/project_services/youtrack_service_spec.rb
index eff9f451b1a..fe608baf16b 100644
--- a/spec/models/project_services/youtrack_service_spec.rb
+++ b/spec/models/project_services/youtrack_service_spec.rb
@@ -45,7 +45,7 @@ describe YoutrackService do
{ project_url: url, issues_url: url, new_issue_url: url }
end
- # this will be removed as part of https://gitlab.com/gitlab-org/gitlab-ce/issues/63084
+ # this will be removed as part of https://gitlab.com/gitlab-org/gitlab-foss/issues/63084
context 'when data are stored in properties' do
let(:properties) { access_params.merge(title: title, description: description) }
let(:service) do
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb
index 419e1dc2459..6dc47e0e501 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -2040,55 +2040,6 @@ describe Repository do
end
end
- describe "#keep_around" do
- it "does not fail if we attempt to reference bad commit" do
- expect(repository.kept_around?('abc1234')).to be_falsey
- end
-
- it "stores a reference to the specified commit sha so it isn't garbage collected" do
- repository.keep_around(sample_commit.id)
-
- expect(repository.kept_around?(sample_commit.id)).to be_truthy
- end
-
- it "attempting to call keep_around on truncated ref does not fail" do
- repository.keep_around(sample_commit.id)
- ref = repository.send(:keep_around_ref_name, sample_commit.id)
-
- path = Gitlab::GitalyClient::StorageSettings.allow_disk_access do
- File.join(repository.path, ref)
- end
- # Corrupt the reference
- File.truncate(path, 0)
-
- expect(repository.kept_around?(sample_commit.id)).to be_falsey
-
- repository.keep_around(sample_commit.id)
-
- expect(repository.kept_around?(sample_commit.id)).to be_falsey
-
- File.delete(path)
- end
-
- context 'for multiple SHAs' do
- it 'skips non-existent SHAs' do
- repository.keep_around('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', sample_commit.id)
-
- expect(repository.kept_around?(sample_commit.id)).to be_truthy
- end
-
- it 'skips already-kept-around SHAs' do
- repository.keep_around(sample_commit.id)
-
- expect(repository.raw_repository).to receive(:write_ref).exactly(1).and_call_original
-
- repository.keep_around(sample_commit.id, another_sample_commit.id)
-
- expect(repository.kept_around?(another_sample_commit.id)).to be_truthy
- end
- end
- end
-
describe '#contribution_guide', :use_clean_rails_memory_store_caching do
it 'returns and caches the output' do
expect(repository).to receive(:file_on_head)
diff --git a/spec/models/todo_spec.rb b/spec/models/todo_spec.rb
index ce17704acbd..c2566ccd047 100644
--- a/spec/models/todo_spec.rb
+++ b/spec/models/todo_spec.rb
@@ -273,6 +273,22 @@ describe Todo do
expect(described_class.any_for_target?(todo.target)).to eq(true)
end
+ it 'returns true if there is at least one todo for a given target with state pending' do
+ issue = create(:issue)
+ create(:todo, state: :done, target: issue)
+ create(:todo, state: :pending, target: issue)
+
+ expect(described_class.any_for_target?(issue)).to eq(true)
+ end
+
+ it 'returns false if there are only todos for a given target with state done while searching for pending' do
+ issue = create(:issue)
+ create(:todo, state: :done, target: issue)
+ create(:todo, state: :done, target: issue)
+
+ expect(described_class.any_for_target?(issue, :pending)).to eq(false)
+ end
+
it 'returns false if there are no todos for a given target' do
issue = create(:issue)
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index c339fad778b..228d1ce9964 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -616,7 +616,7 @@ describe User do
end
describe '#update_notification_email' do
- # Regression: https://gitlab.com/gitlab-org/gitlab-ce/issues/22846
+ # Regression: https://gitlab.com/gitlab-org/gitlab-foss/issues/22846
context 'when changing :email' do
let(:user) { create(:user) }
let(:new_email) { 'new-email@example.com' }