-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For client projects, we will likely have a project-specific Slack channel. We would like to have Beggar notificy the project-specific Slack channel of pull requests in addition to any channels that may be tagged in the PR description. A Project will require a Channel. Channels can be tied to multiple projects. There's no firm requirement these channels be project specific, but that's how I see this being used. To add a Project Channel and a Project, use Beggar's Active Admin GUI.
- Loading branch information
Nathan L. Walls
committed
Apr 3, 2015
1 parent
d28fc86
commit ce3c82a
Showing
13 changed files
with
198 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ActiveAdmin.register Project do | ||
permit_params :name, :default_channel_id, :github_url | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Project < ActiveRecord::Base | ||
validates :default_channel, presence: true | ||
validates :github_url, presence: true, uniqueness: true | ||
validates :name, presence: true, uniqueness: true | ||
|
||
belongs_to :default_channel, class_name: "Channel" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class ProjectMatcher | ||
def self.match(github_url) | ||
Project.where(github_url: github_url) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
class CreateProject < ActiveRecord::Migration | ||
def change | ||
create_table :projects do |t| | ||
t.string :name, null: false, unique: true | ||
t.string :github_url, null: false, unique: true | ||
t.integer :default_channel_id, null: false | ||
end | ||
|
||
add_foreign_key( | ||
:projects, | ||
:channels, | ||
column: :default_channel_id, | ||
on_delete: :cascade | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
require "rails_helper" | ||
|
||
describe Project do | ||
subject { FactoryGirl.build(:project) } | ||
it { should validate_presence_of(:name) } | ||
it { should validate_uniqueness_of(:name) } | ||
it { should belong_to(:default_channel) } | ||
it { should validate_presence_of(:default_channel) } | ||
it { should validate_presence_of(:github_url) } | ||
it { should validate_uniqueness_of(:github_url) } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require "spec_helper" | ||
require "services/project_matcher" | ||
|
||
describe ProjectMatcher do | ||
it "matches when a project has the same github repo name as provided text" do | ||
url = "http://example.com/thoughtbot/beggar" | ||
create(:project, github_url: url) | ||
|
||
result = ProjectMatcher.match(url) | ||
|
||
expect(result.first.github_url).to eq(url) | ||
end | ||
end |