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 | 17 | class ProjectHook < WebHook |
18 | 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 | 22 | scope :push_hooks, -> { where(push_events: true) } |
23 | + scope :tag_push_hooks, -> { where(tag_push_events: true) } | |
23 | 24 | scope :issue_hooks, -> { where(issues_events: true) } |
24 | 25 | scope :merge_request_hooks, -> { where(merge_requests_events: true) } |
25 | 26 | end | ... | ... |
app/views/projects/hooks/index.html.haml
... | ... | @@ -27,6 +27,13 @@ |
27 | 27 | %p.light |
28 | 28 | This url will be triggered by a push to the repository |
29 | 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 | 37 | = f.check_box :issues_events, class: 'pull-left' |
31 | 38 | .prepend-left-20 |
32 | 39 | = f.label :issues_events, class: 'list-label' do |
... | ... | @@ -56,6 +63,6 @@ |
56 | 63 | .clearfix |
57 | 64 | %span.monospace= hook.url |
58 | 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 | 67 | - if hook.send(trigger) |
61 | 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 | 11 | # |
12 | 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 | 19 | create_table "broadcast_messages", force: true do |t| |
17 | 20 | t.text "message", null: false |
18 | 21 | t.datetime "starts_at" |
19 | 22 | t.datetime "ends_at" |
20 | 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 | 26 | t.string "color" |
24 | 27 | t.string "font" |
25 | 28 | end |
... | ... | @@ -27,8 +30,8 @@ ActiveRecord::Schema.define(version: 20140304005354) do |
27 | 30 | create_table "deploy_keys_projects", force: true do |t| |
28 | 31 | t.integer "deploy_key_id", null: false |
29 | 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 | 35 | end |
33 | 36 | |
34 | 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 | 52 | t.string "title" |
50 | 53 | t.text "data" |
51 | 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 | 57 | t.integer "action" |
55 | 58 | t.integer "author_id" |
56 | 59 | end |
... | ... | @@ -65,8 +68,8 @@ ActiveRecord::Schema.define(version: 20140304005354) do |
65 | 68 | create_table "forked_project_links", force: true do |t| |
66 | 69 | t.integer "forked_to_project_id", null: false |
67 | 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 | 73 | end |
71 | 74 | |
72 | 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 | 79 | t.integer "assignee_id" |
77 | 80 | t.integer "author_id" |
78 | 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 | 84 | t.integer "position", default: 0 |
82 | 85 | t.string "branch_name" |
83 | 86 | t.text "description" |
... | ... | @@ -95,8 +98,8 @@ ActiveRecord::Schema.define(version: 20140304005354) do |
95 | 98 | |
96 | 99 | create_table "keys", force: true do |t| |
97 | 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 | 103 | t.text "key" |
101 | 104 | t.string "title" |
102 | 105 | t.string "type" |
... | ... | @@ -106,10 +109,10 @@ ActiveRecord::Schema.define(version: 20140304005354) do |
106 | 109 | add_index "keys", ["user_id"], name: "index_keys_on_user_id", using: :btree |
107 | 110 | |
108 | 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 | 116 | t.datetime "created_at" |
114 | 117 | t.datetime "updated_at" |
115 | 118 | end |
... | ... | @@ -123,8 +126,8 @@ ActiveRecord::Schema.define(version: 20140304005354) do |
123 | 126 | t.integer "author_id" |
124 | 127 | t.integer "assignee_id" |
125 | 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 | 131 | t.integer "milestone_id" |
129 | 132 | t.string "state" |
130 | 133 | t.string "merge_status" |
... | ... | @@ -138,7 +141,7 @@ ActiveRecord::Schema.define(version: 20140304005354) do |
138 | 141 | add_index "merge_requests", ["created_at"], name: "index_merge_requests_on_created_at", using: :btree |
139 | 142 | add_index "merge_requests", ["milestone_id"], name: "index_merge_requests_on_milestone_id", using: :btree |
140 | 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 | 145 | add_index "merge_requests", ["target_branch"], name: "index_merge_requests_on_target_branch", using: :btree |
143 | 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 | 150 | t.integer "project_id", null: false |
148 | 151 | t.text "description" |
149 | 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 | 155 | t.string "state" |
153 | 156 | t.integer "iid" |
154 | 157 | end |
... | ... | @@ -160,8 +163,8 @@ ActiveRecord::Schema.define(version: 20140304005354) do |
160 | 163 | t.string "name", null: false |
161 | 164 | t.string "path", null: false |
162 | 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 | 168 | t.string "type" |
166 | 169 | t.string "description", default: "", null: false |
167 | 170 | t.string "avatar" |
... | ... | @@ -176,15 +179,15 @@ ActiveRecord::Schema.define(version: 20140304005354) do |
176 | 179 | t.text "note" |
177 | 180 | t.string "noteable_type" |
178 | 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 | 184 | t.integer "project_id" |
182 | 185 | t.string "attachment" |
183 | 186 | t.string "line_code" |
184 | 187 | t.string "commit_id" |
185 | 188 | t.integer "noteable_id" |
186 | - t.text "st_diff" | |
187 | 189 | t.boolean "system", default: false, null: false |
190 | + t.text "st_diff" | |
188 | 191 | end |
189 | 192 | |
190 | 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 | 202 | t.string "name" |
200 | 203 | t.string "path" |
201 | 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 | 207 | t.integer "creator_id" |
205 | 208 | t.boolean "issues_enabled", default: true, null: false |
206 | 209 | t.boolean "wall_enabled", default: true, null: false |
... | ... | @@ -217,15 +220,15 @@ ActiveRecord::Schema.define(version: 20140304005354) do |
217 | 220 | t.boolean "archived", default: false, null: false |
218 | 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 | 224 | add_index "projects", ["last_activity_at"], name: "index_projects_on_last_activity_at", using: :btree |
222 | 225 | add_index "projects", ["namespace_id"], name: "index_projects_on_namespace_id", using: :btree |
223 | 226 | |
224 | 227 | create_table "protected_branches", force: true do |t| |
225 | 228 | t.integer "project_id", null: false |
226 | 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 | 232 | end |
230 | 233 | |
231 | 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 | 238 | t.string "title" |
236 | 239 | t.string "token" |
237 | 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 | 243 | t.boolean "active", default: false, null: false |
241 | 244 | t.string "project_url" |
242 | 245 | t.string "subdomain" |
... | ... | @@ -249,14 +252,14 @@ ActiveRecord::Schema.define(version: 20140304005354) do |
249 | 252 | |
250 | 253 | create_table "snippets", force: true do |t| |
251 | 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 | 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 | 260 | t.string "file_name" |
258 | 261 | t.datetime "expires_at" |
259 | - t.boolean "private", default: true, null: false | |
262 | + t.boolean "private", default: true, null: false | |
260 | 263 | t.string "type" |
261 | 264 | end |
262 | 265 | |
... | ... | @@ -293,8 +296,8 @@ ActiveRecord::Schema.define(version: 20140304005354) do |
293 | 296 | t.datetime "last_sign_in_at" |
294 | 297 | t.string "current_sign_in_ip" |
295 | 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 | 301 | t.string "name" |
299 | 302 | t.boolean "admin", default: false, null: false |
300 | 303 | t.integer "projects_limit", default: 10 |
... | ... | @@ -338,8 +341,8 @@ ActiveRecord::Schema.define(version: 20140304005354) do |
338 | 341 | t.integer "group_access", null: false |
339 | 342 | t.integer "group_id", null: false |
340 | 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 | 346 | t.integer "notification_level", default: 3, null: false |
344 | 347 | end |
345 | 348 | |
... | ... | @@ -348,8 +351,8 @@ ActiveRecord::Schema.define(version: 20140304005354) do |
348 | 351 | create_table "users_projects", force: true do |t| |
349 | 352 | t.integer "user_id", null: false |
350 | 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 | 356 | t.integer "project_access", default: 0, null: false |
354 | 357 | t.integer "notification_level", default: 3, null: false |
355 | 358 | end |
... | ... | @@ -361,13 +364,14 @@ ActiveRecord::Schema.define(version: 20140304005354) do |
361 | 364 | create_table "web_hooks", force: true do |t| |
362 | 365 | t.string "url" |
363 | 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 | 369 | t.string "type", default: "ProjectHook" |
367 | 370 | t.integer "service_id" |
368 | 371 | t.boolean "push_events", default: true, null: false |
369 | 372 | t.boolean "issues_events", default: false, null: false |
370 | 373 | t.boolean "merge_requests_events", default: false, null: false |
374 | + t.boolean "tag_push_events", default: false | |
371 | 375 | end |
372 | 376 | |
373 | 377 | add_index "web_hooks", ["project_id"], name: "index_web_hooks_on_project_id", using: :btree | ... | ... |
... | ... | @@ -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 | ... | ... |