VRFS 79 add image URL fields to users and bands tables

This commit is contained in:
Brian Smith 2012-11-28 00:26:43 -05:00
parent 2cf4794fd0
commit 7bb6d6b71e
9 changed files with 40 additions and 27 deletions

View File

@ -40,6 +40,7 @@ gem 'omniauth-facebook'
gem 'fb_graph'
gem 'sendgrid'
gem 'recaptcha'
gem 'filepicker-rails'
group :development, :test do
gem 'rspec-rails', '2.11.0'

View File

@ -21,7 +21,9 @@ class ApiBandsController < ApiController
params[:state],
params[:country],
params[:genres],
current_user.id)
current_user.id,
params[:photo_url],
params[:logo_url])
respond_with @band, responder: ApiResponder, :status => 201, :location => api_band_detail_url(@band)
end
@ -38,7 +40,9 @@ class ApiBandsController < ApiController
params[:state],
params[:country],
params[:genres],
current_user.id,)
current_user.id,
params[:photo_url],
params[:logo_url])
respond_with @band, responder: ApiResponder, :status => :ok
end
@ -120,7 +124,7 @@ class ApiBandsController < ApiController
end
def recording_destroy
@band = Band.find(params[:id])
@band = Band.find_by_id(params[:id])
auth_band_member(@band, current_user)
@recording = Recording.find(params[:recording_id])
@ -138,7 +142,7 @@ class ApiBandsController < ApiController
def invitation_index
@band = Band.find(params[:id])
auth_band_member(@band, current_user)
@invitations = @band.invitations
@invitations = @band.invitations #BandInvitation.find_by_band_id(params[:id])
respond_with @invitations, responder: ApiResponder, :status => 200
end

View File

@ -30,6 +30,7 @@ class ApiUsersController < ApiController
params[:state],
params[:country],
params[:instruments],
params[:photo_url],
ApplicationHelper.base_uri(request) + "/confirm")
# check for errors
@ -68,7 +69,8 @@ class ApiUsersController < ApiController
params[:city],
params[:state],
params[:country],
params[:instruments])
params[:instruments],
params[:photo_url])
respond_with @user, responder: ApiResponder, :status => 200
end
@ -271,7 +273,7 @@ class ApiUsersController < ApiController
def band_invitation_index
auth_user(params[:id])
@user = current_user
@invitations = @user.received_band_invitations #.merge(@user.sent_band_invitations)
@invitations = @user.received_band_invitations#.merge(@user.sent_band_invitations)
respond_with @invitations, responder: ApiResponder, :status => 200
end

View File

@ -46,8 +46,9 @@ class SessionsController < ApplicationController
nil,
auth_hash[:info][:location],
nil, # state
nil, # @country
nil,
nil, # country
nil, # instruments
nil, # photo_url
nil)
# Users who sign up using oauth are presumed to have valid email adddresses.

View File

@ -36,6 +36,7 @@ class UsersController < ApplicationController
params[:jam_ruby_user][:state],
params[:jam_ruby_user][:country],
params[:jam_ruby_user][:instruments],
params[:jam_ruby_user][:photo_url],
ApplicationHelper.base_uri(request) + "/confirm")
# check for errors

View File

@ -9,7 +9,7 @@ class UserManager < BaseManager
end
def signup(first_name, last_name, email, password, password_confirmation,
city, state, country, instruments, signup_confirm_url)
city, state, country, instruments, photo_url, signup_confirm_url)
@user = User.new
@ -22,7 +22,7 @@ class UserManager < BaseManager
#else
# sends email to email account for confirmation
@user = User.signup(first_name, last_name, email, password, password_confirmation,
city, state, country, instruments, signup_confirm_url)
city, state, country, instruments, photo_url, signup_confirm_url)
return @user
#end

View File

