vrfs-884: fixing tests for commit
This commit is contained in:
parent
742402dfa2
commit
60b59a88c7
|
|
@ -130,11 +130,10 @@ module JamRuby
|
|||
|
||||
# helper method for creating / updating a Band
|
||||
def self.save(id, name, website, biography, city, state, country, genres, user_id, photo_url, logo_url)
|
||||
|
||||
user = User.find(user_id)
|
||||
|
||||
# new band
|
||||
if id.nil?
|
||||
if id.blank?
|
||||
|
||||
# ensure person creating this Band is a Musician
|
||||
unless user.musician?
|
||||
|
|
@ -173,35 +172,28 @@ module JamRuby
|
|||
# country
|
||||
band.country = country unless country.nil?
|
||||
|
||||
# genres
|
||||
unless genres.nil?
|
||||
ActiveRecord::Base.transaction do
|
||||
# delete all genres for this band first
|
||||
unless band.id.nil? || band.id.length == 0
|
||||
band.genres.delete_all
|
||||
end
|
||||
|
||||
# loop through each genre in the array and save to the db
|
||||
genres.each do |genre_id|
|
||||
g = Genre.find(genre_id)
|
||||
band.genres << g
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# photo url
|
||||
band.photo_url = photo_url unless photo_url.nil?
|
||||
|
||||
# logo url
|
||||
band.logo_url = logo_url unless logo_url.nil?
|
||||
|
||||
band.updated_at = Time.now.getutc
|
||||
band.save
|
||||
# band.updated_at = Time.now.getutc
|
||||
band.save!
|
||||
band.reload
|
||||
|
||||
# genres
|
||||
unless genres.nil?
|
||||
ActiveRecord::Base.transaction do
|
||||
# delete all genres for this band first
|
||||
band.genres.delete_all if id.present?
|
||||
# loop through each genre in the array and save to the db
|
||||
genres.each { |genre_id| band.genres << Genre.find(genre_id) }
|
||||
end
|
||||
end
|
||||
|
||||
# add the creator as the admin
|
||||
if id.nil?
|
||||
BandMusician.create(:band_id => band.id, :user_id => user_id, :admin => true)
|
||||
end
|
||||
BandMusician.create(:band_id => band.id, :user_id => user_id, :admin => true) if id.blank?
|
||||
|
||||
return band
|
||||
end
|
||||
|
|
@ -243,6 +235,7 @@ module JamRuby
|
|||
if (city_changed? || state_changed? || country_changed?)
|
||||
update_lat_lng
|
||||
end
|
||||
true
|
||||
end
|
||||
|
||||
def update_lat_lng
|
||||
|
|
|
|||
|
|
@ -41,8 +41,7 @@ module JamRuby
|
|||
search_results.take(LIMIT).each do |result|
|
||||
if result.class == User
|
||||
if result.musician
|
||||
@musicians_filter.push(result)
|
||||
@search_type = PARAM_MUSICIAN
|
||||
@musicians.push(result)
|
||||
else
|
||||
@fans.push(result)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ describe User do
|
|||
let(:user) { FactoryGirl.create(:user) }
|
||||
|
||||
before(:each) do
|
||||
@geocode1 = FactoryGirl.create(:geocoder)
|
||||
@geocode2 = FactoryGirl.create(:geocoder)
|
||||
@user = FactoryGirl.create(:user)
|
||||
@band = Band.save(nil, "Example Band", "www.bands.com", "zomg we rock", "Apex", "NC", "US", ["hip hop"], user.id, nil, nil)
|
||||
|
||||
|
|
|
|||
|
|
@ -24,14 +24,12 @@ describe "Musician Search", :js => true, :type => :feature, :capybara_feature =>
|
|||
end
|
||||
|
||||
it "shows submits query" do
|
||||
find("a#btn-refresh-musicians").trigger(:click)
|
||||
expect(page).to have_selector('#musician-filter-results .musician-list-result')
|
||||
end
|
||||
|
||||
it "shows blank result set" do
|
||||
expect(page).to have_selector('#instrument')
|
||||
find('#instrument').find(:xpath, 'option[2]').select_option
|
||||
find("a#btn-refresh-musicians").trigger(:click)
|
||||
expect(page).to have_selector('#musician_instrument')
|
||||
find('#musician_instrument').find(:xpath, 'option[2]').select_option
|
||||
expect(page).to_not have_selector('#musician-filter-results .musician-list-result')
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ describe "Musician Search API", :type => :api do
|
|||
it "default search" do
|
||||
get_query
|
||||
good_response
|
||||
expect(json['musicians'].count).to be [Search::M_PER_PAGE, User.musicians_geocoded.count].min
|
||||
expect(json['musicians'].count).to be [Search::M_PER_PAGE, User.musicians.count].min
|
||||
end
|
||||
|
||||
context 'location filtering' do
|
||||
|
|
|
|||
Loading…
Reference in New Issue