diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-11 09:06:27 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-11 09:06:27 +0300 |
commit | b4e072cbaf808793bafff148b0ec9d47819f479e (patch) | |
tree | c690c706803cf43b3358785681e693ea0e1f9f94 /spec | |
parent | 8c0166b9816477521bf34feb15575bbeb1a3c644 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/groups_controller_spec.rb | 2 | ||||
-rw-r--r-- | spec/features/projects/features_visibility_spec.rb | 2 | ||||
-rw-r--r-- | spec/lib/event_filter_spec.rb | 6 | ||||
-rw-r--r-- | spec/lib/gitlab/database_spec.rb | 14 | ||||
-rw-r--r-- | spec/lib/gitlab/kubernetes/helm/delete_command_spec.rb | 4 | ||||
-rw-r--r-- | spec/lib/gitlab/kubernetes/helm/install_command_spec.rb | 14 | ||||
-rw-r--r-- | spec/models/clusters/applications/cert_manager_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/event_collection_spec.rb | 83 |
8 files changed, 66 insertions, 61 deletions
diff --git a/spec/controllers/groups_controller_spec.rb b/spec/controllers/groups_controller_spec.rb index 404e61c5271..a35ef99ef12 100644 --- a/spec/controllers/groups_controller_spec.rb +++ b/spec/controllers/groups_controller_spec.rb @@ -125,7 +125,7 @@ describe GroupsController do end context 'as json' do - it 'includes all projects from groups and subgroups in event feed' do + it 'includes events from all projects in group and subgroups' do 2.times do project = create(:project, group: group) create(:event, project: project) diff --git a/spec/features/projects/features_visibility_spec.rb b/spec/features/projects/features_visibility_spec.rb index 531592ffd65..9ec61743a11 100644 --- a/spec/features/projects/features_visibility_spec.rb +++ b/spec/features/projects/features_visibility_spec.rb @@ -211,7 +211,7 @@ describe 'Edit Project Settings' do visit activity_project_path(project) page.within(".event-filter") do - expect(page).to have_selector("a", count: 2) + expect(page).to have_content("All") expect(page).not_to have_content("Push events") expect(page).not_to have_content("Merge events") expect(page).not_to have_content("Comments") diff --git a/spec/lib/event_filter_spec.rb b/spec/lib/event_filter_spec.rb index d6eca8d85ff..21b8f726425 100644 --- a/spec/lib/event_filter_spec.rb +++ b/spec/lib/event_filter_spec.rb @@ -3,12 +3,6 @@ require 'spec_helper' describe EventFilter do - describe 'FILTERS' do - it 'returns a definite list of filters' do - expect(described_class::FILTERS).to eq(%w[all push merged issue comments team]) - end - end - describe '#filter' do it 'returns "all" if given filter is nil' do expect(described_class.new(nil).filter).to eq(described_class::ALL) diff --git a/spec/lib/gitlab/database_spec.rb b/spec/lib/gitlab/database_spec.rb index 8d37de32179..15fb1503529 100644 --- a/spec/lib/gitlab/database_spec.rb +++ b/spec/lib/gitlab/database_spec.rb @@ -101,20 +101,6 @@ describe Gitlab::Database do end end - describe '.join_lateral_supported?' do - it 'returns false when using PostgreSQL 9.2' do - allow(described_class).to receive(:version).and_return('9.2.1') - - expect(described_class.join_lateral_supported?).to eq(false) - end - - it 'returns true when using PostgreSQL 9.3.0 or newer' do - allow(described_class).to receive(:version).and_return('9.3.0') - - expect(described_class.join_lateral_supported?).to eq(true) - end - end - describe '.replication_slots_supported?' do it 'returns false when using PostgreSQL 9.3' do allow(described_class).to receive(:version).and_return('9.3.1') diff --git a/spec/lib/gitlab/kubernetes/helm/delete_command_spec.rb b/spec/lib/gitlab/kubernetes/helm/delete_command_spec.rb index 39a46f9bc6d..2d3313cccb7 100644 --- a/spec/lib/gitlab/kubernetes/helm/delete_command_spec.rb +++ b/spec/lib/gitlab/kubernetes/helm/delete_command_spec.rb @@ -14,7 +14,7 @@ describe Gitlab::Kubernetes::Helm::DeleteCommand do let(:commands) do <<~EOS helm init --upgrade - for i in $(seq 1 30); do helm version && break; sleep 1s; echo "Retrying ($i)..."; done + for i in $(seq 1 30); do helm version && break; sleep 1s; echo "Retrying ($i)..."; false; done helm delete --purge app-name EOS end @@ -36,7 +36,7 @@ describe Gitlab::Kubernetes::Helm::DeleteCommand do let(:commands) do <<~EOS helm init --upgrade - for i in $(seq 1 30); do helm version #{tls_flags} && break; sleep 1s; echo "Retrying ($i)..."; done + for i in $(seq 1 30); do helm version #{tls_flags} && break; sleep 1s; echo "Retrying ($i)..."; false; done #{helm_delete_command} EOS end diff --git a/spec/lib/gitlab/kubernetes/helm/install_command_spec.rb b/spec/lib/gitlab/kubernetes/helm/install_command_spec.rb index f7f510f01db..bfe3dc23fed 100644 --- a/spec/lib/gitlab/kubernetes/helm/install_command_spec.rb +++ b/spec/lib/gitlab/kubernetes/helm/install_command_spec.rb @@ -36,7 +36,7 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do let(:commands) do <<~EOS helm init --upgrade - for i in $(seq 1 30); do helm version #{tls_flags} && break; sleep 1s; echo "Retrying ($i)..."; done + for i in $(seq 1 30); do helm version #{tls_flags} && break; sleep 1s; echo "Retrying ($i)..."; false; done helm repo add app-name https://repository.example.com helm repo update #{helm_install_comand} @@ -64,7 +64,7 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do let(:commands) do <<~EOS helm init --upgrade - for i in $(seq 1 30); do helm version #{tls_flags} && break; sleep 1s; echo "Retrying ($i)..."; done + for i in $(seq 1 30); do helm version #{tls_flags} && break; sleep 1s; echo "Retrying ($i)..."; false; done helm repo add app-name https://repository.example.com helm repo update #{helm_install_command} @@ -93,7 +93,7 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do let(:commands) do <<~EOS helm init --upgrade - for i in $(seq 1 30); do helm version #{tls_flags} && break; sleep 1s; echo "Retrying ($i)..."; done + for i in $(seq 1 30); do helm version #{tls_flags} && break; sleep 1s; echo "Retrying ($i)..."; false; done #{helm_install_command} EOS end @@ -120,7 +120,7 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do let(:commands) do <<~EOS helm init --upgrade - for i in $(seq 1 30); do helm version #{tls_flags} && break; sleep 1s; echo "Retrying ($i)..."; done + for i in $(seq 1 30); do helm version #{tls_flags} && break; sleep 1s; echo "Retrying ($i)..."; false; done helm repo add app-name https://repository.example.com helm repo update /bin/date @@ -151,7 +151,7 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do let(:commands) do <<~EOS helm init --upgrade - for i in $(seq 1 30); do helm version #{tls_flags} && break; sleep 1s; echo "Retrying ($i)..."; done + for i in $(seq 1 30); do helm version #{tls_flags} && break; sleep 1s; echo "Retrying ($i)..."; false; done helm repo add app-name https://repository.example.com helm repo update #{helm_install_command} @@ -182,7 +182,7 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do let(:commands) do <<~EOS helm init --upgrade - for i in $(seq 1 30); do helm version && break; sleep 1s; echo "Retrying ($i)..."; done + for i in $(seq 1 30); do helm version && break; sleep 1s; echo "Retrying ($i)..."; false; done helm repo add app-name https://repository.example.com helm repo update #{helm_install_command} @@ -210,7 +210,7 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do let(:commands) do <<~EOS helm init --upgrade - for i in $(seq 1 30); do helm version #{tls_flags} && break; sleep 1s; echo "Retrying ($i)..."; done + for i in $(seq 1 30); do helm version #{tls_flags} && break; sleep 1s; echo "Retrying ($i)..."; false; done helm repo add app-name https://repository.example.com helm repo update #{helm_install_command} diff --git a/spec/models/clusters/applications/cert_manager_spec.rb b/spec/models/clusters/applications/cert_manager_spec.rb index bddc09decc3..7e8780f0c90 100644 --- a/spec/models/clusters/applications/cert_manager_spec.rb +++ b/spec/models/clusters/applications/cert_manager_spec.rb @@ -54,7 +54,7 @@ describe Clusters::Applications::CertManager do 'kubectl label --overwrite namespace gitlab-managed-apps certmanager.k8s.io/disable-validation=true' ]) expect(subject.postinstall).to eq([ - 'for i in $(seq 1 30); do kubectl apply -f /data/helm/certmanager/config/cluster_issuer.yaml && break; sleep 1s; echo "Retrying ($i)..."; done' + 'for i in $(seq 1 30); do kubectl apply -f /data/helm/certmanager/config/cluster_issuer.yaml && break; sleep 1s; echo "Retrying ($i)..."; false; done' ]) end diff --git a/spec/models/event_collection_spec.rb b/spec/models/event_collection_spec.rb index efe511042c3..c421ffa000d 100644 --- a/spec/models/event_collection_spec.rb +++ b/spec/models/event_collection_spec.rb @@ -4,50 +4,75 @@ require 'spec_helper' describe EventCollection do describe '#to_a' do - let(:project) { create(:project_empty_repo) } - let(:projects) { Project.where(id: project.id) } - let(:user) { create(:user) } + set(:group) { create(:group) } + set(:project) { create(:project_empty_repo, group: group) } + set(:projects) { Project.where(id: project.id) } + set(:user) { create(:user) } - before do - 20.times do - event = create(:push_event, project: project, author: user) + context 'with project events' do + before do + 20.times do + event = create(:push_event, project: project, author: user) - create(:push_event_payload, event: event) + create(:push_event_payload, event: event) + end + + create(:closed_issue_event, project: project, author: user) end - create(:closed_issue_event, project: project, author: user) - end + it 'returns an Array of events' do + events = described_class.new(projects).to_a - it 'returns an Array of events' do - events = described_class.new(projects).to_a + expect(events).to be_an_instance_of(Array) + end - expect(events).to be_an_instance_of(Array) - end + it 'applies a limit to the number of events' do + events = described_class.new(projects).to_a - it 'applies a limit to the number of events' do - events = described_class.new(projects).to_a + expect(events.length).to eq(20) + end - expect(events.length).to eq(20) - end + it 'can paginate through events' do + events = described_class.new(projects, offset: 20).to_a - it 'can paginate through events' do - events = described_class.new(projects, offset: 20).to_a + expect(events.length).to eq(1) + end - expect(events.length).to eq(1) - end + it 'returns an empty Array when crossing the maximum page number' do + events = described_class.new(projects, limit: 1, offset: 15).to_a - it 'returns an empty Array when crossing the maximum page number' do - events = described_class.new(projects, limit: 1, offset: 15).to_a + expect(events).to be_empty + end + + it 'allows filtering of events using an EventFilter' do + filter = EventFilter.new(EventFilter::ISSUE) + events = described_class.new(projects, filter: filter).to_a - expect(events).to be_empty + expect(events.length).to eq(1) + expect(events[0].action).to eq(Event::CLOSED) + end end - it 'allows filtering of events using an EventFilter' do - filter = EventFilter.new(EventFilter::ISSUE) - events = described_class.new(projects, filter: filter).to_a + context 'with group events' do + let(:groups) { group.self_and_descendants.public_or_visible_to_user(user) } + let(:subject) { described_class.new(projects, groups: groups).to_a } + + it 'includes also group events' do + subgroup = create(:group, parent: group) + event1 = create(:event, project: project, author: user) + event2 = create(:event, project: nil, group: group, author: user) + event3 = create(:event, project: nil, group: subgroup, author: user) - expect(events.length).to eq(1) - expect(events[0].action).to eq(Event::CLOSED) + expect(subject).to eq([event3, event2, event1]) + end + + it 'does not include events from inaccessible groups' do + subgroup = create(:group, :private, parent: group) + event1 = create(:event, project: nil, group: group, author: user) + create(:event, project: nil, group: subgroup, author: user) + + expect(subject).to eq([event1]) + end end end end |