Commit 9cf442fe authored by Sean McGivern's avatar Sean McGivern

Merge branch '42546-in-gitlab_subscription_histories-do-not-track-the-creation' into 'master'

Do not track creations in gitlab_subscription_histories

See merge request gitlab-org/gitlab!21642
parents 2b201e5d 6b8a0283
......@@ -2,7 +2,6 @@
class GitlabSubscription < ApplicationRecord
default_value_for(:start_date) { Date.today }
after_create_commit :log_previous_state_for_create
before_update :log_previous_state_for_update
after_destroy_commit :log_previous_state_for_destroy
......@@ -59,10 +58,6 @@ class GitlabSubscription < ApplicationRecord
private
def log_previous_state_for_create
log_previous_state_to_history(:gitlab_subscription_created)
end
def log_previous_state_for_update
attrs = self.attributes.merge(self.attributes_in_database)
log_previous_state_to_history(:gitlab_subscription_updated, attrs)
......
......@@ -244,24 +244,12 @@ describe GitlabSubscription do
expect(GitlabSubscriptionHistory.attribute_names - described_class.attribute_names).to eq(diff_attrs)
end
context 'after_create_commit' do
it 'logs previous state to gitlab subscription history' do
subject.save!
expect(GitlabSubscriptionHistory.count).to eq(1)
expect(GitlabSubscriptionHistory.last.attributes).to include(
'gitlab_subscription_id' => subject.id,
'change_type' => 'gitlab_subscription_created'
)
end
end
context 'before_update' do
it 'logs previous state to gitlab subscription history' do
subject.update! max_seats_used: 42, seats: 13
subject.update! max_seats_used: 32
expect(GitlabSubscriptionHistory.count).to eq(2)
expect(GitlabSubscriptionHistory.count).to eq(1)
expect(GitlabSubscriptionHistory.last.attributes).to include(
'gitlab_subscription_id' => subject.id,
'change_type' => 'gitlab_subscription_updated',
......@@ -280,7 +268,7 @@ describe GitlabSubscription do
subject.destroy!
expect(GitlabSubscriptionHistory.count).to eq(2)
expect(GitlabSubscriptionHistory.count).to eq(1)
expect(GitlabSubscriptionHistory.last.attributes).to include(
'gitlab_subscription_id' => subject.id,
'change_type' => 'gitlab_subscription_destroyed',
......
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