22 |
We're sorry, but something went wrong.
23 |
We've been notified about this issue and we'll take a look at it shortly.
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mongoid/echo/1d28bbbd09d5cbf266520fa7aade5b16e724867d/public/favicon.ico
--------------------------------------------------------------------------------
/public/images/rails.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mongoid/echo/1d28bbbd09d5cbf266520fa7aade5b16e724867d/public/images/rails.png
--------------------------------------------------------------------------------
/public/robots.txt:
--------------------------------------------------------------------------------
1 | # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
2 | #
3 | # To ban all spiders from the entire site uncomment the next two lines:
4 | # User-Agent: *
5 | # Disallow: /
6 |
--------------------------------------------------------------------------------
/script/rails:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3 |
4 | APP_PATH = File.expand_path('../../config/application', __FILE__)
5 | require File.expand_path('../../config/boot', __FILE__)
6 | require 'rails/commands'
7 |
--------------------------------------------------------------------------------
/spec/controllers/home_controller_spec.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | require "spec_helper"
3 |
4 | describe HomeController do
5 | end
6 |
--------------------------------------------------------------------------------
/spec/fabricators/access_fabricator.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | Fabricator(:access) do
3 | category :download
4 |
5 | after_build do |access|
6 | band = Fabricate.build(:depeche_mode)
7 | album = band.albums.first
8 | access.album_id = album.id
9 | access.band = band
10 | access.track_id = album.tracks.first.id
11 | end
12 | end
13 |
14 | Fabricator(:download, from: :access)
15 |
16 | Fabricator(:stream, from: :access) do
17 | category :stream
18 | end
19 |
--------------------------------------------------------------------------------
/spec/fabricators/address_fabricator.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | Fabricator(:address) do
3 | street "Columbiadamm 13"
4 | postcode "10965"
5 | city "Berlin"
6 | country "Deutschland"
7 | end
8 |
--------------------------------------------------------------------------------
/spec/fabricators/album_fabricator.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | Fabricator(:album) do
3 | name "Fresh Fruit for Rotting Vegetables"
4 | released Date.new(1980, 9, 5)
5 | end
6 |
7 | # Special fabricator for a multi-disc full album.
8 | Fabricator(:singles_86_98, class_name: "Album") do
9 | name "The Singles 86 > 98"
10 | released Date.new(1998, 9, 28)
11 |
12 | after_build do |album|
13 | album.tracks.push([
14 | Fabricate.build(:stripped),
15 | Fabricate.build(:a_question_of_lust),
16 | Fabricate.build(:a_question_of_time),
17 | Fabricate.build(:strangelove),
18 | Fabricate.build(:never_let_me_down_again),
19 | Fabricate.build(:behind_the_wheel),
20 | Fabricate.build(:personal_jesus),
21 | Fabricate.build(:enjoy_the_silence),
22 | Fabricate.build(:i_feel_you),
23 | Fabricate.build(:walking_in_my_shoes),
24 | Fabricate.build(:condemnation),
25 | Fabricate.build(:in_your_room),
26 | Fabricate.build(:barrel_of_a_gun),
27 | Fabricate.build(:its_no_good),
28 | Fabricate.build(:home),
29 | Fabricate.build(:useless),
30 | Fabricate.build(:only_when_i_lose_myself),
31 | Fabricate.build(:little_15),
32 | Fabricate.build(:everything_counts)
33 | ])
34 | album.photos.push([
35 | Fabricate.build(:singles_86_98_cover),
36 | Fabricate.build(:singles_86_98_back)
37 | ])
38 | album.producer = Fabricate(:daniel_miller)
39 | end
40 | end
41 |
42 | Fabricator(:halo_one, class_name: "Album") do
43 | name "Down In It"
44 |
45 | after_build do |album|
46 | album.tracks.push(Fabricate.build(:down_in_it))
47 | album.producer = Fabricate(:daniel_miller)
48 | end
49 | end
50 |
--------------------------------------------------------------------------------
/spec/fabricators/band_fabricator.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | Fabricator(:band) do
3 | name "Dead Kennedys"
4 | end
5 |
6 | # Use Depeche Mode for testing of the entire object graph.
7 | Fabricator(:depeche_mode, class_name: "Band") do
8 | description {
9 | "Depeche Mode are an English electronic music band which formed in 1980, in " +
10 | "Basildon, Essex. The group's original line-up consisted of Dave Gahan " +
11 | "(lead vocals), Martin Gore (keyboards, guitar, vocals, chief songwriter " +
12 | "after 1981), Andy Fletcher (keyboards) and Vince Clarke (keyboards, chief " +
13 | "songwriter 1980–81). Vince Clarke left the band after the release of their " +
14 | "1981 debut album, Speak & Spell, and was replaced by Alan Wilder " +
15 | "(keyboards, drums) with Gore taking over songwriting. Wilder left the band " +
16 | "in 1995 and since then Gahan, Gore, and Fletcher have continued as a trio."
17 | }
18 | genres [ "Electronic", "Synth Pop", "New Romantic" ]
19 | name "Depeche Mode"
20 | similarities [ "Pet Shop Boys", "New Order", "Mute" ]
21 | sounds [ "Synthesizer", "Piano", "Drum Machine", "Sequencer" ]
22 |
23 | after_build do |band|
24 | band.albums.push(Fabricate.build(:singles_86_98))
25 | band.photos.push([
26 | Fabricate.build(:depeche_mode_wall),
27 | Fabricate.build(:depeche_mode_universe),
28 | Fabricate.build(:depeche_mode_table)
29 | ])
30 | end
31 | end
32 |
33 | # Use Nine Inch Nails for a smaller full object graph
34 | Fabricator(:nine_inch_nails, class_name: "Band") do
35 | description "Trent Reznor's baby."
36 | name "Nine Inch Nails"
37 |
38 | after_build do |band|
39 | band.albums.push(Fabricate.build(:halo_one))
40 | end
41 | end
42 |
--------------------------------------------------------------------------------
/spec/fabricators/following_fabricator.rb:
--------------------------------------------------------------------------------
1 | Fabricator(:following) do
2 | user { Fabricate(:subscriber) }
3 | band { Fabricate(:band) }
4 | end
5 |
--------------------------------------------------------------------------------
/spec/fabricators/metadata_fabricator.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | Fabricator(:metadata) do
3 | tags [ "Depeche Mode", "Electronic", "Alan Wilder", "Synth", "Piano", "electronic" ]
4 | end
5 |
--------------------------------------------------------------------------------
/spec/fabricators/photo_fabricator.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | DIR = "#{Rails.root}/spec/support/bands/depeche-mode"
3 | DM_TABLE = "#{DIR}/depeche-mode-table.jpg"
4 | DM_UNIVERSE = "#{DIR}/depeche-mode-universe.jpg"
5 | DM_WALL = "#{DIR}/depeche-mode-wall.jpg"
6 | SINGLES_BACK = "#{DIR}/singles-86-98-back.jpg"
7 | SINGLES_COVER = "#{DIR}/singles-86-98-cover.jpg"
8 |
9 | Fabricator(:photo) do
10 | caption "Depeche Mode"
11 | cover false
12 | image File.new(DM_TABLE)
13 | end
14 |
15 | Fabricator(:depeche_mode_table, class_name: "Photo") do
16 | caption "Depeche Mode at a table."
17 | cover false
18 | image File.new(DM_TABLE)
19 | end
20 |
21 | Fabricator(:depeche_mode_universe, class_name: "Photo") do
22 | caption "Depeche Mode outside."
23 | cover false
24 | image File.new(DM_UNIVERSE)
25 | end
26 |
27 | Fabricator(:depeche_mode_wall, class_name: "Photo") do
28 | caption "Depeche Mode at the wall."
29 | cover true
30 | image File.new(DM_WALL)
31 | end
32 |
33 | Fabricator(:singles_86_98_cover, class_name: "Photo") do
34 | caption "The Singles 86 > 98 Cover."
35 | cover true
36 | image File.new(SINGLES_COVER)
37 | end
38 |
39 | Fabricator(:singles_86_98_back, class_name: "Photo") do
40 | caption "The Singles 86 > 98 Back."
41 | cover false
42 | image File.new(SINGLES_BACK)
43 | end
44 |
--------------------------------------------------------------------------------
/spec/fabricators/review_fabricator.rb:
--------------------------------------------------------------------------------
1 | Fabricator(:review) do
2 | content "This is the greatest album of all time."
3 | rating 9.5
4 | reviewer { User.subscribers.first || Fabricate(:subscriber) }
5 | end
6 |
--------------------------------------------------------------------------------
/spec/fabricators/role_fabricator.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | Fabricator(:role, class_name: "Reference::Role") do
3 | name "administrator"
4 | actions do
5 | {
6 | "download-track" => :all,
7 | "manage-band" => :all,
8 | "manage-user" => :all,
9 | "stream-track" => :all,
10 | "view-band" => :all,
11 | "view-user" => :all
12 | }
13 | end
14 | end
15 |
16 | Fabricator(:administrator_role, from: :role)
17 |
18 | Fabricator(:artist_role, class_name: "Reference::Role") do
19 | name "artist"
20 | actions do
21 | {
22 | "download-track" => :all,
23 | "manage-band" => :id,
24 | "manage-user" => :id,
25 | "stream-track" => :all,
26 | "view-band" => :all,
27 | "view-user" => :all
28 | }
29 | end
30 | end
31 |
32 | Fabricator(:producer_role, class_name: "Reference::Role") do
33 | name "producer"
34 | actions do
35 | {
36 | "download-track" => :all,
37 | "manage-user" => :id,
38 | "stream-track" => :all,
39 | "view-band" => :all,
40 | "view-user" => :all
41 | }
42 | end
43 | end
44 |
45 | Fabricator(:subscriber_role, class_name: "Reference::Role") do
46 | name "subscriber"
47 | actions do
48 | {
49 | "download-track" => :all,
50 | "manage-user" => :id,
51 | "stream-track" => :all,
52 | "view-band" => :all,
53 | "view-user" => :all
54 | }
55 | end
56 | end
57 |
58 | Fabricator(:visitor_role, class_name: "Reference::Role") do
59 | name "visitor"
60 | actions do
61 | {
62 | "stream-track" => :all,
63 | "view-band" => :all,
64 | "view-user" => :all
65 | }
66 | end
67 | end
68 |
--------------------------------------------------------------------------------
/spec/fabricators/settings_fabricator.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | Fabricator(:settings) do
3 | facebook_notifiable false
4 | twitter_notifiable false
5 | end
6 |
7 | Fabricator(:facebook_notifiable_settings, from: :settings) do
8 | facebook_notifiable true
9 | end
10 |
11 | Fabricator(:twitter_notifiable_settings, from: :settings) do
12 | twitter_notifiable true
13 | end
14 |
--------------------------------------------------------------------------------
/spec/fabricators/show_fabricator.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | Fabricator(:show) do
3 | date 100.days.from_now
4 | end
5 |
--------------------------------------------------------------------------------
/spec/fabricators/tour_fabricator.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | Fabricator(:tour) do
3 | name "Devotional"
4 | end
5 |
--------------------------------------------------------------------------------
/spec/fabricators/track_fabricator.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | Fabricator(:track) do
3 | disc 1
4 | name "California Über Alles"
5 | number 1
6 | length "3:03"
7 | end
8 |
9 | # The following tracks are used when desiring to create a full length triple
10 | # disc album, from the every intoxicating Depeche Mode.
11 | Fabricator(:stripped, class_name: "Track") do
12 | disc 1
13 | length "3:51"
14 | name "Stripped (7\" Version)"
15 | number 1
16 | end
17 |
18 | Fabricator(:a_question_of_lust, class_name: "Track") do
19 | disc 1
20 | length "4:31"
21 | name "A Question Of Lust"
22 | number 2
23 | end
24 |
25 | Fabricator(:a_question_of_time, class_name: "Track") do
26 | disc 1
27 | length "4:00"
28 | name "A Question Of Time (Remix)"
29 | number 3
30 | end
31 |
32 | Fabricator(:strangelove, class_name: "Track") do
33 | disc 1
34 | length "3:47"
35 | name "Strangelove"
36 | number 4
37 | end
38 |
39 | Fabricator(:never_let_me_down_again, class_name: "Track") do
40 | disc 1
41 | length "4:22"
42 | name "Never Let Me Down Again"
43 | number 5
44 | end
45 |
46 | Fabricator(:behind_the_wheel, class_name: "Track") do
47 | disc 1
48 | length "4:00"
49 | name "Behind The Wheel (Remix)"
50 | number 6
51 | end
52 |
53 | Fabricator(:personal_jesus, class_name: "Track") do
54 | disc 1
55 | length "3:46"
56 | name "Personal Jesus"
57 | number 7
58 | end
59 |
60 | Fabricator(:enjoy_the_silence, class_name: "Track") do
61 | disc 1
62 | length "4:16"
63 | name "Enjoy The Silence (7\" Version)"
64 | number 8
65 | end
66 |
67 | Fabricator(:policy_of_truth, class_name: "Track") do
68 | disc 1
69 | length "5:14"
70 | name "Policy Of Truth"
71 | number 9
72 | end
73 |
74 | Fabricator(:world_in_my_eyes, class_name: "Track") do
75 | disc 1
76 | length "3:56"
77 | name "World In My Eyes (7\" Version)"
78 | number 10
79 | end
80 |
81 | Fabricator(:i_feel_you, class_name: "Track") do
82 | disc 2
83 | length "4:35"
84 | name "I Feel You"
85 | number 1
86 | end
87 |
88 | Fabricator(:walking_in_my_shoes, class_name: "Track") do
89 | disc 2
90 | length "5:02"
91 | name "Walking In My Shoes (Single Version)"
92 | number 2
93 | end
94 |
95 | Fabricator(:condemnation, class_name: "Track") do
96 | disc 2
97 | length "3:23"
98 | name "Condemnation (Paris Mix)"
99 | number 3
100 | end
101 |
102 | Fabricator(:in_your_room, class_name: "Track") do
103 | disc 2
104 | length "4:50"
105 | name "In Your Room (Zephyr Mix)"
106 | number 4
107 | end
108 |
109 | Fabricator(:barrel_of_a_gun, class_name: "Track") do
110 | disc 2
111 | length "5:26"
112 | name "Barrel Of A Gun"
113 | number 5
114 | end
115 |
116 | Fabricator(:its_no_good, class_name: "Track") do
117 | disc 2
118 | length "5:59"
119 | name "It's No Good"
120 | number 6
121 | end
122 |
123 | Fabricator(:home, class_name: "Track") do
124 | disc 2
125 | length "5:46"
126 | name "Home"
127 | number 7
128 | end
129 |
130 | Fabricator(:useless, class_name: "Track") do
131 | disc 2
132 | length "4:53"
133 | name "Useless (Remix)"
134 | number 8
135 | end
136 |
137 | Fabricator(:only_when_i_lose_myself, class_name: "Track") do
138 | disc 2
139 | length "4:41"
140 | name "Only When I Lose Myself"
141 | number 9
142 | end
143 |
144 | Fabricator(:little_15, class_name: "Track") do
145 | disc 2
146 | length "4:14"
147 | name "Little 15"
148 | number 10
149 | end
150 |
151 | Fabricator(:everything_counts, class_name: "Track") do
152 | disc 2
153 | length "6:38"
154 | name "Everything Counts (Live)"
155 | number 11
156 | end
157 |
158 | Fabricator(:down_in_it, class_name: "Track") do
159 | disc 1
160 | length "3:44"
161 | name "Down In It"
162 | number 1
163 | end
164 |
--------------------------------------------------------------------------------
/spec/fabricators/user_fabricator.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | Fabricator(:user) do
3 | email "durran@echo.am"
4 | first_name "Durran"
5 | last_name "Jordan"
6 | role do
7 | role = Reference::Role.first || Fabricate(:role)
8 | role.denormalized
9 | end
10 | end
11 |
12 | Fabricator(:admin, class_name: "User") do
13 | email "durran@echo.am"
14 | first_name "Durran"
15 | last_name "Jordan"
16 | role do
17 | role = Reference::Role.administrator || Fabricate(:administrator_role)
18 | role.denormalized
19 | end
20 | end
21 |
22 | Fabricator(:artist, class_name: "User") do
23 | email "east.bay.ray@kennedys.com"
24 | first_name "Raymond"
25 | last_name "Pepperell"
26 | handle "East Bay Ray"
27 | role do
28 | role = Reference::Role.artist || Fabricate(:artist_role)
29 | role.denormalized
30 | end
31 | end
32 |
33 | Fabricator(:producer, class_name: "User") do
34 | email "moses.schneider@echo.am"
35 | first_name "Moses"
36 | last_name "Schneider"
37 | role do
38 | role = Reference::Role.producer || Fabricate(:producer_role)
39 | role.denormalized
40 | end
41 | end
42 |
43 | Fabricator(:subscriber, class_name: "User") do
44 | email "joe.blow@gmail.com"
45 | first_name "Joe"
46 | last_name "Blow"
47 | role do
48 | role = Reference::Role.subscriber || Fabricate(:subscriber_role)
49 | role.denormalized
50 | end
51 | end
52 |
53 | Fabricator(:visitor, class_name: "User") do
54 | email "info@echo.am"
55 | first_name "Echo"
56 | last_name "Visitor"
57 | role do
58 | role = Reference::Role.visitor || Fabricate(:visitor_role)
59 | role.denormalized
60 | end
61 | end
62 |
63 | Fabricator(:daniel_miller, class_name: "User") do
64 | email "daniel.miller@echo.am"
65 | first_name "Daniel"
66 | last_name "Miller"
67 | role do
68 | role = Reference::Role.producer || Fabricate(:producer_role)
69 | role.denormalized
70 | end
71 | end
72 |
73 |
--------------------------------------------------------------------------------
/spec/fabricators/venue_fabricator.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | Fabricator(:venue) do
3 | name "Columbiahalle"
4 | location [ 52.48445, 13.39269 ]
5 |
6 | after_build do |venue|
7 | venue.address = Fabricate.build(:address)
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/spec/helpers/start_helper_spec.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | require "spec_helper"
3 |
4 | describe StartHelper do
5 | end
6 |
--------------------------------------------------------------------------------
/spec/models/access_spec.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | require "spec_helper"
3 |
4 | describe Access do
5 |
6 | describe "#download?" do
7 |
8 | context "when the access is a download" do
9 |
10 | let(:access) do
11 | Fabricate.build(:download)
12 | end
13 |
14 | it "returns true" do
15 | access.should be_download
16 | end
17 | end
18 |
19 | context "when the access is not a download" do
20 |
21 | let(:access) do
22 | Fabricate.build(:stream)
23 | end
24 |
25 | it "returns false" do
26 | access.should_not be_download
27 | end
28 | end
29 | end
30 |
31 | describe ".downloaded" do
32 |
33 | let(:user) do
34 | Fabricate.build(:subscriber)
35 | end
36 |
37 | let(:band) do
38 | Fabricate.build(:nine_inch_nails)
39 | end
40 |
41 | let(:album) do
42 | band.albums.first
43 | end
44 |
45 | let(:track) do
46 | album.tracks.first
47 | end
48 |
49 | let(:access) do
50 | Access.downloaded(track, user)
51 | end
52 |
53 | it "returns a download access" do
54 | access.should be_download
55 | end
56 |
57 | it "sets the album id" do
58 | access.album_id.should == album.id
59 | end
60 |
61 | it "sets the band" do
62 | access.band.should == band
63 | end
64 |
65 | it "sets the track id" do
66 | access.track_id.should == track.id
67 | end
68 |
69 | it "sets the user" do
70 | access.user.should == user
71 | end
72 | end
73 |
74 | describe "#stream?" do
75 |
76 | context "when the access is a stream" do
77 |
78 | let(:access) do
79 | Fabricate.build(:stream)
80 | end
81 |
82 | it "returns true" do
83 | access.should be_stream
84 | end
85 | end
86 |
87 | context "when the access is not a stream" do
88 |
89 | let(:access) do
90 | Fabricate.build(:download)
91 | end
92 |
93 | it "returns false" do
94 | access.should_not be_stream
95 | end
96 | end
97 | end
98 |
99 | describe ".streamed" do
100 |
101 | let(:user) do
102 | Fabricate.build(:subscriber)
103 | end
104 |
105 | let(:band) do
106 | Fabricate.build(:nine_inch_nails)
107 | end
108 |
109 | let(:album) do
110 | band.albums.first
111 | end
112 |
113 | let(:track) do
114 | album.tracks.first
115 | end
116 |
117 | let(:access) do
118 | Access.streamed(track, user)
119 | end
120 |
121 | it "returns a stream access" do
122 | access.should be_stream
123 | end
124 |
125 | it "sets the album id" do
126 | access.album_id.should == album.id
127 | end
128 |
129 | it "sets the band" do
130 | access.band.should == band
131 | end
132 |
133 | it "sets the track id" do
134 | access.track_id.should == track.id
135 | end
136 |
137 | it "sets the user" do
138 | access.user.should == user
139 | end
140 | end
141 |
142 | [ :album_id, :band, :category, :track_id, :user ].each do |field|
143 |
144 | context "when validating #{field} presence" do
145 |
146 | let(:access) do
147 | Fabricate.build(:access)
148 | end
149 |
150 | before do
151 | access.send("#{field}=", nil)
152 | access.valid?
153 | end
154 |
155 | it "must be provided" do
156 | access.errors[field].should == [ "can't be blank" ]
157 | end
158 | end
159 | end
160 | end
161 |
--------------------------------------------------------------------------------
/spec/models/address_spec.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | require "spec_helper"
3 |
4 | describe Address do
5 |
6 | [ :city, :country, :postcode, :street ].each do |field|
7 |
8 | context "when validating #{field} presence" do
9 |
10 | let(:address) do
11 | Fabricate.build(:address, "#{field}" => nil)
12 | end
13 |
14 | before do
15 | address.valid?
16 | end
17 |
18 | it "must be provided" do
19 | address.errors[field].should == [ "can't be blank" ]
20 | end
21 | end
22 | end
23 | end
24 |
--------------------------------------------------------------------------------
/spec/models/album_spec.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | require "spec_helper"
3 |
4 | describe Album do
5 |
6 | describe "#average_rating" do
7 |
8 | let(:band) do
9 | Fabricate(:band)
10 | end
11 |
12 | let(:album) do
13 | Fabricate.build(:album)
14 | end
15 |
16 | let(:review_one) do
17 | Fabricate.build(:review, rating: 5)
18 | end
19 |
20 | let(:review_two) do
21 | Fabricate.build(:review, rating: 10)
22 | end
23 |
24 | before do
25 | band.albums << album
26 | album.reviews << [ review_one, review_two ]
27 | end
28 |
29 | it "returns the average review rating" do
30 | album.average_rating.should == 7.5
31 | end
32 | end
33 |
34 | describe "#discs" do
35 |
36 | context "when the album has only 1 disc" do
37 |
38 | let(:album) do
39 | Fabricate.build(:album)
40 | end
41 |
42 | before do
43 | album.tracks << Fabricate.build(:track)
44 | end
45 |
46 | it "returns 1" do
47 | album.discs.should == 1
48 | end
49 | end
50 |
51 | context "when the album has multiple discs" do
52 |
53 | let(:album) do
54 | Fabricate.build(:singles_86_98)
55 | end
56 |
57 | it "returns the total number of discs" do
58 | album.discs.should == 2
59 | end
60 | end
61 | end
62 |
63 | describe ".produced_by" do
64 |
65 | let(:user) do
66 | Fabricate(:producer)
67 | end
68 |
69 | let(:band) do
70 | Fabricate.build(:band)
71 | end
72 |
73 | let(:first_album) do
74 | Fabricate.build(:album, producer: user)
75 | end
76 |
77 | let(:second_album) do
78 | Fabricate.build(:album)
79 | end
80 |
81 | before do
82 | band.albums << [ first_album, second_album ]
83 | end
84 |
85 | let(:albums) do
86 | band.albums.produced_by(user)
87 | end
88 |
89 | it "returns the albums produced by the user" do
90 | albums.should == [ first_album ]
91 | end
92 | end
93 |
94 | context "when validating name presence" do
95 |
96 | let(:album) do
97 | Fabricate.build(:album, name: nil)
98 | end
99 |
100 | before do
101 | album.valid?
102 | end
103 |
104 | it "must be provided" do
105 | album.errors[:name].should == [ "can't be blank" ]
106 | end
107 | end
108 | end
109 |
--------------------------------------------------------------------------------
/spec/models/band_spec.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | require "spec_helper"
3 |
4 | describe Band do
5 |
6 | describe ".named" do
7 |
8 | let!(:band) do
9 | Fabricate(:band, name: "Beat Steaks")
10 | end
11 |
12 | context "when provided a name" do
13 |
14 | context "when the name matches" do
15 |
16 | let(:result) do
17 | Band.named("Beat Steaks")
18 | end
19 |
20 | it "returns the matching band" do
21 | result.should == band
22 | end
23 | end
24 |
25 | context "when the name does not match" do
26 |
27 | let(:result) do
28 | Band.named("Beat Sticks")
29 | end
30 |
31 | it "returns nil" do
32 | result.should be_nil
33 | end
34 | end
35 | end
36 |
37 | context "when provided nil" do
38 |
39 | it "returns nil" do
40 | Band.named(nil).should be_nil
41 | end
42 | end
43 |
44 | context "when provided an empty string" do
45 |
46 | it "returns nil" do
47 | Band.named("").should be_nil
48 | end
49 | end
50 | end
51 |
52 | describe "#producers" do
53 |
54 | let(:band) do
55 | Fabricate(:nine_inch_nails)
56 | end
57 |
58 | let(:producers) do
59 | band.producers
60 | end
61 |
62 | it "returns all producers for all albums" do
63 | producers.first.name.should == "Daniel Miller"
64 | end
65 | end
66 |
67 | describe ".reviewed_by" do
68 |
69 | let(:band) do
70 | Fabricate(:band)
71 | end
72 |
73 | let!(:unreviewed) do
74 | Fabricate(:band, name: "Radiohead")
75 | end
76 |
77 | let(:album) do
78 | Fabricate.build(:album)
79 | end
80 |
81 | let(:review) do
82 | Fabricate.build(:review)
83 | end
84 |
85 | before do
86 | album.reviews << review
87 | band.albums << album
88 | end
89 |
90 | let(:reviewer) do
91 | review.reviewer
92 | end
93 |
94 | let(:bands) do
95 | Band.reviewed_by(reviewer)
96 | end
97 |
98 | it "returns the bands with the provided reviewer" do
99 | bands.should == [ band ]
100 | end
101 | end
102 |
103 | describe "#reviews" do
104 |
105 | let(:band) do
106 | Fabricate(:band)
107 | end
108 |
109 | let(:album) do
110 | Fabricate.build(:album)
111 | end
112 |
113 | let(:review) do
114 | Fabricate.build(:review)
115 | end
116 |
117 | before do
118 | album.reviews << review
119 | band.albums << album
120 | end
121 |
122 | it "returns the band's reviews" do
123 | band.reviews.should == [ review ]
124 | end
125 | end
126 |
127 | describe "#reviews_by" do
128 |
129 | let(:band) do
130 | Fabricate(:band)
131 | end
132 |
133 | let(:album) do
134 | Fabricate.build(:album)
135 | end
136 |
137 | let(:review) do
138 | Fabricate.build(:review)
139 | end
140 |
141 | let(:reviewer) do
142 | review.reviewer
143 | end
144 |
145 | before do
146 | album.reviews << review
147 | band.albums << album
148 | end
149 |
150 | it "returns the reviews for the provided user" do
151 | band.reviews_by(reviewer).should == [ review ]
152 | end
153 | end
154 |
155 | describe "#searchables" do
156 |
157 | let(:band) do
158 | Fabricate(:depeche_mode)
159 | end
160 |
161 | let(:searchables) do
162 | band.searchables
163 | end
164 |
165 | it "includes genres" do
166 | searchables.should include("Electronic")
167 | end
168 |
169 | it "includes the name" do
170 | searchables.should include("Depeche Mode")
171 | end
172 |
173 | it "includes producer names" do
174 | searchables.should include("Daniel Miller")
175 | end
176 |
177 | it "includes similarities" do
178 | searchables.should include("New Order")
179 | end
180 |
181 | it "includes sounds" do
182 | searchables.should include("Piano")
183 | end
184 | end
185 |
186 | context "when validating name presence" do
187 |
188 | let(:band) do
189 | Fabricate.build(:band, name: nil)
190 | end
191 |
192 | before do
193 | band.valid?
194 | end
195 |
196 | it "must be provided" do
197 | band.errors[:name].should == [ "can't be blank" ]
198 | end
199 | end
200 |
201 | context "when validating name uniqueness" do
202 |
203 | let(:band) do
204 | Fabricate.build(:band)
205 | end
206 |
207 | before do
208 | Fabricate(:band)
209 | band.valid?
210 | end
211 |
212 | it "must be unique" do
213 | band.errors[:name].should == [ "is already taken" ]
214 | end
215 | end
216 | end
217 |
--------------------------------------------------------------------------------
/spec/models/following_spec.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | require "spec_helper"
3 |
4 | describe Following do
5 |
6 | describe ".ranked" do
7 |
8 | let!(:dead_kennedys) do
9 | Fabricate(:band, name: "Dead Kennedys")
10 | end
11 |
12 | let!(:clash) do
13 | Fabricate(:band, name: "The Clash")
14 | end
15 |
16 | let!(:ramones) do
17 | Fabricate(:band, name: "Ramones")
18 | end
19 |
20 | let!(:durran) do
21 | Fabricate(:subscriber, email: "durran@gmail.com")
22 | end
23 |
24 | let!(:moses) do
25 | Fabricate(:subscriber, email: "mosesschneider@gmx.net")
26 | end
27 |
28 | before do
29 | durran.follow(dead_kennedys)
30 | durran.follow(clash)
31 | moses.follow(clash)
32 | end
33 |
34 | it "returns the bands ranked by number of followings", service: :following do
35 | Following.ranked.should ==
36 | [
37 | { "value" => { "followers" => 1.0 }, "_id" => dead_kennedys.id },
38 | { "value" => { "followers" => 2.0 }, "_id" => clash.id }
39 | ]
40 | end
41 | end
42 | end
43 |
--------------------------------------------------------------------------------
/spec/models/message_spec.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | require "spec_helper"
3 |
4 | describe Message do
5 |
6 | describe "#create" do
7 |
8 | let(:message) do
9 | Message.create!
10 | end
11 |
12 | let(:report) do
13 | message.message_reports.create!
14 | end
15 |
16 | it "has fk on report same as pk on message" do
17 | report.message_report_id.should eq(message.message_id)
18 | end
19 |
20 | it "does not use _id on message fk" do
21 | report.message_report_id.should_not eq(message.id)
22 | end
23 | end
24 |
25 | describe "reloading from db" do
26 |
27 | let(:message) do
28 | Message.create!
29 | end
30 |
31 | let!(:report) do
32 | message.message_reports.create!
33 | end
34 |
35 | let(:from_db) do
36 | Message.find(message.id)
37 | end
38 |
39 | it "has all reports" do
40 | from_db.message_reports.should eq([report])
41 | end
42 | end
43 | end
44 |
--------------------------------------------------------------------------------
/spec/models/metadata_spec.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | require "spec_helper"
3 |
4 | describe Metadata do
5 |
6 | describe "#matches_on" do
7 |
8 | let!(:metadata) do
9 | Fabricate(:metadata)
10 | end
11 |
12 | context "when terms match" do
13 |
14 | let(:matches) do
15 | metadata.matches_on("Depeche Mode")
16 | end
17 |
18 | it "returns an array of matching terms" do
19 | matches.should == [ "Depeche Mode" ]
20 | end
21 | end
22 |
23 | context "when terms do not match" do
24 |
25 | let(:matches) do
26 | metadata.matches_on("Radiohead")
27 | end
28 |
29 | it "returns an empty array" do
30 | matches.should be_empty
31 | end
32 | end
33 | end
34 |
35 | describe ".search_for" do
36 |
37 | let!(:metadata) do
38 | Fabricate(:metadata)
39 | end
40 |
41 | context "when providing an exact match" do
42 |
43 | let(:results) do
44 | Metadata.search_for("Depeche Mode")
45 | end
46 |
47 | it "returns the matching entities" do
48 | results.should == [ metadata ]
49 | end
50 | end
51 |
52 | context "when providing a substring match" do
53 |
54 | context "when matching at the start" do
55 |
56 | let(:results) do
57 | Metadata.search_for("Depeche")
58 | end
59 |
60 | it "returns the matching entities" do
61 | results.should == [ metadata ]
62 | end
63 | end
64 |
65 | context "when matching in the middle" do
66 |
67 | let(:results) do
68 | Metadata.search_for("che M")
69 | end
70 |
71 | it "returns the matching entities" do
72 | results.should == [ metadata ]
73 | end
74 | end
75 |
76 | context "when matching in the end" do
77 |
78 | let(:results) do
79 | Metadata.search_for("Mode")
80 | end
81 |
82 | it "returns the matching entities" do
83 | results.should == [ metadata ]
84 | end
85 | end
86 | end
87 |
88 | context "when providing multiple terms" do
89 |
90 | context "when all terms match" do
91 |
92 | let(:results) do
93 | Metadata.search_for("piano synth")
94 | end
95 |
96 | it "returns the matching entities" do
97 | results.should == [ metadata ]
98 | end
99 | end
100 |
101 | context "when some terms match" do
102 |
103 | let(:results) do
104 | Metadata.search_for("piano synth bass")
105 | end
106 |
107 | it "returns the matching entities" do
108 | results.should == [ metadata ]
109 | end
110 | end
111 |
112 | context "when separating terms with a comma" do
113 |
114 | let(:results) do
115 | Metadata.search_for("piano, synth,bass")
116 | end
117 |
118 | it "returns the matching entities" do
119 | results.should == [ metadata ]
120 | end
121 | end
122 | end
123 | end
124 | end
125 |
--------------------------------------------------------------------------------
/spec/models/photo_spec.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | require "spec_helper"
3 |
4 | describe Photo do
5 | end
6 |
--------------------------------------------------------------------------------
/spec/models/reference/role_spec.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | require "spec_helper"
3 |
4 | describe Reference::Role do
5 |
6 | describe ".administrator" do
7 |
8 | let!(:administrator) do
9 | Fabricate(:administrator_role)
10 | end
11 |
12 | it "returns the only administrator" do
13 | Reference::Role.administrator.should == administrator
14 | end
15 | end
16 |
17 | describe ".administrators" do
18 |
19 | let!(:administrator) do
20 | Fabricate(:administrator_role)
21 | end
22 |
23 | it "returns the administrator role in an array" do
24 | Reference::Role.administrators.should == [ administrator ]
25 | end
26 | end
27 |
28 | describe ".artist" do
29 |
30 | let!(:artist) do
31 | Fabricate(:artist_role)
32 | end
33 |
34 | it "returns the only artist" do
35 | Reference::Role.artist.should == artist
36 | end
37 | end
38 |
39 | describe ".artists" do
40 |
41 | let!(:artist) do
42 | Fabricate(:artist_role)
43 | end
44 |
45 | it "returns the artist role in an array" do
46 | Reference::Role.artists.should == [ artist ]
47 | end
48 | end
49 |
50 | describe "#denormalized" do
51 |
52 | let!(:reference) do
53 | Fabricate.build(:role, name: "administrator", actions: {})
54 | end
55 |
56 | let(:denormalized) do
57 | reference.denormalized
58 | end
59 |
60 | it "returns a denormalized role" do
61 | denormalized.should be_a(::Role)
62 | end
63 |
64 | it "sets the name on the denormalized role" do
65 | denormalized.name.should == reference.name
66 | end
67 |
68 | it "sets the actions on the denormalized role" do
69 | denormalized.actions.should == reference.actions
70 | end
71 |
72 | it "sets the role id on the denormalized role" do
73 | denormalized.role_id.should == reference.id
74 | end
75 | end
76 |
77 | describe ".producer" do
78 |
79 | let!(:producer) do
80 | Fabricate(:producer_role)
81 | end
82 |
83 | it "returns the only producer" do
84 | Reference::Role.producer.should == producer
85 | end
86 | end
87 |
88 | describe ".producers" do
89 |
90 | let!(:producer) do
91 | Fabricate(:producer_role)
92 | end
93 |
94 | it "returns the producer role in an array" do
95 | Reference::Role.producers.should == [ producer ]
96 | end
97 | end
98 |
99 | describe ".subscriber" do
100 |
101 | let!(:subscriber) do
102 | Fabricate(:subscriber_role)
103 | end
104 |
105 | it "returns the only subscriber" do
106 | Reference::Role.subscriber.should == subscriber
107 | end
108 | end
109 |
110 | describe ".subscribers" do
111 |
112 | let!(:subscriber) do
113 | Fabricate(:subscriber_role)
114 | end
115 |
116 | it "returns the subscriber role in an array" do
117 | Reference::Role.subscribers.should == [ subscriber ]
118 | end
119 | end
120 |
121 | context "when validating name uniqueness" do
122 |
123 | let(:role) do
124 | Fabricate.build(:role)
125 | end
126 |
127 | before do
128 | Fabricate(:role)
129 | role.valid?
130 | end
131 |
132 | it "must be unique" do
133 | role.errors[:name].should == [ "is already taken" ]
134 | end
135 | end
136 |
137 | context "when validating name presence" do
138 |
139 | let(:role) do
140 | Fabricate.build(:role, name: nil)
141 | end
142 |
143 | before do
144 | role.valid?
145 | end
146 |
147 | it "must be provided" do
148 | role.errors[:name].should == [ "can't be blank" ]
149 | end
150 | end
151 | end
152 |
--------------------------------------------------------------------------------
/spec/models/review_spec.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | require "spec_helper"
3 |
4 | describe Review do
5 |
6 | context "when validating content presence" do
7 |
8 | let(:review) do
9 | Fabricate.build(:review, content: nil)
10 | end
11 |
12 | before do
13 | review.valid?
14 | end
15 |
16 | it "must be provided" do
17 | review.errors[:content].should == [ "can't be blank" ]
18 | end
19 | end
20 |
21 | context "when validating rating value" do
22 |
23 | context "when the rating is below the minimum" do
24 |
25 | let(:review) do
26 | Fabricate.build(:review, rating: -1)
27 | end
28 |
29 | before do
30 | review.valid?
31 | end
32 |
33 | it "must be equal to or above 0" do
34 | review.errors[:rating].should ==
35 | [ "must be greater than or equal to 0" ]
36 | end
37 | end
38 |
39 | context "when the rating is above the maximum" do
40 |
41 | let(:review) do
42 | Fabricate.build(:review, rating: 11)
43 | end
44 |
45 | before do
46 | review.valid?
47 | end
48 |
49 | it "must be equal to or below 10" do
50 | review.errors[:rating].should ==
51 | [ "must be less than or equal to 10" ]
52 | end
53 | end
54 | end
55 |
56 | context "when validating reviewer presence" do
57 |
58 | let(:review) do
59 | Fabricate.build(:review, reviewer: nil)
60 | end
61 |
62 | before do
63 | review.valid?
64 | end
65 |
66 | it "must be provided" do
67 | review.errors[:reviewer].should == [ "can't be blank" ]
68 | end
69 | end
70 | end
71 |
--------------------------------------------------------------------------------
/spec/models/role_spec.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | require "spec_helper"
3 |
4 | describe Role do
5 |
6 | describe "#able_to?" do
7 |
8 | context "when the role can perform the action" do
9 |
10 | context "when the action is general" do
11 |
12 | let(:role) do
13 | Role.new(actions: { "manage.user" => :all })
14 | end
15 |
16 | it "returns true" do
17 | role.should be_able_to("manage.user")
18 | end
19 | end
20 |
21 | context "when the action is document specific" do
22 |
23 | let(:user) do
24 | Fabricate.build(:user)
25 | end
26 |
27 | let(:role) do
28 | Role.new(actions: { "manage.user" => user.id })
29 | end
30 |
31 | it "returns true" do
32 | role.should be_able_to("manage.user", user)
33 | end
34 | end
35 | end
36 |
37 | context "when the role cannot perform the action" do
38 |
39 | let(:role) do
40 | Role.new
41 | end
42 |
43 | it "returns false" do
44 | role.should_not be_able_to("manage.user")
45 | end
46 | end
47 | end
48 |
49 | describe "#administrator?" do
50 |
51 | context "when the role is an administrator" do
52 |
53 | let(:role) do
54 | Fabricate.build(:administrator_role).denormalized
55 | end
56 |
57 | it "returns true" do
58 | role.should be_administrator
59 | end
60 | end
61 |
62 | context "when the role is not an administrator" do
63 |
64 | let(:role) do
65 | Fabricate.build(:artist_role).denormalized
66 | end
67 |
68 | it "returns false" do
69 | role.should_not be_administrator
70 | end
71 | end
72 | end
73 |
74 | describe "#artist?" do
75 |
76 | context "when the role is an artist" do
77 |
78 | let(:role) do
79 | Fabricate.build(:artist_role).denormalized
80 | end
81 |
82 | it "returns true" do
83 | role.should be_artist
84 | end
85 | end
86 |
87 | context "when the role is not an artist" do
88 |
89 | let(:role) do
90 | Fabricate.build(:administrator_role).denormalized
91 | end
92 |
93 | it "returns false" do
94 | role.should_not be_artist
95 | end
96 | end
97 | end
98 |
99 | describe "#producer?" do
100 |
101 | context "when the role is a procuder" do
102 |
103 | let(:role) do
104 | Fabricate.build(:producer_role).denormalized
105 | end
106 |
107 | it "returns true" do
108 | role.should be_producer
109 | end
110 | end
111 |
112 | context "when the role is not a producer" do
113 |
114 | let(:role) do
115 | Fabricate.build(:artist_role).denormalized
116 | end
117 |
118 | it "returns false" do
119 | role.should_not be_producer
120 | end
121 | end
122 | end
123 |
124 | describe "#subscriber?" do
125 |
126 | context "when the role is a subscriber" do
127 |
128 | let(:role) do
129 | Fabricate.build(:subscriber_role).denormalized
130 | end
131 |
132 | it "returns true" do
133 | role.should be_subscriber
134 | end
135 | end
136 |
137 | context "when the role is not a subscriber" do
138 |
139 | let(:role) do
140 | Fabricate.build(:artist_role).denormalized
141 | end
142 |
143 | it "returns false" do
144 | role.should_not be_subscriber
145 | end
146 | end
147 | end
148 |
149 | describe "#visitor?" do
150 |
151 | context "when the role is a visitor" do
152 |
153 | let(:role) do
154 | Fabricate.build(:visitor_role).denormalized
155 | end
156 |
157 | it "returns true" do
158 | role.should be_visitor
159 | end
160 | end
161 |
162 | context "when the role is not a visitor" do
163 |
164 | let(:role) do
165 | Fabricate.build(:artist_role).denormalized
166 | end
167 |
168 | it "returns false" do
169 | role.should_not be_visitor
170 | end
171 | end
172 | end
173 | end
174 |
--------------------------------------------------------------------------------
/spec/models/show_spec.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | require "spec_helper"
3 |
4 | describe Show do
5 |
6 | context "when validating date presence" do
7 |
8 | let(:show) do
9 | Fabricate.build(:show, date: nil)
10 | end
11 |
12 | before do
13 | show.valid?
14 | end
15 |
16 | it "must be provided" do
17 | show.errors[:date].should == [ "can't be blank" ]
18 | end
19 | end
20 | end
21 |
--------------------------------------------------------------------------------
/spec/models/tour_spec.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | require "spec_helper"
3 |
4 | describe Tour do
5 |
6 | context "when validating name presence" do
7 |
8 | let(:tour) do
9 | Fabricate.build(:tour, name: nil)
10 | end
11 |
12 | before do
13 | tour.valid?
14 | end
15 |
16 | it "must be provided" do
17 | tour.errors[:name].should == [ "can't be blank" ]
18 | end
19 | end
20 | end
21 |
--------------------------------------------------------------------------------
/spec/models/track_spec.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | require "spec_helper"
3 |
4 | describe Track do
5 |
6 | describe "#send_to" do
7 |
8 | let(:user) do
9 | Fabricate.build(:subscriber)
10 | end
11 |
12 | let(:band) do
13 | Fabricate.build(:nine_inch_nails)
14 | end
15 |
16 | let(:album) do
17 | band.albums.first
18 | end
19 |
20 | let(:track) do
21 | album.tracks.first
22 | end
23 |
24 | let!(:download) do
25 | track.send_to(user)
26 | end
27 |
28 | it "returns a new access document" do
29 | download.should be_a(Access)
30 | end
31 |
32 | it "sets the track id on the access" do
33 | download.track_id.should == track.id
34 | end
35 |
36 | it "sets the album id on the access" do
37 | download.album_id.should == track.album.id
38 | end
39 |
40 | it "sets the band on the access" do
41 | download.band.should == track.album.band
42 | end
43 |
44 | it "sets the access category to download" do
45 | download.should be_download
46 | end
47 |
48 | it "sets the user on the access" do
49 | download.user.should == user
50 | end
51 |
52 | it "increments the downloads" do
53 | track.downloads.should == 1
54 | end
55 | end
56 |
57 | describe "#stream_to" do
58 |
59 | let(:user) do
60 | Fabricate.build(:subscriber)
61 | end
62 |
63 | let(:band) do
64 | Fabricate.build(:nine_inch_nails)
65 | end
66 |
67 | let(:album) do
68 | band.albums.first
69 | end
70 |
71 | let(:track) do
72 | album.tracks.first
73 | end
74 |
75 | let!(:download) do
76 | track.stream_to(user)
77 | end
78 |
79 | it "returns a new access document" do
80 | download.should be_a(Access)
81 | end
82 |
83 | it "sets the track id on the access" do
84 | download.track_id.should == track.id
85 | end
86 |
87 | it "sets the album id on the access" do
88 | download.album_id.should == track.album.id
89 | end
90 |
91 | it "sets the band on the access" do
92 | download.band.should == track.album.band
93 | end
94 |
95 | it "sets the access category to stream" do
96 | download.should be_stream
97 | end
98 |
99 | it "sets the user on the access" do
100 | download.user.should == user
101 | end
102 |
103 | it "increments the streams" do
104 | track.streams.should == 1
105 | end
106 | end
107 |
108 | context "when validating disc presence" do
109 |
110 | let(:track) do
111 | Fabricate.build(:track, disc: nil)
112 | end
113 |
114 | before do
115 | track.valid?
116 | end
117 |
118 | it "must be provided" do
119 | track.errors[:disc].should == [ "can't be blank" ]
120 | end
121 | end
122 |
123 | context "when validating length presence" do
124 |
125 | let(:track) do
126 | Fabricate.build(:track, length: nil)
127 | end
128 |
129 | before do
130 | track.valid?
131 | end
132 |
133 | it "must be provided" do
134 | track.errors[:length].should == [ "can't be blank" ]
135 | end
136 | end
137 |
138 | context "when validating name presence" do
139 |
140 | let(:track) do
141 | Fabricate.build(:track, name: nil)
142 | end
143 |
144 | before do
145 | track.valid?
146 | end
147 |
148 | it "must be provided" do
149 | track.errors[:name].should == [ "can't be blank" ]
150 | end
151 | end
152 |
153 | context "when validating number presence" do
154 |
155 | let(:track) do
156 | Fabricate.build(:track, number: nil)
157 | end
158 |
159 | before do
160 | track.valid?
161 | end
162 |
163 | it "must be provided" do
164 | track.errors[:number].should == [ "can't be blank" ]
165 | end
166 | end
167 | end
168 |
--------------------------------------------------------------------------------
/spec/models/user_spec.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | require "spec_helper"
3 |
4 | describe User do
5 |
6 | describe "#able_to?" do
7 |
8 | context "when the user can perform the action" do
9 |
10 | let(:user) do
11 | Fabricate.build(:admin)
12 | end
13 |
14 | it "returns true" do
15 | user.should be_able_to("manage-user")
16 | end
17 | end
18 |
19 | context "when the user cannot perform the action" do
20 |
21 | let(:user) do
22 | Fabricate.build(:subscriber)
23 | end
24 |
25 | it "returns false" do
26 | user.should_not be_able_to("manage-user")
27 | end
28 | end
29 | end
30 |
31 | describe ".administrators" do
32 |
33 | let!(:user) do
34 | Fabricate(:admin)
35 | end
36 |
37 | let(:admins) do
38 | User.administrators
39 | end
40 |
41 | it "returns all admin users" do
42 | admins.should == [ user ]
43 | end
44 | end
45 |
46 | describe "#administrator?" do
47 |
48 | context "when the user is an administrator" do
49 |
50 | let(:user) do
51 | Fabricate.build(:admin)
52 | end
53 |
54 | it "returns true" do
55 | user.should be_administrator
56 | end
57 | end
58 |
59 | context "when the user is not an administrator" do
60 |
61 | let(:user) do
62 | Fabricate.build(:artist)
63 | end
64 |
65 | it "returns false" do
66 | user.should_not be_administrator
67 | end
68 | end
69 | end
70 |
71 | describe ".artists" do
72 |
73 | let!(:user) do
74 | Fabricate(:artist)
75 | end
76 |
77 | let(:artists) do
78 | User.artists
79 | end
80 |
81 | it "returns all artist users" do
82 | artists.should == [ user ]
83 | end
84 | end
85 |
86 | describe "#artist?" do
87 |
88 | context "when the user is an artist" do
89 |
90 | let(:user) do
91 | Fabricate.build(:artist)
92 | end
93 |
94 | it "returns true" do
95 | user.should be_artist
96 | end
97 | end
98 |
99 | context "when the user is not an artist" do
100 |
101 | let(:user) do
102 | Fabricate.build(:admin)
103 | end
104 |
105 | it "returns false" do
106 | user.should_not be_artist
107 | end
108 | end
109 | end
110 |
111 | describe "#follow" do
112 |
113 | let!(:user) do
114 | Fabricate(:subscriber)
115 | end
116 |
117 | let!(:band) do
118 | Fabricate(:band)
119 | end
120 |
121 | before do
122 | user.follow(band)
123 | end
124 |
125 | it "adds a following to the user" do
126 | user.followings.count.should == 1
127 | end
128 |
129 | it "adds a following to the band" do
130 | band.followings.count.should == 1
131 | end
132 | end
133 |
134 | describe "#name" do
135 |
136 | context "when a handle exists" do
137 |
138 | let(:user) do
139 | Fabricate.build(:artist)
140 | end
141 |
142 | it "returns the handle" do
143 | user.name.should == "East Bay Ray"
144 | end
145 | end
146 |
147 | context "when a handle does not exist" do
148 |
149 | let(:user) do
150 | Fabricate.build(:subscriber)
151 | end
152 |
153 | it "returns the first and last name" do
154 | user.name.should == "Joe Blow"
155 | end
156 | end
157 | end
158 |
159 | describe "#producer?" do
160 |
161 | context "when the user is a procuder" do
162 |
163 | let(:user) do
164 | Fabricate.build(:producer)
165 | end
166 |
167 | it "returns true" do
168 | user.should be_producer
169 | end
170 | end
171 |
172 | context "when the user is not a producer" do
173 |
174 | let(:user) do
175 | Fabricate.build(:artist)
176 | end
177 |
178 | it "returns false" do
179 | user.should_not be_producer
180 | end
181 | end
182 | end
183 |
184 | describe ".producers" do
185 |
186 | let!(:user) do
187 | Fabricate(:producer)
188 | end
189 |
190 | let(:producers) do
191 | User.producers
192 | end
193 |
194 | it "returns all producer users" do
195 | producers.should == [ user ]
196 | end
197 | end
198 |
199 | describe "#productions" do
200 |
201 | let!(:user) do
202 | Fabricate(:producer)
203 | end
204 |
205 | let!(:band) do
206 | Fabricate(:band)
207 | end
208 |
209 | let!(:album) do
210 | Fabricate.build(:album, producer: user)
211 | end
212 |
213 | before do
214 | band.albums << album
215 | end
216 |
217 | it "returns the albums produced" do
218 | user.productions.should == [ album ]
219 | end
220 | end
221 |
222 | describe "#reviews" do
223 |
224 | let(:band) do
225 | Fabricate(:band)
226 | end
227 |
228 | let(:album) do
229 | Fabricate.build(:album)
230 | end
231 |
232 | let(:user) do
233 | Fabricate(:subscriber)
234 | end
235 |
236 | let(:review) do
237 | Fabricate.build(:review, reviewer: user)
238 | end
239 |
240 | before do
241 | band.albums << album
242 | album.reviews << review
243 | end
244 |
245 | let(:reviews) do
246 | user.reviews
247 | end
248 |
249 | it "returns the reviews the user authored" do
250 | user.reviews.should == [ review ]
251 | end
252 | end
253 |
254 | describe ".subscribe" do
255 |
256 | before do
257 | Fabricate(:subscriber_role)
258 | end
259 |
260 | context "when the subscription is successful" do
261 |
262 | let!(:subscribe) do
263 | User.subscribe("syd.vicious@pistols.net")
264 | end
265 |
266 | let(:user) do
267 | User.where(email: "syd.vicious@pistols.net").first
268 | end
269 |
270 | it "sets the users role to a subscriber" do
271 | user.role.name.should == "subscriber"
272 | end
273 |
274 | it "returns true" do
275 | subscribe.should be true
276 | end
277 | end
278 | end
279 |
280 | describe "#subscriber?" do
281 |
282 | context "when the user is a subscriber" do
283 |
284 | let(:user) do
285 | Fabricate.build(:subscriber)
286 | end
287 |
288 | it "returns true" do
289 | user.should be_subscriber
290 | end
291 | end
292 |
293 | context "when the user is not a subscriber" do
294 |
295 | let(:user) do
296 | Fabricate.build(:artist)
297 | end
298 |
299 | it "returns false" do
300 | user.should_not be_subscriber
301 | end
302 | end
303 | end
304 |
305 | describe ".subscribers" do
306 |
307 | let!(:user) do
308 | Fabricate(:subscriber)
309 | end
310 |
311 | let(:subscribers) do
312 | User.subscribers
313 | end
314 |
315 | it "returns all subscribers" do
316 | subscribers.should == [ user ]
317 | end
318 | end
319 |
320 | describe "#unfollow" do
321 |
322 | let!(:user) do
323 | Fabricate(:subscriber)
324 | end
325 |
326 | let!(:band) do
327 | Fabricate(:band)
328 | end
329 |
330 | before do
331 | user.follow(band)
332 | user.unfollow(band)
333 | end
334 |
335 | it "removes the following from the user" do
336 | user.followings.count.should == 0
337 | end
338 |
339 | it "removes the following from the band" do
340 | band.followings.count.should == 0
341 | end
342 | end
343 |
344 | describe "#visitor?" do
345 |
346 | context "when the user is a visitor" do
347 |
348 | let(:user) do
349 | Fabricate.build(:visitor)
350 | end
351 |
352 | it "returns true" do
353 | user.should be_visitor
354 | end
355 | end
356 |
357 | context "when the user is not a visitor" do
358 |
359 | let(:user) do
360 | Fabricate.build(:artist)
361 | end
362 |
363 | it "returns false" do
364 | user.should_not be_visitor
365 | end
366 | end
367 | end
368 |
369 | context "when validating email presence" do
370 |
371 | let(:user) do
372 | Fabricate.build(:user, email: nil)
373 | end
374 |
375 | before do
376 | user.valid?
377 | end
378 |
379 | it "must be provided" do
380 | user.errors[:email].should == [ "can't be blank" ]
381 | end
382 | end
383 |
384 | context "when validating email uniqueness" do
385 |
386 | let(:user) do
387 | Fabricate.build(:user)
388 | end
389 |
390 | before do
391 | Fabricate(:user)
392 | user.valid?
393 | end
394 |
395 | it "must be unique" do
396 | user.errors[:email].should == [ "is already taken" ]
397 | end
398 | end
399 |
400 | context "when validating role presence" do
401 |
402 | let(:user) do
403 | Fabricate.build(:user, role: nil)
404 | end
405 |
406 | before do
407 | user.valid?
408 | end
409 |
410 | it "must be provided" do
411 | user.errors[:role].should == [ "can't be blank" ]
412 | end
413 | end
414 | end
415 |
--------------------------------------------------------------------------------
/spec/models/venue_spec.rb:
--------------------------------------------------------------------------------
1 | # encoding: utf-8
2 | require "spec_helper"
3 |
4 | describe Venue do
5 |
6 | context "when validating name presence" do
7 |
8 | let(:venue) do
9 | Fabricate.build(:venue, name: nil)
10 | end
11 |
12 | before do
13 | venue.valid?
14 | end
15 |
16 | it "must be provided" do
17 | venue.errors[:name].should == [ "can't be blank" ]
18 | end
19 | end
20 | end
21 |
--------------------------------------------------------------------------------
/spec/spec_helper.rb:
--------------------------------------------------------------------------------
1 | require "rubygems"
2 |
3 | ENV["RAILS_ENV"] ||= "test"
4 |
5 | require File.expand_path("../../config/environment", __FILE__)
6 | require "rspec/rails"
7 |
8 | # Requires supporting ruby files with custom matchers and macros, etc,
9 | # in spec/support/ and its subdirectories.
10 | Dir[Rails.root.join("spec/support/**/*.rb")].each{ |f| require f }
11 |
12 | ECHO_USER = Mongo::Auth::User.new(
13 | database: Mongo::Database::ADMIN,
14 | user: 'echo-user',
15 | password: 'password',
16 | roles: [
17 | Mongo::Auth::Roles::USER_ADMIN_ANY_DATABASE,
18 | Mongo::Auth::Roles::DATABASE_ADMIN_ANY_DATABASE,
19 | Mongo::Auth::Roles::READ_WRITE_ANY_DATABASE,
20 | Mongo::Auth::Roles::HOST_MANAGER
21 | ]
22 | )
23 |
24 | RSpec.configure do |config|
25 |
26 | config.before(:suite) do
27 | client = Mongo::Client.new(["127.0.0.1:27017"])
28 | begin
29 | # Create the root user administrator as the first user to be added to the
30 | # database. This user will need to be authenticated in order to add any
31 | # more users to any other databases.
32 | client.database.users.create(ECHO_USER)
33 | rescue Exception => e
34 | end
35 | end
36 |
37 | # Clean up all collections before each spec runs.
38 | config.before do
39 | Mongoid.purge!
40 | end
41 | end
42 |
--------------------------------------------------------------------------------
/spec/support/bands/depeche-mode/depeche-mode-table.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mongoid/echo/1d28bbbd09d5cbf266520fa7aade5b16e724867d/spec/support/bands/depeche-mode/depeche-mode-table.jpg
--------------------------------------------------------------------------------
/spec/support/bands/depeche-mode/depeche-mode-universe.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mongoid/echo/1d28bbbd09d5cbf266520fa7aade5b16e724867d/spec/support/bands/depeche-mode/depeche-mode-universe.jpg
--------------------------------------------------------------------------------
/spec/support/bands/depeche-mode/depeche-mode-wall.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mongoid/echo/1d28bbbd09d5cbf266520fa7aade5b16e724867d/spec/support/bands/depeche-mode/depeche-mode-wall.jpg
--------------------------------------------------------------------------------
/spec/support/bands/depeche-mode/singles-86-98-back.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mongoid/echo/1d28bbbd09d5cbf266520fa7aade5b16e724867d/spec/support/bands/depeche-mode/singles-86-98-back.jpg
--------------------------------------------------------------------------------
/spec/support/bands/depeche-mode/singles-86-98-cover.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mongoid/echo/1d28bbbd09d5cbf266520fa7aade5b16e724867d/spec/support/bands/depeche-mode/singles-86-98-cover.jpg
--------------------------------------------------------------------------------
/vendor/plugins/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mongoid/echo/1d28bbbd09d5cbf266520fa7aade5b16e724867d/vendor/plugins/.gitkeep
--------------------------------------------------------------------------------