Commit 58d84274 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'namespace-onboarding-action-git-write' into 'master'

Add git write namespace onboarding action

See merge request gitlab-org/gitlab!48924
parents 9b0a4a27 946ea280
# frozen_string_literal: true # frozen_string_literal: true
class NamespaceOnboardingAction < ApplicationRecord class NamespaceOnboardingAction < ApplicationRecord
belongs_to :namespace belongs_to :namespace, optional: false
validates :action, presence: true
ACTIONS = { ACTIONS = {
subscription_created: 1 subscription_created: 1,
git_write: 2
}.freeze }.freeze
enum action: ACTIONS enum action: ACTIONS
......
...@@ -40,6 +40,8 @@ class PostReceiveService ...@@ -40,6 +40,8 @@ class PostReceiveService
response.add_basic_message(redirect_message) response.add_basic_message(redirect_message)
response.add_basic_message(project_created_message) response.add_basic_message(project_created_message)
record_onboarding_progress
end end
response response
...@@ -90,6 +92,10 @@ class PostReceiveService ...@@ -90,6 +92,10 @@ class PostReceiveService
banner&.message banner&.message
end end
def record_onboarding_progress
NamespaceOnboardingAction.create_action(project.namespace, :git_write)
end
end end
PostReceiveService.prepend_if_ee('EE::PostReceiveService') PostReceiveService.prepend_if_ee('EE::PostReceiveService')
...@@ -5,7 +5,13 @@ require 'spec_helper' ...@@ -5,7 +5,13 @@ require 'spec_helper'
RSpec.describe NamespaceOnboardingAction do RSpec.describe NamespaceOnboardingAction do
let(:namespace) { build(:namespace) } let(:namespace) { build(:namespace) }
it { is_expected.to belong_to :namespace } describe 'associations' do
it { is_expected.to belong_to(:namespace).required }
end
describe 'validations' do
it { is_expected.to validate_presence_of(:action) }
end
describe '.completed?' do describe '.completed?' do
let(:action) { :subscription_created } let(:action) { :subscription_created }
......
...@@ -45,6 +45,12 @@ RSpec.describe PostReceiveService do ...@@ -45,6 +45,12 @@ RSpec.describe PostReceiveService do
it 'does not return error' do it 'does not return error' do
expect(subject).to be_empty expect(subject).to be_empty
end end
it 'does not record a namespace onboarding progress action' do
expect(NamespaceOnboardingAction).not_to receive(:create_action)
subject
end
end end
context 'when repository is nil' do context 'when repository is nil' do
...@@ -80,6 +86,13 @@ RSpec.describe PostReceiveService do ...@@ -80,6 +86,13 @@ RSpec.describe PostReceiveService do
expect(response.reference_counter_decreased).to be(true) expect(response.reference_counter_decreased).to be(true)
end end
it 'records a namespace onboarding progress action' do
expect(NamespaceOnboardingAction).to receive(:create_action)
.with(project.namespace, :git_write)
subject
end
end end
context 'with Project' do context 'with Project' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment