Commit 946ea280 authored by Alex Buijs's avatar Alex Buijs

Add git write namespace onboarding action

For tracking onboarding progress
parent b53c6d07
# frozen_string_literal: true
class NamespaceOnboardingAction < ApplicationRecord
belongs_to :namespace
belongs_to :namespace, optional: false
validates :action, presence: true
ACTIONS = {
subscription_created: 1
subscription_created: 1,
git_write: 2
}.freeze
enum action: ACTIONS
......
......@@ -40,6 +40,8 @@ class PostReceiveService
response.add_basic_message(redirect_message)
response.add_basic_message(project_created_message)
record_onboarding_progress
end
response
......@@ -90,6 +92,10 @@ class PostReceiveService
banner&.message
end
def record_onboarding_progress
NamespaceOnboardingAction.create_action(project.namespace, :git_write)
end
end
PostReceiveService.prepend_if_ee('EE::PostReceiveService')
......@@ -5,7 +5,13 @@ require 'spec_helper'
RSpec.describe NamespaceOnboardingAction do
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
let(:action) { :subscription_created }
......
......@@ -45,6 +45,12 @@ RSpec.describe PostReceiveService do
it 'does not return error' do
expect(subject).to be_empty
end
it 'does not record a namespace onboarding progress action' do
expect(NamespaceOnboardingAction).not_to receive(:create_action)
subject
end
end
context 'when repository is nil' do
......@@ -80,6 +86,13 @@ RSpec.describe PostReceiveService do
expect(response.reference_counter_decreased).to be(true)
end
it 'records a namespace onboarding progress action' do
expect(NamespaceOnboardingAction).to receive(:create_action)
.with(project.namespace, :git_write)
subject
end
end
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