Commit 86a8796b1322879d01e9cea8fb728458e0e328cb

Authored by Dmitriy Zaporozhets
1 parent 5ac57305

Create EmailsOnPushService model

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
app/models/project.rb
@@ -25,6 +25,7 @@ @@ -25,6 +25,7 @@
25 25
26 require_relative "project_services/assembla_service" 26 require_relative "project_services/assembla_service"
27 require_relative "project_services/campfire_service" 27 require_relative "project_services/campfire_service"
  28 +require_relative "project_services/emails_on_push_service"
28 require_relative "project_services/flowdock_service" 29 require_relative "project_services/flowdock_service"
29 require_relative "project_services/gitlab_ci_service" 30 require_relative "project_services/gitlab_ci_service"
30 require_relative "project_services/hipchat_service" 31 require_relative "project_services/hipchat_service"
@@ -55,6 +56,7 @@ class Project &lt; ActiveRecord::Base @@ -55,6 +56,7 @@ class Project &lt; ActiveRecord::Base
55 has_one :last_event, -> {order 'events.created_at DESC'}, class_name: 'Event', foreign_key: 'project_id' 56 has_one :last_event, -> {order 'events.created_at DESC'}, class_name: 'Event', foreign_key: 'project_id'
56 has_one :gitlab_ci_service, dependent: :destroy 57 has_one :gitlab_ci_service, dependent: :destroy
57 has_one :campfire_service, dependent: :destroy 58 has_one :campfire_service, dependent: :destroy
  59 + has_one :emails_on_push_service, dependent: :destroy
58 has_one :pivotaltracker_service, dependent: :destroy 60 has_one :pivotaltracker_service, dependent: :destroy
59 has_one :hipchat_service, dependent: :destroy 61 has_one :hipchat_service, dependent: :destroy
60 has_one :flowdock_service, dependent: :destroy 62 has_one :flowdock_service, dependent: :destroy
@@ -244,7 +246,7 @@ class Project &lt; ActiveRecord::Base @@ -244,7 +246,7 @@ class Project &lt; ActiveRecord::Base
244 end 246 end
245 247
246 def available_services_names 248 def available_services_names
247 - %w(gitlab_ci campfire hipchat pivotaltracker flowdock assembla) 249 + %w(gitlab_ci campfire hipchat pivotaltracker flowdock assembla emails_on_push)
248 end 250 end
249 251
250 def gitlab_ci? 252 def gitlab_ci?
app/models/project_services/emails_on_push_service.rb 0 → 100644
@@ -0,0 +1,45 @@ @@ -0,0 +1,45 @@
  1 +# == Schema Information
  2 +#
  3 +# Table name: services
  4 +#
  5 +# id :integer not null, primary key
  6 +# type :string(255)
  7 +# title :string(255)
  8 +# token :string(255)
  9 +# project_id :integer not null
  10 +# created_at :datetime not null
  11 +# updated_at :datetime not null
  12 +# active :boolean default(FALSE), not null
  13 +# project_url :string(255)
  14 +# subdomain :string(255)
  15 +# room :string(255)
  16 +#
  17 +
  18 +class EmailsOnPushService < Service
  19 + attr_accessible :recipients
  20 +
  21 + validates :recipients, presence: true, if: :activated?
  22 +
  23 + def title
  24 + 'Emails on push'
  25 + end
  26 +
  27 + def description
  28 + 'Send emails to recipients on push'
  29 + end
  30 +
  31 + def to_param
  32 + 'emails_on_push'
  33 + end
  34 +
  35 + def execute
  36 + true
  37 + end
  38 +
  39 + def fields
  40 + [
  41 + { type: 'textarea', name: 'recipients', placeholder: 'Recipients' },
  42 + ]
  43 + end
  44 +end
  45 +
db/migrate/20131217102743_add_recipients_to_service.rb 0 → 100644
@@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
  1 +class AddRecipientsToService < ActiveRecord::Migration
  2 + def change
  3 + add_column :services, :recipients, :text
  4 + end
  5 +end
