-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to add slack integration points
- Loading branch information
1 parent
026a1f2
commit b282d38
Showing
21 changed files
with
221 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Place all the behaviors and hooks related to the matching controller here. | ||
# All this logic will automatically be available in application.js. | ||
# You can use CoffeeScript in this file: http://coffeescript.org/ |
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 @@ | ||
// Place all the styles related to the slack_integrations controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: http://sass-lang.com/ |
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,82 @@ | ||
class SlackIntegrationsController < ApplicationController | ||
before_action :set_integration, only: [:show, :edit, :update, :destroy] | ||
before_filter :authenticate_user! | ||
|
||
def index | ||
if current_user.admin? | ||
@slack_integrations = SlackIntegration.all | ||
else | ||
render_404 | ||
end | ||
end | ||
|
||
def show | ||
render_404 unless current_user.admin? | ||
end | ||
|
||
def new | ||
if current_user.admin? | ||
@slack_integration = SlackIntegration.new | ||
else | ||
render_404 | ||
end | ||
end | ||
|
||
def edit | ||
render_404 unless current_user.admin? | ||
end | ||
|
||
def create | ||
if current_user.admin? | ||
@slack_integration = SlackIntegration.new(slack_integration_params) | ||
|
||
if @slack_integration.save | ||
redirect_to @slack_integration, notice: 'Integration was successfully created.' | ||
else | ||
render :new | ||
end | ||
|
||
else | ||
render_404 | ||
end | ||
end | ||
|
||
def update | ||
if current_user.admin? | ||
if @slack_integration.update(slack_integration_params) | ||
redirect_to @slack_integration, notice: 'Integration was successfully updated.' | ||
else | ||
render :edit | ||
end | ||
else | ||
render_404 | ||
end | ||
end | ||
|
||
def destroy | ||
if current_user.admin? | ||
@slack_integration.destroy | ||
redirect_to uuids_url, notice: 'Integration was successfully destroyed.' | ||
else | ||
render_404 | ||
end | ||
end | ||
|
||
private | ||
def set_integration | ||
@slack_integration = SlackIntegration.find(params[:id]) | ||
end | ||
|
||
def slack_integration_params | ||
params.require(:slack_integration).permit(:slack_integration, :hook_url) | ||
end | ||
|
||
def render_404 | ||
respond_to do |format| | ||
format.html { render :file => "#{Rails.root}/public/404", :layout => false, :status => :not_found } | ||
format.xml { head :not_found } | ||
format.any { head :not_found } | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module SlackIntegrationsHelper | ||
end |
This file was deleted.
Oops, something went wrong.
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,2 @@ | ||
class SlackIntegration < ActiveRecord::Base | ||
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,21 @@ | ||
<%= form_for(@slack_integration) do |f| %> | ||
<% if @slack_integration.errors.any? %> | ||
<div id="error_explanation"> | ||
<h2><%= pluralize(@slack_integration.errors.count, "error") %> prohibited this integration from being saved:</h2> | ||
|
||
<ul> | ||
<% @slack_integration.errors.full_messages.each do |message| %> | ||
<li><%= message %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
|
||
<div class="field"> | ||
<%= f.label :hook_url %><br> | ||
<%= f.text_field :hook_url %> | ||
</div> | ||
<div class="actions"> | ||
<%= f.submit %> | ||
</div> | ||
<% 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,6 @@ | ||
<h1>Editing Integration</h1> | ||
|
||
<%= render 'form' %> | ||
|
||
<%= link_to 'Show', @slack_integration %> | | ||
<%= link_to 'Back', slack_integrations_path %> |
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,28 @@ | ||
<p id="notice"><%= notice %></p> | ||
|
||
<h1>Integrations</h1> | ||
|
||
<table> | ||
<thead> | ||
<tr> | ||
<th>Hook URL</th> | ||
<th colspan="3"></th> | ||
</tr> | ||
</thead> | ||
|
||
<tbody> | ||
<% @slack_integrations.each do |integration| %> | ||
<tr> | ||
<td><%= integration.hook_url %></td> | ||
<td><%= link_to 'Show', integration %></td> | ||
<td><%= link_to 'Edit', edit_slack_integration_path(integration) %></td> | ||
<td><%= link_to 'Destroy', integration, method: :delete, data: { confirm: 'Are you sure?' } %></td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
|
||
<br> | ||
|
||
<%= link_to 'New Integration', new_slack_integration_path %> | ||
<%= link_to 'Back', controller: :admin, action: :index %> |
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 @@ | ||
<h1>New Integration</h1> | ||
|
||
<%= render 'form' %> | ||
|
||
<%= link_to 'Back', slack_integrations_path %> |
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,9 @@ | ||
<p id="notice"><%= notice %></p> | ||
|
||
<p> | ||
<strong>Integration:</strong> | ||
<%= @slack_integration.hook_url %> | ||
</p> | ||
|
||
<%= link_to 'Edit', edit_slack_integration_path(@slack_integration) %> | | ||
<%= link_to 'Back', slack_integrations_path %> |
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,9 @@ | ||
class CreateSlackIntegrations < ActiveRecord::Migration | ||
def change | ||
create_table :slack_integrations do |t| | ||
t.text :hook_url | ||
|
||
t.timestamps null: false | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe SlackIntegrationsController, type: :controller do | ||
|
||
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,6 @@ | ||
FactoryGirl.define do | ||
factory :slack_integration do | ||
|
||
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,15 @@ | ||
require 'rails_helper' | ||
|
||
# Specs in this file have access to a helper object that includes | ||
# the SlackIntegrationsHelper. For example: | ||
# | ||
# describe SlackIntegrationsHelper do | ||
# describe "string concat" do | ||
# it "concats two strings with spaces" do | ||
# expect(helper.concat_strings("this","that")).to eq("this that") | ||
# end | ||
# end | ||
# end | ||
RSpec.describe SlackIntegrationsHelper, type: :helper do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
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,5 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe SlackIntegration, type: :model do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
end |