Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-09-10 21:47:59 +0400
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-09-10 21:47:59 +0400
commitebae2d0241c5f84f48af6a15d7b8217cb12840af (patch)
treee62674095374fb6a87cec2a18098125691f5e18b
parent1e1dd539481048c975c37aed6d957d70d63b30f8 (diff)
parent6135eb0adf6e3f2a13b7ef1d998b02a0f3349cc4 (diff)
Merge branch 'master' of github.com:gitlabhq/gitlabhq
-rw-r--r--app/models/project_services/assembla_service.rb8
-rw-r--r--app/models/project_services/campfire_service.rb8
-rw-r--r--app/models/project_services/ci_service.rb7
-rw-r--r--app/models/project_services/emails_on_push_service.rb8
-rw-r--r--app/models/project_services/flowdock_service.rb8
-rw-r--r--app/models/project_services/gemnasium_service.rb8
-rw-r--r--app/models/project_services/gitlab_ci_service.rb8
-rw-r--r--app/models/project_services/hipchat_service.rb8
-rw-r--r--app/models/project_services/pivotaltracker_service.rb8
-rw-r--r--app/models/project_services/slack_service.rb8
-rw-r--r--app/models/service.rb27
-rw-r--r--db/migrate/20140907220153_serialize_service_properties.rb35
-rw-r--r--db/schema.rb13
-rw-r--r--spec/factories.rb1
-rw-r--r--spec/models/assembla_service_spec.rb7
-rw-r--r--spec/models/flowdock_service_spec.rb7
-rw-r--r--spec/models/gemnasium_service_spec.rb7
-rw-r--r--spec/models/gitlab_ci_service_spec.rb7
-rw-r--r--spec/models/service_spec.rb7
-rw-r--r--spec/models/slack_service_spec.rb7
20 files changed, 84 insertions, 113 deletions
diff --git a/app/models/project_services/assembla_service.rb b/app/models/project_services/assembla_service.rb
index 9a8cbb32ac1..3421a0330aa 100644
--- a/app/models/project_services/assembla_service.rb
+++ b/app/models/project_services/assembla_service.rb
@@ -5,21 +5,17 @@
# id :integer not null, primary key
# type :string(255)
# title :string(255)
-# token :string(255)
# project_id :integer not null
# created_at :datetime
# updated_at :datetime
# active :boolean default(FALSE), not null
-# project_url :string(255)
-# subdomain :string(255)
-# room :string(255)
-# recipients :text
-# api_key :string(255)
+# properties :text
#
class AssemblaService < Service
include HTTParty
+ prop_accessor :token, :subdomain
validates :token, presence: true, if: :activated?
def title
diff --git a/app/models/project_services/campfire_service.rb b/app/models/project_services/campfire_service.rb
index 83e1bac1ef2..2d8950db491 100644
--- a/app/models/project_services/campfire_service.rb
+++ b/app/models/project_services/campfire_service.rb
@@ -5,19 +5,15 @@
# id :integer not null, primary key
# type :string(255)
# title :string(255)
-# token :string(255)
# project_id :integer not null
# created_at :datetime
# updated_at :datetime
# active :boolean default(FALSE), not null
-# project_url :string(255)
-# subdomain :string(255)
-# room :string(255)
-# recipients :text
-# api_key :string(255)
+# properties :text
#
class CampfireService < Service
+ prop_accessor :token, :subdomain, :room
validates :token, presence: true, if: :activated?
def title
diff --git a/app/models/project_services/ci_service.rb b/app/models/project_services/ci_service.rb
index 1a107f92c93..829f495abc6 100644
--- a/app/models/project_services/ci_service.rb
+++ b/app/models/project_services/ci_service.rb
@@ -5,16 +5,11 @@
# id :integer not null, primary key
# type :string(255)
# title :string(255)
-# token :string(255)
# project_id :integer not null
# created_at :datetime
# updated_at :datetime
# active :boolean default(FALSE), not null
-# project_url :string(255)
-# subdomain :string(255)
-# room :string(255)
-# recipients :text
-# api_key :string(255)
+# properties :text
#
# Base class for CI services
diff --git a/app/models/project_services/emails_on_push_service.rb b/app/models/project_services/emails_on_push_service.rb
index be5bab4ec32..5c4537cfca5 100644
--- a/app/models/project_services/emails_on_push_service.rb
+++ b/app/models/project_services/emails_on_push_service.rb
@@ -5,19 +5,15 @@
# id :integer not null, primary key
# type :string(255)
# title :string(255)
-# token :string(255)
# project_id :integer not null
# created_at :datetime
# updated_at :datetime
# active :boolean default(FALSE), not null
-# project_url :string(255)
-# subdomain :string(255)
-# room :string(255)
-# recipients :text
-# api_key :string(255)
+# properties :text
#
class EmailsOnPushService < Service
+ prop_accessor :recipients
validates :recipients, presence: true, if: :activated?
def title
diff --git a/app/models/project_services/flowdock_service.rb b/app/models/project_services/flowdock_service.rb
index 6cdd04a8648..4d11b00c192 100644
--- a/app/models/project_services/flowdock_service.rb
+++ b/app/models/project_services/flowdock_service.rb
@@ -5,21 +5,17 @@
# id :integer not null, primary key
# type :string(255)
# title :string(255)
-# token :string(255)
# project_id :integer not null
# created_at :datetime
# updated_at :datetime
# active :boolean default(FALSE), not null
-# project_url :string(255)
-# subdomain :string(255)
-# room :string(255)
-# recipients :text
-# api_key :string(255)
+# properties :text
#
require "flowdock-git-hook"
class FlowdockService < Service
+ prop_accessor :token
validates :token, presence: true, if: :activated?
def title
diff --git a/app/models/project_services/gemnasium_service.rb b/app/models/project_services/gemnasium_service.rb
index b363d7f57d2..7b6c87e4cec 100644
--- a/app/models/project_services/gemnasium_service.rb
+++ b/app/models/project_services/gemnasium_service.rb
@@ -5,21 +5,17 @@
# id :integer not null, primary key
# type :string(255)
# title :string(255)
-# token :string(255)
# project_id :integer not null
# created_at :datetime
# updated_at :datetime
# active :boolean default(FALSE), not null
-# project_url :string(255)
-# subdomain :string(255)
-# room :string(255)
-# recipients :text
-# api_key :string(255)
+# properties :text
#
require "gemnasium/gitlab_service"
class GemnasiumService < Service
+ prop_accessor :token, :api_key
validates :token, :api_key, presence: true, if: :activated?
def title
diff --git a/app/models/project_services/gitlab_ci_service.rb b/app/models/project_services/gitlab_ci_service.rb
index 58ddce45288..0f327e75289 100644
--- a/app/models/project_services/gitlab_ci_service.rb
+++ b/app/models/project_services/gitlab_ci_service.rb
@@ -5,19 +5,15 @@
# id :integer not null, primary key
# type :string(255)
# title :string(255)
-# token :string(255)
# project_id :integer not null
# created_at :datetime
# updated_at :datetime
# active :boolean default(FALSE), not null
-# project_url :string(255)
-# subdomain :string(255)
-# room :string(255)
-# recipients :text
-# api_key :string(255)
+# property :text
#
class GitlabCiService < CiService
+ prop_accessor :project_url, :token
validates :project_url, presence: true, if: :activated?
validates :token, presence: true, if: :activated?
diff --git a/app/models/project_services/hipchat_service.rb b/app/models/project_services/hipchat_service.rb
index 256debffc51..3a1ba168e6a 100644
--- a/app/models/project_services/hipchat_service.rb
+++ b/app/models/project_services/hipchat_service.rb
@@ -5,21 +5,17 @@
# id :integer not null, primary key
# type :string(255)
# title :string(255)
-# token :string(255)
# project_id :integer not null
# created_at :datetime
# updated_at :datetime
# active :boolean default(FALSE), not null
-# project_url :string(255)
-# subdomain :string(255)
-# room :string(255)
-# recipients :text
-# api_key :string(255)
+# properties :text
#
class HipchatService < Service
MAX_COMMITS = 3
+ prop_accessor :token, :room
validates :token, presence: true, if: :activated?
def title
diff --git a/app/models/project_services/pivotaltracker_service.rb b/app/models/project_services/pivotaltracker_service.rb
index aa2bcc5def7..3aa928b92a0 100644
--- a/app/models/project_services/pivotaltracker_service.rb
+++ b/app/models/project_services/pivotaltracker_service.rb
@@ -5,21 +5,17 @@
# id :integer not null, primary key
# type :string(255)
# title :string(255)
-# token :string(255)
# project_id :integer not null
# created_at :datetime
# updated_at :datetime
# active :boolean default(FALSE), not null
-# project_url :string(255)
-# subdomain :string(255)
-# room :string(255)
-# recipients :text
-# api_key :string(255)
+# properties :text
#
class PivotaltrackerService < Service
include HTTParty
+ prop_accessor :token
validates :token, presence: true, if: :activated?
def title
diff --git a/app/models/project_services/slack_service.rb b/app/models/project_services/slack_service.rb
index 7e54188abf7..4bda93f6006 100644
--- a/app/models/project_services/slack_service.rb
+++ b/app/models/project_services/slack_service.rb
@@ -5,19 +5,15 @@
# id :integer not null, primary key
# type :string(255)
# title :string(255)
-# token :string(255)
# project_id :integer not null
# created_at :datetime
# updated_at :datetime
# active :boolean default(FALSE), not null
-# project_url :string(255)
-# subdomain :string(255)
-# room :string(255)
-# recipients :text
-# api_key :string(255)
+# properties :text
#
class SlackService < Service
+ prop_accessor :room, :subdomain, :token
validates :room, presence: true, if: :activated?
validates :subdomain, presence: true, if: :activated?
validates :token, presence: true, if: :activated?
diff --git a/app/models/service.rb b/app/models/service.rb
index 0dc6d514b46..edfb31cbe08 100644
--- a/app/models/service.rb
+++ b/app/models/service.rb
@@ -5,22 +5,19 @@
# id :integer not null, primary key
# type :string(255)
# title :string(255)
-# token :string(255)
# project_id :integer not null
# created_at :datetime
# updated_at :datetime
# active :boolean default(FALSE), not null
-# project_url :string(255)
-# subdomain :string(255)
-# room :string(255)
-# recipients :text
-# api_key :string(255)
-#
+# properties :text
# To add new service you should build a class inherited from Service
# and implement a set of methods
class Service < ActiveRecord::Base
+ serialize :properties, JSON
+
default_value_for :active, false
+ default_value_for :properties, {}
belongs_to :project
has_one :service_hook
@@ -63,4 +60,20 @@ class Service < ActiveRecord::Base
def can_test?
!project.empty_repo?
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
diff --git a/db/migrate/20140907220153_serialize_service_properties.rb b/db/migrate/20140907220153_serialize_service_properties.rb
new file mode 100644
index 00000000000..2326fd0aebf
--- /dev/null
+++ b/db/migrate/20140907220153_serialize_service_properties.rb
@@ -0,0 +1,35 @@
+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
diff --git a/db/schema.rb b/db/schema.rb
index a2dda07c102..e9b3713557d 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20140903115954) do
+ActiveRecord::Schema.define(version: 20140907220153) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -265,16 +265,11 @@ ActiveRecord::Schema.define(version: 20140903115954) do
create_table "services", force: true do |t|
t.string "type"
t.string "title"
- t.string "token"
- t.integer "project_id", null: false
+ t.integer "project_id", null: false
t.datetime "created_at"
t.datetime "updated_at"
- t.boolean "active", default: false, null: false
- t.string "project_url"
- t.string "subdomain"
- t.string "room"
- t.text "recipients"
- t.string "api_key"
+ t.boolean "active", default: false, null: false
+ t.text "properties"
end
add_index "services", ["project_id"], name: "index_services_on_project_id", using: :btree
diff --git a/spec/factories.rb b/spec/factories.rb
index 03c87fcc6c5..f7f65bffb8b 100644
--- a/spec/factories.rb
+++ b/spec/factories.rb
@@ -165,7 +165,6 @@ FactoryGirl.define do
factory :service do
type ""
title "GitLab CI"
- token "x56olispAND34ng"
project
end
diff --git a/spec/models/assembla_service_spec.rb b/spec/models/assembla_service_spec.rb
index acc08fc4d69..0ef475b87c3 100644
--- a/spec/models/assembla_service_spec.rb
+++ b/spec/models/assembla_service_spec.rb
@@ -5,16 +5,11 @@
# id :integer not null, primary key
# type :string(255)
# title :string(255)
-# token :string(255)
# project_id :integer not null
# created_at :datetime
# updated_at :datetime
# active :boolean default(FALSE), not null
-# project_url :string(255)
-# subdomain :string(255)
-# room :string(255)
-# recipients :text
-# api_key :string(255)
+# properties :text
#
require 'spec_helper'
diff --git a/spec/models/flowdock_service_spec.rb b/spec/models/flowdock_service_spec.rb
index 25ad133e122..710b8cba502 100644
--- a/spec/models/flowdock_service_spec.rb
+++ b/spec/models/flowdock_service_spec.rb
@@ -5,16 +5,11 @@
# id :integer not null, primary key
# type :string(255)
# title :string(255)
-# token :string(255)
# project_id :integer not null
# created_at :datetime
# updated_at :datetime
# active :boolean default(FALSE), not null
-# project_url :string(255)
-# subdomain :string(255)
-# room :string(255)
-# recipients :text
-# api_key :string(255)
+# properties :text
#
require 'spec_helper'
diff --git a/spec/models/gemnasium_service_spec.rb b/spec/models/gemnasium_service_spec.rb
index efdf0dc891b..5de645cdf33 100644
--- a/spec/models/gemnasium_service_spec.rb
+++ b/spec/models/gemnasium_service_spec.rb
@@ -5,16 +5,11 @@
# id :integer not null, primary key
# type :string(255)
# title :string(255)
-# token :string(255)
# project_id :integer not null
# created_at :datetime
# updated_at :datetime
# active :boolean default(FALSE), not null
-# project_url :string(255)
-# subdomain :string(255)
-# room :string(255)
-# recipients :text
-# api_key :string(255)
+# properties :text
#
require 'spec_helper'
diff --git a/spec/models/gitlab_ci_service_spec.rb b/spec/models/gitlab_ci_service_spec.rb
index 439a30869bb..e4cd8bb90c3 100644
--- a/spec/models/gitlab_ci_service_spec.rb
+++ b/spec/models/gitlab_ci_service_spec.rb
@@ -5,16 +5,11 @@
# id :integer not null, primary key
# type :string(255)
# title :string(255)
-# token :string(255)
# project_id :integer not null
# created_at :datetime
# updated_at :datetime
# active :boolean default(FALSE), not null
-# project_url :string(255)
-# subdomain :string(255)
-# room :string(255)
-# recipients :text
-# api_key :string(255)
+# properties :text
#
require 'spec_helper'
diff --git a/spec/models/service_spec.rb b/spec/models/service_spec.rb
index adeeac115c1..480aeabf67f 100644
--- a/spec/models/service_spec.rb
+++ b/spec/models/service_spec.rb
@@ -5,16 +5,11 @@
# id :integer not null, primary key
# type :string(255)
# title :string(255)
-# token :string(255)
# project_id :integer not null
# created_at :datetime
# updated_at :datetime
# active :boolean default(FALSE), not null
-# project_url :string(255)
-# subdomain :string(255)
-# room :string(255)
-# recipients :text
-# api_key :string(255)
+# properties :text
#
require 'spec_helper'
diff --git a/spec/models/slack_service_spec.rb b/spec/models/slack_service_spec.rb
index b00eb30569b..4576913b473 100644
--- a/spec/models/slack_service_spec.rb
+++ b/spec/models/slack_service_spec.rb
@@ -5,16 +5,11 @@
# id :integer not null, primary key
# type :string(255)
# title :string(255)
-# token :string(255)
# project_id :integer not null
# created_at :datetime
# updated_at :datetime
# active :boolean default(FALSE), not null
-# project_url :string(255)
-# subdomain :string(255)
-# room :string(255)
-# recipients :text
-# api_key :string(255)
+# properties :text
#
require 'spec_helper'