@@ -11,7 +11,10 @@ @@ -11,7 +11,10 @@
11 # 11 #
12 # It's strongly recommended that you check this file into your version control system. 12 # It's strongly recommended that you check this file into your version control system.
13 13
14 -ActiveRecord::Schema.define(version: 20131214224427) do 14 +ActiveRecord::Schema.define(version: 20131217102743) do
  15 +
  16 + # These are extensions that must be enabled in order to support this database
  17 + enable_extension "plpgsql"
15 18
16 create_table "broadcast_messages", force: true do |t| 19 create_table "broadcast_messages", force: true do |t|
17 t.text "message", null: false 20 t.text "message", null: false
@@ -94,20 +97,20 @@ ActiveRecord::Schema.define(version: 20131214224427) do @@ -94,20 +97,20 @@ ActiveRecord::Schema.define(version: 20131214224427) do
94 add_index "keys", ["user_id"], name: "index_keys_on_user_id", using: :btree 97 add_index "keys", ["user_id"], name: "index_keys_on_user_id", using: :btree
95 98
96 create_table "merge_requests", force: true do |t| 99 create_table "merge_requests", force: true do |t|
97 - t.string "target_branch", null: false  
98 - t.string "source_branch", null: false  
99 - t.integer "source_project_id", null: false 100 + t.string "target_branch", null: false
  101 + t.string "source_branch", null: false
  102 + t.integer "source_project_id", null: false
100 t.integer "author_id" 103 t.integer "author_id"
101 t.integer "assignee_id" 104 t.integer "assignee_id"
102 t.string "title" 105 t.string "title"
103 - t.datetime "created_at", null: false  
104 - t.datetime "updated_at", null: false  
105 - t.text "st_commits", limit: 2147483647  
106 - t.text "st_diffs", limit: 2147483647 106 + t.datetime "created_at", null: false
  107 + t.datetime "updated_at", null: false
  108 + t.text "st_commits"
  109 + t.text "st_diffs"
107 t.integer "milestone_id" 110 t.integer "milestone_id"
108 t.string "state" 111 t.string "state"
109 t.string "merge_status" 112 t.string "merge_status"
110 - t.integer "target_project_id", null: false 113 + t.integer "target_project_id", null: false
111 t.integer "iid" 114 t.integer "iid"
112 t.text "description" 115 t.text "description"
113 end 116 end
@@ -219,20 +222,21 @@ ActiveRecord::Schema.define(version: 20131214224427) do @@ -219,20 +222,21 @@ ActiveRecord::Schema.define(version: 20131214224427) do
219 t.string "project_url" 222 t.string "project_url"
220 t.string "subdomain" 223 t.string "subdomain"
221 t.string "room" 224 t.string "room"
  225 + t.text "recipients"
222 end 226 end
223 227
224 add_index "services", ["project_id"], name: "index_services_on_project_id", using: :btree 228 add_index "services", ["project_id"], name: "index_services_on_project_id", using: :btree
225 229
226 create_table "snippets", force: true do |t| 230 create_table "snippets", force: true do |t|
227 t.string "title" 231 t.string "title"
228 - t.text "content", limit: 2147483647  
229 - t.integer "author_id", null: false 232 + t.text "content"
  233 + t.integer "author_id", null: false
230 t.integer "project_id" 234 t.integer "project_id"
231 - t.datetime "created_at", null: false  
232 - t.datetime "updated_at", null: false 235 + t.datetime "created_at", null: false
  236 + t.datetime "updated_at", null: false
233 t.string "file_name" 237 t.string "file_name"
234 t.datetime "expires_at" 238 t.datetime "expires_at"
235 - t.boolean "private", default: true, null: false 239 + t.boolean "private", default: true, null: false
236 t.string "type" 240 t.string "type"
237 end 241 end
238 242