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,6 +8,7 @@ class ProjectsController < ApplicationController | ||
| 8 | # GET /projects/new | 8 | # GET /projects/new |
| 9 | def new | 9 | def new |
| 10 | @project = Project.new | 10 | @project = Project.new |
| 11 | + @project_image = ProjectImage.new | ||
| 11 | end | 12 | end |
| 12 | 13 | ||
| 13 | # GET /projects | 14 | # GET /projects |
| @@ -31,7 +32,7 @@ class ProjectsController < ApplicationController | @@ -31,7 +32,7 @@ class ProjectsController < ApplicationController | ||
| 31 | def show | 32 | def show |
| 32 | set_project | 33 | set_project |
| 33 | @project_repositories = @project.repositories | 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 | end | 36 | end |
| 36 | 37 | ||
| 37 | # GET /projects/1/edit | 38 | # GET /projects/1/edit |
| @@ -98,13 +99,19 @@ class ProjectsController < ApplicationController | @@ -98,13 +99,19 @@ class ProjectsController < ApplicationController | ||
| 98 | if url.blank? | 99 | if url.blank? |
| 99 | url = "no-image-available.png" | 100 | url = "no-image-available.png" |
| 100 | end | 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 | end | 106 | end |
| 103 | 107 | ||
| 104 | def check_no_image project_id | 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 | end | 115 | end |
| 109 | end | 116 | end |
| 110 | 117 |
app/views/projects/_form.html.erb
| @@ -20,7 +20,7 @@ | @@ -20,7 +20,7 @@ | ||
| 20 | <div class="form-row"> | 20 | <div class="form-row"> |
| 21 | <div class="field-container"> | 21 | <div class="field-container"> |
| 22 | <%= f.label "Image url", class: 'control-label' %><br> | 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 | </div> | 24 | </div> |
| 25 | </div> | 25 | </div> |
| 26 | 26 |
app/views/projects/edit.html.erb
app/views/projects/show.html.erb
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | <div class="page-header"> | 2 | <div class="page-header"> |
| 3 | <div class="media"> | 3 | <div class="media"> |
| 4 | <a class="pull-left"> | 4 | <a class="pull-left"> |
| 5 | - <%= image_tag "#{@project_image}", size:"64x64" %> | 5 | + <%= image_tag "#{@project_image.image_url}", size:"64x64" %> |
| 6 | </a> | 6 | </a> |
| 7 | <div class="media-body"> | 7 | <div class="media-body"> |
| 8 | <h4 class="media-heading"> | 8 | <h4 class="media-heading"> |
spec/factories/projects.rb
| @@ -5,6 +5,7 @@ FactoryGirl.define do | @@ -5,6 +5,7 @@ FactoryGirl.define do | ||
| 5 | id 1 | 5 | id 1 |
| 6 | name "QT Calculator" | 6 | name "QT Calculator" |
| 7 | description "A simple calculator for us." | 7 | description "A simple calculator for us." |
| 8 | + image_url "example" | ||
| 8 | end | 9 | end |
| 9 | 10 | ||
| 10 | factory :another_project, class: Project do | 11 | factory :another_project, class: Project do |