@ -11,7 +11,7 @@ describe UserManager do
describe "signup" do
it "signup successfully" do
@user = @user_manager.signup("bob", "smith", "bob@jamkazam.com", "foobar", "foobar", "Austin", "TX", "USA", nil, "http://localhost:3000/confirm" )
@user = @user_manager.signup("bob", "smith", "bob@jamkazam.com", "foobar", "foobar", "Austin", "TX", "USA", nil, nil, "http://localhost:3000/confirm" )
@user.errors.any?.should be_false
@user.first_name.should == "bob"
@ -29,7 +29,7 @@ describe UserManager do
it "signup successfully with instruments" do
@user = @user_manager.signup("bob", "smith", "bob@jamkazam.com", "foobar", "foobar", "Austin", "TX", "USA",
[{ :instrument_id => "electric guitar", :proficiency_level => 3, :priority => 0}], "http://localhost:3000/confirm")
[{ :instrument_id => "electric guitar", :proficiency_level => 3, :priority => 0}], nil, "http://localhost:3000/confirm")
@user.errors.any?.should be_false
@user.instruments.length.should == 1
@ -39,26 +39,26 @@ describe UserManager do
end
it "duplicate signup failure" do
@user = @user_manager.signup("bob", "smith", "bob@jamkazam.com", "foobar", "foobar", "Austin", "TX", "USA", nil, "http://localhost:3000/confirm")
@user = @user_manager.signup("bob", "smith", "bob@jamkazam.com", "foobar", "foobar", "Austin", "TX", "USA", nil, nil, "http://localhost:3000/confirm")
UserMailer.deliveries.length.should == 1
@user.errors.any?.should be_false
# exactly the same parameters; should dup on email, and send no email
@user = @user_manager.signup("bob", "smith", "bob@jamkazam.com", "foobar", "foobar", "Austin", "TX", "USA", nil, "http://localhost:3000/confirm")
@user = @user_manager.signup("bob", "smith", "bob@jamkazam.com", "foobar", "foobar", "Austin", "TX", "USA", nil, nil, "http://localhost:3000/confirm")
UserMailer.deliveries.length.should == 1
@user.errors.any?.should be_true
@user.errors[:email][0].should == "has already been taken"
end
it "fail on no username" do
@user = @user_manager.signup("", "", "bob@jamkazam.com", "foobar", "foobar", "Austin", "TX", "USA", nil, "http://localhost:3000/confirm")
@user = @user_manager.signup("", "", "bob@jamkazam.com", "foobar", "foobar", "Austin", "TX", "USA", nil, nil, "http://localhost:3000/confirm")
UserMailer.deliveries.length.should == 0
@user.errors.any?.should be_true
@user.errors[:first_name][0].should == "can't be blank"
end
it "fail on no email" do
@user = @user_manager.signup("murp", "blurp", "", "foobar", "foobar", "Austin", "TX", "USA", nil, "http://localhost:3000/confirm" )
@user = @user_manager.signup("murp", "blurp", "", "foobar", "foobar", "Austin", "TX", "USA", nil, nil, "http://localhost:3000/confirm" )
UserMailer.deliveries.length.should == 0
@user.errors.any?.should be_true
@user.errors[:email][0].should == "can't be blank"
@ -67,7 +67,7 @@ describe UserManager do
describe "signup_confirm" do
it "fail on no username" do
@user = @user_manager.signup("bob", "smith", "bob@jamkazam.com", "foobar", "foobar", "Austin", "TX", "USA", nil, "http://localhost:3000/confirm" )
@user = @user_manager.signup("bob", "smith", "bob@jamkazam.com", "foobar", "foobar", "Austin", "TX", "USA", nil, nil, "http://localhost:3000/confirm" )
@user = @user_manager.signup_confirm(@user.signup_token)
@user.email_confirmed.should be_true
end

View File

