Fix the problem where the last domain could not be removed. Closes #335.
This commit is contained in:
parent
f134601306
commit
4c1e9fa9c4
@ -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
|
||||
|
||||
|
@ -38,6 +38,7 @@ module Locomotive
|
||||
module InstanceMethods
|
||||
|
||||
def domains=(array)
|
||||
array.reject!(&:blank?)
|
||||
array = [] if array.blank?; super(array)
|
||||
end
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user