Commit c3b074acab554fc40a8fcb6060ed7ab10e4171a4
1 parent
be1dc554
Exists in
master
and in
4 other branches
Service model and service hook
Showing
7 changed files
with
97 additions
and
0 deletions
Show diff stats
2.69 KB
... | ... | @@ -0,0 +1,21 @@ |
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 | +# | |
13 | + | |
14 | +class Service < ActiveRecord::Base | |
15 | + attr_accessible :title, :token, :type | |
16 | + | |
17 | + belongs_to :project | |
18 | + has_one :service_hook | |
19 | + | |
20 | + validates :project_id, presence: true | |
21 | +end | ... | ... |
... | ... | @@ -0,0 +1,15 @@ |
1 | +# == Schema Information | |
2 | +# | |
3 | +# Table name: web_hooks | |
4 | +# | |
5 | +# id :integer not null, primary key | |
6 | +# url :string(255) | |
7 | +# project_id :integer | |
8 | +# created_at :datetime not null | |
9 | +# updated_at :datetime not null | |
10 | +# type :string(255) default("ProjectHook") | |
11 | +# | |
12 | + | |
13 | +class ServiceHook < WebHook | |
14 | + belongs_to :service | |
15 | +end | ... | ... |
... | ... | @@ -0,0 +1,19 @@ |
1 | +# == Schema Information | |
2 | +# | |
3 | +# Table name: web_hooks | |
4 | +# | |
5 | +# id :integer not null, primary key | |
6 | +# url :string(255) | |
7 | +# project_id :integer | |
8 | +# created_at :datetime not null | |
9 | +# updated_at :datetime not null | |
10 | +# type :string(255) default("ProjectHook") | |
11 | +# | |
12 | + | |
13 | +require "spec_helper" | |
14 | + | |
15 | +describe ServiceHook do | |
16 | + describe "Associations" do | |
17 | + it { should belong_to :service } | |
18 | + end | |
19 | +end | ... | ... |
... | ... | @@ -0,0 +1,25 @@ |
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 | +# | |
13 | + | |
14 | +require 'spec_helper' | |
15 | + | |
16 | +describe Service do | |
17 | + describe "Associations" do | |
18 | + it { should belong_to :project } | |
19 | + it { should have_one :service_hook } | |
20 | + end | |
21 | + | |
22 | + describe "Mass assignment" do | |
23 | + it { should_not allow_mass_assignment_of(:project_id) } | |
24 | + end | |
25 | +end | ... | ... |