summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/helpers/projects_helper_spec.rb68
-rw-r--r--spec/javascripts/visibility_select_spec.js98
2 files changed, 0 insertions, 166 deletions
diff --git a/spec/helpers/projects_helper_spec.rb b/spec/helpers/projects_helper_spec.rb
index ce96e90e2d7..46c55da24f8 100644
--- a/spec/helpers/projects_helper_spec.rb
+++ b/spec/helpers/projects_helper_spec.rb
@@ -322,74 +322,6 @@ describe ProjectsHelper do
end
end
- describe "#project_feature_access_select" do
- let(:project) { create(:project, :public) }
- let(:user) { create(:user) }
-
- context "when project is internal or public" do
- it "shows all options" do
- helper.instance_variable_set(:@project, project)
- result = helper.project_feature_access_select(:issues_access_level)
- expect(result).to include("Disabled")
- expect(result).to include("Only team members")
- expect(result).to include("Everyone with access")
- end
- end
-
- context "when project is private" do
- before do
- project.update_attributes(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
- end
-
- it "shows only allowed options" do
- helper.instance_variable_set(:@project, project)
- result = helper.project_feature_access_select(:issues_access_level)
- expect(result).to include("Disabled")
- expect(result).to include("Only team members")
- expect(result).to have_selector('option[disabled]', text: "Everyone with access")
- end
- end
-
- context "when project moves from public to private" do
- before do
- project.update_attributes(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
- end
-
- it "shows the highest allowed level selected" do
- helper.instance_variable_set(:@project, project)
- result = helper.project_feature_access_select(:issues_access_level)
-
- expect(result).to include("Disabled")
- expect(result).to include("Only team members")
- expect(result).to have_selector('option[disabled]', text: "Everyone with access")
- expect(result).to have_selector('option[selected]', text: "Only team members")
- end
- end
- end
-
- describe "#visibility_select_options" do
- let(:project) { create(:project, :repository) }
- let(:user) { create(:user) }
-
- before do
- allow(helper).to receive(:current_user).and_return(user)
-
- stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::PUBLIC])
- end
-
- it "does not include the Public restricted level" do
- expect(helper.send(:visibility_select_options, project, Gitlab::VisibilityLevel::PRIVATE)).not_to include('Public')
- end
-
- it "includes the Internal level" do
- expect(helper.send(:visibility_select_options, project, Gitlab::VisibilityLevel::PRIVATE)).to include('Internal')
- end
-
- it "includes the Private level" do
- expect(helper.send(:visibility_select_options, project, Gitlab::VisibilityLevel::PRIVATE)).to include('Private')
- end
- end
-
describe '#get_project_nav_tabs' do
let(:project) { create(:project) }
let(:user) { create(:user) }
diff --git a/spec/javascripts/visibility_select_spec.js b/spec/javascripts/visibility_select_spec.js
deleted file mode 100644
index 82714cb69bd..00000000000
--- a/spec/javascripts/visibility_select_spec.js
+++ /dev/null
@@ -1,98 +0,0 @@
-import VisibilitySelect from '~/visibility_select';
-
-(() => {
- describe('VisibilitySelect', function () {
- const lockedElement = document.createElement('div');
- lockedElement.dataset.helpBlock = 'lockedHelpBlock';
-
- const checkedElement = document.createElement('div');
- checkedElement.dataset.description = 'checkedDescription';
-
- const mockElements = {
- container: document.createElement('div'),
- select: document.createElement('div'),
- '.help-block': document.createElement('div'),
- '.js-locked': lockedElement,
- 'option:checked': checkedElement,
- };
-
- beforeEach(function () {
- spyOn(Element.prototype, 'querySelector').and.callFake(selector => mockElements[selector]);
- });
-
- describe('constructor', function () {
- beforeEach(function () {
- this.visibilitySelect = new VisibilitySelect(mockElements.container);
- });
-
- it('sets the container member', function () {
- expect(this.visibilitySelect.container).toEqual(mockElements.container);
- });
-
- it('queries and sets the helpBlock member', function () {
- expect(Element.prototype.querySelector).toHaveBeenCalledWith('.help-block');
- expect(this.visibilitySelect.helpBlock).toEqual(mockElements['.help-block']);
- });
-
- it('queries and sets the select member', function () {
- expect(Element.prototype.querySelector).toHaveBeenCalledWith('select');
- expect(this.visibilitySelect.select).toEqual(mockElements.select);
- });
-
- describe('if there is no container element provided', function () {
- it('throws an error', function () {
- expect(() => new VisibilitySelect()).toThrowError('VisibilitySelect requires a container element as argument 1');
- });
- });
- });
-
- describe('init', function () {
- describe('if there is a select', function () {
- beforeEach(function () {
- this.visibilitySelect = new VisibilitySelect(mockElements.container);
- });
-
- it('calls updateHelpText', function () {
- spyOn(VisibilitySelect.prototype, 'updateHelpText');
- this.visibilitySelect.init();
- expect(this.visibilitySelect.updateHelpText).toHaveBeenCalled();
- });
-
- it('adds a change event listener', function () {
- spyOn(this.visibilitySelect.select, 'addEventListener');
- this.visibilitySelect.init();
- expect(this.visibilitySelect.select.addEventListener.calls.argsFor(0)).toContain('change');
- });
- });
-
- describe('if there is no select', function () {
- beforeEach(function () {
- mockElements.select = undefined;
- this.visibilitySelect = new VisibilitySelect(mockElements.container);
- this.visibilitySelect.init();
- });
-
- it('updates the helpBlock text to the locked `data-help-block` messaged', function () {
- expect(this.visibilitySelect.helpBlock.textContent)
- .toEqual(lockedElement.dataset.helpBlock);
- });
-
- afterEach(function () {
- mockElements.select = document.createElement('div');
- });
- });
- });
-
- describe('updateHelpText', function () {
- beforeEach(function () {
- this.visibilitySelect = new VisibilitySelect(mockElements.container);
- this.visibilitySelect.init();
- });
-
- it('updates the helpBlock text to the selected options `data-description`', function () {
- expect(this.visibilitySelect.helpBlock.textContent)
- .toEqual(checkedElement.dataset.description);
- });
- });
- });
-})();