more work

This commit is contained in:
Mike Slemmer 2013-01-14 18:13:45 -08:00
parent 41781e8121
commit 60366d5c0e
8 changed files with 107 additions and 2 deletions

View File

@ -1,6 +1,6 @@
#ruby=1.9.3
source 'https://rubygems.org'
source 'https://jamjam:blueberryjam@www.jamkazam.com/gems/'
#source 'https://jamjam:blueberryjam@www.jamkazam.com/gems/'
# Look for $WORKSPACE, otherwise use "workspace" as dev path.
workspace = ENV["WORKSPACE"] || "~/workspace"
@ -18,6 +18,7 @@ gem 'amqp'
gem 'will_paginate'
gem 'actionmailer'
gem 'sendgrid'
gem 'aws-sdk'
if devenv
gem 'jam_db', :path=> "#{workspace}/jam-db/target/ruby_package"

13
config/aws.yml Normal file
View File

@ -0,0 +1,13 @@
# Just like the config/database.yml this file requires an entry for each environment
# # http://aws.amazon.com/security-credentials
development:
access_key_id: AKIAJEPHN6RUIUZKEQDA
secret_access_key: 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
test:
access_key_id: AKIAJEPHN6RUIUZKEQDA
secret_access_key: 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
production:
access_key_id: AKIAJEPHN6RUIUZKEQDA
secret_access_key: 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

View File

@ -49,6 +49,7 @@ require "jam_ruby/models/user_favorite"
require "jam_ruby/models/search"
require "jam_ruby/models/recording"
require "jam_ruby/models/musician_recording"
require "jam_ruby/models/saved_track"
include Jampb

View File

@ -7,8 +7,9 @@ module JamRuby
has_many :musician_instruments, :class_name => "JamRuby::MusicianInstrument"
has_many :users, :through => :musician_instruments, :class_name => "JamRuby::User"
has_many :tracks, :class_name => "JamRuby::Track", :inverse_of => :instrument
has_many :saved_tracks, :class_name => "JamRuby::SavedTrack", :inverse_of => :instrument
# music sessions
has_and_belongs_to_many :music_sessions, :class_name => "JamRuby::MusicSession", :join_table => "genres_music_sessions"
end
end
end

View File

@ -0,0 +1,50 @@
module JamRuby
class SavedTrack < ActiveRecord::Base
self.table_name = "saved_tracks"
self.primary_key = 'id'
SOUND = %w(mono stereo)
belongs_to :user, :class_name => "JamRuby::User", :inverse_of => :saved_tracks
belongs_to :instrument, :class_name => "JamRuby::Instrument"
validates :sound, :inclusion => {:in => SOUND}
# Copy an ephemeral track to create a saved one. Some fields are ok with defaults
def self.create_from_track(track)
saved_track = self.new
saved_track.user_id = track.connection.user.id
saved_track.instrument_id = track.instrument_id
saved_track.sound = track.sound
saved_track.save
saved_track
end
=begin
def self.save(id, connection_id, instrument_id, sound)
if id.nil?
track = Track.new()
track.connection_id = connection_id
else
track = Track.find(id)
end
unless instrument_id.nil?
track.instrument_id = instrument_id
end
unless sound.nil?
track.sound = sound
end
track.updated_at = Time.now.getutc
track.save
return track
end
=end
end
end

View File

@ -80,6 +80,9 @@ module JamRuby
# session history
has_many :music_session_histories, :foreign_key => "user_id", :class_name => "JamRuby::MusicSessionHistory"
# saved tracks
has_many :saved_tracks, :foreign_key => "user_id", :class_name => "JamRuby::SavedTrack", :inverse_of => :user
# This causes the authenticate method to be generated (among other stuff)
has_secure_password

View File

@ -57,4 +57,15 @@ FactoryGirl.define do
factory :join_request, :class => JamRuby::JoinRequest do
text 'let me in to the session!'
end
factory :track, :class => JamRuby::Track do
sound "mono"
end
factory :saved_track, :class => JamRuby::SavedTrack do
end
factory :instrument, :class => JamRuby::Instrument do
end
end

View File

@ -0,0 +1,25 @@
require 'spec_helper'
describe SavedTrack do
before do
@user = FactoryGirl.create(:user)
@connection = FactoryGirl.create(:connection, :user => @user)
@instrument = FactoryGirl.create(:instrument, :description => 'a great instrument')
@track = FactoryGirl.create(:track, :connection => @connection, :instrument => @instrument)
end
describe "Saved track" do
it "should copy from a regular track properly" do
@saved_track = SavedTrack.create_from_track(@track)
@saved_track.user.id.should == @track.connection.user.id
@saved_track.instrument.id.should == @track.instrument.id
@saved_track.next_part_to_upload.should == 0
@saved_track.fully_uploaded.should == false
end
end
end