Commit 7815bba39a668709ab38b81819a719f7e2f337de
1 parent
4187ef90
Exists in
colab
and in
4 other branches
Renamed ProjectImage image_url to url
Showing
9 changed files
with
17 additions
and
29 deletions
Show diff stats
app/controllers/projects_controller.rb
@@ -23,7 +23,7 @@ class ProjectsController < ApplicationController | @@ -23,7 +23,7 @@ class ProjectsController < ApplicationController | ||
23 | @project = Project.new(project_params) | 23 | @project = Project.new(project_params) |
24 | respond_to do |format| | 24 | respond_to do |format| |
25 | create_and_redir(format) | 25 | create_and_redir(format) |
26 | - ProjectImage.create(image_url: project_params[:image_url],project_id: @project.id ) | 26 | + ProjectImage.create(url: project_params[:url],project_id: @project.id ) |
27 | end | 27 | end |
28 | end | 28 | end |
29 | 29 | ||
@@ -46,7 +46,7 @@ class ProjectsController < ApplicationController | @@ -46,7 +46,7 @@ class ProjectsController < ApplicationController | ||
46 | def update | 46 | def update |
47 | set_project | 47 | set_project |
48 | @project_image = ProjectImage.find_by_project_id(@project.id) | 48 | @project_image = ProjectImage.find_by_project_id(@project.id) |
49 | - if @project.update(project_params) && @project_image.update(image_url: project_params[:image_url]) | 49 | + if @project.update(project_params) && @project_image.update(url: project_params[:image_url]) |
50 | redirect_to(project_path(@project.id)) | 50 | redirect_to(project_path(@project.id)) |
51 | else | 51 | else |
52 | render "edit" | 52 | render "edit" |
app/models/project.rb
@@ -3,7 +3,7 @@ require "validators/kalibro_uniqueness_validator.rb" | @@ -3,7 +3,7 @@ require "validators/kalibro_uniqueness_validator.rb" | ||
3 | class Project < KalibroGatekeeperClient::Entities::Project | 3 | class Project < KalibroGatekeeperClient::Entities::Project |
4 | include KalibroRecord | 4 | include KalibroRecord |
5 | 5 | ||
6 | - attr_accessor :name,:image_url | 6 | + attr_accessor :name |
7 | validates :name, presence: true, kalibro_uniqueness: true | 7 | validates :name, presence: true, kalibro_uniqueness: true |
8 | 8 | ||
9 | def repositories | 9 | def repositories |
app/views/projects/_form.html.erb
@@ -17,7 +17,7 @@ | @@ -17,7 +17,7 @@ | ||
17 | <div class="form-row"> | 17 | <div class="form-row"> |
18 | <div class="field-container"> | 18 | <div class="field-container"> |
19 | <%= f.label "Image url", class: 'control-label' %><br> | 19 | <%= f.label "Image url", class: 'control-label' %><br> |
20 | - <%= f.text_field :image_url, class: 'text-area' ,value: @project_image.nil? ? '#' : @project_image.image_url %> | 20 | + <%= f.text_field :image_url, class: 'text-area' ,value: @project_image.nil? ? '#' : @project_image.url %> |
21 | </div> | 21 | </div> |
22 | </div> | 22 | </div> |
23 | </div> | 23 | </div> |
app/views/projects/show.html.erb
@@ -2,8 +2,8 @@ | @@ -2,8 +2,8 @@ | ||
2 | <div class="page-header"> | 2 | <div class="page-header"> |
3 | <div class="row"> | 3 | <div class="row"> |
4 | <div class="col-md-2"> | 4 | <div class="col-md-2"> |
5 | - <% if @project_image && !@project_image.image_url.empty? %> | ||
6 | - <%= image_tag "#{@project_image.image_url}", size:"128x128" %> | 5 | + <% if @project_image && !@project_image.url.empty? %> |
6 | + <%= image_tag "#{@project_image.url}", size:"128x128" %> | ||
7 | <% else %> | 7 | <% else %> |
8 | <center><i class="fa fa-file-image-o fa-5x"></i></center><br /> | 8 | <center><i class="fa fa-file-image-o fa-5x"></i></center><br /> |
9 | No image available | 9 | No image available |
db/migrate/20141119173020_rename_project_image_image_url_to_url.rb
0 → 100644
db/schema.rb
@@ -11,7 +11,7 @@ | @@ -11,7 +11,7 @@ | ||
11 | # | 11 | # |
12 | # It's strongly recommended that you check this file into your version control system. | 12 | # It's strongly recommended that you check this file into your version control system. |
13 | 13 | ||
14 | -ActiveRecord::Schema.define(version: 20141006232631) do | 14 | +ActiveRecord::Schema.define(version: 20141119173020) do |
15 | 15 | ||
16 | create_table "mezuro_configuration_ownerships", force: true do |t| | 16 | create_table "mezuro_configuration_ownerships", force: true do |t| |
17 | t.integer "user_id" | 17 | t.integer "user_id" |
@@ -22,7 +22,7 @@ ActiveRecord::Schema.define(version: 20141006232631) do | @@ -22,7 +22,7 @@ ActiveRecord::Schema.define(version: 20141006232631) do | ||
22 | 22 | ||
23 | create_table "project_images", force: true do |t| | 23 | create_table "project_images", force: true do |t| |
24 | t.integer "project_id" | 24 | t.integer "project_id" |
25 | - t.string "image_url" | 25 | + t.string "url" |
26 | t.datetime "created_at" | 26 | t.datetime "created_at" |
27 | t.datetime "updated_at" | 27 | t.datetime "updated_at" |
28 | end | 28 | end |
spec/factories/project_images.rb
@@ -3,10 +3,10 @@ | @@ -3,10 +3,10 @@ | ||
3 | FactoryGirl.define do | 3 | FactoryGirl.define do |
4 | factory :project_image do | 4 | factory :project_image do |
5 | project_id 1 | 5 | project_id 1 |
6 | - image_url "Example" | 6 | + url "Example" |
7 | end | 7 | end |
8 | 8 | ||
9 | factory :project_no_image, class: ProjectImage do | 9 | factory :project_no_image, class: ProjectImage do |
10 | - image_url nil | 10 | + url nil |
11 | end | 11 | end |
12 | end | 12 | end |
spec/factories/projects.rb
@@ -5,7 +5,6 @@ FactoryGirl.define do | @@ -5,7 +5,6 @@ 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 { FactoryGirl.build(:project_image) } | ||
9 | end | 8 | end |
10 | 9 | ||
11 | factory :another_project, class: Project do | 10 | factory :another_project, class: Project do |
spec/models/project_image_spec.rb
@@ -3,23 +3,5 @@ require 'rails_helper' | @@ -3,23 +3,5 @@ require 'rails_helper' | ||
3 | RSpec.describe ProjectImage, :type => :model do | 3 | RSpec.describe ProjectImage, :type => :model do |
4 | describe 'associations' do | 4 | describe 'associations' do |
5 | it { is_expected.to belong_to(:project) } | 5 | it { is_expected.to belong_to(:project) } |
6 | - it { should belong_to(:project) } | ||
7 | - end | ||
8 | - | ||
9 | - describe 'methods' do | ||
10 | - | ||
11 | - it 'should validate url blank' do | ||
12 | - @project_no_image = FactoryGirl.create(:project_no_image) | ||
13 | - expect(@project_no_image.image_url).to eq("no-image-available.png") | ||
14 | - end | ||
15 | - | ||
16 | - it "Can be assigns" do | ||
17 | - expect(ProjectImage.new).to be_an_instance_of(ProjectImage) | ||
18 | - end | ||
19 | - | ||
20 | - it 'should validate url field' do | ||
21 | - @project_no_image = FactoryGirl.create(:project_no_image) | ||
22 | - expect(@project_no_image.check_no_image).to eq("") | ||
23 | - end | ||
24 | end | 6 | end |
25 | end | 7 | end |