vrfs988: added band spec and band.website value integrity on save
This commit is contained in:
parent
1276c66bd3
commit
74e95ad908
|
|
@ -14,6 +14,7 @@ module JamRuby
|
|||
validates :biography, no_profanity: true
|
||||
|
||||
before_save :check_lat_lng
|
||||
before_save :check_website_url
|
||||
|
||||
# musicians
|
||||
has_many :band_musicians, :class_name => "JamRuby::BandMusician"
|
||||
|
|
@ -237,6 +238,14 @@ module JamRuby
|
|||
false
|
||||
end
|
||||
|
||||
def check_website_url
|
||||
if website_changed? && self.website.present?
|
||||
self.website.strip!
|
||||
self.website = "http://#{self.website}" unless self.website =~ /^http/
|
||||
end
|
||||
true
|
||||
end
|
||||
|
||||
private
|
||||
def self.validate_genres(genres, is_nil_ok)
|
||||
if is_nil_ok && genres.nil?
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Band do
|
||||
|
||||
let(:band) { FactoryGirl.create(:band) }
|
||||
|
||||
describe 'website update' do
|
||||
it 'should have http prefix on website url' do
|
||||
band.website = 'example.com'
|
||||
band.save!
|
||||
expect(band.website).to match(/^http:\/\/example.com$/)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
Loading…
Reference in New Issue