Commit 6b8a0283 authored by Alper Akgun's avatar Alper Akgun

Do not track gitlab_subscription creations

parent 56a1cb09
......@@ -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)
......
......@@ -243,24 +243,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',
......@@ -279,7 +267,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