Commit edb3368c93c6ff64840ef5cd12f2af30b18b5b52
Exists in
master
and in
4 other branches
Merge pull request #5048 from Nullreff/image-diff
Fix bug with rendering changing images in commits
Showing
3 changed files
with
16 additions
and
2 deletions
Show diff stats
app/views/projects/commits/_image.html.haml
@@ -9,7 +9,7 @@ | @@ -9,7 +9,7 @@ | ||
9 | %div.two-up.view | 9 | %div.two-up.view |
10 | %span.wrap | 10 | %span.wrap |
11 | .frame.deleted | 11 | .frame.deleted |
12 | - %a{href: project_tree_path(@project, tree_join(@commit.id, diff.old_path))} | 12 | + %a{href: project_blob_path(@project, tree_join(@commit.parent_id, diff.old_path))} |
13 | %img{src: "data:#{old_file.mime_type};base64,#{Base64.encode64(old_file.data)}"} | 13 | %img{src: "data:#{old_file.mime_type};base64,#{Base64.encode64(old_file.data)}"} |
14 | %p.image-info.hide | 14 | %p.image-info.hide |
15 | %span.meta-filesize= "#{number_to_human_size old_file.size}" | 15 | %span.meta-filesize= "#{number_to_human_size old_file.size}" |
@@ -21,7 +21,7 @@ | @@ -21,7 +21,7 @@ | ||
21 | %span.meta-height | 21 | %span.meta-height |
22 | %span.wrap | 22 | %span.wrap |
23 | .frame.added | 23 | .frame.added |
24 | - %a{href: project_tree_path(@project, tree_join(@commit.id, diff.new_path))} | 24 | + %a{href: project_blob_path(@project, tree_join(@commit.id, diff.new_path))} |
25 | %img{src: "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"} | 25 | %img{src: "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"} |
26 | %p.image-info.hide | 26 | %p.image-info.hide |
27 | %span.meta-filesize= "#{number_to_human_size file.size}" | 27 | %span.meta-filesize= "#{number_to_human_size file.size}" |
features/project/commits/commits.feature
@@ -35,3 +35,7 @@ Feature: Project Browse commits | @@ -35,3 +35,7 @@ Feature: Project Browse commits | ||
35 | Scenario: I browse huge commit | 35 | Scenario: I browse huge commit |
36 | Given I visit huge commit page | 36 | Given I visit huge commit page |
37 | Then I see huge commit message | 37 | Then I see huge commit message |
38 | + | ||
39 | + Scenario: I browse a commit with an image | ||
40 | + Given I visit a commit with an image that changed | ||
41 | + Then The diff links to both the previous and current image |
features/steps/project/project_browse_commits.rb
@@ -78,4 +78,14 @@ class ProjectBrowseCommits < Spinach::FeatureSteps | @@ -78,4 +78,14 @@ class ProjectBrowseCommits < Spinach::FeatureSteps | ||
78 | page.should have_content "Warning! This is a large diff" | 78 | page.should have_content "Warning! This is a large diff" |
79 | page.should_not have_content "If you still want to see the diff" | 79 | page.should_not have_content "If you still want to see the diff" |
80 | end | 80 | end |
81 | + | ||
82 | + Given 'I visit a commit with an image that changed' do | ||
83 | + visit project_commit_path(@project, 'cc1ba255d6c5ffdce87a357ba7ccc397a4f4026b') | ||
84 | + end | ||
85 | + | ||
86 | + Then 'The diff links to both the previous and current image' do | ||
87 | + links = page.all('.two-up span div a') | ||
88 | + links[0]['href'].should =~ %r{blob/bc3735004cb45cec5e0e4fa92710897a910a5957} | ||
89 | + links[1]['href'].should =~ %r{blob/cc1ba255d6c5ffdce87a357ba7ccc397a4f4026b} | ||
90 | + end | ||
81 | end | 91 | end |