mirror of
https://github.com/wahyd4/ocelots.git
synced 2026-08-09 04:56:21 +10:00
filter blanks of slug when create a team
This commit is contained in:
@@ -14,7 +14,7 @@ class AntechamberController < ApplicationController
|
||||
with_team do |team|
|
||||
message = Message.create team: team, person: current_person, content: params[:content]
|
||||
|
||||
Pusher.trigger(team.name, 'new_message',{content:render_to_string( partial: 'shared/one_message', locals: {message: message})})
|
||||
Pusher.trigger(team.slug, 'new_message',{content:render_to_string( partial: 'shared/one_message', locals: {message: message})})
|
||||
|
||||
render text:'ok'
|
||||
end
|
||||
|
||||
@@ -4,6 +4,7 @@ class Team < ActiveRecord::Base
|
||||
validates_presence_of :name
|
||||
validates_presence_of :slug
|
||||
validates_uniqueness_of :slug
|
||||
validate :format_slug ,:on => :create
|
||||
|
||||
has_many :memberships
|
||||
has_many :people, through: :memberships
|
||||
@@ -26,4 +27,10 @@ class Team < ActiveRecord::Base
|
||||
def add_to (organisation)
|
||||
organisations << organisation if organisation
|
||||
end
|
||||
|
||||
def format_slug
|
||||
|
||||
slug.gsub!(/ /, "_") if slug
|
||||
end
|
||||
|
||||
end
|
||||
@@ -8,8 +8,8 @@
|
||||
h1 = @team.name
|
||||
form.form-inline action="/antechamber/#{@team.slug}"
|
||||
input type="hidden" id="pusher_key" value="#{ENV['PUSHER_KEY']}"
|
||||
input type="hidden" id="team_name" value="#{@team.name}"
|
||||
p #{text_area_tag :content, nil, placeholder: 'Enter Message', rows: 4,class:'message-body'}
|
||||
input type="hidden" id="team_name" value="#{@team.slug}"
|
||||
p #{text_area_tag :content, nil, placeholder: 'Enter Message', rows: 4 ,class:'message-body',style:"width:30%"}
|
||||
a.btn.submit-mess Send
|
||||
|
||||
div.message-list
|
||||
|
||||
@@ -19,4 +19,14 @@ describe Team do
|
||||
|
||||
end
|
||||
|
||||
describe 'create team' do
|
||||
|
||||
it 'ensure when create a team,if team"s slug has blanks, it will be format to url string "' do
|
||||
@person = Person.create_for_email 'test@thoughworks.com'
|
||||
@team = @person.teams.create(name: 'LSP', slug: 'l s p')
|
||||
@team.slug.should == 'l_s_p'
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user