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