-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
279 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
class ScheduleScheduling < ApplicationRecord | ||
belongs_to :event_schedule | ||
|
||
validates :title, :start_date, :end_date, :short_description, presence: true | ||
|
||
validates :start_date, comparison: { greater_than: :end_date } | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,11 @@ | ||
FactoryBot.define do | ||
factory :track do | ||
title { "MyString" } | ||
sequence(:title) {|n| "title-#{n}" } | ||
private { false } | ||
slug { "MyString" } | ||
caption { "MyString" } | ||
user { nil } | ||
notification_settings { "" } | ||
metadata { "" } | ||
likes_count { 1 } | ||
reposts_count { 1 } | ||
state { "MyString" } | ||
tags { "" } | ||
tags { [] } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,10 @@ | ||
FactoryBot.define do | ||
factory :user do | ||
email { "MyString" } | ||
username { "MyString" } | ||
label { false } | ||
support_link { "MyString" } | ||
first_name { "MyString" } | ||
last_name { "MyString" } | ||
country { "MyString" } | ||
city { "MyString" } | ||
bio { "MyText" } | ||
settings { "" } | ||
role { "MyString" } | ||
first_name { "User Name" } | ||
last_name { "User Name" } | ||
password { "123456" } | ||
password_confirmation {"123456"} | ||
sequence(:username) {|n| "user-#{n}" } | ||
sequence(:email) { |n| "person#{n}@example.com" } | ||
end | ||
end |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,61 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe Event, type: :model do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
let!(:user) { | ||
FactoryBot.create(:user, username: "user", role: "user") | ||
} | ||
|
||
describe 'associations' do | ||
it { should belong_to(:user) } | ||
it { should have_many(:event_hosts) } | ||
it { should have_many(:event_schedules) } | ||
it { should have_many(:event_recordings) } | ||
# it { should have_many(:schedule_schedulings).through(:event_schedules) } | ||
it { should have_many(:event_tickets) } | ||
it { should have_many(:purchases) } | ||
it { should have_many(:purchased_items) } | ||
it { should have_many(:paid_purchased_items) } | ||
it { should have_many(:purchased_event_tickets) } | ||
it { should have_one_attached(:cover) } | ||
end | ||
|
||
describe 'scopes' do | ||
before do | ||
@event1 = FactoryBot.create(:event, state: "published", user: user, event_start: 1.day.from_now) | ||
@event2 = FactoryBot.create(:event, state: "draft", user: user, event_start: 2.days.from_now) | ||
@event3 = FactoryBot.create(:event, state: "published", user: user, event_start: 3.days.from_now) | ||
@event4 = FactoryBot.create(:event, state: "published", user: user, event_start: 3.days.ago) | ||
end | ||
|
||
describe '.upcoming' do | ||
it 'returns events in ascending order of start date' do | ||
expect(Event.upcoming_events).to eq([@event1, @event3]) | ||
end | ||
end | ||
|
||
describe '.published' do | ||
it 'returns published events' do | ||
expect(Event.upcoming_events).to eq([@event1, @event3]) | ||
end | ||
end | ||
|
||
describe '.past_events' do | ||
it 'returns past_events events' do | ||
expect(Event.past_events).to eq([@event4]) | ||
end | ||
end | ||
|
||
describe 'creating tickets' do | ||
let(:event) { FactoryBot.create(:event, user: user) } | ||
|
||
it 'can create associated tickets' do | ||
ticket = FactoryBot.create(:event_ticket, event: event, selling_start: 1.day.from_now, selling_end: 3.day.from_now) | ||
expect(event.event_tickets).to include(ticket) | ||
|
||
expect(event.available_tickets(2.day.from_now)).to be_any | ||
expect(event.available_tickets(Time.now)).to be_empty | ||
|
||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,34 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe Playlist, type: :model do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
it { belong_to( :user) } | ||
it { have_many( :track_playlists) } | ||
it { have_many( :tracks).through(:track_playlists) } | ||
it { have_many( :listening_events) } | ||
it { have_many( :comments) } | ||
it { have_many( :likes) } | ||
it { have_one_attached( :cover) } | ||
it { have_one_attached( :zip) } | ||
|
||
let!(:user) { FactoryBot.create(:user) } | ||
|
||
describe 'scopes' do | ||
before do | ||
@playlist1 = FactoryBot.create(:playlist, private: false, user: user, created_at: 1.day.ago) | ||
@playlist2 = FactoryBot.create(:playlist, private: true, user: user, created_at: 2.days.ago) | ||
@playlist3 = FactoryBot.create(:playlist, private: false, user: user, created_at: 3.days.ago) | ||
end | ||
|
||
describe '.published' do | ||
it 'returns only published tracks' do | ||
expect(Playlist.published).to contain_exactly(@playlist1, @playlist3) | ||
end | ||
end | ||
|
||
describe '.latests' do | ||
it 'returns tracks in descending order of creation' do | ||
expect(Playlist.latests.ids).to eq([@playlist3.id, @playlist2.id, @playlist1.id]) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,70 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe Track, type: :model do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
|
||
it { should belong_to(:user) } | ||
it { should have_many(:track_comments) } | ||
it { should have_many(:track_playlists) } | ||
it { should have_many(:playlists).through(:track_playlists) } | ||
it { should have_many(:listening_events) } | ||
it { should have_many(:reposts) } | ||
it { should have_many(:purchased_items) } | ||
it { should have_many(:likes) } | ||
it { should have_many(:comments) } | ||
|
||
it { should have_one_attached(:cover) } | ||
it { should have_one_attached(:audio) } | ||
it { should have_one_attached(:mp3_audio) } | ||
it { should have_one_attached(:zip) } | ||
|
||
let!(:user) { | ||
FactoryBot.create(:user, username: "user", role: "user") | ||
} | ||
|
||
describe 'scopes' do | ||
before do | ||
@track1 = FactoryBot.create(:track, private: false, user: user, created_at: 1.day.ago) | ||
@track2 = FactoryBot.create(:track, private: true, user: user, created_at: 2.days.ago) | ||
@track3 = FactoryBot.create(:track, private: false, user: user, created_at: 3.days.ago) | ||
end | ||
|
||
describe '.published' do | ||
it 'returns only published tracks' do | ||
expect(Track.published).to contain_exactly(@track1, @track3) | ||
end | ||
end | ||
|
||
describe '.latests' do | ||
it 'returns tracks in descending order of creation' do | ||
expect(Track.latests.ids).to eq([@track3.id, @track2.id, @track1.id]) | ||
end | ||
end | ||
end | ||
|
||
describe 'state' do | ||
it "pending" do | ||
@track = FactoryBot.create(:track, private: false, user: user, created_at: 1.day.ago) | ||
expect(@track).to be_pending | ||
end | ||
end | ||
|
||
describe 'tags' do | ||
it "create with tags" do | ||
@track = FactoryBot.create(:track, user: user, tags: ["Ambient", "Techno"]) | ||
expect(@track.tags).to be == ["ambient", "techno"] | ||
expect(Track.get_tracks_by_tag("Ambient")).to be_any | ||
expect(Track.get_tracks_by_tag("ambient")).to be_any | ||
end | ||
end | ||
|
||
describe 'audio' do | ||
xit 'can be created with an audio file' do | ||
audio = Rack::Test::UploadedFile.new(Rails.root.join('spec', 'fixtures', 'audio.mp3'), 'audio/mp3') | ||
track = FactoryBot.create(:track, audio: audio, user: user) | ||
expect_any_instance_of(Track).to receive(:reprocess_async) | ||
expect(track).to be_persisted | ||
expect(track.audio).to be_persisted | ||
end | ||
end | ||
|
||
end |
Oops, something went wrong.