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
4df3e5c5
Commit
4df3e5c5
authored
Jul 12, 2021
by
Max Woolf
Committed by
Tiger Watson
Jul 12, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ability to remove and disable terms and conditions
parent
bc4d5b35
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
21 additions
and
11 deletions
+21
-11
app/models/application_setting/term.rb
app/models/application_setting/term.rb
+4
-2
app/services/application_settings/update_service.rb
app/services/application_settings/update_service.rb
+1
-3
db/migrate/20210708134446_remove_not_null_constraint_from_terms.rb
...e/20210708134446_remove_not_null_constraint_from_terms.rb
+11
-0
db/schema_migrations/20210708134446
db/schema_migrations/20210708134446
+1
-0
db/structure.sql
db/structure.sql
+1
-1
spec/models/application_setting/term_spec.rb
spec/models/application_setting/term_spec.rb
+1
-3
spec/services/application_settings/update_service_spec.rb
spec/services/application_settings/update_service_spec.rb
+2
-2
No files found.
app/models/application_setting/term.rb
View file @
4df3e5c5
...
...
@@ -3,12 +3,14 @@
class
ApplicationSetting
class
Term
<
ApplicationRecord
include
CacheMarkdownField
has_many
:term_agreements
include
NullifyIfBlank
validates
:terms
,
presence:
true
has_many
:term_agreements
cache_markdown_field
:terms
nullify_if_blank
:terms
def
self
.
latest
order
(
:id
).
last
end
...
...
app/services/application_settings/update_service.rb
View file @
4df3e5c5
...
...
@@ -67,10 +67,8 @@ module ApplicationSettings
end
def
update_terms
(
terms
)
return
unless
terms
.
present?
# Avoid creating a new terms record if the text is exactly the same.
terms
=
terms
.
strip
terms
=
terms
&
.
strip
return
if
terms
==
@application_setting
.
terms
ApplicationSetting
::
Term
.
create
(
terms:
terms
)
...
...
db/migrate/20210708134446_remove_not_null_constraint_from_terms.rb
0 → 100644
View file @
4df3e5c5
# frozen_string_literal: true
class
RemoveNotNullConstraintFromTerms
<
ActiveRecord
::
Migration
[
6.1
]
def
up
change_column_null
:application_setting_terms
,
:terms
,
true
end
def
down
change_column_null
:application_setting_terms
,
:terms
,
false
end
end
db/schema_migrations/20210708134446
0 → 100644
View file @
4df3e5c5
1367865e22f6129fa69f3c86dc72b88a9af0479a41f2029a446464aeeed9c18e
\ No newline at end of file
db/structure.sql
View file @
4df3e5c5
...
...
@@ -9215,7 +9215,7 @@ ALTER SEQUENCE appearances_id_seq OWNED BY appearances.id;
CREATE TABLE application_setting_terms (
id integer NOT NULL,
cached_markdown_version integer,
terms text
NOT NULL
,
terms text,
terms_html text
);
spec/models/application_setting/term_spec.rb
View file @
4df3e5c5
...
...
@@ -3,9 +3,7 @@
require
'spec_helper'
RSpec
.
describe
ApplicationSetting
::
Term
do
describe
'validations'
do
it
{
is_expected
.
to
validate_presence_of
(
:terms
)
}
end
it
{
is_expected
.
to
nullify_if_blank
(
:terms
)
}
describe
'.latest'
do
it
'finds the latest terms'
do
...
...
spec/services/application_settings/update_service_spec.rb
View file @
4df3e5c5
...
...
@@ -23,8 +23,8 @@ RSpec.describe ApplicationSettings::UpdateService do
context
'when the passed terms are blank'
do
let
(
:params
)
{
{
terms:
''
}
}
it
'does
not
create terms'
do
expect
{
subject
.
execute
}.
not_to
change
{
ApplicationSetting
::
Term
.
count
}
it
'does create terms'
do
expect
{
subject
.
execute
}.
to
change
{
ApplicationSetting
::
Term
.
count
}.
by
(
1
)
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