@ -19,27 +19,31 @@ describe "Band API", :type => :api do
end
################################## BANDS ##################################
def create_band(authenticated_user, name, website, biography, city, state, country, genres)
def create_band(authenticated_user, name, website, biography, city, state, country, genres, photo_url, logo_url)
post "/api/bands.json", { :name => name,
:website => website,
:biography => biography,
:city => city,
:state => state,
:country => country,
:genres => genres
:genres => genres,
:photo_url => photo_url,
:logo_url => logo_url
}.to_json,
"CONTENT_TYPE" => 'application/json'
return last_response
end
def update_band(authenticated_user, band_id, name, website, biography, city, state, country, genres)
def update_band(authenticated_user, band_id, name, website, biography, city, state, country, genres, photo_url, logo_url)
post "/api/bands/#{band_id}.json", { :name => name,
:website => website,
:biography => biography,
:city => city,
:state => state,
:country => country,
:genres => genres
:genres => genres,
:photo_url => photo_url,
:logo_url => logo_url
}.to_json,
"CONTENT_TYPE" => 'application/json'
return last_response
@ -96,7 +100,7 @@ describe "Band API", :type => :api do
it "should allow band creation" do
last_response = create_band(user, "My Band", "http://www.myband.com", "Bio", "Apex", "NC", "USA", ["african", "hip hop", "country"])
last_response = create_band(user, "My Band", "http://www.myband.com", "Bio", "Apex", "NC", "USA", ["african", "hip hop", "country"], "www.photos.com", "www.logos.com")
last_response.status.should == 201
new_band = JSON.parse(last_response.body)
@ -113,14 +117,14 @@ describe "Band API", :type => :api do
end
it "should prevent bands with less than 1 genre" do
last_response = create_band(user, "My Band", "http://www.myband.com", "Bio", "Apex", "NC", "USA", nil)
last_response = create_band(user, "My Band", "http://www.myband.com", "Bio", "Apex", "NC", "USA", nil, "www.photos.com", "www.logos.com")
last_response.status.should == 400
error_msg = JSON.parse(last_response.body)
error_msg["message"].should == ValidationMessages::GENRE_MINIMUM_NOT_MET
end
it "should prevent bands with more than 3 genres" do
last_response = create_band(user, "My Band", "http://www.myband.com", "Bio", "Apex", "NC", "USA", ["african", "hip hop", "country", "reggae"])
last_response = create_band(user, "My Band", "http://www.myband.com", "Bio", "Apex", "NC", "USA", ["african", "hip hop", "country", "reggae"], "www.photos.com", "www.logos.com")
last_response.status.should == 400
error_msg = JSON.parse(last_response.body)
error_msg["message"].should == ValidationMessages::GENRE_LIMIT_EXCEEDED
@ -141,7 +145,7 @@ describe "Band API", :type => :api do
band.genres.size.should == 3
last_response = update_band(user, band.id, "Brian's Band", "http://www.briansband.com", "Bio", "Apex", "NC", "USA", ["african", "blues"])
last_response = update_band(user, band.id, "Brian's Band", "http://www.briansband.com", "Bio", "Apex", "NC", "USA", ["african", "blues"], "www.photos.com", "www.logos.com")
last_response.status.should == 200
updated_band = JSON.parse(last_response.body)

View File

@ -29,8 +29,8 @@ describe "Search API", :type => :api do
User.create_search_index
@musician = FactoryGirl.create(:user, first_name: "Peach", last_name: "Nothing", email: "user@example.com", musician: true)
@fan = FactoryGirl.create(:user, first_name: "Peach Peach", last_name: "Grovery", email: "fan@example.com", musician: false)
@band = Band.save(nil, "Peach pit", "www.bands.com", "zomg we rock", "Apex", "NC", "USA", ["hip hop"], user.id)
@band2 = Band.save(nil, "Peach", "www.bands2.com", "zomg we rock", "Apex", "NC", "USA", ["hip hop"], user.id)
@band = Band.save(nil, "Peach pit", "www.bands.com", "zomg we rock", "Apex", "NC", "USA", ["hip hop"], user.id, nil, nil)
@band2 = Band.save(nil, "Peach", "www.bands2.com", "zomg we rock", "Apex", "NC", "USA", ["hip hop"], user.id, nil, nil)
User.search_index.refresh
Band.search_index.refresh