Commits

Jakob Skjerning  committed fc90192

Clean up the tests a bit

  • Participants
  • Parent commits 55f2042

Comments (0)

Files changed (2)

File app/controllers/github_hook_controller.rb

     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

File test/functional/github_hook_controller_test.rb

       "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