diff --git a/admin/app/controllers/application_controller.rb b/admin/app/controllers/application_controller.rb index 15e327c98..d3e00deb6 100644 --- a/admin/app/controllers/application_controller.rb +++ b/admin/app/controllers/application_controller.rb @@ -1,4 +1,6 @@ class ApplicationController < ActionController::Base + include ApplicationHelper + protect_from_forgery before_filter :prepare_gon diff --git a/admin/app/helpers/application_helper.rb b/admin/app/helpers/application_helper.rb index 6e9385e59..80731359d 100644 --- a/admin/app/helpers/application_helper.rb +++ b/admin/app/helpers/application_helper.rb @@ -1,4 +1,5 @@ module ApplicationHelper + end diff --git a/ruby/lib/jam_ruby/models/teacher_payment.rb b/ruby/lib/jam_ruby/models/teacher_payment.rb index 8c879fadf..3ee7ee162 100644 --- a/ruby/lib/jam_ruby/models/teacher_payment.rb +++ b/ruby/lib/jam_ruby/models/teacher_payment.rb @@ -6,7 +6,7 @@ module JamRuby has_one :teacher_distribution, class_name: "JamRuby::TeacherDistribution" - def self.daily_check + def self.hourly_check teacher_payments end @@ -48,7 +48,7 @@ module JamRuby teacher_payment_charge.last_billed_at_date end def charge_retry_hours - 22 # thi is only run once a day, so we make sure that slightly differences in trigger time don't cause a skip for a day + 24 end def calculate_teacher_fee diff --git a/ruby/lib/jam_ruby/models/user.rb b/ruby/lib/jam_ruby/models/user.rb index 8e8b929e9..bfd92fdae 100644 --- a/ruby/lib/jam_ruby/models/user.rb +++ b/ruby/lib/jam_ruby/models/user.rb @@ -1126,7 +1126,7 @@ module JamRuby elsif user.is_a_teacher school = School.find_by_id(school_id) school_name = school ? school.name : 'a music school' - user.teacher = Teacher.build_teacher(user, validate_introduction: true, biography: "Teaches for #{school.name}", school_id: school_id) + user.teacher = Teacher.build_teacher(user, validate_introduction: true, biography: "Teaches for #{school_name}", school_id: school_id) end end # FIXME: Setting random password for social network logins. This diff --git a/ruby/lib/jam_ruby/resque/scheduled/daily_job.rb b/ruby/lib/jam_ruby/resque/scheduled/daily_job.rb index 623ea5378..8dd28d3b6 100644 --- a/ruby/lib/jam_ruby/resque/scheduled/daily_job.rb +++ b/ruby/lib/jam_ruby/resque/scheduled/daily_job.rb @@ -8,8 +8,6 @@ module JamRuby def self.perform @@log.debug("waking up") - TeacherPayment.daily_check - bounced_emails calendar_manager = CalendarManager.new diff --git a/ruby/lib/jam_ruby/resque/scheduled/hourly_job.rb b/ruby/lib/jam_ruby/resque/scheduled/hourly_job.rb index 726dc415f..d9097d3c6 100644 --- a/ruby/lib/jam_ruby/resque/scheduled/hourly_job.rb +++ b/ruby/lib/jam_ruby/resque/scheduled/hourly_job.rb @@ -10,6 +10,7 @@ module JamRuby LessonBooking.hourly_check LessonSession.hourly_check + TeacherPayment.hourly_check @@log.debug("done") end diff --git a/ruby/spec/jam_ruby/connection_manager_spec.rb b/ruby/spec/jam_ruby/connection_manager_spec.rb index ae6d7feab..b16efb2d0 100644 --- a/ruby/spec/jam_ruby/connection_manager_spec.rb +++ b/ruby/spec/jam_ruby/connection_manager_spec.rb @@ -568,11 +568,5 @@ describe ConnectionManager, no_transaction: true do # connection = @connman.join_music_session(user, client_id, music_session, true, TRACKS) # connection.errors.size.should == 0 end - - # should be deleted - it "testfunc" do - @connman.testfunc.should eql 1 - end - end diff --git a/ruby/spec/jam_ruby/flows/normal_lesson_spec.rb b/ruby/spec/jam_ruby/flows/normal_lesson_spec.rb index 6467f9f4c..24b85c2ad 100644 --- a/ruby/spec/jam_ruby/flows/normal_lesson_spec.rb +++ b/ruby/spec/jam_ruby/flows/normal_lesson_spec.rb @@ -71,9 +71,9 @@ describe "Normal Lesson Flow" do lesson_session.music_session.scheduled_start.should eql booking.default_slot.scheduled_time(0) booking.status.should eql LessonBooking::STATUS_APPROVED - UserMailer.deliveries.length.should eql 2 + UserMailer.deliveries.length.should eql 4 chat = ChatMessage.unscoped.order(:created_at).last - chat.message.should eql 'Yeah I got this' + chat.message.should eql "Lesson Approved: 'Yeah I got this'" chat.channel.should eql ChatMessage::CHANNEL_LESSON chat.user.should eql teacher_user chat.target_user.should eql user @@ -82,8 +82,6 @@ describe "Normal Lesson Flow" do notification.student_directed.should eql true notification.purpose.should eql 'accept' notification.description.should eql NotificationTypes::LESSON_MESSAGE - notification.message.should eql "Your lesson request is confirmed!" - # teacher & student get into session start = lesson_session.scheduled_start @@ -316,7 +314,6 @@ describe "Normal Lesson Flow" do notification.student_directed.should eql true notification.purpose.should eql 'counter' notification.description.should eql NotificationTypes::LESSON_MESSAGE - notification.message.should eql "Instructor has proposed a different time for your lesson." ######### Student counters with new slot student_countered_slot = FactoryGirl.build(:lesson_booking_slot_single, hour: 16) @@ -340,7 +337,6 @@ describe "Normal Lesson Flow" do notification.student_directed.should eql false notification.purpose.should eql 'counter' notification.description.should eql NotificationTypes::LESSON_MESSAGE - notification.message.should eql "Student has proposed a different time for your lesson." ######## Teacher accepts slot UserMailer.deliveries.clear @@ -355,9 +351,9 @@ describe "Normal Lesson Flow" do lesson_session.music_session.scheduled_start.should eql booking.default_slot.scheduled_time(0) booking.status.should eql LessonBooking::STATUS_APPROVED - UserMailer.deliveries.length.should eql 2 + UserMailer.deliveries.length.should eql 4 chat = ChatMessage.unscoped.order(:created_at).last - chat.message.should eql 'Yeah I got this' + chat.message.should eql "Lesson Approved: 'Yeah I got this'" chat.channel.should eql ChatMessage::CHANNEL_LESSON chat.user.should eql teacher_user chat.target_user.should eql user @@ -366,8 +362,6 @@ describe "Normal Lesson Flow" do notification.student_directed.should eql true notification.purpose.should eql 'accept' notification.description.should eql NotificationTypes::LESSON_MESSAGE - notification.message.should eql "Your lesson request is confirmed!" - # teacher & student get into session start = lesson_session.scheduled_start diff --git a/ruby/spec/jam_ruby/flows/recurring_lesson_spec.rb b/ruby/spec/jam_ruby/flows/recurring_lesson_spec.rb index 511ac542b..3946eecdc 100644 --- a/ruby/spec/jam_ruby/flows/recurring_lesson_spec.rb +++ b/ruby/spec/jam_ruby/flows/recurring_lesson_spec.rb @@ -52,7 +52,7 @@ describe "Recurring Lesson Flow" do booking.status.should eql LessonBooking::STATUS_REQUESTED ######### Teacher counters with new slot - teacher_countered_slot = FactoryGirl.build(:lesson_booking_slot_single, hour: 14) + teacher_countered_slot = FactoryGirl.build(:lesson_booking_slot_single, hour: 14, update_all: true) UserMailer.deliveries.clear lesson_session.counter({proposer: teacher_user, slot: teacher_countered_slot, message: 'Does this work?'}) booking.reload @@ -75,10 +75,10 @@ describe "Recurring Lesson Flow" do notification.student_directed.should eql true notification.purpose.should eql 'counter' notification.description.should eql NotificationTypes::LESSON_MESSAGE - notification.message.should eql "Instructor has proposed a different time for your lesson." + #notification.message.should eql "Instructor has proposed a different time for your lesson." ######### Student counters with new slot - student_countered_slot = FactoryGirl.build(:lesson_booking_slot_single, hour: 16) + student_countered_slot = FactoryGirl.build(:lesson_booking_slot_single, hour: 16, update_all: true) UserMailer.deliveries.clear lesson_session.counter({proposer: user, slot: student_countered_slot, message: 'Does this work better?'}) lesson_session.errors.any?.should be false @@ -99,7 +99,6 @@ describe "Recurring Lesson Flow" do notification.student_directed.should eql false notification.purpose.should eql 'counter' notification.description.should eql NotificationTypes::LESSON_MESSAGE - notification.message.should eql "Student has proposed a different time for your lesson." ######## Teacher accepts slot UserMailer.deliveries.clear @@ -108,7 +107,7 @@ describe "Recurring Lesson Flow" do # puts del.inspect end # get acceptance emails, as well as 'your stuff is accepted' - UserMailer.deliveries.length.should eql 4 + UserMailer.deliveries.length.should eql 6 lesson_session.errors.any?.should be_false lesson_session.reload lesson_session.slot.should eql student_counter @@ -118,9 +117,9 @@ describe "Recurring Lesson Flow" do lesson_session.music_session.scheduled_start.should eql booking.default_slot.scheduled_time(0) booking.status.should eql LessonBooking::STATUS_APPROVED - UserMailer.deliveries.length.should eql 4 + UserMailer.deliveries.length.should eql 6 chat = ChatMessage.unscoped.order(:created_at).last - chat.message.should eql 'Yeah I got this' + chat.message.should eql "Lesson Approved: 'Yeah I got this'" chat.channel.should eql ChatMessage::CHANNEL_LESSON chat.user.should eql teacher_user chat.target_user.should eql user @@ -129,7 +128,6 @@ describe "Recurring Lesson Flow" do notification.student_directed.should eql true notification.purpose.should eql 'accept' notification.description.should eql NotificationTypes::LESSON_MESSAGE - notification.message.should eql "Your lesson request is confirmed!" # teacher & student get into session diff --git a/ruby/spec/jam_ruby/flows/testdrive_lesson_spec.rb b/ruby/spec/jam_ruby/flows/testdrive_lesson_spec.rb index 8ffd452b7..e9545cfbe 100644 --- a/ruby/spec/jam_ruby/flows/testdrive_lesson_spec.rb +++ b/ruby/spec/jam_ruby/flows/testdrive_lesson_spec.rb @@ -97,7 +97,6 @@ describe "TestDrive Lesson Flow" do notification.student_directed.should eql true notification.purpose.should eql 'counter' notification.description.should eql NotificationTypes::LESSON_MESSAGE - notification.message.should eql "Instructor has proposed a different time for your lesson." ######### Student counters with new slot student_countered_slot = FactoryGirl.build(:lesson_booking_slot_single, hour: 16) @@ -121,7 +120,6 @@ describe "TestDrive Lesson Flow" do notification.student_directed.should eql false notification.purpose.should eql 'counter' notification.description.should eql NotificationTypes::LESSON_MESSAGE - notification.message.should eql "Student has proposed a different time for your lesson." ######## Teacher accepts slot UserMailer.deliveries.clear @@ -136,7 +134,7 @@ describe "TestDrive Lesson Flow" do lesson_session.music_session.scheduled_start.should eql booking.default_slot.scheduled_time(0) booking.status.should eql LessonBooking::STATUS_APPROVED - UserMailer.deliveries.length.should eql 2 + UserMailer.deliveries.length.should eql 4 chat = ChatMessage.unscoped.order(:created_at).last chat.message.should eql 'Yeah I got this' chat.channel.should eql ChatMessage::CHANNEL_LESSON diff --git a/ruby/spec/jam_ruby/models/teacher_spec.rb b/ruby/spec/jam_ruby/models/teacher_spec.rb index 62fdee73e..3b0c305d0 100644 --- a/ruby/spec/jam_ruby/models/teacher_spec.rb +++ b/ruby/spec/jam_ruby/models/teacher_spec.rb @@ -14,14 +14,14 @@ describe Teacher do describe "index" do it "no params" do - teacher = FactoryGirl.create(:teacher) + teacher = FactoryGirl.create(:teacher, ready_for_session_at: Time.now) teachers = Teacher.index(nil)[:query] teachers.length.should eq 1 teachers[0].should eq(teacher.user) end it "instruments" do - teacher = FactoryGirl.create(:teacher) + teacher = FactoryGirl.create(:teacher, ready_for_session_at: Time.now) teachers = Teacher.index(nil, {instruments: ['acoustic guitar']})[:query] teachers.length.should eq 0 @@ -39,7 +39,7 @@ describe Teacher do end it "subjects" do - teacher = FactoryGirl.create(:teacher) + teacher = FactoryGirl.create(:teacher, ready_for_session_at: Time.now) teachers = Teacher.index(nil, {subjects: ['music-theory']})[:query] teachers.length.should eq 0 @@ -51,7 +51,7 @@ describe Teacher do end it "genres" do - teacher = FactoryGirl.create(:teacher) + teacher = FactoryGirl.create(:teacher, ready_for_session_at: Time.now) teachers = Teacher.index(nil, {genres: ['ambient']})[:query] teachers.length.should eq 0 @@ -64,7 +64,7 @@ describe Teacher do it "languages" do - teacher = FactoryGirl.create(:teacher) + teacher = FactoryGirl.create(:teacher, ready_for_session_at: Time.now) teachers = Teacher.index(nil, {languages: ['EN']})[:query] teachers.length.should eq 0 @@ -76,7 +76,7 @@ describe Teacher do end it "country" do - teacher = FactoryGirl.create(:teacher) + teacher = FactoryGirl.create(:teacher, ready_for_session_at: Time.now) teachers = Teacher.index(nil, {country: 'DO'})[:query] teachers.length.should eq 0 @@ -88,7 +88,7 @@ describe Teacher do end it "region" do - teacher = FactoryGirl.create(:teacher) + teacher = FactoryGirl.create(:teacher, ready_for_session_at: Time.now) teachers = Teacher.index(nil, {region: 'HE'})[:query] teachers.length.should eq 0 @@ -100,7 +100,7 @@ describe Teacher do end it "years_teaching" do - teacher = FactoryGirl.create(:teacher, years_teaching: 5) + teacher = FactoryGirl.create(:teacher, ready_for_session_at: Time.now, years_teaching: 5) teachers = Teacher.index(nil, {years_teaching: 10})[:query] teachers.length.should eq 0 @@ -110,7 +110,7 @@ describe Teacher do end it "teaches beginner/intermediate/advanced" do - teacher = FactoryGirl.create(:teacher) + teacher = FactoryGirl.create(:teacher, ready_for_session_at: Time.now) teachers = Teacher.index(nil, {teaches_beginner: true})[:query] teachers.length.should eq 0 @@ -133,7 +133,7 @@ describe Teacher do end it "student_age" do - teacher = FactoryGirl.create(:teacher) + teacher = FactoryGirl.create(:teacher, ready_for_session_at: Time.now) teachers = Teacher.index(nil, {student_age: 5})[:query] teachers.length.should eq 1 diff --git a/web/app/assets/javascripts/jam_rest.js b/web/app/assets/javascripts/jam_rest.js index 2e380a886..c9ae84cd4 100644 --- a/web/app/assets/javascripts/jam_rest.js +++ b/web/app/assets/javascripts/jam_rest.js @@ -2218,9 +2218,10 @@ } function getLessonSessions(options) { + options = options || {} return $.ajax({ type: "GET", - url: "/api/lesson_sessions?" + $.param(query), + url: "/api/lesson_sessions?" + $.param(options), dataType: "json", contentType: 'application/json' }); diff --git a/web/app/assets/javascripts/react-components/landing/SchoolStudentLandingPage.js.jsx.coffee b/web/app/assets/javascripts/react-components/landing/SchoolStudentLandingPage.js.jsx.coffee index dae523676..dadf5ceee 100644 --- a/web/app/assets/javascripts/react-components/landing/SchoolStudentLandingPage.js.jsx.coffee +++ b/web/app/assets/javascripts/react-components/landing/SchoolStudentLandingPage.js.jsx.coffee @@ -106,7 +106,8 @@ rest = context.JK.Rest() loggedIn = context.JK.currentUserId? if loggedIn - window.location.href = "/client#/jamclass" + #window.location.href = "/client#/jamclass" + window.location.href = "/client#/profile/#{context.JK.currentUserId}" else @createUser() @@ -130,7 +131,8 @@ rest = context.JK.Rest() }) .done((response) => @setState({done: true}) - window.location.href = "/client#/jamclass" + #window.location.href = "/client#/jamclass" + window.location.href = "/client#/profile/#{response.id}" ).fail((jqXHR) => @setState({processing: false}) if jqXHR.status == 422 diff --git a/web/app/assets/javascripts/react-components/landing/SchoolTeacherLandingPage.js.jsx.coffee b/web/app/assets/javascripts/react-components/landing/SchoolTeacherLandingPage.js.jsx.coffee index 635dc67a4..7f6292fad 100644 --- a/web/app/assets/javascripts/react-components/landing/SchoolTeacherLandingPage.js.jsx.coffee +++ b/web/app/assets/javascripts/react-components/landing/SchoolTeacherLandingPage.js.jsx.coffee @@ -106,7 +106,8 @@ rest = context.JK.Rest() loggedIn = context.JK.currentUserId? if loggedIn - window.location.href = "/client#/jamclass" + #window.location.href = "/client#/jamclass" + window.location.href = "/client#/profile/#{context.JK.currentUserId}" else @createUser() @@ -130,7 +131,8 @@ rest = context.JK.Rest() }) .done((response) => @setState({done: true}) - window.location.href = "/client#/jamclass" + #window.location.href = "/client#/jamclass" + window.location.href = "/client#/profile/#{response.id}" ).fail((jqXHR) => @setState({processing: false}) if jqXHR.status == 422 diff --git a/web/app/controllers/clients_controller.rb b/web/app/controllers/clients_controller.rb index 90c6ec1a3..2078bd5a8 100644 --- a/web/app/controllers/clients_controller.rb +++ b/web/app/controllers/clients_controller.rb @@ -9,7 +9,7 @@ class ClientsController < ApplicationController def index - @olark_enabled = true + enable_olark gon.olark_box_start_hidden = true # we want to enforce that /client is always the client view prefix diff --git a/web/app/controllers/landings_controller.rb b/web/app/controllers/landings_controller.rb index 0890c3a6c..1896acce9 100644 --- a/web/app/controllers/landings_controller.rb +++ b/web/app/controllers/landings_controller.rb @@ -69,7 +69,7 @@ class LandingsController < ApplicationController end def jam_class_students - @olark_enabled = true + enable_olark @no_landing_tag = true @landing_tag_play_learn_earn = true @show_after_black_bar_border = true @@ -81,7 +81,7 @@ class LandingsController < ApplicationController end def jam_class_students_free - @olark_enabled = true + enable_olark @no_landing_tag = true @landing_tag_play_learn_earn = true @show_after_black_bar_border = true @@ -93,7 +93,7 @@ class LandingsController < ApplicationController end def jam_class_teachers - @olark_enabled = true + enable_olark @no_landing_tag = true @landing_tag_play_learn_earn = true @show_after_black_bar_border = true @@ -101,7 +101,7 @@ class LandingsController < ApplicationController end def jam_class_affiliates - @olark_enabled = true + enable_olark @no_landing_tag = true @landing_tag_play_learn_earn = true @show_after_black_bar_border = true @@ -111,7 +111,7 @@ class LandingsController < ApplicationController def individual_jamtrack - @olark_enabled = true + enable_olark @no_landing_tag = true @landing_tag_play_learn_earn = true @show_after_black_bar_border = true @@ -147,7 +147,7 @@ class LandingsController < ApplicationController def individual_jamtrack_band - @olark_enabled = true + enable_olark @no_landing_tag = true @landing_tag_play_learn_earn = true @show_after_black_bar_border = true @@ -228,12 +228,12 @@ class LandingsController < ApplicationController end def product_jamblaster - @olark_enabled = true + enable_olark render 'product_jamblaster', layout: 'web' end def product_platform - @olark_enabled = true + enable_olark @no_landing_tag = true @landing_tag_play_learn_earn = true @show_after_black_bar_border = true @@ -241,7 +241,7 @@ class LandingsController < ApplicationController end def product_jamtracks - @olark_enabled = true + enable_olark gon.generic = true gon.just_previews = true jam_track = JamTrack.select('plan_code').where(plan_code: Rails.application.config.nominated_jam_track).first diff --git a/web/app/controllers/popups_controller.rb b/web/app/controllers/popups_controller.rb index 5ec169d8c..8f21de6b5 100644 --- a/web/app/controllers/popups_controller.rb +++ b/web/app/controllers/popups_controller.rb @@ -30,7 +30,7 @@ class PopupsController < ApplicationController end def jamtrack_player - @olark_enabled = true + enable_olark @jamtrack_id = params[:jam_track_id] @websocket = true gon.jamtrack_id = @jamtrack_id diff --git a/web/app/helpers/application_helper.rb b/web/app/helpers/application_helper.rb index 160a1b3cf..24003e5b8 100644 --- a/web/app/helpers/application_helper.rb +++ b/web/app/helpers/application_helper.rb @@ -1,5 +1,10 @@ module ApplicationHelper + + def enable_olark + @olark_enabled = true if Rails.application.config.olark_enabled + end + # Returns the full title on a per-page basis. def full_title(page_title) base_title = "JamKazam" diff --git a/web/config/application.rb b/web/config/application.rb index 77f4b70cb..7ea572ec1 100644 --- a/web/config/application.rb +++ b/web/config/application.rb @@ -435,7 +435,7 @@ if defined?(Bundler) config.lesson_join_time_window_minutes = 5 config.lesson_wait_time_window_minutes = 10 config.end_of_wait_window_forgiveness_minutes = 1 - + config.olark_enabled = true end end diff --git a/web/config/environments/test.rb b/web/config/environments/test.rb index c6d7e3d00..e0ad3315c 100644 --- a/web/config/environments/test.rb +++ b/web/config/environments/test.rb @@ -15,9 +15,9 @@ SampleApp::Application.configure do config.whiny_nils = true # useful when debugging a javascript problem... - # config.assets.compress = false + config.assets.compress = false - config.assets.compress = true # Compress precompiled assets + #config.assets.compress = true # Compress precompiled assets config.assets.compile = true # Refuse to compile assets on-the-fly config.assets.digest = true #config.assets.debug = true @@ -109,7 +109,7 @@ SampleApp::Application.configure do config.video_available = "full" config.guard_against_fraud = true config.error_on_fraud = false - + config.olark_enabled = false config.stripe = { :publishable_key => 'pk_test_HLTvioRAxN3hr5fNfrztZeoX', :secret_key => 'sk_test_OkjoIF7FmdjunyNsdVqJD02D', diff --git a/web/lib/user_manager.rb b/web/lib/user_manager.rb index d1b60cf3d..f95409d95 100644 --- a/web/lib/user_manager.rb +++ b/web/lib/user_manager.rb @@ -81,7 +81,8 @@ class UserManager < BaseManager gift_card: gift_card, student: student, teacher: teacher, - school_invitation_code: school_invitation_code) + school_invitation_code: school_invitation_code, + school_id: school_id) user end diff --git a/web/spec/features/account_school_spec.rb b/web/spec/features/account_school_spec.rb new file mode 100644 index 000000000..60eb64488 --- /dev/null +++ b/web/spec/features/account_school_spec.rb @@ -0,0 +1,46 @@ +require 'spec_helper' + +describe "Account School", :js => true, :type => :feature, :capybara_feature => true do + + subject { page } + + let(:user) {FactoryGirl.create(:user)} + let(:school) {FactoryGirl.create(:school) } + let(:school_owner) {school.owner} + + before(:each) do + SchoolInvitation.delete_all + School.delete_all + UserMailer.deliveries.clear + emulate_client + end + + describe "account school" do + it "allows invitation" do + + sign_in_poltergeist school_owner + visit "/client#/account" + + find('#account-school-link').trigger(:click) + + find('h4', text: 'Management Preference') + + find('.profile-nav a', text: 'members' ).trigger(:click) + + find('a.invite-dialog', text: 'INVITE TEACHER').trigger(:click) + + find('h1', text: 'invite teacher') + fill_in "first_name", with: "Seth" + fill_in "last_name", with: "Call" + fill_in "email", with: "seth+invited_teacher@jamkazam.com" + find('#invite-school-user-dialog .actions a', text: 'SEND INVITATION').trigger(:click) + + find('#banner .dialog-inner', text: 'Your invitation has been sent!') + SchoolInvitation.count.should eql 1 + school_invitation = SchoolInvitation.first + school_invitation.email.should eql "seth+invited_teacher@jamkazam.com" + + find('.teacher-invites td.description', "#{school_invitation.first_name} #{school_invitation.last_name}") + end + end +end diff --git a/web/spec/features/school_student_register_spec.rb b/web/spec/features/school_student_register_spec.rb new file mode 100644 index 000000000..4857e5c36 --- /dev/null +++ b/web/spec/features/school_student_register_spec.rb @@ -0,0 +1,108 @@ +require 'spec_helper' + +describe "Student Landing", :js => true, :type => :feature, :capybara_feature => true do + + subject { page } + + before(:all) do + ShoppingCart.delete_all + JamTrackRight.delete_all + JamTrack.delete_all + JamTrackTrack.delete_all + JamTrackLicensor.delete_all + SchoolInvitation.delete_all + School.delete_all + end + + + let(:user) { FactoryGirl.create(:user, country: 'US') } + let(:school) {FactoryGirl.create(:school, name: 'Hot Dog')} + + + it "logged out and no invitation" do + + visit "/school/#{school.id}/student" + + find('.header-content h1', 'REGISTER AS STUDENT') + find('.header-content h2', "with #{school.name}") + + find('button.cta-button', text: 'SIGN UP').trigger(:click) + + # should fail because we haven't filled out email/password/terms + find('.register-area .errors', text: "Email can't be blank") + + fill_in "email", with: 'school_student_123@jamkazam.com' + fill_in "password", with: 'jam123' + find('.register-area ins', visible: false).trigger(:click) + find('button.cta-button', text: 'SIGN UP').trigger(:click) + + #find('h2', text: 'my lessons') + find('#type-label', text: 'musician') + + + student = User.find_by_email('school_student_123@jamkazam.com') + student.is_a_student.should be true + student.is_a_teacher.should be false + student.musician.should be true + student.teacher.should be_nil + student.school.should eql school + + find('#user-profile #username', text: student.name) + end + + it "logged out and has invitation" do + + school_invitation = FactoryGirl.create(:school_invitation, school: school, accepted: false, as_teacher: false) + + visit "/school/#{school.id}/student?invitation_code=#{school_invitation.invitation_code}" + + find('.header-content h1', 'REGISTER AS STUDENT') + find('.header-content h2', "with #{school.name}") + + find('button.cta-button', text: 'SIGN UP').trigger(:click) + + # should fail because we haven't filled out email/password/terms + find('.register-area .errors', text: "Password is too short (minimum is 6 characters)") + + #fill_in "email", with: 'school_student_124@jamkazam.com' + fill_in "password", with: 'jam123' + find('.register-area ins', visible: false).trigger(:click) + find('button.cta-button', text: 'SIGN UP').trigger(:click) + + #find('h2', text: 'my lessons') + find('#type-label', text: 'musician') + + student = User.find_by_email(school_invitation.email) + student.is_a_student.should be true + student.is_a_teacher.should be false + student.musician.should be true + student.teacher.should be_nil + student.school.should eql school + + school_invitation.reload + school_invitation.accepted.should be_true + find('#user-profile #username', text: student.name) + end + + + it "logged in" do + school.touch + fast_signin(user,"/school/#{school.id}/student") + + find('.header-content h1', 'REGISTER AS STUDENT') + find('.header-content h2', "with #{school.name}") + + find('button.cta-button', text: 'GO TO JAMKAZAM').trigger(:click) + + # this should show on the /client#/home page (WILL CHANGE) + #find('h2', text: 'my lessons') + find('#type-label', text: 'musician') + find('#user-profile #username', text: user.name) + + user.reload + #user.is_a_student.should be true + #user.is_a_teacher.should be false + #user.musician.should be true + end + +end diff --git a/web/spec/features/school_teacher_register_spec.rb b/web/spec/features/school_teacher_register_spec.rb new file mode 100644 index 000000000..70df2bfe8 --- /dev/null +++ b/web/spec/features/school_teacher_register_spec.rb @@ -0,0 +1,109 @@ +require 'spec_helper' + +describe "Teacher Landing", :js => true, :type => :feature, :capybara_feature => true do + + subject { page } + + before(:all) do + ShoppingCart.delete_all + JamTrackRight.delete_all + JamTrack.delete_all + JamTrackTrack.delete_all + JamTrackLicensor.delete_all + SchoolInvitation.delete_all + School.delete_all + end + + + let(:user) { FactoryGirl.create(:user, country: 'US') } + let(:school) {FactoryGirl.create(:school, name: 'Hot Dog')} + + it "logged out and no invitation" do + + visit "/school/#{school.id}/teacher" + + find('.header-content h1', 'REGISTER AS TEACHER') + find('.header-content h2', "with #{school.name}") + + find('button.cta-button', text: 'SIGN UP').trigger(:click) + + # should fail because we haven't filled out email/password/terms + find('.register-area .errors', text: "Email can't be blank") + + fill_in "email", with: 'school_teacher_123@jamkazam.com' + fill_in "password", with: 'jam123' + find('.register-area ins', visible: false).trigger(:click) + find('button.cta-button', text: 'SIGN UP').trigger(:click) + + #find('h2', text: 'my lessons') + find('#type-label', text: 'musician') + + + teacher = User.find_by_email('school_teacher_123@jamkazam.com') + teacher.is_a_student.should be false + teacher.is_a_teacher.should be true + teacher.musician.should be true + teacher.teacher.should_not be_nil + teacher.school.should be_nil + teacher.teacher.school.should eql school + + find('#user-profile #username', text: teacher.name) + end + + it "logged out and has invitation" do + + school_invitation = FactoryGirl.create(:school_invitation, school: school, accepted: false, as_teacher: true) + + visit "/school/#{school.id}/teacher?invitation_code=#{school_invitation.invitation_code}" + + find('.header-content h1', 'REGISTER AS A TEACHER') + find('.header-content h2', "with #{school.name}") + + find('button.cta-button', text: 'SIGN UP').trigger(:click) + + # should fail because we haven't filled out email/password/terms + find('.register-area .errors', text: "Password is too short (minimum is 6 characters)") + + #fill_in "email", with: 'school_student_124@jamkazam.com' + fill_in "password", with: 'jam123' + find('.register-area ins', visible: false).trigger(:click) + find('button.cta-button', text: 'SIGN UP').trigger(:click) + + #find('h2', text: 'my lessons') + find('#type-label', text: 'musician') + + teacher = User.find_by_email(school_invitation.email) + teacher.is_a_student.should be false + teacher.is_a_teacher.should be true + teacher.musician.should be true + teacher.teacher.should_not be_nil + teacher.school.should be_nil + teacher.teacher.school.should eql school + + school_invitation.reload + school_invitation.accepted.should be_true + find('#user-profile #username', text: teacher.name) + end + + + it "logged in" do + school.touch + fast_signin(user,"/school/#{school.id}/teacher") + + find('.header-content h1', 'REGISTER AS A TEACHER') + find('.header-content h2', "with #{school.name}") + + find('button.cta-button', text: 'GO TO JAMKAZAM').trigger(:click) + + # this should show on the /client#/home page (WILL CHANGE) + #find('h2', text: 'my lessons') + find('#type-label', text: 'musician') + find('#user-profile #username', text: user.name) + + user.reload + #user.is_a_student.should be true + #user.is_a_teacher.should be false + #user.musician.should be true + end + +end