summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-24 09:08:51 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-24 09:08:51 +0000
commit38149afcf95e7669a7a99828c579d185b70c04dc (patch)
tree3a90504bd926407c0cc60f44e20dba08217b928b /spec
parentbe660fe1d28a65ad61be24c71e66ae90f6488dc4 (diff)
downloadgitlab-ce-38149afcf95e7669a7a99828c579d185b70c04dc.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/fixtures/api/schemas/entities/issue_board.json1
-rw-r--r--spec/frontend/boards/components/issue_due_date_spec.js13
-rw-r--r--spec/lib/gitlab/omniauth_logging/json_formatter_spec.rb12
-rw-r--r--spec/lib/gitlab/reactive_cache_set_cache_spec.rb74
-rw-r--r--spec/support/caching.rb15
5 files changed, 112 insertions, 3 deletions
diff --git a/spec/fixtures/api/schemas/entities/issue_board.json b/spec/fixtures/api/schemas/entities/issue_board.json
index 09f66813c95..d7e3c45b13b 100644
--- a/spec/fixtures/api/schemas/entities/issue_board.json
+++ b/spec/fixtures/api/schemas/entities/issue_board.json
@@ -5,6 +5,7 @@
"iid": { "type": "integer" },
"title": { "type": "string" },
"confidential": { "type": "boolean" },
+ "closed": { "type": "boolean" },
"due_date": { "type": "date" },
"project_id": { "type": "integer" },
"relative_position": { "type": ["integer", "null"] },
diff --git a/spec/frontend/boards/components/issue_due_date_spec.js b/spec/frontend/boards/components/issue_due_date_spec.js
index 68e26b68f04..8cb1d963851 100644
--- a/spec/frontend/boards/components/issue_due_date_spec.js
+++ b/spec/frontend/boards/components/issue_due_date_spec.js
@@ -7,8 +7,8 @@ describe('Issue Due Date component', () => {
let vm;
let date;
const Component = Vue.extend(IssueDueDate);
- const createComponent = (dueDate = new Date()) =>
- mountComponent(Component, { date: dateFormat(dueDate, 'yyyy-mm-dd', true) });
+ const createComponent = (dueDate = new Date(), closed = false) =>
+ mountComponent(Component, { closed, date: dateFormat(dueDate, 'yyyy-mm-dd', true) });
beforeEach(() => {
date = new Date();
@@ -56,10 +56,17 @@ describe('Issue Due Date component', () => {
expect(vm.$el.querySelector('time').textContent.trim()).toEqual(dateFormat(date, format));
});
- it('should contain the correct `.text-danger` css class for overdue issue', () => {
+ it('should contain the correct `.text-danger` css class for overdue issue that is open', () => {
date.setDate(date.getDate() - 17);
vm = createComponent(date);
expect(vm.$el.querySelector('time').classList.contains('text-danger')).toEqual(true);
});
+
+ it('should not contain the `.text-danger` css class for overdue issue that is closed', () => {
+ date.setDate(date.getDate() - 17);
+ vm = createComponent(date, true);
+
+ expect(vm.$el.querySelector('time').classList.contains('text-danger')).toEqual(false);
+ });
});
diff --git a/spec/lib/gitlab/omniauth_logging/json_formatter_spec.rb b/spec/lib/gitlab/omniauth_logging/json_formatter_spec.rb
new file mode 100644
index 00000000000..36405daed5a
--- /dev/null
+++ b/spec/lib/gitlab/omniauth_logging/json_formatter_spec.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Gitlab::OmniauthLogging::JSONFormatter do
+ it "generates log in json format" do
+ Timecop.freeze(Time.utc(2019, 12, 04, 9, 10, 11, 123456)) do
+ expect(subject.call(:info, Time.now, 'omniauth', 'log message'))
+ .to eq %Q({"severity":"info","timestamp":"2019-12-04T09:10:11.123Z","pid":#{Process.pid},"progname":"omniauth","message":"log message"}\n)
+ end
+ end
+end
diff --git a/spec/lib/gitlab/reactive_cache_set_cache_spec.rb b/spec/lib/gitlab/reactive_cache_set_cache_spec.rb
new file mode 100644
index 00000000000..58c8fd0c1c3
--- /dev/null
+++ b/spec/lib/gitlab/reactive_cache_set_cache_spec.rb
@@ -0,0 +1,74 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Gitlab::ReactiveCacheSetCache, :clean_gitlab_redis_cache do
+ let_it_be(:project) { create(:project) }
+ let(:cache_prefix) { 'cache_prefix' }
+ let(:expires_in) { 10.minutes }
+ let(:cache) { described_class.new(expires_in: expires_in) }
+
+ describe '#cache_key' do
+ subject { cache.cache_key(cache_prefix) }
+
+ it 'includes the suffix' do
+ expect(subject).to eq "#{cache_prefix}:set"
+ end
+ end
+
+ describe '#read' do
+ subject { cache.read(cache_prefix) }
+
+ it { is_expected.to be_empty }
+
+ context 'after item added' do
+ before do
+ cache.write(cache_prefix, 'test_item')
+ end
+
+ it { is_expected.to contain_exactly('test_item') }
+ end
+ end
+
+ describe '#write' do
+ it 'writes the value to the cache' do
+ cache.write(cache_prefix, 'test_item')
+
+ expect(cache.read(cache_prefix)).to contain_exactly('test_item')
+ end
+
+ it 'sets the expiry of the set' do
+ cache.write(cache_prefix, 'test_item')
+
+ expect(cache.ttl(cache_prefix)).to be_within(1).of(expires_in.seconds)
+ end
+ end
+
+ describe '#clear_cache!', :use_clean_rails_redis_caching do
+ it 'deletes the cached items' do
+ # Cached key and value
+ Rails.cache.write('test_item', 'test_value')
+ # Add key to set
+ cache.write(cache_prefix, 'test_item')
+
+ expect(cache.read(cache_prefix)).to contain_exactly('test_item')
+ cache.clear_cache!(cache_prefix)
+
+ expect(cache.read(cache_prefix)).to be_empty
+ end
+ end
+
+ describe '#include?' do
+ subject { cache.include?(cache_prefix, 'test_item') }
+
+ it { is_expected.to be(false) }
+
+ context 'item added' do
+ before do
+ cache.write(cache_prefix, 'test_item')
+ end
+
+ it { is_expected.to be(true) }
+ end
+ end
+end
diff --git a/spec/support/caching.rb b/spec/support/caching.rb
index ecbe65f7e97..883d531550a 100644
--- a/spec/support/caching.rb
+++ b/spec/support/caching.rb
@@ -21,6 +21,21 @@ RSpec.configure do |config|
ActionController::Base.cache_store = caching_store
end
+ config.around(:each, :use_clean_rails_redis_caching) do |example|
+ original_null_store = Rails.cache
+ caching_config_hash = Gitlab::Redis::Cache.params
+ caching_config_hash[:namespace] = Gitlab::Redis::Cache::CACHE_NAMESPACE
+ Rails.cache = ActiveSupport::Cache::RedisCacheStore.new(caching_config_hash)
+
+ redis_cache_cleanup!
+
+ example.run
+
+ redis_cache_cleanup!
+
+ Rails.cache = original_null_store
+ end
+
config.around(:each, :use_sql_query_cache) do |example|
ActiveRecord::Base.cache do
example.run