Skip to content
This repository has been archived by the owner on Jul 19, 2021. It is now read-only.

Commit

Permalink
FIX tests
Browse files Browse the repository at this point in the history
  • Loading branch information
a-barbieri committed Feb 6, 2018
1 parent 2bbd52c commit fa053a3
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
binda (0.1.5)
binda (0.1.6)
aasm (>= 4.11, < 4.13)
ancestry (>= 2.1, < 3.1)
bourbon (= 4.3.4)
Expand Down
6 changes: 6 additions & 0 deletions app/models/binda/image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ class Image < Asset

mount_uploader :image, ImageUploader

# Register image details
#
# This method is used by a rake task
def register_deatils
if !self.image.present?
puts "Ops, there is no image for Binda::Image id=#{self.id}"
Expand All @@ -16,6 +19,9 @@ def register_deatils
end
end

# Register image details
#
# This method is used by register_deatils in a rake task
def register_details_of(file)
self.file_width = file.width
self.file_height = file.height
Expand Down
4 changes: 2 additions & 2 deletions app/models/concerns/binda/fieldable_association_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def get_image_info(field_slug, size, info)
# Get image size
#
# @param field_slug [string] The slug of the field setting
# @return [string] with image type
# @return [float] with image type
def get_image_size(field_slug)
obj = self.images.find{ |t| t.field_setting_id == FieldSetting.get_id( field_slug ) }
return bytes_to_megabytes(obj.file_size)
Expand All @@ -165,7 +165,7 @@ def get_image_mime_type(field_slug)
# Get image dimension
#
# @param field_slug [string] The slug of the field setting
# @return [hash] with width and height
# @return [hash] with width and height as floats
def get_image_dimension(field_slug)
obj = self.images.find{ |t| t.field_setting_id == FieldSetting.get_id( field_slug ) }
return { width: obj.file_width, height: obj.file_height }
Expand Down
7 changes: 3 additions & 4 deletions config/initializers/simple_form__fileupload.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,14 @@ def detail(wrapper_options = nil)
html << '<p class="fileupload--size">'
html << "<strong>#{t 'binda.filesize'}:</strong> "
html << '<span class="fileupload--filesize">'
html << bytes_to_megabytes(obj.file_size).to_s if obj.image.present? && !obj.file_size.blank?
html << bytes_to_megabytes(obj.file_size).to_s if obj.video.present? && !obj.file_size.blank?
html << bytes_to_megabytes(obj.file_size).to_s unless obj.file_size.blank?
html << 'MB</span></p>'
html << '<p class="fileupload--dimension">'
html << "<strong>#{t 'binda.filedimension'}:</strong> "
html << '<span class="fileupload--width">'
html << obj.file_width.round.to_s unless obj.image.present? && obj.file_width.blank?
html << obj.file_width.round.to_s unless obj.file_width.blank?
html << '</span> x <span class="fileupload--height">'
html << obj.file_height.round.to_s unless obj.image.present? && obj.file_height.blank?
html << obj.file_height.round.to_s unless obj.file_height.blank?
html << '</span> px</p>'
html << '<p class="fileupload--videolink"><a href="'
html << obj.video.url if obj.video.present?
Expand Down
2 changes: 1 addition & 1 deletion lib/binda/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Binda
VERSION = '0.1.5'.freeze
VERSION = '0.1.6'.freeze
end
5 changes: 5 additions & 0 deletions spec/features/components_edit_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require "rails_helper"

describe "GET component#edit", type: :feature, js: true do
include CarrierWave::Test::Matchers

let(:user){ Binda::User.first }

Expand Down Expand Up @@ -101,6 +102,8 @@
end

it "allows to add an image to an image field and store it" do
Binda::Image::ImageUploader.enable_processing = true

# Create an image field setting on which will work
image_setting = create(:image_setting, field_group_id: @structure.field_groups.first.id)

Expand Down Expand Up @@ -143,6 +146,8 @@
expect( page ).to have_content image_name
expect( page ).to have_content file.width
end

Binda::Image::ImageUploader.enable_processing = false
end

it "allows to add an image to an image field in a repeater" do
Expand Down

0 comments on commit fa053a3

Please sign in to comment.