Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/frontend/labels_select_spec.js44
-rw-r--r--spec/frontend/registry/settings/components/registry_settings_app_spec.js27
-rw-r--r--spec/models/zoom_meeting_spec.rb47
3 files changed, 108 insertions, 10 deletions
diff --git a/spec/frontend/labels_select_spec.js b/spec/frontend/labels_select_spec.js
index 59116b64298..5f48bad4970 100644
--- a/spec/frontend/labels_select_spec.js
+++ b/spec/frontend/labels_select_spec.js
@@ -23,6 +23,16 @@ const mockScopedLabels = [
},
];
+const mockScopedLabels2 = [
+ {
+ id: 28,
+ title: 'Foo::Bar2',
+ description: 'Foobar2',
+ color: '#FFFFFF',
+ text_color: '#000000',
+ },
+];
+
describe('LabelsSelect', () => {
describe('getLabelTemplate', () => {
describe('when normal label is present', () => {
@@ -108,11 +118,45 @@ describe('LabelsSelect', () => {
expect($labelEl.find('span.gl-label-text').attr('style')).toBe(
`background-color: ${label.color}; color: ${label.text_color};`,
);
+ expect(
+ $labelEl
+ .find('span.gl-label-text')
+ .last()
+ .attr('style'),
+ ).toBe(`color: ${label.color};`);
});
it('generated label item has a badge class', () => {
expect($labelEl.find('span').hasClass('gl-label-text')).toEqual(true);
});
});
+
+ describe('when scoped label is present, with text color not white', () => {
+ const label = mockScopedLabels2[0];
+ let $labelEl;
+
+ beforeEach(() => {
+ $labelEl = $(
+ LabelsSelect.getLabelTemplate({
+ labels: mockScopedLabels2,
+ issueUpdateURL: mockUrl,
+ enableScopedLabels: true,
+ scopedLabelsDocumentationLink: 'docs-link',
+ }),
+ );
+ });
+
+ it('generated label item template has correct label styles', () => {
+ expect($labelEl.find('span.gl-label-text').attr('style')).toBe(
+ `background-color: ${label.color}; color: ${label.text_color};`,
+ );
+ expect(
+ $labelEl
+ .find('span.gl-label-text')
+ .last()
+ .attr('style'),
+ ).toBe(`color: ${label.text_color};`);
+ });
+ });
});
});
diff --git a/spec/frontend/registry/settings/components/registry_settings_app_spec.js b/spec/frontend/registry/settings/components/registry_settings_app_spec.js
index e9ba65e4387..c83cc0c00dd 100644
--- a/spec/frontend/registry/settings/components/registry_settings_app_spec.js
+++ b/spec/frontend/registry/settings/components/registry_settings_app_spec.js
@@ -44,15 +44,6 @@ describe('Registry Settings App', () => {
expect(store.dispatch).toHaveBeenCalledWith('fetchSettings');
});
- it('show a toast if fetchSettings fails', () => {
- mountComponent({ dispatchMock: 'mockRejectedValue' });
- return wrapper.vm.$nextTick().then(() =>
- expect(wrapper.vm.$toast.show).toHaveBeenCalledWith(FETCH_SETTINGS_ERROR_MESSAGE, {
- type: 'error',
- }),
- );
- });
-
it('renders the setting form', () => {
mountComponent();
expect(findSettingsComponent().exists()).toBe(true);
@@ -68,7 +59,23 @@ describe('Registry Settings App', () => {
});
it('shows an alert', () => {
- expect(findAlert().exists()).toBe(true);
+ expect(findAlert().html()).toContain(
+ 'Currently, the Container Registry tag expiration feature is not available',
+ );
+ });
+ });
+
+ describe('fetchSettingsError', () => {
+ beforeEach(() => {
+ mountComponent({ dispatchMock: 'mockRejectedValue' });
+ });
+
+ it('the form is hidden', () => {
+ expect(findSettingsComponent().exists()).toBe(false);
+ });
+
+ it('shows an alert', () => {
+ expect(findAlert().html()).toContain(FETCH_SETTINGS_ERROR_MESSAGE);
});
});
});
diff --git a/spec/models/zoom_meeting_spec.rb b/spec/models/zoom_meeting_spec.rb
index 3dad957a1ce..d496b968f1e 100644
--- a/spec/models/zoom_meeting_spec.rb
+++ b/spec/models/zoom_meeting_spec.rb
@@ -151,4 +151,51 @@ describe ZoomMeeting do
it_behaves_like 'can remove meetings'
end
end
+
+ describe '.distinct_count_by' do
+ let(:issue_1) { create(:issue) }
+ let(:issue_2) { create(:issue) }
+
+ context 'two meetings for the same issue' do
+ before do
+ create(:zoom_meeting, issue: issue_1)
+ create(:zoom_meeting, :removed_from_issue, issue: issue_1)
+ end
+
+ it 'returns a count of 1' do
+ expect(described_class.distinct_count_by(:issue_id)).to eq(1)
+ end
+
+ context 'when given no colum to count' do
+ it 'counts by :id and returns a count of 2' do
+ expect(described_class.distinct_count_by).to eq(2)
+ end
+ end
+ end
+
+ context 'one meeting for each issue' do
+ it 'returns a count of 2' do
+ create(:zoom_meeting, issue: issue_1)
+ create(:zoom_meeting, issue: issue_2)
+
+ expect(described_class.distinct_count_by(:issue_id)).to eq(2)
+ end
+ end
+
+ context 'the count query times out' do
+ before do
+ allow_next_instance_of(ActiveRecord::Relation) do |instance|
+ allow(instance).to receive(:count).and_raise(ActiveRecord::StatementInvalid.new(''))
+ end
+ end
+
+ it 'does not raise an error' do
+ expect { described_class.distinct_count_by(:issue_id) }.not_to raise_error
+ end
+
+ it 'returns -1' do
+ expect(described_class.distinct_count_by(:issue_id)).to eq(-1)
+ end
+ end
+ end
end