Fix the problem where the last domain could not be removed. Closes #335.

This commit is contained in:
Mario Visic 2012-04-02 21:11:30 +08:00
parent f134601306
commit 4c1e9fa9c4
4 changed files with 2 additions and 21 deletions

View File

@ -24,7 +24,7 @@ class Locomotive.Models.Site extends Backbone.Model
delete hash.memberships
hash.memberships_attributes = @get('memberships').toJSONForSave() if @get('memberships')? && @get('memberships').length > 0
delete hash.domains
hash.domains = _.map(@get('domains'), (domain) -> domain.get('name')) if @get('domains')? && @get('domains').length > 0
hash.domains = _.map(@get('domains'), (domain) -> domain.get('name'))
class Locomotive.Models.CurrentSite extends Locomotive.Models.Site

View File

@ -38,6 +38,7 @@ module Locomotive
module InstanceMethods
def domains=(array)
array.reject!(&:blank?)
array = [] if array.blank?; super(array)
end

View File

@ -26,8 +26,3 @@ Feature: Manage my site
Scenario: Adding a domain to a site
Given I am an authenticated user
Then I should be able to add a domain to my site
@javascript
Scenario: Removing a domain from a site
Given I am an authenticated user
Then I should be able to remove a domain from my site

View File

@ -34,7 +34,6 @@ Given /^a robot_txt set to "([^"]*)"$/ do |value|
@site.update_attributes(:robots_txt => value)
end
Then /^I should be able to add a domain to my site$/ do
visit edit_current_site_path
@ -45,17 +44,3 @@ Then /^I should be able to add a domain to my site$/ do
page.should have_content 'My site was successfully updated'
@site.reload.domains.should include 'monkeys.com'
end
Then /^I should be able to remove a domain from my site$/ do
@site.domains = [ 'monkeys.com' ]
@site.save!
visit edit_current_site_path
click_link 'x'
click_button 'Save'
page.should have_content 'My site was successfully updated'
@site.reload.domains.should be_blank
end