Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
b8dace3f
Commit
b8dace3f
authored
Dec 04, 2019
by
Alper Akgun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Review test improve & use of except
parent
f411615d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
16 deletions
+12
-16
ee/app/models/gitlab_subscription.rb
ee/app/models/gitlab_subscription.rb
+1
-2
ee/spec/models/gitlab_subscription_spec.rb
ee/spec/models/gitlab_subscription_spec.rb
+11
-14
No files found.
ee/app/models/gitlab_subscription.rb
View file @
b8dace3f
...
...
@@ -80,9 +80,8 @@ class GitlabSubscription < ApplicationRecord
attrs
[
'change_type'
]
=
change_type
omitted_attrs
=
%w(id created_at updated_at)
attrs
.
reject!
{
|
k
,
v
|
omitted_attrs
.
include?
(
k
)
}
GitlabSubscriptionHistory
.
create
(
attrs
)
GitlabSubscriptionHistory
.
create
(
attrs
.
except
(
*
omitted_attrs
)
)
end
def
hosted?
...
...
ee/spec/models/gitlab_subscription_spec.rb
View file @
b8dace3f
...
...
@@ -245,30 +245,28 @@ describe GitlabSubscription do
context
'after_create_commit'
do
it
'logs previous state to gitlab subscription history'
do
subject
.
save
subject
.
save
!
expect
(
GitlabSubscriptionHistory
.
count
).
to
eq
(
1
)
expect
ed_attrs
=
{
expect
(
GitlabSubscriptionHistory
.
last
.
attributes
).
to
include
(
'gitlab_subscription_id'
=>
subject
.
id
,
'change_type'
=>
'gitlab_subscription_created'
}
expect
(
GitlabSubscriptionHistory
.
last
.
attributes
).
to
include
(
expected_attrs
)
)
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
subject
.
update
!
max_seats_used:
42
,
seats:
13
subject
.
update
!
max_seats_used:
32
expect
(
GitlabSubscriptionHistory
.
count
).
to
eq
(
2
)
expect
ed_attrs
=
{
expect
(
GitlabSubscriptionHistory
.
last
.
attributes
).
to
include
(
'gitlab_subscription_id'
=>
subject
.
id
,
'change_type'
=>
'gitlab_subscription_updated'
,
'max_seats_used'
=>
42
,
'seats'
=>
13
}
expect
(
GitlabSubscriptionHistory
.
last
.
attributes
).
to
include
(
expected_attrs
)
)
end
end
...
...
@@ -276,13 +274,13 @@ describe GitlabSubscription do
it
'logs previous state to gitlab subscription history'
do
group
=
create
(
:group
)
plan
=
create
(
:bronze_plan
)
subject
.
update
max_seats_used:
37
,
seats:
11
,
namespace:
group
,
hosted_plan:
plan
subject
.
update
!
max_seats_used:
37
,
seats:
11
,
namespace:
group
,
hosted_plan:
plan
db_created_at
=
described_class
.
last
.
created_at
subject
.
destroy
subject
.
destroy
!
expect
(
GitlabSubscriptionHistory
.
count
).
to
eq
(
2
)
expect
ed_attrs
=
{
expect
(
GitlabSubscriptionHistory
.
last
.
attributes
).
to
include
(
'gitlab_subscription_id'
=>
subject
.
id
,
'change_type'
=>
'gitlab_subscription_destroyed'
,
'max_seats_used'
=>
37
,
...
...
@@ -290,8 +288,7 @@ describe GitlabSubscription do
'namespace_id'
=>
group
.
id
,
'hosted_plan_id'
=>
plan
.
id
,
'gitlab_subscription_created_at'
=>
db_created_at
}
expect
(
GitlabSubscriptionHistory
.
last
.
attributes
).
to
include
(
expected_attrs
)
)
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment