Skip to content

Commit

Permalink
Merge pull request hotsh#641 from carols10cents/author_image_url
Browse files Browse the repository at this point in the history
Use image_url as the variable/attribute name consistently in Author
  • Loading branch information
wilkie committed Sep 10, 2012
2 parents bc2bf60 + 655f400 commit 91c821f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 14 deletions.
28 changes: 14 additions & 14 deletions app/models/author.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def self.create_from_hash!(hash, domain)
username = user['username']
website = user['urls']['Website']
bio = user['description']
image = user['image']
image_url = user['image']
remote = user['url']

# Creates an Author object with the details
Expand All @@ -84,31 +84,31 @@ def self.create_from_hash!(hash, domain)
username: username,
website: website,
bio: bio,
image_url: image,
image_url: image_url,
remote_url: remote,
domain: domain
)
end

def self.new_from_session!(session, params, domain)
new(
:name => session[:name],
:username => params[:username],
:website => session[:website],
:bio => session[:description],
:image => session[:image],
:domain => domain
:name => session[:name],
:username => params[:username],
:website => session[:website],
:bio => session[:description],
:image_url => session[:image],
:domain => domain
)
end

def self.create_from_session!(session, params, domain)
create!(
:name => session[:name],
:username => params[:username],
:website => session[:website],
:bio => session[:description],
:image => session[:image],
:domain => domain
:name => session[:name],
:username => params[:username],
:website => session[:website],
:bio => session[:description],
:image_url => session[:image],
:domain => domain
)
end

Expand Down
19 changes: 19 additions & 0 deletions test/models/author_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,25 @@
assert Author.create_from_hash!(hash, "rstat.us").is_a?(Author)
end

describe "new_from_session!" do
it "has an image_url if the session has image" do
session_hash = {:image => "foo.png"}
a = Author.new_from_session!(session_hash, {}, "http://example.com")
a.save!

a.image_url.must_equal "foo.png"
end
end

describe "create_from_session!" do
it "has an image_url if the session has image" do
session_hash = {:image => "foo.png"}
a = Author.create_from_session!(session_hash, {}, "http://example.com")

a.image_url.must_equal "foo.png"
end
end

it "stores the domain of a local user by normalizing the base url" do
@author.domain = "http://example.com/"
@author.save
Expand Down

0 comments on commit 91c821f

Please sign in to comment.