fix a bug that person add a team with nil name

This commit is contained in:
szpyxlwoni
2012-12-05 11:30:33 +08:00
parent 5c0bf3bd1f
commit f277ab8b9c
3 changed files with 16 additions and 25 deletions
@@ -18,28 +18,4 @@ $ ->
$('.fancybox').fancybox()
# $("#map_canvas").each ->
# lat = parseFloat($('#person_lat').val()) || -34.397
# lng = parseFloat($('#person_lng').val()) || 150.644
#
# map_options = {
# center: new google.maps.LatLng(lat, lng),
# zoom: 8,
# mapTypeId: google.maps.MapTypeId.ROADMAP
# }
#
# map = new google.maps.Map(this, map_options)
#
# marker_options = {
# draggable: true,
# position: new google.maps.LatLng(lat, lng),
# map: map
# }
# marker = new google.maps.Marker(marker_options)
#
# google.maps.event.addListener marker, 'dragend', (event) ->
# point = marker.getPosition()
# $('#person_lat').val point.lat()
# $('#person_lng').val point.lng()
+1 -1
View File
@@ -11,7 +11,6 @@ class TeamsController < ApplicationController
end
def create
@teams = current_person.teams
@team = Team.new params[:team].merge creator: current_person
if @team.save
@@ -23,6 +22,7 @@ class TeamsController < ApplicationController
redirect_to "/teams/#{@team.slug}"
else
@memberships = current_person.memberships
render :index
end
end
+15
View File
@@ -54,6 +54,21 @@ describe TeamsController do
new_team.name.should == 'CDI'
new_team.organisations.first.should == @organisation
end
it 'not create team with null name' do
lambda do
post :create, team: {name: nil, slug: 'cdi'}, org_ids: [@organisation.id.to_s]
end.should_not change(Team, :count)
assigns(:memberships).should_not be_nil
end
it 'not create team with null name' do
lambda do
post :create, team: {name: 'CDI', slug: nil}, org_ids: [@organisation.id.to_s]
end.should_not change(Team, :count)
assigns(:memberships).should_not be_nil
end
end
describe :join do