Commit bee9ea0a3e8951ebfbb985a99fcf0cfdc3afede8
Committed by
Rafael Manzo
1 parent
2217176f
Exists in
colab
and in
4 other branches
Fix broken tests
Signed-off-by: Vinicius Franco <viniciusf.arantes@gmail.com> Signed-off-by: Thiago Ribeiro <thiagitosouza@hotmail.com>
Showing
5 changed files
with
15 additions
and
15 deletions
Show diff stats
app/controllers/projects_controller.rb
| ... | ... | @@ -8,6 +8,7 @@ class ProjectsController < ApplicationController |
| 8 | 8 | # GET /projects/new |
| 9 | 9 | def new |
| 10 | 10 | @project = Project.new |
| 11 | + @project_image = ProjectImage.new | |
| 11 | 12 | end |
| 12 | 13 | |
| 13 | 14 | # GET /projects |
| ... | ... | @@ -31,7 +32,7 @@ class ProjectsController < ApplicationController |
| 31 | 32 | def show |
| 32 | 33 | set_project |
| 33 | 34 | @project_repositories = @project.repositories |
| 34 | - @project_image = ProjectImage.find_by_project_id(@project.id).image_url | |
| 35 | + @project_image = ProjectImage.find_by_project_id(@project.id) | |
| 35 | 36 | end |
| 36 | 37 | |
| 37 | 38 | # GET /projects/1/edit |
| ... | ... | @@ -98,13 +99,19 @@ class ProjectsController < ApplicationController |
| 98 | 99 | if url.blank? |
| 99 | 100 | url = "no-image-available.png" |
| 100 | 101 | end |
| 101 | - ProjectImage.find_by_project_id(project_id).update(image_url: url) | |
| 102 | + @project_image = ProjectImage.find_by_project_id(project_id) | |
| 103 | + if !@project_image.blank? | |
| 104 | + @project_image.update(image_url: url) | |
| 105 | + end | |
| 102 | 106 | end |
| 103 | 107 | |
| 104 | 108 | def check_no_image project_id |
| 105 | - @project_image = ProjectImage.find_by_project_id(project_id).image_url | |
| 106 | - if @project_image == "no-image-available.png" | |
| 107 | - @project_image = "" | |
| 109 | + @project_image = ProjectImage.find_by_project_id(project_id) | |
| 110 | + | |
| 111 | + if !@project_image.blank? | |
| 112 | + if @project_image.image_url == "no-image-available.png" | |
| 113 | + @project_image.image_url = "" | |
| 114 | + end | |
| 108 | 115 | end |
| 109 | 116 | end |
| 110 | 117 | ... | ... |
app/views/projects/_form.html.erb
| ... | ... | @@ -20,7 +20,7 @@ |
| 20 | 20 | <div class="form-row"> |
| 21 | 21 | <div class="field-container"> |
| 22 | 22 | <%= f.label "Image url", class: 'control-label' %><br> |
| 23 | - <%= f.text_field :image_url, class: 'text-area', value: @project_image %> | |
| 23 | + <%= f.text_field :image_url, class: 'text-area' ,value: @project_image.image_url %> | |
| 24 | 24 | </div> |
| 25 | 25 | </div> |
| 26 | 26 | ... | ... |
app/views/projects/edit.html.erb
app/views/projects/show.html.erb
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | <div class="page-header"> |
| 3 | 3 | <div class="media"> |
| 4 | 4 | <a class="pull-left"> |
| 5 | - <%= image_tag "#{@project_image}", size:"64x64" %> | |
| 5 | + <%= image_tag "#{@project_image.image_url}", size:"64x64" %> | |
| 6 | 6 | </a> |
| 7 | 7 | <div class="media-body"> |
| 8 | 8 | <h4 class="media-heading"> | ... | ... |