# HG changeset patch # User Jakob Skjerning # Date 1249307864 -7200 # Node ID fc9019211859bb7fbdc476abbee77ba09c8baad1 # Parent 55f2042ef79597c7684bd65efcdadd278a58ede1 Clean up the tests a bit diff -r 55f2042ef79597c7684bd65efcdadd278a58ede1 -r fc9019211859bb7fbdc476abbee77ba09c8baad1 app/controllers/github_hook_controller.rb --- a/app/controllers/github_hook_controller.rb Mon Aug 03 15:50:28 2009 +0200 +++ b/app/controllers/github_hook_controller.rb Mon Aug 03 15:57:44 2009 +0200 @@ -6,13 +6,14 @@ payload = JSON.parse(params[:payload]) logger.debug { "Received from Github: #{payload.inspect}" } + # For now, we assume that the repository name is the same as the project identifier identifier = payload['repository']['name'] - # For now, we assume that the repository name is the same as the project identifier + project = Project.find_by_identifier(identifier) raise ActiveRecord::RecordNotFound, "No project found with identifier '#{identifier}'" if project.nil? - raise TypeError, "Project '#{identifier}' has no repository" if project.repository.nil? repository = project.repository + raise TypeError, "Project '#{identifier}' has no repository" if repository.nil? raise TypeError, "Repository for project '#{identifier}' is not a Git repository" unless repository.is_a?(Repository::Git) # Get updates from the Github repository diff -r 55f2042ef79597c7684bd65efcdadd278a58ede1 -r fc9019211859bb7fbdc476abbee77ba09c8baad1 test/functional/github_hook_controller_test.rb --- a/test/functional/github_hook_controller_test.rb Mon Aug 03 15:50:28 2009 +0200 +++ b/test/functional/github_hook_controller_test.rb Mon Aug 03 15:57:44 2009 +0200 @@ -46,12 +46,14 @@ "after": "de8251ff97ee194a289832576287d6f8ad74e3d0", "ref": "refs/heads/master" }' - @project = Project.first @repository = Repository::Git.new @repository.stubs(:fetch_changesets).returns(true) - @project.expects(:repository).at_least(1).returns(@repository) + + @project = Project.new + @project.stubs(:repository).returns(@repository) + Project.stubs(:find_by_identifier).with('github').returns(@project) @controller.stubs(:exec) - Project.stubs(:find_by_identifier).with('github').returns(@project) + Repository.expects(:fetch_changesets).never end