Commit 57c32d2047f9f5c2131424656accdf3006b508e6
Committed by
Rafael Manzo
1 parent
f672063d
Exists in
colab
and in
4 other branches
Making suggested changes
Showing
10 changed files
with
20 additions
and
8 deletions
Show diff stats
app/controllers/projects_controller.rb
... | ... | @@ -40,14 +40,13 @@ class ProjectsController < ApplicationController |
40 | 40 | def edit |
41 | 41 | set_project |
42 | 42 | @project_image = ProjectImage.find_by_project_id(@project.id) |
43 | - @project_image.check_no_image | |
43 | + @project_image ? @project_image.check_no_image : ProjectImage.new | |
44 | 44 | end |
45 | 45 | |
46 | 46 | def update |
47 | 47 | set_project |
48 | 48 | @project_image = ProjectImage.find_by_project_id(@project.id) |
49 | - if @project.update(project_params) | |
50 | - @project_image.update(image_url: project_params[:image_url]) | |
49 | + if @project.update(project_params) && @project_image.update(image_url: project_params[:image_url]) | |
51 | 50 | redirect_to(project_path(@project.id)) |
52 | 51 | else |
53 | 52 | render "edit" | ... | ... |
app/views/projects/_form.html.erb
... | ... | @@ -16,7 +16,7 @@ |
16 | 16 | <div class="form-row"> |
17 | 17 | <div class="field-container"> |
18 | 18 | <%= f.label "Image url", class: 'control-label' %><br> |
19 | - <%= f.text_field :image_url, class: 'text-area' ,value: @project_image.image_url %> | |
19 | + <%= f.text_field :image_url, class: 'text-area' ,value: @project_image.nil? ? '#' : @project_image.image_url %> | |
20 | 20 | </div> |
21 | 21 | </div> |
22 | 22 | </div> | ... | ... |
config/kalibro_gatekeeper.yml.sample
config/kalibro_processor.yml.sample
features/project/deletion.feature
... | ... | @@ -22,6 +22,7 @@ Feature: Project Deletion |
22 | 22 | Given I am a regular user |
23 | 23 | And I am signed in |
24 | 24 | And I own a sample project |
25 | + And I have a sample project_image | |
25 | 26 | And I am at the Sample Project page |
26 | 27 | When I click the Destroy Project link |
27 | 28 | Then I should be in the All Projects page | ... | ... |
features/project/edition.feature
... | ... | @@ -8,6 +8,7 @@ Feature: Project |
8 | 8 | Given I am a regular user |
9 | 9 | And I am signed in |
10 | 10 | And I own a sample project |
11 | + And I have a sample project_image | |
11 | 12 | And I am at the All Projects page |
12 | 13 | When I click the Edit link |
13 | 14 | Then I should be in the Edit Project page |
... | ... | @@ -34,6 +35,7 @@ Feature: Project |
34 | 35 | Given I am a regular user |
35 | 36 | And I am signed in |
36 | 37 | And I own a sample project |
38 | + And I have a sample project_image | |
37 | 39 | And I am at the All Projects page |
38 | 40 | When I click the Edit link |
39 | 41 | Then The field "project[name]" should be filled with the sample project "name" |
... | ... | @@ -44,6 +46,7 @@ Feature: Project |
44 | 46 | Given I am a regular user |
45 | 47 | And I am signed in |
46 | 48 | And I own a sample project |
49 | + And I have a sample project_image | |
47 | 50 | And I am at the sample project edit page |
48 | 51 | And I fill the Name field with "Kalibro" |
49 | 52 | And I fill the Description field with "Web Service to collect metrics" |
... | ... | @@ -58,6 +61,7 @@ Feature: Project |
58 | 61 | And I have a project named "Qt-Calculator" |
59 | 62 | And I own a project named "Kalibro" |
60 | 63 | And I am at the sample project edit page |
64 | + And I have a sample project_image | |
61 | 65 | And I fill the Name field with "Qt-Calculator" |
62 | 66 | When I press the Save button |
63 | 67 | Then I should see "Name There is already a Project with name Qt-Calculator!" |
... | ... | @@ -67,6 +71,7 @@ Feature: Project |
67 | 71 | Given I am a regular user |
68 | 72 | And I am signed in |
69 | 73 | And I own a sample project |
74 | + And I have a sample project_image | |
70 | 75 | And I am at the sample project edit page |
71 | 76 | And I fill the Description field with "Web Service to collect metrics" |
72 | 77 | When I press the Save button |
... | ... | @@ -77,6 +82,7 @@ Feature: Project |
77 | 82 | Given I am a regular user |
78 | 83 | And I am signed in |
79 | 84 | And I own a sample project |
85 | + And I have a sample project_image | |
80 | 86 | And I am at the sample project edit page |
81 | 87 | And I fill the Name field with " " |
82 | 88 | When I press the Save button | ... | ... |
features/project/listing.feature
... | ... | @@ -25,6 +25,7 @@ Feature: Project listing |
25 | 25 | Given I am a regular user |
26 | 26 | And I am signed in |
27 | 27 | And I have a sample project |
28 | + And I have a sample project_image | |
28 | 29 | And I am at the All Projects page |
29 | 30 | When I click the Show link |
30 | 31 | Then the sample project should be there |
31 | 32 | \ No newline at end of file | ... | ... |
features/project/show.feature
... | ... | @@ -7,6 +7,7 @@ Feature: Show Project |
7 | 7 | Scenario: Should not show the create repository link to user that doesn't own the project |
8 | 8 | Given I am a regular user |
9 | 9 | And I have a sample project |
10 | + And I have a sample project_image | |
10 | 11 | And I have a sample configuration with native metrics |
11 | 12 | And I have a sample repository within the sample project |
12 | 13 | When I am at the Sample Project page |
... | ... | @@ -19,6 +20,7 @@ Scenario: Should show the create repository link the project owner |
19 | 20 | Given I am a regular user |
20 | 21 | And I am signed in |
21 | 22 | And I own a sample project |
23 | + And I have a sample project_image | |
22 | 24 | When I am at the Sample Project page |
23 | 25 | Then I should see "New Repository" |
24 | 26 | |
... | ... | @@ -26,6 +28,7 @@ Scenario: Should show the create repository link the project owner |
26 | 28 | @kalibro_processor_restart |
27 | 29 | Scenario: Considering the project has no repositories |
28 | 30 | Given I have a sample project |
31 | + And I have a sample project_image | |
29 | 32 | When I am at the Sample Project page |
30 | 33 | Then I should see "There are no Repositories yet!" |
31 | 34 | |
... | ... | @@ -40,5 +43,6 @@ Scenario: Considering the project has repositories |
40 | 43 | @kalibro_processor_restart |
41 | 44 | Scenario: Checking project contents |
42 | 45 | Given I have a sample project |
46 | + And I have a sample project_image | |
43 | 47 | When I am at the Sample Project page |
44 | 48 | Then the sample project should be there | ... | ... |
features/step_definitions/project_steps.rb
... | ... | @@ -8,6 +8,10 @@ Given(/^I have a sample project$/) do |
8 | 8 | @project = FactoryGirl.create(:project, {id: nil}) |
9 | 9 | end |
10 | 10 | |
11 | +Given(/^I have a sample project_image$/) do | |
12 | + @project_image = FactoryGirl.create(:project_image, {id: nil}) | |
13 | +end | |
14 | + | |
11 | 15 | Given(/^I have a project named "(.*?)"$/) do |name| |
12 | 16 | @project = FactoryGirl.create(:project, {id: nil, name: name}) |
13 | 17 | end | ... | ... |
spec/factories/projects.rb