summaryrefslogtreecommitdiff
path: root/spec/controllers/projects_controller_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-04-20 23:50:22 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-04-20 23:50:22 +0000
commit9dc93a4519d9d5d7be48ff274127136236a3adb3 (patch)
tree70467ae3692a0e35e5ea56bcb803eb512a10bedb /spec/controllers/projects_controller_spec.rb
parent4b0f34b6d759d6299322b3a54453e930c6121ff0 (diff)
downloadgitlab-ce-9dc93a4519d9d5d7be48ff274127136236a3adb3.tar.gz
Add latest changes from gitlab-org/gitlab@13-11-stable-eev13.11.0-rc43
Diffstat (limited to 'spec/controllers/projects_controller_spec.rb')
-rw-r--r--spec/controllers/projects_controller_spec.rb30
1 files changed, 19 insertions, 11 deletions
diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb
index 554487db8f2..ffe2d393b1e 100644
--- a/spec/controllers/projects_controller_spec.rb
+++ b/spec/controllers/projects_controller_spec.rb
@@ -10,6 +10,7 @@ RSpec.describe ProjectsController do
let_it_be(:project, reload: true) { create(:project, service_desk_enabled: false) }
let_it_be(:public_project) { create(:project, :public) }
let_it_be(:user) { create(:user) }
+
let(:jpg) { fixture_file_upload('spec/fixtures/rails_sample.jpg', 'image/jpg') }
let(:txt) { fixture_file_upload('spec/fixtures/doc_sample.txt', 'text/plain') }
@@ -159,7 +160,7 @@ RSpec.describe ProjectsController do
before do
setting = user.notification_settings_for(public_project)
setting.level = :watch
- setting.save
+ setting.save!
end
it "shows current notification setting" do
@@ -221,24 +222,23 @@ RSpec.describe ProjectsController do
allow(controller).to receive(:record_experiment_user)
end
- context 'when user can push to default branch' do
+ context 'when user can push to default branch', :experiment do
let(:user) { empty_project.owner }
- it 'creates an "view_project_show" experiment tracking event', :snowplow do
- allow_next_instance_of(ApplicationExperiment) do |e|
- allow(e).to receive(:should_track?).and_return(true)
- end
+ it 'creates an "view_project_show" experiment tracking event' do
+ expect(experiment(:empty_repo_upload)).to track(
+ :view_project_show,
+ property: 'empty'
+ ).on_next_instance
get :show, params: { namespace_id: empty_project.namespace, id: empty_project }
-
- expect_snowplow_event(category: 'empty_repo_upload', action: 'view_project_show', context: [{ schema: 'iglu:com.gitlab/gitlab_experiment/jsonschema/0-3-0', data: anything }], property: 'empty')
end
end
User.project_views.keys.each do |project_view|
context "with #{project_view} view set" do
before do
- user.update(project_view: project_view)
+ user.update!(project_view: project_view)
get :show, params: { namespace_id: empty_project.namespace, id: empty_project }
end
@@ -261,7 +261,7 @@ RSpec.describe ProjectsController do
User.project_views.keys.each do |project_view|
context "with #{project_view} view set" do
before do
- user.update(project_view: project_view)
+ user.update!(project_view: project_view)
get :show, params: { namespace_id: empty_project.namespace, id: empty_project }
end
@@ -444,7 +444,13 @@ RSpec.describe ProjectsController do
:created,
property: 'blank',
value: 1
- ).on_any_instance.with_context(actor: user)
+ ).with_context(actor: user).on_next_instance
+
+ post :create, params: { project: project_params }
+ end
+
+ it 'tracks a created event for the new_repo experiment', :experiment do
+ expect(experiment(:new_repo, :candidate)).to track(:project_created).on_next_instance
post :create, params: { project: project_params }
end
@@ -549,6 +555,7 @@ RSpec.describe ProjectsController do
describe '#housekeeping' do
let_it_be(:group) { create(:group) }
let_it_be(:project) { create(:project, group: group) }
+
let(:housekeeping) { Repositories::HousekeepingService.new(project) }
context 'when authenticated as owner' do
@@ -1098,6 +1105,7 @@ RSpec.describe ProjectsController do
context 'state filter on references' do
let_it_be(:issue) { create(:issue, :closed, project: public_project) }
+
let(:merge_request) { create(:merge_request, :closed, target_project: public_project) }
it 'renders JSON body with state filter for issues' do