Skip to content

Commit

Permalink
wip - something is not working
Browse files Browse the repository at this point in the history
  • Loading branch information
alxndr committed Jul 1, 2013
1 parent b06931a commit 16d7dff
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 44 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -4,6 +4,8 @@
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile '~/.gitignore_global'

/coverage/

# Ignore bundler config.
/.bundle

Expand Down
9 changes: 0 additions & 9 deletions app/models/album.rb

This file was deleted.

5 changes: 3 additions & 2 deletions app/models/artist.rb
Expand Up @@ -5,6 +5,8 @@ class Artist < ActiveRecord::Base
has_many :songs

def fetch_data
Rails.logger.info '*'*18
Rails.logger.info "fetch_data, #{self.inspect}"
raise 'no input' unless name && name.present?
@artist_data = fetch_data_for_artist(name) or raise('artist not found')
self
Expand Down Expand Up @@ -65,9 +67,8 @@ def lyrem(opts)
def fetch_new_song_lyrics
lyrics, i = [], 0
until lyrics.present? || i > 5
new_song = Song.new(name: pick_new_song_name)
new_song = Song.new(name: pick_new_song_name, artist: self)
songs_fetched << new_song
self.songs << new_song
lyrics = process_lyrics(fetch_lyrics(display_name, new_song))
i += 1 # TODO better way of covering potential infloop
end
Expand Down
5 changes: 3 additions & 2 deletions app/models/song.rb
Expand Up @@ -3,7 +3,8 @@ class Song < ActiveRecord::Base
attr_accessor :name
attr_accessor :lyrics

belongs_to :album
# has one artist through album ?
belongs_to :artist

validates :artist, presence: true

end
12 changes: 0 additions & 12 deletions db/migrate/20130621050208_create_albums.rb

This file was deleted.

2 changes: 1 addition & 1 deletion db/migrate/20130624024221_create_songs.rb
Expand Up @@ -3,7 +3,7 @@ class CreateSongs < ActiveRecord::Migration
def change
create_table :songs do |t|
t.string :name
t.references :album
t.references :artist
t.string :lyrics

t.timestamps
Expand Down
13 changes: 2 additions & 11 deletions db/schema.rb
Expand Up @@ -11,27 +11,18 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20130624024221) do
ActiveRecord::Schema.define(version: 20130630231033) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"

create_table "albums", force: true do |t|
t.string "name"
t.integer "artist_id"
t.datetime "created_at"
t.datetime "updated_at"
end

add_index "albums", ["artist_id"], name: "index_albums_on_artist_id", using: :btree

create_table "artists", force: true do |t|
t.string "name", null: false
end

create_table "songs", force: true do |t|
t.string "name"
t.integer "album_id"
t.integer "artist_id"
t.string "lyrics"
t.datetime "created_at"
t.datetime "updated_at"
Expand Down
7 changes: 0 additions & 7 deletions spec/models/album_spec.rb

This file was deleted.

8 changes: 8 additions & 0 deletions spec/models/song_spec.rb
@@ -0,0 +1,8 @@
require 'spec_helper'

describe Song do

it { should belong_to :artist }
it { should validate_presence_of :artist }

end

0 comments on commit 16d7dff

Please sign in to comment.