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 | 23 | @project = Project.new(project_params) |
| 24 | 24 | respond_to do |format| |
| 25 | 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 | 27 | end |
| 28 | 28 | end |
| 29 | 29 | |
| ... | ... | @@ -46,7 +46,7 @@ class ProjectsController < ApplicationController |
| 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) && @project_image.update(image_url: project_params[:image_url]) | |
| 49 | + if @project.update(project_params) && @project_image.update(url: project_params[:image_url]) | |
| 50 | 50 | redirect_to(project_path(@project.id)) |
| 51 | 51 | else |
| 52 | 52 | render "edit" | ... | ... |
app/models/project.rb
| ... | ... | @@ -3,7 +3,7 @@ require "validators/kalibro_uniqueness_validator.rb" |
| 3 | 3 | class Project < KalibroGatekeeperClient::Entities::Project |
| 4 | 4 | include KalibroRecord |
| 5 | 5 | |
| 6 | - attr_accessor :name,:image_url | |
| 6 | + attr_accessor :name | |
| 7 | 7 | validates :name, presence: true, kalibro_uniqueness: true |
| 8 | 8 | |
| 9 | 9 | def repositories | ... | ... |
app/views/projects/_form.html.erb
| ... | ... | @@ -17,7 +17,7 @@ |
| 17 | 17 | <div class="form-row"> |
| 18 | 18 | <div class="field-container"> |
| 19 | 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 | 21 | </div> |
| 22 | 22 | </div> |
| 23 | 23 | </div> | ... | ... |
app/views/projects/show.html.erb
| ... | ... | @@ -2,8 +2,8 @@ |
| 2 | 2 | <div class="page-header"> |
| 3 | 3 | <div class="row"> |
| 4 | 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 | 7 | <% else %> |
| 8 | 8 | <center><i class="fa fa-file-image-o fa-5x"></i></center><br /> |
| 9 | 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 | 11 | # |
| 12 | 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 | 16 | create_table "mezuro_configuration_ownerships", force: true do |t| |
| 17 | 17 | t.integer "user_id" |
| ... | ... | @@ -22,7 +22,7 @@ ActiveRecord::Schema.define(version: 20141006232631) do |
| 22 | 22 | |
| 23 | 23 | create_table "project_images", force: true do |t| |
| 24 | 24 | t.integer "project_id" |
| 25 | - t.string "image_url" | |
| 25 | + t.string "url" | |
| 26 | 26 | t.datetime "created_at" |
| 27 | 27 | t.datetime "updated_at" |
| 28 | 28 | end | ... | ... |
spec/factories/project_images.rb
spec/factories/projects.rb
spec/models/project_image_spec.rb
| ... | ... | @@ -3,23 +3,5 @@ require 'rails_helper' |
| 3 | 3 | RSpec.describe ProjectImage, :type => :model do |
| 4 | 4 | describe 'associations' do |
| 5 | 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 | 6 | end |
| 25 | 7 | end | ... | ... |