BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
82eeb72c
Commit
82eeb72c
authored
Apr 25, 2018
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add model to track users accepting agreements
parent
3d6d0a09
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
0 deletions
+56
-0
term_agreement.rb
app/models/term_agreement.rb
+6
-0
20180425075446_create_term_agreements.rb
db/migrate/20180425075446_create_term_agreements.rb
+28
-0
schema.rb
db/schema.rb
+14
-0
term_agreement_spec.rb
spec/models/term_agreement_spec.rb
+8
-0
No files found.
app/models/term_agreement.rb
0 → 100644
View file @
82eeb72c
class
TermAgreement
<
ActiveRecord
::
Base
belongs_to
:term
,
class_name:
'ApplicationSetting::Term'
belongs_to
:user
validates
:user
,
:term
,
presence:
true
end
db/migrate/20180425075446_create_term_agreements.rb
0 → 100644
View file @
82eeb72c
class
CreateTermAgreements
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
def
up
create_table
:term_agreements
do
|
t
|
t
.
references
:term
,
index:
true
,
null:
false
t
.
foreign_key
:application_setting_terms
,
column: :term_id
t
.
references
:user
,
index:
true
,
null:
false
,
foreign_key:
{
on_delete: :cascade
}
t
.
boolean
:accepted
,
default:
false
,
null:
false
t
.
timestamps_with_timezone
null:
false
end
add_index
:term_agreements
,
[
:user_id
,
:term_id
],
unique:
true
,
name:
'term_agreements_unique_index'
end
def
down
remove_index
:term_agreements
,
name:
'term_agreements_unique_index'
drop_table
:term_agreements
end
end
db/schema.rb
View file @
82eeb72c
...
...
@@ -1824,6 +1824,18 @@ ActiveRecord::Schema.define(version: 20180503150427) do
add_index
"tags"
,
[
"name"
],
name:
"index_tags_on_name"
,
unique:
true
,
using: :btree
create_table
"term_agreements"
,
force: :cascade
do
|
t
|
t
.
integer
"term_id"
,
null:
false
t
.
integer
"user_id"
,
null:
false
t
.
boolean
"accepted"
,
default:
false
,
null:
false
t
.
datetime_with_timezone
"created_at"
,
null:
false
t
.
datetime_with_timezone
"updated_at"
,
null:
false
end
add_index
"term_agreements"
,
[
"term_id"
],
name:
"index_term_agreements_on_term_id"
,
using: :btree
add_index
"term_agreements"
,
[
"user_id"
,
"term_id"
],
name:
"term_agreements_unique_index"
,
unique:
true
,
using: :btree
add_index
"term_agreements"
,
[
"user_id"
],
name:
"index_term_agreements_on_user_id"
,
using: :btree
create_table
"timelogs"
,
force: :cascade
do
|
t
|
t
.
integer
"time_spent"
,
null:
false
t
.
integer
"user_id"
...
...
@@ -2212,6 +2224,8 @@ ActiveRecord::Schema.define(version: 20180503150427) do
add_foreign_key
"snippets"
,
"projects"
,
name:
"fk_be41fd4bb7"
,
on_delete: :cascade
add_foreign_key
"subscriptions"
,
"projects"
,
on_delete: :cascade
add_foreign_key
"system_note_metadata"
,
"notes"
,
name:
"fk_d83a918cb1"
,
on_delete: :cascade
add_foreign_key
"term_agreements"
,
"application_setting_terms"
,
column:
"term_id"
add_foreign_key
"term_agreements"
,
"users"
,
on_delete: :cascade
add_foreign_key
"timelogs"
,
"issues"
,
name:
"fk_timelogs_issues_issue_id"
,
on_delete: :cascade
add_foreign_key
"timelogs"
,
"merge_requests"
,
name:
"fk_timelogs_merge_requests_merge_request_id"
,
on_delete: :cascade
add_foreign_key
"todos"
,
"notes"
,
name:
"fk_91d1f47b13"
,
on_delete: :cascade
...
...
spec/models/term_agreement_spec.rb
0 → 100644
View file @
82eeb72c
require
'spec_helper'
describe
TermAgreement
do
describe
'validations'
do
it
{
is_expected
.
to
validate_presence_of
(
:term
)
}
it
{
is_expected
.
to
validate_presence_of
(
:user
)
}
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