diff --git a/app/controllers/api_music_sessions_controller.rb b/app/controllers/api_music_sessions_controller.rb index 88ad7047e..f150784b7 100644 --- a/app/controllers/api_music_sessions_controller.rb +++ b/app/controllers/api_music_sessions_controller.rb @@ -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) diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb index a02ba9293..accea25d3 100644 --- a/app/views/users/edit.html.erb +++ b/app/views/users/edit.html.erb @@ -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 %> diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb index e57b20430..56d0e0e55 100644 --- a/app/views/users/new.html.erb +++ b/app/views/users/new.html.erb @@ -11,10 +11,10 @@
<%= 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 %> diff --git a/spec/factories.rb b/spec/factories.rb index 2a8c04b8f..89138357f 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -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 diff --git a/spec/managers/user_manager_spec.rb b/spec/managers/user_manager_spec.rb index f934f69ab..599690e8b 100644 --- a/spec/managers/user_manager_spec.rb +++ b/spec/managers/user_manager_spec.rb @@ -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 diff --git a/spec/requests/music_session_pages_spec.rb b/spec/requests/music_session_pages_spec.rb index 41448a5a8..5b7691be4 100644 --- a/spec/requests/music_session_pages_spec.rb +++ b/spec/requests/music_session_pages_spec.rb @@ -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 diff --git a/spec/requests/user_pages_spec.rb b/spec/requests/user_pages_spec.rb index 20b8cef5b..073f22066 100644 --- a/spec/requests/user_pages_spec.rb +++ b/spec/requests/user_pages_spec.rb @@ -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