merge
This commit is contained in:
commit
4a0db8e97a
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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 %>
|
||||
|
|
|
|||
|
|
@ -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 %>
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
FactoryGirl.define do
|
||||
factory :user, :class => "JamRuby::User" do
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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", "last", "", "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"
|
||||
|
|
@ -78,7 +72,7 @@ describe UserManager do
|
|||
@user.email_confirmed.should be_true
|
||||
end
|
||||
|
||||
it "fail to confirm bogus signup token" do
|
||||
it "fail to confirm bogus signup_confirmnup token" do
|
||||
@user_manager.signup_confirm("murp").should be_nil
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ describe "User pages" do
|
|||
|
||||
before do
|
||||
sign_in FactoryGirl.create(:user)
|
||||
|
||||
FactoryGirl.create(:user, first_name: "Bob", last_name: "Smith", email: "bob@example.com")
|
||||
FactoryGirl.create(:user, first_name: "Ben", last_name: "Smith", email: "ben@example.com")
|
||||
visit users_path
|
||||
|
|
@ -114,6 +115,7 @@ describe "User pages" 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"
|
||||
fill_in "State", with: "TX"
|
||||
|
|
@ -152,8 +154,8 @@ describe "User pages" do
|
|||
|
||||
|
||||
describe "with valid information" do
|
||||
let(:new_first_name) { "New First Name" }
|
||||
let(:new_last_name) { "New Last Name" }
|
||||
let(:new_first_name) { "New" }
|
||||
let(:new_last_name) { "Name" }
|
||||
let(:new_email) { "new@example.com" }
|
||||
before do
|
||||
fill_in "First Name", with: new_first_name
|
||||
|
|
|
|||
Loading…
Reference in New Issue