Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

Commit

Permalink
Merge branch 'master' of git@github.com:railsrumble/teamwnn
Browse files Browse the repository at this point in the history
  • Loading branch information
kellishaver committed Oct 19, 2008
2 parents 60ec64b + 66f1317 commit 4122f47
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/project.rb
Expand Up @@ -15,6 +15,6 @@ def to_s
end

def self.fetch(user, id_or_token)
Project.find_by_token(id_or_token) || user.projects.find(id_or_token)
Project.find_by_token(id_or_token) || (user || User.new).projects.find(id_or_token)
end
end
6 changes: 6 additions & 0 deletions spec/models/project_spec.rb
Expand Up @@ -34,4 +34,10 @@
project = Factory(:project)
Project.fetch(nil, project.token).should == project
end

it "should not beable to fetch if user is nil with bad token" do
lambda {
Project.fetch(nil, 'badtoken')
}.should raise_error(ActiveRecord::RecordNotFound)
end
end

0 comments on commit 4122f47

Please sign in to comment.