* VRFS-100 completed

This commit is contained in:
Seth Call 2012-11-17 21:41:26 -06:00
parent abac3cab38
commit e27083e45c
9 changed files with 34 additions and 29 deletions

View File

@ -46,7 +46,7 @@ class ApiMusicSessionsController < ApiController
unless @music_session.errors.any?
# auto-join this user into the newly created session
connection_manager.join_music_session(current_user.id, client_id, @music_session.id)
connection_manager.join_music_session(current_user.id, client_id, @music_session.id, true)
@connection = Connection.find_by_client_id(client_id)
tracks = params[:tracks]
@ -110,7 +110,8 @@ class ApiMusicSessionsController < ApiController
ConnectionManager.active_record_transaction do |connection_manager|
@music_session = MusicSession.find(params[:id])
client_id = params[:client_id]
connection_manager.join_music_session(current_user.id, client_id, @music_session.id)
as_musician = params[:as_musician]
connection_manager.join_music_session(current_user.id, client_id, @music_session.id, as_musician)
@connection = Connection.find_by_client_id(client_id)
tracks = params[:tracks]
associate_tracks(@connection, tracks)

View File

@ -27,7 +27,8 @@ class UsersController < ApplicationController
end
@user = UserManager.new.signup(params[:jam_ruby_user][:name],
@user = UserManager.new.signup(params[:jam_ruby_user][:first_name],
params[:jam_ruby_user][:last_name],
params[:jam_ruby_user][:email],
params[:jam_ruby_user][:password],
params[:jam_ruby_user][:password_confirmation],

View File

@ -6,8 +6,11 @@
<%= form_for(@user) do |f| %>
<%= render 'shared/error_messages', object: f.object %>
<%= f.label :name %>
<%= f.text_field :name %>
<%= f.label :first_name, "First Name" %>
<%= f.text_field :first_name %>
<%= f.label :last_name, "Last Name" %>
<%= f.text_field :last_name %>
<%= f.label :email %>
<%= f.text_field :email %>

View File

@ -11,10 +11,10 @@
<div class="span6 offset3">
<%= form_for(@user) do |f| %>
<%= render 'shared/error_messages', object: f.object %>
<%= f.label :first_name %>
<%= f.label :first_name, "First Name" %>
<%= f.text_field :first_name %>
<%= f.label :last_name %>
<%= f.label :last_name, "Last Name" %>
<%= f.text_field :last_name %>
<%= f.label :email %>

View File

@ -1,10 +1,12 @@
FactoryGirl.define do
factory :user, :class => "JamRuby::User" do
sequence(:name) { |n| "Person #{n}" }
sequence(:first_name) { |n| "Person" }
sequence(:last_name) { |n| "#{n}" }
sequence(:email) { |n| "person_#{n}@example.com"}
password "foobar"
password_confirmation "foobar"
email_confirmed true
musician true
factory :admin do
admin true

View File

@ -48,12 +48,6 @@ describe UserManager do
UserMailer.deliveries.length.should == 1
@user.errors.any?.should be_true
@user.errors[:email][0].should == "has already been taken"
# change email so that name appears dupped
@user = @user_manager.signup("bob", "smith", "bobbie@jamkazam.com", "foobar", "foobar", "Austin", "TX", "USA", nil, "http://localhost:3000/confirm" )
UserMailer.deliveries.length.should == 1
@user.errors.any?.should be_true
@user.errors[:name][0].should == "has already been taken"
end
it "fail on no username" do
@ -63,8 +57,8 @@ describe UserManager do
@user.errors[:first_name][0].should == "can't be blank"
end
it "fail on no username" do
@user = @user_manager.signup("murp", "", "foobar", "foobar", "Austin", "TX", "USA", nil, "http://localhost:3000/confirm" )
it "fail on no email" do
@user = @user_manager.signup("murp", "blurp", "", "foobar", "foobar", "Austin", "TX", "USA", 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"

View File

@ -118,7 +118,7 @@ describe "Music Session API ", :type => :api do
end
it "should add a second member to the second" do
it "should add a second member to the session" do
user2 = FactoryGirl.create(:user)
client = FactoryGirl.create(:connection, :user => user, :ip_address => "1.1.1.1")
@ -143,7 +143,7 @@ describe "Music Session API ", :type => :api do
musician["client_id"].should == client.client_id
login(user2)
post "/api/sessions/#{music_session["id"]}/participants.json", { :client_id => client2.client_id, :tracks => [{"instrument_id" => "bass guitar", "sound" => "mono"}]}.to_json, "CONTENT_TYPE" => 'application/json'
post "/api/sessions/#{music_session["id"]}/participants.json", { :client_id => client2.client_id, :as_musician => true, :tracks => [{"instrument_id" => "bass guitar", "sound" => "mono"}]}.to_json, "CONTENT_TYPE" => 'application/json'
last_response.status.should eql(201)
@ -321,7 +321,7 @@ describe "Music Session API ", :type => :api do
# users are friends, but no invitation... so we shouldn't be able to join as user 2
login(user2)
post "/api/sessions/#{session["id"]}/participants.json", { :client_id => client2.client_id }.to_json
post "/api/sessions/#{session["id"]}/participants.json", { :client_id => client2.client_id, :as_musician => true }.to_json, "CONTENT_TYPE" => 'application/json'
last_response.status.should eql(500)
join_response = JSON.parse(last_response.body)
join_response["type"].should == "PermissionError"
@ -332,7 +332,7 @@ describe "Music Session API ", :type => :api do
last_response.status.should eql(201)
login(user2)
post "/api/sessions/#{session["id"]}/participants.json", { :client_id => client2.client_id }.to_json, "CONTENT_TYPE" => 'application/json'
post "/api/sessions/#{session["id"]}/participants.json", { :client_id => client2.client_id, :as_musician => true }.to_json, "CONTENT_TYPE" => 'application/json'
last_response.status.should eql(201)
end
end

View File

@ -28,8 +28,8 @@ describe "Search API ", :type => :api do
it "simple search" do
User.delete_search_index # so that the user created before the test and logged in doesn't show up
User.create_search_index
@musician = FactoryGirl.create(:user, first_name: "Peach", last_name: "Nothing", name: "peach1", email: "user@example.com", musician: true)
@fan = FactoryGirl.create(:user, first_name: "Peach Peach", last_name: "Grovery", name: "peach2", email: "fan@example.com", musician: false)
@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(name: "Peach pit", website: "www.bands.com", biography: "zomg we rock")
@band2 = Band.save(name: "Peach", website: "www.bands2.com", biography: "zomg we rock")
User.search_index.refresh

View File

@ -8,8 +8,8 @@ describe "User pages" do
before do
sign_in FactoryGirl.create(:user)
FactoryGirl.create(:user, name: "Bob", email: "bob@example.com")
FactoryGirl.create(:user, name: "Ben", email: "ben@example.com")
FactoryGirl.create(:user, first_name: "Bob", last_name: "User", email: "bob@example.com")
FactoryGirl.create(:user, first_name: "Ben", last_name: "User", email: "ben@example.com")
visit users_path
end
@ -112,6 +112,8 @@ describe "User pages" do
describe "with valid information" do
before do
fill_in "First Name", with: "Example"
fill_in "Last Name", with: "User"
fill_in "Name", with: "Example User"
fill_in "Email", with: "user@example.com"
fill_in "City", with: "Austin"
@ -151,20 +153,22 @@ describe "User pages" do
describe "with valid information" do
let(:new_name) { "New Name" }
let(:new_first_name) { "New" }
let(:new_last_name) { "Name" }
let(:new_email) { "new@example.com" }
before do
fill_in "Name", with: new_name
fill_in "First Name", with: new_first_name
fill_in "Last Name", with: new_last_name
fill_in "Email", with: new_email
fill_in "Password", with: user.password
fill_in "Confirm Password", with: user.password
click_button "Save changes"
end
it { should have_selector('title', text: new_name) }
it { should have_selector('div.alert.alert-success') }
it { should have_link('Sign out', href: signout_path) }
specify { user.reload.name.should == new_name }
specify { user.reload.first_name.should == new_first_name }
specify { user.reload.last_name.should == new_last_name }
specify { user.reload.email.should == new_email }
end
end