Commit 9a676ccc0a8dd26eb1ebd5042acbf31cfb906f91
1 parent
d02e129a
Exists in
spb-stable
and in
3 other branches
Added tag_push_events to the web_hooks
* Added a scope to the web_hooks model * Added extra checkbooks in de hooks overview window
Showing
5 changed files
with
85 additions
and
49 deletions
Show diff stats
app/models/project_hook.rb
@@ -17,9 +17,10 @@ | @@ -17,9 +17,10 @@ | ||
17 | class ProjectHook < WebHook | 17 | class ProjectHook < WebHook |
18 | belongs_to :project | 18 | belongs_to :project |
19 | 19 | ||
20 | - attr_accessible :push_events, :issues_events, :merge_requests_events | 20 | + attr_accessible :push_events, :issues_events, :merge_requests_events, :tag_push_events |
21 | 21 | ||
22 | scope :push_hooks, -> { where(push_events: true) } | 22 | scope :push_hooks, -> { where(push_events: true) } |
23 | + scope :tag_push_hooks, -> { where(tag_push_events: true) } | ||
23 | scope :issue_hooks, -> { where(issues_events: true) } | 24 | scope :issue_hooks, -> { where(issues_events: true) } |
24 | scope :merge_request_hooks, -> { where(merge_requests_events: true) } | 25 | scope :merge_request_hooks, -> { where(merge_requests_events: true) } |
25 | end | 26 | end |
app/views/projects/hooks/index.html.haml
@@ -27,6 +27,13 @@ | @@ -27,6 +27,13 @@ | ||
27 | %p.light | 27 | %p.light |
28 | This url will be triggered by a push to the repository | 28 | This url will be triggered by a push to the repository |
29 | %div | 29 | %div |
30 | + = f.check_box :tag_push_events, class: 'pull-left' | ||
31 | + .prepend-left-20 | ||
32 | + = f.label :tag_push_events, class: 'list-label' do | ||
33 | + %strong Tag push events | ||
34 | + %p.light | ||
35 | + This url will be triggered when a new tag is pushed to the repository | ||
36 | + %div | ||
30 | = f.check_box :issues_events, class: 'pull-left' | 37 | = f.check_box :issues_events, class: 'pull-left' |
31 | .prepend-left-20 | 38 | .prepend-left-20 |
32 | = f.label :issues_events, class: 'list-label' do | 39 | = f.label :issues_events, class: 'list-label' do |
@@ -56,6 +63,6 @@ | @@ -56,6 +63,6 @@ | ||
56 | .clearfix | 63 | .clearfix |
57 | %span.monospace= hook.url | 64 | %span.monospace= hook.url |
58 | %p | 65 | %p |
59 | - - %w(push_events issues_events merge_requests_events).each do |trigger| | 66 | + - %w(push_events tag_push_events issues_events merge_requests_events).each do |trigger| |
60 | - if hook.send(trigger) | 67 | - if hook.send(trigger) |
61 | %span.label.label-gray= trigger.titleize | 68 | %span.label.label-gray= trigger.titleize |
db/migrate/20140305193308_add_tag_push_hooks_to_project_hook.rb
0 → 100644
db/schema.rb
@@ -11,15 +11,18 @@ | @@ -11,15 +11,18 @@ | ||
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: 20140304005354) do | 14 | +ActiveRecord::Schema.define(version: 20140305193308) 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 |
18 | t.datetime "starts_at" | 21 | t.datetime "starts_at" |
19 | t.datetime "ends_at" | 22 | t.datetime "ends_at" |
20 | t.integer "alert_type" | 23 | t.integer "alert_type" |
21 | - t.datetime "created_at", null: false | ||
22 | - t.datetime "updated_at", null: false | 24 | + t.datetime "created_at" |
25 | + t.datetime "updated_at" | ||
23 | t.string "color" | 26 | t.string "color" |
24 | t.string "font" | 27 | t.string "font" |
25 | end | 28 | end |
@@ -27,8 +30,8 @@ ActiveRecord::Schema.define(version: 20140304005354) do | @@ -27,8 +30,8 @@ ActiveRecord::Schema.define(version: 20140304005354) do | ||
27 | create_table "deploy_keys_projects", force: true do |t| | 30 | create_table "deploy_keys_projects", force: true do |t| |
28 | t.integer "deploy_key_id", null: false | 31 | t.integer "deploy_key_id", null: false |
29 | t.integer "project_id", null: false | 32 | t.integer "project_id", null: false |
30 | - t.datetime "created_at", null: false | ||
31 | - t.datetime "updated_at", null: false | 33 | + t.datetime "created_at" |
34 | + t.datetime "updated_at" | ||
32 | end | 35 | end |
33 | 36 | ||
34 | add_index "deploy_keys_projects", ["project_id"], name: "index_deploy_keys_projects_on_project_id", using: :btree | 37 | add_index "deploy_keys_projects", ["project_id"], name: "index_deploy_keys_projects_on_project_id", using: :btree |
@@ -49,8 +52,8 @@ ActiveRecord::Schema.define(version: 20140304005354) do | @@ -49,8 +52,8 @@ ActiveRecord::Schema.define(version: 20140304005354) do | ||
49 | t.string "title" | 52 | t.string "title" |
50 | t.text "data" | 53 | t.text "data" |
51 | t.integer "project_id" | 54 | t.integer "project_id" |
52 | - t.datetime "created_at", null: false | ||
53 | - t.datetime "updated_at", null: false | 55 | + t.datetime "created_at" |
56 | + t.datetime "updated_at" | ||
54 | t.integer "action" | 57 | t.integer "action" |
55 | t.integer "author_id" | 58 | t.integer "author_id" |
56 | end | 59 | end |
@@ -65,8 +68,8 @@ ActiveRecord::Schema.define(version: 20140304005354) do | @@ -65,8 +68,8 @@ ActiveRecord::Schema.define(version: 20140304005354) do | ||
65 | create_table "forked_project_links", force: true do |t| | 68 | create_table "forked_project_links", force: true do |t| |
66 | t.integer "forked_to_project_id", null: false | 69 | t.integer "forked_to_project_id", null: false |
67 | t.integer "forked_from_project_id", null: false | 70 | t.integer "forked_from_project_id", null: false |
68 | - t.datetime "created_at", null: false | ||
69 | - t.datetime "updated_at", null: false | 71 | + t.datetime "created_at" |
72 | + t.datetime "updated_at" | ||
70 | end | 73 | end |
71 | 74 | ||
72 | add_index "forked_project_links", ["forked_to_project_id"], name: "index_forked_project_links_on_forked_to_project_id", unique: true, using: :btree | 75 | add_index "forked_project_links", ["forked_to_project_id"], name: "index_forked_project_links_on_forked_to_project_id", unique: true, using: :btree |
@@ -76,8 +79,8 @@ ActiveRecord::Schema.define(version: 20140304005354) do | @@ -76,8 +79,8 @@ ActiveRecord::Schema.define(version: 20140304005354) do | ||
76 | t.integer "assignee_id" | 79 | t.integer "assignee_id" |
77 | t.integer "author_id" | 80 | t.integer "author_id" |
78 | t.integer "project_id" | 81 | t.integer "project_id" |
79 | - t.datetime "created_at", null: false | ||
80 | - t.datetime "updated_at", null: false | 82 | + t.datetime "created_at" |
83 | + t.datetime "updated_at" | ||
81 | t.integer "position", default: 0 | 84 | t.integer "position", default: 0 |
82 | t.string "branch_name" | 85 | t.string "branch_name" |
83 | t.text "description" | 86 | t.text "description" |
@@ -95,8 +98,8 @@ ActiveRecord::Schema.define(version: 20140304005354) do | @@ -95,8 +98,8 @@ ActiveRecord::Schema.define(version: 20140304005354) do | ||
95 | 98 | ||
96 | create_table "keys", force: true do |t| | 99 | create_table "keys", force: true do |t| |
97 | t.integer "user_id" | 100 | t.integer "user_id" |
98 | - t.datetime "created_at", null: false | ||
99 | - t.datetime "updated_at", null: false | 101 | + t.datetime "created_at" |
102 | + t.datetime "updated_at" | ||
100 | t.text "key" | 103 | t.text "key" |
101 | t.string "title" | 104 | t.string "title" |
102 | t.string "type" | 105 | t.string "type" |
@@ -106,10 +109,10 @@ ActiveRecord::Schema.define(version: 20140304005354) do | @@ -106,10 +109,10 @@ ActiveRecord::Schema.define(version: 20140304005354) do | ||
106 | add_index "keys", ["user_id"], name: "index_keys_on_user_id", using: :btree | 109 | add_index "keys", ["user_id"], name: "index_keys_on_user_id", using: :btree |
107 | 110 | ||
108 | create_table "merge_request_diffs", force: true do |t| | 111 | create_table "merge_request_diffs", force: true do |t| |
109 | - t.string "state", default: "collected", null: false | ||
110 | - t.text "st_commits", limit: 2147483647 | ||
111 | - t.text "st_diffs", limit: 2147483647 | ||
112 | - t.integer "merge_request_id", null: false | 112 | + t.string "state", default: "collected", null: false |
113 | + t.text "st_commits" | ||
114 | + t.text "st_diffs" | ||
115 | + t.integer "merge_request_id", null: false | ||
113 | t.datetime "created_at" | 116 | t.datetime "created_at" |
114 | t.datetime "updated_at" | 117 | t.datetime "updated_at" |
115 | end | 118 | end |
@@ -123,8 +126,8 @@ ActiveRecord::Schema.define(version: 20140304005354) do | @@ -123,8 +126,8 @@ ActiveRecord::Schema.define(version: 20140304005354) do | ||
123 | t.integer "author_id" | 126 | t.integer "author_id" |
124 | t.integer "assignee_id" | 127 | t.integer "assignee_id" |
125 | t.string "title" | 128 | t.string "title" |
126 | - t.datetime "created_at", null: false | ||
127 | - t.datetime "updated_at", null: false | 129 | + t.datetime "created_at" |
130 | + t.datetime "updated_at" | ||
128 | t.integer "milestone_id" | 131 | t.integer "milestone_id" |
129 | t.string "state" | 132 | t.string "state" |
130 | t.string "merge_status" | 133 | t.string "merge_status" |
@@ -138,7 +141,7 @@ ActiveRecord::Schema.define(version: 20140304005354) do | @@ -138,7 +141,7 @@ ActiveRecord::Schema.define(version: 20140304005354) do | ||
138 | add_index "merge_requests", ["created_at"], name: "index_merge_requests_on_created_at", using: :btree | 141 | add_index "merge_requests", ["created_at"], name: "index_merge_requests_on_created_at", using: :btree |
139 | add_index "merge_requests", ["milestone_id"], name: "index_merge_requests_on_milestone_id", using: :btree | 142 | add_index "merge_requests", ["milestone_id"], name: "index_merge_requests_on_milestone_id", using: :btree |
140 | add_index "merge_requests", ["source_branch"], name: "index_merge_requests_on_source_branch", using: :btree | 143 | add_index "merge_requests", ["source_branch"], name: "index_merge_requests_on_source_branch", using: :btree |
141 | - add_index "merge_requests", ["source_project_id"], name: "index_merge_requests_on_project_id", using: :btree | 144 | + add_index "merge_requests", ["source_project_id"], name: "index_merge_requests_on_source_project_id", using: :btree |
142 | add_index "merge_requests", ["target_branch"], name: "index_merge_requests_on_target_branch", using: :btree | 145 | add_index "merge_requests", ["target_branch"], name: "index_merge_requests_on_target_branch", using: :btree |
143 | add_index "merge_requests", ["title"], name: "index_merge_requests_on_title", using: :btree | 146 | add_index "merge_requests", ["title"], name: "index_merge_requests_on_title", using: :btree |
144 | 147 | ||
@@ -147,8 +150,8 @@ ActiveRecord::Schema.define(version: 20140304005354) do | @@ -147,8 +150,8 @@ ActiveRecord::Schema.define(version: 20140304005354) do | ||
147 | t.integer "project_id", null: false | 150 | t.integer "project_id", null: false |
148 | t.text "description" | 151 | t.text "description" |
149 | t.date "due_date" | 152 | t.date "due_date" |
150 | - t.datetime "created_at", null: false | ||
151 | - t.datetime "updated_at", null: false | 153 | + t.datetime "created_at" |
154 | + t.datetime "updated_at" | ||
152 | t.string "state" | 155 | t.string "state" |
153 | t.integer "iid" | 156 | t.integer "iid" |
154 | end | 157 | end |
@@ -160,8 +163,8 @@ ActiveRecord::Schema.define(version: 20140304005354) do | @@ -160,8 +163,8 @@ ActiveRecord::Schema.define(version: 20140304005354) do | ||
160 | t.string "name", null: false | 163 | t.string "name", null: false |
161 | t.string "path", null: false | 164 | t.string "path", null: false |
162 | t.integer "owner_id" | 165 | t.integer "owner_id" |
163 | - t.datetime "created_at", null: false | ||
164 | - t.datetime "updated_at", null: false | 166 | + t.datetime "created_at" |
167 | + t.datetime "updated_at" | ||
165 | t.string "type" | 168 | t.string "type" |
166 | t.string "description", default: "", null: false | 169 | t.string "description", default: "", null: false |
167 | t.string "avatar" | 170 | t.string "avatar" |
@@ -176,15 +179,15 @@ ActiveRecord::Schema.define(version: 20140304005354) do | @@ -176,15 +179,15 @@ ActiveRecord::Schema.define(version: 20140304005354) do | ||
176 | t.text "note" | 179 | t.text "note" |
177 | t.string "noteable_type" | 180 | t.string "noteable_type" |
178 | t.integer "author_id" | 181 | t.integer "author_id" |
179 | - t.datetime "created_at", null: false | ||
180 | - t.datetime "updated_at", null: false | 182 | + t.datetime "created_at" |
183 | + t.datetime "updated_at" | ||
181 | t.integer "project_id" | 184 | t.integer "project_id" |
182 | t.string "attachment" | 185 | t.string "attachment" |
183 | t.string "line_code" | 186 | t.string "line_code" |
184 | t.string "commit_id" | 187 | t.string "commit_id" |
185 | t.integer "noteable_id" | 188 | t.integer "noteable_id" |
186 | - t.text "st_diff" | ||
187 | t.boolean "system", default: false, null: false | 189 | t.boolean "system", default: false, null: false |
190 | + t.text "st_diff" | ||
188 | end | 191 | end |
189 | 192 | ||
190 | add_index "notes", ["author_id"], name: "index_notes_on_author_id", using: :btree | 193 | add_index "notes", ["author_id"], name: "index_notes_on_author_id", using: :btree |
@@ -199,8 +202,8 @@ ActiveRecord::Schema.define(version: 20140304005354) do | @@ -199,8 +202,8 @@ ActiveRecord::Schema.define(version: 20140304005354) do | ||
199 | t.string "name" | 202 | t.string "name" |
200 | t.string "path" | 203 | t.string "path" |
201 | t.text "description" | 204 | t.text "description" |
202 | - t.datetime "created_at", null: false | ||
203 | - t.datetime "updated_at", null: false | 205 | + t.datetime "created_at" |
206 | + t.datetime "updated_at" | ||
204 | t.integer "creator_id" | 207 | t.integer "creator_id" |
205 | t.boolean "issues_enabled", default: true, null: false | 208 | t.boolean "issues_enabled", default: true, null: false |
206 | t.boolean "wall_enabled", default: true, null: false | 209 | t.boolean "wall_enabled", default: true, null: false |
@@ -217,15 +220,15 @@ ActiveRecord::Schema.define(version: 20140304005354) do | @@ -217,15 +220,15 @@ ActiveRecord::Schema.define(version: 20140304005354) do | ||
217 | t.boolean "archived", default: false, null: false | 220 | t.boolean "archived", default: false, null: false |
218 | end | 221 | end |
219 | 222 | ||
220 | - add_index "projects", ["creator_id"], name: "index_projects_on_owner_id", using: :btree | 223 | + add_index "projects", ["creator_id"], name: "index_projects_on_creator_id", using: :btree |
221 | add_index "projects", ["last_activity_at"], name: "index_projects_on_last_activity_at", using: :btree | 224 | add_index "projects", ["last_activity_at"], name: "index_projects_on_last_activity_at", using: :btree |
222 | add_index "projects", ["namespace_id"], name: "index_projects_on_namespace_id", using: :btree | 225 | add_index "projects", ["namespace_id"], name: "index_projects_on_namespace_id", using: :btree |
223 | 226 | ||
224 | create_table "protected_branches", force: true do |t| | 227 | create_table "protected_branches", force: true do |t| |
225 | t.integer "project_id", null: false | 228 | t.integer "project_id", null: false |
226 | t.string "name", null: false | 229 | t.string "name", null: false |
227 | - t.datetime "created_at", null: false | ||
228 | - t.datetime "updated_at", null: false | 230 | + t.datetime "created_at" |
231 | + t.datetime "updated_at" | ||
229 | end | 232 | end |
230 | 233 | ||
231 | add_index "protected_branches", ["project_id"], name: "index_protected_branches_on_project_id", using: :btree | 234 | add_index "protected_branches", ["project_id"], name: "index_protected_branches_on_project_id", using: :btree |
@@ -235,8 +238,8 @@ ActiveRecord::Schema.define(version: 20140304005354) do | @@ -235,8 +238,8 @@ ActiveRecord::Schema.define(version: 20140304005354) do | ||
235 | t.string "title" | 238 | t.string "title" |
236 | t.string "token" | 239 | t.string "token" |
237 | t.integer "project_id", null: false | 240 | t.integer "project_id", null: false |
238 | - t.datetime "created_at", null: false | ||
239 | - t.datetime "updated_at", null: false | 241 | + t.datetime "created_at" |
242 | + t.datetime "updated_at" | ||
240 | t.boolean "active", default: false, null: false | 243 | t.boolean "active", default: false, null: false |
241 | t.string "project_url" | 244 | t.string "project_url" |
242 | t.string "subdomain" | 245 | t.string "subdomain" |
@@ -249,14 +252,14 @@ ActiveRecord::Schema.define(version: 20140304005354) do | @@ -249,14 +252,14 @@ ActiveRecord::Schema.define(version: 20140304005354) do | ||
249 | 252 | ||
250 | create_table "snippets", force: true do |t| | 253 | create_table "snippets", force: true do |t| |
251 | t.string "title" | 254 | t.string "title" |
252 | - t.text "content", limit: 2147483647 | ||
253 | - t.integer "author_id", null: false | 255 | + t.text "content" |
256 | + t.integer "author_id", null: false | ||
254 | t.integer "project_id" | 257 | t.integer "project_id" |
255 | - t.datetime "created_at", null: false | ||
256 | - t.datetime "updated_at", null: false | 258 | + t.datetime "created_at" |
259 | + t.datetime "updated_at" | ||
257 | t.string "file_name" | 260 | t.string "file_name" |
258 | t.datetime "expires_at" | 261 | t.datetime "expires_at" |
259 | - t.boolean "private", default: true, null: false | 262 | + t.boolean "private", default: true, null: false |
260 | t.string "type" | 263 | t.string "type" |
261 | end | 264 | end |
262 | 265 | ||
@@ -293,8 +296,8 @@ ActiveRecord::Schema.define(version: 20140304005354) do | @@ -293,8 +296,8 @@ ActiveRecord::Schema.define(version: 20140304005354) do | ||
293 | t.datetime "last_sign_in_at" | 296 | t.datetime "last_sign_in_at" |
294 | t.string "current_sign_in_ip" | 297 | t.string "current_sign_in_ip" |
295 | t.string "last_sign_in_ip" | 298 | t.string "last_sign_in_ip" |
296 | - t.datetime "created_at", null: false | ||
297 | - t.datetime "updated_at", null: false | 299 | + t.datetime "created_at" |
300 | + t.datetime "updated_at" | ||
298 | t.string "name" | 301 | t.string "name" |
299 | t.boolean "admin", default: false, null: false | 302 | t.boolean "admin", default: false, null: false |
300 | t.integer "projects_limit", default: 10 | 303 | t.integer "projects_limit", default: 10 |
@@ -338,8 +341,8 @@ ActiveRecord::Schema.define(version: 20140304005354) do | @@ -338,8 +341,8 @@ ActiveRecord::Schema.define(version: 20140304005354) do | ||
338 | t.integer "group_access", null: false | 341 | t.integer "group_access", null: false |
339 | t.integer "group_id", null: false | 342 | t.integer "group_id", null: false |
340 | t.integer "user_id", null: false | 343 | t.integer "user_id", null: false |
341 | - t.datetime "created_at", null: false | ||
342 | - t.datetime "updated_at", null: false | 344 | + t.datetime "created_at" |
345 | + t.datetime "updated_at" | ||
343 | t.integer "notification_level", default: 3, null: false | 346 | t.integer "notification_level", default: 3, null: false |
344 | end | 347 | end |
345 | 348 | ||
@@ -348,8 +351,8 @@ ActiveRecord::Schema.define(version: 20140304005354) do | @@ -348,8 +351,8 @@ ActiveRecord::Schema.define(version: 20140304005354) do | ||
348 | create_table "users_projects", force: true do |t| | 351 | create_table "users_projects", force: true do |t| |
349 | t.integer "user_id", null: false | 352 | t.integer "user_id", null: false |
350 | t.integer "project_id", null: false | 353 | t.integer "project_id", null: false |
351 | - t.datetime "created_at", null: false | ||
352 | - t.datetime "updated_at", null: false | 354 | + t.datetime "created_at" |
355 | + t.datetime "updated_at" | ||
353 | t.integer "project_access", default: 0, null: false | 356 | t.integer "project_access", default: 0, null: false |
354 | t.integer "notification_level", default: 3, null: false | 357 | t.integer "notification_level", default: 3, null: false |
355 | end | 358 | end |
@@ -361,13 +364,14 @@ ActiveRecord::Schema.define(version: 20140304005354) do | @@ -361,13 +364,14 @@ ActiveRecord::Schema.define(version: 20140304005354) do | ||
361 | create_table "web_hooks", force: true do |t| | 364 | create_table "web_hooks", force: true do |t| |
362 | t.string "url" | 365 | t.string "url" |
363 | t.integer "project_id" | 366 | t.integer "project_id" |
364 | - t.datetime "created_at", null: false | ||
365 | - t.datetime "updated_at", null: false | 367 | + t.datetime "created_at" |
368 | + t.datetime "updated_at" | ||
366 | t.string "type", default: "ProjectHook" | 369 | t.string "type", default: "ProjectHook" |
367 | t.integer "service_id" | 370 | t.integer "service_id" |
368 | t.boolean "push_events", default: true, null: false | 371 | t.boolean "push_events", default: true, null: false |
369 | t.boolean "issues_events", default: false, null: false | 372 | t.boolean "issues_events", default: false, null: false |
370 | t.boolean "merge_requests_events", default: false, null: false | 373 | t.boolean "merge_requests_events", default: false, null: false |
374 | + t.boolean "tag_push_events", default: false | ||
371 | end | 375 | end |
372 | 376 | ||
373 | add_index "web_hooks", ["project_id"], name: "index_web_hooks_on_project_id", using: :btree | 377 | add_index "web_hooks", ["project_id"], name: "index_web_hooks_on_project_id", using: :btree |
@@ -0,0 +1,19 @@ | @@ -0,0 +1,19 @@ | ||
1 | +require 'spec_helper' | ||
2 | + | ||
3 | +describe ProjectHook do | ||
4 | + describe '.push_hooks' do | ||
5 | + it 'should return hooks for push events only' do | ||
6 | + hook = create(:project_hook, push_events: true) | ||
7 | + hook2 = create(:project_hook, push_events: false) | ||
8 | + expect(ProjectHook.push_hooks).to eq([hook]) | ||
9 | + end | ||
10 | + end | ||
11 | + | ||
12 | + describe '.tag_push_hooks' do | ||
13 | + it 'should return hooks for tag push events only' do | ||
14 | + hook = create(:project_hook, tag_push_events: true) | ||
15 | + hook2 = create(:project_hook, tag_push_events: false) | ||
16 | + expect(ProjectHook.tag_push_hooks).to eq([hook]) | ||
17 | + end | ||
18 | + end | ||
19 | +end |