From 413a310faa17f626f351fa3afd6423e8782935a9 Mon Sep 17 00:00:00 2001
From: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Date: Wed, 3 Apr 2013 10:06:31 +0300
Subject: [PATCH] fixed blame and mr factory

---
 app/controllers/blame_controller.rb | 1 +
 app/views/blame/show.html.haml      | 6 +++---
 app/views/blob/_actions.html.haml   | 2 +-
 app/workers/post_receive.rb         | 2 +-
 features/steps/shared/paths.rb      | 2 +-
 spec/factories.rb                   | 8 +++++---
 spec/lib/git/commit_spec.rb         | 2 ++
 spec/support/matchers.rb            | 2 +-
 8 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/app/controllers/blame_controller.rb b/app/controllers/blame_controller.rb
index 310b567cfe..c950af56e2 100644
--- a/app/controllers/blame_controller.rb
+++ b/app/controllers/blame_controller.rb
@@ -8,6 +8,7 @@ class BlameController < ProjectResourceController
   before_filter :require_non_empty_project
 
   def show
+    @blob = Gitlab::Git::Blob.new(@repository, @commit.id, @ref, @path)
     @blame = Gitlab::Git::Blame.new(project.repository, @commit.id, @path)
   end
 end
diff --git a/app/views/blame/show.html.haml b/app/views/blame/show.html.haml
index 96d153e627..d4cd3ac1a3 100644
--- a/app/views/blame/show.html.haml
+++ b/app/views/blame/show.html.haml
@@ -15,9 +15,9 @@
     .file_title
       %i.icon-file
       %span.file_name
-        = @tree.name
-        %small= number_to_human_size @tree.size
-      %span.options= render "tree/blob_actions"
+        = @blob.name
+        %small= number_to_human_size @blob.size
+      %span.options= render "blob/actions"
     .file_content.blame
       %table
         - current_line = 1
diff --git a/app/views/blob/_actions.html.haml b/app/views/blob/_actions.html.haml
index c3655bfb90..1da39e72c9 100644
--- a/app/views/blob/_actions.html.haml
+++ b/app/views/blob/_actions.html.haml
@@ -6,7 +6,7 @@
   -# only show normal/blame view links for text files
   - if @blob.text?
     - if current_page? project_blame_path(@project, @id)
-      = link_to "normal view", project_tree_path(@project, @id), class: "btn btn-tiny"
+      = link_to "normal view", project_blob_path(@project, @id), class: "btn btn-tiny"
     - else
       = link_to "blame", project_blame_path(@project, @id), class: "btn btn-tiny"
   = link_to "history", project_commits_path(@project, @id), class: "btn btn-tiny"
diff --git a/app/workers/post_receive.rb b/app/workers/post_receive.rb
index 72cef0fd29..132f1a6d7e 100644
--- a/app/workers/post_receive.rb
+++ b/app/workers/post_receive.rb
@@ -23,7 +23,7 @@ class PostReceive
 
     user = if identifier.blank?
              # Local push from gitlab
-             email = project.repository.commit(newrev).author.email rescue nil
+             email = project.repository.commit(newrev).author_email rescue nil
              User.find_by_email(email) if email
 
            elsif identifier =~ /\Auser-\d+\Z/
diff --git a/features/steps/shared/paths.rb b/features/steps/shared/paths.rb
index 1af8b47815..27ca65b22d 100644
--- a/features/steps/shared/paths.rb
+++ b/features/steps/shared/paths.rb
@@ -205,7 +205,7 @@ module SharedPaths
   end
 
   Given 'I visit blob file from repo' do
-    visit project_tree_path(@project, File.join(ValidCommit::ID, ValidCommit::BLOB_FILE_PATH))
+    visit project_blob_path(@project, File.join(ValidCommit::ID, ValidCommit::BLOB_FILE_PATH))
   end
 
   Given 'I visit project source page for "8470d70"' do
diff --git a/spec/factories.rb b/spec/factories.rb
index 3205cabd15..9859fbf69c 100644
--- a/spec/factories.rb
+++ b/spec/factories.rb
@@ -86,9 +86,11 @@ FactoryGirl.define do
       target_branch "master" # pretend bcf03b5d~3
       source_branch "stable" # pretend bcf03b5d
       st_commits do
-        [Commit.new(project.repository.commit('bcf03b5d')),
-         Commit.new(project.repository.commit('bcf03b5d~1')),
-         Commit.new(project.repository.commit('bcf03b5d~2'))]
+        [
+          project.repository.commit('bcf03b5d').to_hash,
+          project.repository.commit('bcf03b5d~1').to_hash,
+          project.repository.commit('bcf03b5d~2').to_hash
+        ]
       end
       st_diffs do
         project.repo.diff("bcf03b5d~3", "bcf03b5d")
diff --git a/spec/lib/git/commit_spec.rb b/spec/lib/git/commit_spec.rb
index 475bc359a1..5f3297eea1 100644
--- a/spec/lib/git/commit_spec.rb
+++ b/spec/lib/git/commit_spec.rb
@@ -20,6 +20,8 @@ describe Gitlab::Git::Commit do
         author: @author,
         committer: @committer,
         committed_date: Date.yesterday,
+        authored_date: Date.yesterday,
+        parents: [],
         message: 'Refactoring specs'
       )
 
diff --git a/spec/support/matchers.rb b/spec/support/matchers.rb
index 29d16ecbac..15fb47004e 100644
--- a/spec/support/matchers.rb
+++ b/spec/support/matchers.rb
@@ -3,7 +3,7 @@ RSpec::Matchers.define :be_valid_commit do
     actual != nil
     actual.id == ValidCommit::ID
     actual.message == ValidCommit::MESSAGE
-    actual.author.name == ValidCommit::AUTHOR_FULL_NAME
+    actual.author_name == ValidCommit::AUTHOR_FULL_NAME
   end
 end
 
-- 
2.30.9