VRFS-1577
This commit is contained in:
parent
294bb22cdd
commit
5f74bce061
|
|
@ -15,7 +15,7 @@ module JamRuby
|
|||
|
||||
batch.did_send(emails)
|
||||
|
||||
mail(:to => batch.from_email,
|
||||
mail(:to => emails,
|
||||
:from => batch.from_email,
|
||||
:subject => batch.subject) do |format|
|
||||
format.text
|
||||
|
|
|
|||
|
|
@ -110,9 +110,11 @@ module JamRuby
|
|||
end
|
||||
end
|
||||
|
||||
MIN_SESSION_DURATION_RATING = 60
|
||||
|
||||
def should_rate_session?
|
||||
(2 <= music_session_history.unique_users.all.count &&
|
||||
60 < (Time.now - music_session_history.created_at).seconds) ||
|
||||
MIN_SESSION_DURATION_RATING < (Time.now - music_session_history.created_at).seconds) ||
|
||||
Rails.env.development?
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ describe MusicSessionUserHistory do
|
|||
let(:user_history2) { FactoryGirl.create(:music_session_user_history, :history => music_session.music_session_history, :user => some_user) }
|
||||
|
||||
describe "create" do
|
||||
pending
|
||||
it {user_history1.music_session_id.should == music_session.id }
|
||||
it {user_history1.created_at.should_not be_nil }
|
||||
it {user_history1.session_removed_at.should be_nil }
|
||||
|
|
@ -15,28 +16,35 @@ describe MusicSessionUserHistory do
|
|||
|
||||
describe "rating" do
|
||||
|
||||
describe "success" do
|
||||
|
||||
before(:each) do
|
||||
user_history1.update_attribute(:rating ,0)
|
||||
end
|
||||
|
||||
it { user_history1.errors.any?.should be_false}
|
||||
it "success" do
|
||||
user_history1.update_attribute(:rating, 1)
|
||||
expect( user_history1.errors.any? ).to eq(false)
|
||||
end
|
||||
|
||||
describe "out of range" do
|
||||
before(:each) do
|
||||
user_history1.update_attribute(:rating, 2)
|
||||
user_history1.save
|
||||
end
|
||||
it "out of range" do
|
||||
user_history1.rating = 2
|
||||
user_history1.save
|
||||
expect( user_history1.errors.any? ).to eq(true)
|
||||
end
|
||||
|
||||
it { user_history1.errors.any?.should be_true}
|
||||
it 'should rate success' do
|
||||
users = [user_history1, user_history2]
|
||||
Timecop.travel(Time.now + (MusicSessionUserHistory::MIN_SESSION_DURATION_RATING * 1.5).seconds)
|
||||
expect( user_history1.should_rate_session? ).to eq(true)
|
||||
Timecop.return
|
||||
end
|
||||
|
||||
it 'should rate fails' do
|
||||
users = [user_history1]
|
||||
expect( user_history1.should_rate_session? ).to eq(false)
|
||||
users = [user_history1, user_history2]
|
||||
expect( user_history2.should_rate_session? ).to eq(false)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "end_history" do
|
||||
|
||||
pending
|
||||
it "histories created at the same time" do
|
||||
user_history1.reload
|
||||
user_history2.reload
|
||||
|
|
|
|||
Loading…
Reference in New Issue