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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
a0dbcd23
Commit
a0dbcd23
authored
Sep 07, 2014
by
Drew Blessing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Serialize services properties
parent
f42a1ded
Changes
20
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
84 additions
and
113 deletions
+84
-113
app/models/project_services/assembla_service.rb
app/models/project_services/assembla_service.rb
+2
-6
app/models/project_services/campfire_service.rb
app/models/project_services/campfire_service.rb
+2
-6
app/models/project_services/ci_service.rb
app/models/project_services/ci_service.rb
+1
-6
app/models/project_services/emails_on_push_service.rb
app/models/project_services/emails_on_push_service.rb
+2
-6
app/models/project_services/flowdock_service.rb
app/models/project_services/flowdock_service.rb
+2
-6
app/models/project_services/gemnasium_service.rb
app/models/project_services/gemnasium_service.rb
+2
-6
app/models/project_services/gitlab_ci_service.rb
app/models/project_services/gitlab_ci_service.rb
+2
-6
app/models/project_services/hipchat_service.rb
app/models/project_services/hipchat_service.rb
+2
-6
app/models/project_services/pivotaltracker_service.rb
app/models/project_services/pivotaltracker_service.rb
+2
-6
app/models/project_services/slack_service.rb
app/models/project_services/slack_service.rb
+2
-6
app/models/service.rb
app/models/service.rb
+20
-7
db/migrate/20140907220153_serialize_service_properties.rb
db/migrate/20140907220153_serialize_service_properties.rb
+35
-0
db/schema.rb
db/schema.rb
+4
-9
spec/factories.rb
spec/factories.rb
+0
-1
spec/models/assembla_service_spec.rb
spec/models/assembla_service_spec.rb
+1
-6
spec/models/flowdock_service_spec.rb
spec/models/flowdock_service_spec.rb
+1
-6
spec/models/gemnasium_service_spec.rb
spec/models/gemnasium_service_spec.rb
+1
-6
spec/models/gitlab_ci_service_spec.rb
spec/models/gitlab_ci_service_spec.rb
+1
-6
spec/models/service_spec.rb
spec/models/service_spec.rb
+1
-6
spec/models/slack_service_spec.rb
spec/models/slack_service_spec.rb
+1
-6
No files found.
app/models/project_services/assembla_service.rb
View file @
a0dbcd23
...
@@ -5,21 +5,17 @@
...
@@ -5,21 +5,17 @@
# id :integer not null, primary key
# id :integer not null, primary key
# type :string(255)
# type :string(255)
# title :string(255)
# title :string(255)
# token :string(255)
# project_id :integer not null
# project_id :integer not null
# created_at :datetime
# created_at :datetime
# updated_at :datetime
# updated_at :datetime
# active :boolean default(FALSE), not null
# active :boolean default(FALSE), not null
# project_url :string(255)
# properties :text
# subdomain :string(255)
# room :string(255)
# recipients :text
# api_key :string(255)
#
#
class
AssemblaService
<
Service
class
AssemblaService
<
Service
include
HTTParty
include
HTTParty
prop_accessor
:token
,
:subdomain
validates
:token
,
presence:
true
,
if: :activated?
validates
:token
,
presence:
true
,
if: :activated?
def
title
def
title
...
...
app/models/project_services/campfire_service.rb
View file @
a0dbcd23
...
@@ -5,19 +5,15 @@
...
@@ -5,19 +5,15 @@
# id :integer not null, primary key
# id :integer not null, primary key
# type :string(255)
# type :string(255)
# title :string(255)
# title :string(255)
# token :string(255)
# project_id :integer not null
# project_id :integer not null
# created_at :datetime
# created_at :datetime
# updated_at :datetime
# updated_at :datetime
# active :boolean default(FALSE), not null
# active :boolean default(FALSE), not null
# project_url :string(255)
# properties :text
# subdomain :string(255)
# room :string(255)
# recipients :text
# api_key :string(255)
#
#
class
CampfireService
<
Service
class
CampfireService
<
Service
prop_accessor
:token
,
:subdomain
,
:room
validates
:token
,
presence:
true
,
if: :activated?
validates
:token
,
presence:
true
,
if: :activated?
def
title
def
title
...
...
app/models/project_services/ci_service.rb
View file @
a0dbcd23
...
@@ -5,16 +5,11 @@
...
@@ -5,16 +5,11 @@
# id :integer not null, primary key
# id :integer not null, primary key
# type :string(255)
# type :string(255)
# title :string(255)
# title :string(255)
# token :string(255)
# project_id :integer not null
# project_id :integer not null
# created_at :datetime
# created_at :datetime
# updated_at :datetime
# updated_at :datetime
# active :boolean default(FALSE), not null
# active :boolean default(FALSE), not null
# project_url :string(255)
# properties :text
# subdomain :string(255)
# room :string(255)
# recipients :text
# api_key :string(255)
#
#
# Base class for CI services
# Base class for CI services
...
...
app/models/project_services/emails_on_push_service.rb
View file @
a0dbcd23
...
@@ -5,19 +5,15 @@
...
@@ -5,19 +5,15 @@
# id :integer not null, primary key
# id :integer not null, primary key
# type :string(255)
# type :string(255)
# title :string(255)
# title :string(255)
# token :string(255)
# project_id :integer not null
# project_id :integer not null
# created_at :datetime
# created_at :datetime
# updated_at :datetime
# updated_at :datetime
# active :boolean default(FALSE), not null
# active :boolean default(FALSE), not null
# project_url :string(255)
# properties :text
# subdomain :string(255)
# room :string(255)
# recipients :text
# api_key :string(255)
#
#
class
EmailsOnPushService
<
Service
class
EmailsOnPushService
<
Service
prop_accessor
:recipients
validates
:recipients
,
presence:
true
,
if: :activated?
validates
:recipients
,
presence:
true
,
if: :activated?
def
title
def
title
...
...
app/models/project_services/flowdock_service.rb
View file @
a0dbcd23
...
@@ -5,21 +5,17 @@
...
@@ -5,21 +5,17 @@
# id :integer not null, primary key
# id :integer not null, primary key
# type :string(255)
# type :string(255)
# title :string(255)
# title :string(255)
# token :string(255)
# project_id :integer not null
# project_id :integer not null
# created_at :datetime
# created_at :datetime
# updated_at :datetime
# updated_at :datetime
# active :boolean default(FALSE), not null
# active :boolean default(FALSE), not null
# project_url :string(255)
# properties :text
# subdomain :string(255)
# room :string(255)
# recipients :text
# api_key :string(255)
#
#
require
"flowdock-git-hook"
require
"flowdock-git-hook"
class
FlowdockService
<
Service
class
FlowdockService
<
Service
prop_accessor
:token
validates
:token
,
presence:
true
,
if: :activated?
validates
:token
,
presence:
true
,
if: :activated?
def
title
def
title
...
...
app/models/project_services/gemnasium_service.rb
View file @
a0dbcd23
...
@@ -5,21 +5,17 @@
...
@@ -5,21 +5,17 @@
# id :integer not null, primary key
# id :integer not null, primary key
# type :string(255)
# type :string(255)
# title :string(255)
# title :string(255)
# token :string(255)
# project_id :integer not null
# project_id :integer not null
# created_at :datetime
# created_at :datetime
# updated_at :datetime
# updated_at :datetime
# active :boolean default(FALSE), not null
# active :boolean default(FALSE), not null
# project_url :string(255)
# properties :text
# subdomain :string(255)
# room :string(255)
# recipients :text
# api_key :string(255)
#
#
require
"gemnasium/gitlab_service"
require
"gemnasium/gitlab_service"
class
GemnasiumService
<
Service
class
GemnasiumService
<
Service
prop_accessor
:token
,
:api_key
validates
:token
,
:api_key
,
presence:
true
,
if: :activated?
validates
:token
,
:api_key
,
presence:
true
,
if: :activated?
def
title
def
title
...
...
app/models/project_services/gitlab_ci_service.rb
View file @
a0dbcd23
...
@@ -5,19 +5,15 @@
...
@@ -5,19 +5,15 @@
# id :integer not null, primary key
# id :integer not null, primary key
# type :string(255)
# type :string(255)
# title :string(255)
# title :string(255)
# token :string(255)
# project_id :integer not null
# project_id :integer not null
# created_at :datetime
# created_at :datetime
# updated_at :datetime
# updated_at :datetime
# active :boolean default(FALSE), not null
# active :boolean default(FALSE), not null
# project_url :string(255)
# property :text
# subdomain :string(255)
# room :string(255)
# recipients :text
# api_key :string(255)
#
#
class
GitlabCiService
<
CiService
class
GitlabCiService
<
CiService
prop_accessor
:project_url
,
:token
validates
:project_url
,
presence:
true
,
if: :activated?
validates
:project_url
,
presence:
true
,
if: :activated?
validates
:token
,
presence:
true
,
if: :activated?
validates
:token
,
presence:
true
,
if: :activated?
...
...
app/models/project_services/hipchat_service.rb
View file @
a0dbcd23
...
@@ -5,21 +5,17 @@
...
@@ -5,21 +5,17 @@
# id :integer not null, primary key
# id :integer not null, primary key
# type :string(255)
# type :string(255)
# title :string(255)
# title :string(255)
# token :string(255)
# project_id :integer not null
# project_id :integer not null
# created_at :datetime
# created_at :datetime
# updated_at :datetime
# updated_at :datetime
# active :boolean default(FALSE), not null
# active :boolean default(FALSE), not null
# project_url :string(255)
# properties :text
# subdomain :string(255)
# room :string(255)
# recipients :text
# api_key :string(255)
#
#
class
HipchatService
<
Service
class
HipchatService
<
Service
MAX_COMMITS
=
3
MAX_COMMITS
=
3
prop_accessor
:token
,
:room
validates
:token
,
presence:
true
,
if: :activated?
validates
:token
,
presence:
true
,
if: :activated?
def
title
def
title
...
...
app/models/project_services/pivotaltracker_service.rb
View file @
a0dbcd23
...
@@ -5,21 +5,17 @@
...
@@ -5,21 +5,17 @@
# id :integer not null, primary key
# id :integer not null, primary key
# type :string(255)
# type :string(255)
# title :string(255)
# title :string(255)
# token :string(255)
# project_id :integer not null
# project_id :integer not null
# created_at :datetime
# created_at :datetime
# updated_at :datetime
# updated_at :datetime
# active :boolean default(FALSE), not null
# active :boolean default(FALSE), not null
# project_url :string(255)
# properties :text
# subdomain :string(255)
# room :string(255)
# recipients :text
# api_key :string(255)
#
#
class
PivotaltrackerService
<
Service
class
PivotaltrackerService
<
Service
include
HTTParty
include
HTTParty
prop_accessor
:token
validates
:token
,
presence:
true
,
if: :activated?
validates
:token
,
presence:
true
,
if: :activated?
def
title
def
title
...
...
app/models/project_services/slack_service.rb
View file @
a0dbcd23
...
@@ -5,19 +5,15 @@
...
@@ -5,19 +5,15 @@
# id :integer not null, primary key
# id :integer not null, primary key
# type :string(255)
# type :string(255)
# title :string(255)
# title :string(255)
# token :string(255)
# project_id :integer not null
# project_id :integer not null
# created_at :datetime
# created_at :datetime
# updated_at :datetime
# updated_at :datetime
# active :boolean default(FALSE), not null
# active :boolean default(FALSE), not null
# project_url :string(255)
# properties :text
# subdomain :string(255)
# room :string(255)
# recipients :text
# api_key :string(255)
#
#
class
SlackService
<
Service
class
SlackService
<
Service
prop_accessor
:room
,
:subdomain
,
:token
validates
:room
,
presence:
true
,
if: :activated?
validates
:room
,
presence:
true
,
if: :activated?
validates
:subdomain
,
presence:
true
,
if: :activated?
validates
:subdomain
,
presence:
true
,
if: :activated?
validates
:token
,
presence:
true
,
if: :activated?
validates
:token
,
presence:
true
,
if: :activated?
...
...
app/models/service.rb
View file @
a0dbcd23
...
@@ -5,22 +5,19 @@
...
@@ -5,22 +5,19 @@
# id :integer not null, primary key
# id :integer not null, primary key
# type :string(255)
# type :string(255)
# title :string(255)
# title :string(255)
# token :string(255)
# project_id :integer not null
# project_id :integer not null
# created_at :datetime
# created_at :datetime
# updated_at :datetime
# updated_at :datetime
# active :boolean default(FALSE), not null
# active :boolean default(FALSE), not null
# project_url :string(255)
# properties :text
# subdomain :string(255)
# room :string(255)
# recipients :text
# api_key :string(255)
#
# To add new service you should build a class inherited from Service
# To add new service you should build a class inherited from Service
# and implement a set of methods
# and implement a set of methods
class
Service
<
ActiveRecord
::
Base
class
Service
<
ActiveRecord
::
Base
serialize
:properties
,
JSON
default_value_for
:active
,
false
default_value_for
:active
,
false
default_value_for
:properties
,
{}
belongs_to
:project
belongs_to
:project
has_one
:service_hook
has_one
:service_hook
...
@@ -63,4 +60,20 @@ class Service < ActiveRecord::Base
...
@@ -63,4 +60,20 @@ class Service < ActiveRecord::Base
def
can_test?
def
can_test?
!
project
.
empty_repo?
!
project
.
empty_repo?
end
end
# Provide convenient accessor methods
# for each serialized property.
def
self
.
prop_accessor
(
*
args
)
args
.
each
do
|
arg
|
class_eval
%{
def #{arg}
properties['#{arg}']
end
def #{arg}=(value)
self.properties['#{arg}'] = value
end
}
end
end
end
end
db/migrate/20140907220153_serialize_service_properties.rb
0 → 100644
View file @
a0dbcd23
class
SerializeServiceProperties
<
ActiveRecord
::
Migration
def
change
add_column
:services
,
:properties
,
:text
associations
=
{
AssemblaService
:
[
:token
,
:subdomain
],
CampfireService
:
[
:token
,
:subdomain
,
:room
],
EmailsOnPushService
:
[
:recipients
],
FlowdockService
:
[
:token
],
GemnasiumService
:
[
:api_key
,
:token
],
GitlabCiService
:
[
:token
,
:project_url
],
HipchatService
:
[
:token
,
:room
],
PivotaltrackerService
:
[
:token
],
SlackService
:
[
:subdomain
,
:token
,
:room
],
JenkinsService
:
[
:token
,
:subdomain
],
JiraService
:
[
:project_url
,
:username
,
:password
,
:api_version
,
:jira_issue_transition_id
],
}
Service
.
all
.
each
do
|
service
|
associations
[
service
.
type
.
to_sym
].
each
do
|
attribute
|
service
.
send
(
"
#{
attribute
}
="
,
service
.
attributes
[
attribute
.
to_s
])
end
service
.
save!
end
remove_column
:services
,
:project_url
,
:string
remove_column
:services
,
:subdomain
,
:string
remove_column
:services
,
:room
,
:string
remove_column
:services
,
:recipients
,
:text
remove_column
:services
,
:api_key
,
:string
remove_column
:services
,
:token
,
:string
end
end
db/schema.rb
View file @
a0dbcd23
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
#
#
# It's strongly recommended that you check this file into your version control system.
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
2014090
3115954
)
do
ActiveRecord
::
Schema
.
define
(
version:
2014090
7220153
)
do
# These are extensions that must be enabled in order to support this database
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
enable_extension
"plpgsql"
...
@@ -265,16 +265,11 @@ ActiveRecord::Schema.define(version: 20140903115954) do
...
@@ -265,16 +265,11 @@ ActiveRecord::Schema.define(version: 20140903115954) do
create_table
"services"
,
force:
true
do
|
t
|
create_table
"services"
,
force:
true
do
|
t
|
t
.
string
"type"
t
.
string
"type"
t
.
string
"title"
t
.
string
"title"
t
.
string
"token"
t
.
integer
"project_id"
,
null:
false
t
.
integer
"project_id"
,
null:
false
t
.
datetime
"created_at"
t
.
datetime
"created_at"
t
.
datetime
"updated_at"
t
.
datetime
"updated_at"
t
.
boolean
"active"
,
default:
false
,
null:
false
t
.
boolean
"active"
,
default:
false
,
null:
false
t
.
string
"project_url"
t
.
text
"properties"
t
.
string
"subdomain"
t
.
string
"room"
t
.
text
"recipients"
t
.
string
"api_key"
end
end
add_index
"services"
,
[
"project_id"
],
name:
"index_services_on_project_id"
,
using: :btree
add_index
"services"
,
[
"project_id"
],
name:
"index_services_on_project_id"
,
using: :btree
...
...
spec/factories.rb
View file @
a0dbcd23
...
@@ -165,7 +165,6 @@ FactoryGirl.define do
...
@@ -165,7 +165,6 @@ FactoryGirl.define do
factory
:service
do
factory
:service
do
type
""
type
""
title
"GitLab CI"
title
"GitLab CI"
token
"x56olispAND34ng"
project
project
end
end
...
...
spec/models/assembla_service_spec.rb
View file @
a0dbcd23
...
@@ -5,16 +5,11 @@
...
@@ -5,16 +5,11 @@
# id :integer not null, primary key
# id :integer not null, primary key
# type :string(255)
# type :string(255)
# title :string(255)
# title :string(255)
# token :string(255)
# project_id :integer not null
# project_id :integer not null
# created_at :datetime
# created_at :datetime
# updated_at :datetime
# updated_at :datetime
# active :boolean default(FALSE), not null
# active :boolean default(FALSE), not null
# project_url :string(255)
# properties :text
# subdomain :string(255)
# room :string(255)
# recipients :text
# api_key :string(255)
#
#
require
'spec_helper'
require
'spec_helper'
...
...
spec/models/flowdock_service_spec.rb
View file @
a0dbcd23
...
@@ -5,16 +5,11 @@
...
@@ -5,16 +5,11 @@
# id :integer not null, primary key
# id :integer not null, primary key
# type :string(255)
# type :string(255)
# title :string(255)
# title :string(255)
# token :string(255)
# project_id :integer not null
# project_id :integer not null
# created_at :datetime
# created_at :datetime
# updated_at :datetime
# updated_at :datetime
# active :boolean default(FALSE), not null
# active :boolean default(FALSE), not null
# project_url :string(255)
# properties :text
# subdomain :string(255)
# room :string(255)
# recipients :text
# api_key :string(255)
#
#
require
'spec_helper'
require
'spec_helper'
...
...
spec/models/gemnasium_service_spec.rb
View file @
a0dbcd23
...
@@ -5,16 +5,11 @@
...
@@ -5,16 +5,11 @@
# id :integer not null, primary key
# id :integer not null, primary key
# type :string(255)
# type :string(255)
# title :string(255)
# title :string(255)
# token :string(255)
# project_id :integer not null
# project_id :integer not null
# created_at :datetime
# created_at :datetime
# updated_at :datetime
# updated_at :datetime
# active :boolean default(FALSE), not null
# active :boolean default(FALSE), not null
# project_url :string(255)
# properties :text
# subdomain :string(255)
# room :string(255)
# recipients :text
# api_key :string(255)
#
#
require
'spec_helper'
require
'spec_helper'
...
...
spec/models/gitlab_ci_service_spec.rb
View file @
a0dbcd23
...
@@ -5,16 +5,11 @@
...
@@ -5,16 +5,11 @@
# id :integer not null, primary key
# id :integer not null, primary key
# type :string(255)
# type :string(255)
# title :string(255)
# title :string(255)
# token :string(255)
# project_id :integer not null
# project_id :integer not null
# created_at :datetime
# created_at :datetime
# updated_at :datetime
# updated_at :datetime
# active :boolean default(FALSE), not null
# active :boolean default(FALSE), not null
# project_url :string(255)
# properties :text
# subdomain :string(255)
# room :string(255)
# recipients :text
# api_key :string(255)
#
#
require
'spec_helper'
require
'spec_helper'
...
...
spec/models/service_spec.rb
View file @
a0dbcd23
...
@@ -5,16 +5,11 @@
...
@@ -5,16 +5,11 @@
# id :integer not null, primary key
# id :integer not null, primary key
# type :string(255)
# type :string(255)
# title :string(255)
# title :string(255)
# token :string(255)
# project_id :integer not null
# project_id :integer not null
# created_at :datetime
# created_at :datetime
# updated_at :datetime
# updated_at :datetime
# active :boolean default(FALSE), not null
# active :boolean default(FALSE), not null
# project_url :string(255)
# properties :text
# subdomain :string(255)
# room :string(255)
# recipients :text
# api_key :string(255)
#
#
require
'spec_helper'
require
'spec_helper'
...
...
spec/models/slack_service_spec.rb
View file @
a0dbcd23
...
@@ -5,16 +5,11 @@
...
@@ -5,16 +5,11 @@
# id :integer not null, primary key
# id :integer not null, primary key
# type :string(255)
# type :string(255)
# title :string(255)
# title :string(255)
# token :string(255)
# project_id :integer not null
# project_id :integer not null
# created_at :datetime
# created_at :datetime
# updated_at :datetime
# updated_at :datetime
# active :boolean default(FALSE), not null
# active :boolean default(FALSE), not null
# project_url :string(255)
# properties :text
# subdomain :string(255)
# room :string(255)
# recipients :text
# api_key :string(255)
#
#
require
'spec_helper'
require
'spec_helper'
...
...
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