Skip to content

Commit

Permalink
Upgrade carrierwave to version 2.1 (#7213)
Browse files Browse the repository at this point in the history
  • Loading branch information
alecslupu authored and andreslucena committed Feb 3, 2021
1 parent 9291d03 commit fffd381
Show file tree
Hide file tree
Showing 27 changed files with 218 additions and 111 deletions.
74 changes: 47 additions & 27 deletions Gemfile.lock
Expand Up @@ -74,7 +74,7 @@ PATH
autoprefixer-rails (~> 8.0)
batch-loader (~> 1.2)
browser (~> 2.7)
carrierwave (~> 1.3)
carrierwave (~> 2.1)
cells-erb (~> 0.1.0)
cells-rails (~> 0.0.9)
charlock_holmes (~> 0.7)
Expand All @@ -87,6 +87,7 @@ PATH
doorkeeper-i18n (~> 4.0)
etherpad-lite (~> 0.3)
file_validators (~> 2.1)
fog-local
foundation-rails (~> 6.6, < 6.7)
foundation_rails_helper (~> 3.0)
geocoder (>= 1.5)
Expand Down Expand Up @@ -308,18 +309,21 @@ GEM
browser (2.7.1)
builder (3.2.4)
byebug (11.1.3)
capybara (3.34.0)
capybara (3.35.0)
addressable
mini_mime (>= 0.1.3)
nokogiri (~> 1.8)
rack (>= 1.6.0)
rack-test (>= 0.6.3)
regexp_parser (~> 1.5)
regexp_parser (>= 1.5, < 3.0)
xpath (~> 3.2)
carrierwave (1.3.1)
activemodel (>= 4.0.0)
activesupport (>= 4.0.0)
mime-types (>= 1.16)
carrierwave (2.1.0)
activemodel (>= 5.0.0)
activesupport (>= 5.0.0)
addressable (~> 2.6)
image_processing (~> 1.1)
mimemagic (>= 0.3.0)
mini_mime (>= 0.1.3)
cells (4.1.7)
declarative-builder (< 0.2.0)
declarative-option (< 0.2.0)
Expand All @@ -332,7 +336,7 @@ GEM
actionpack (>= 3.0)
cells (>= 4.1.6, < 5.0.0)
charlock_holmes (0.7.7)
chef-utils (16.8.14)
chef-utils (16.9.29)
childprocess (3.0.0)
coercible (1.0.0)
descendants_tracker (~> 0.0.1)
Expand All @@ -346,9 +350,10 @@ GEM
colorize (0.8.1)
concurrent-ruby (1.1.7)
cookiejar (0.3.3)
crack (0.4.4)
crack (0.4.5)
rexml
crass (1.0.6)
css_parser (1.7.1)
css_parser (1.8.0)
addressable
date_validator (0.9.0)
activemodel
Expand Down Expand Up @@ -400,13 +405,13 @@ GEM
em-synchrony (1.0.6)
eventmachine (>= 1.0.0.beta.1)
equalizer (0.0.11)
erb_lint (0.0.35)
erb_lint (0.0.37)
activesupport
better_html (~> 1.0.7)
html_tokenizer
parser (>= 2.7.1.4)
rainbow
rubocop (~> 0.79)
rubocop
smart_properties
erbse (0.1.4)
temple
Expand All @@ -415,6 +420,7 @@ GEM
rest-client (>= 1.6)
eventmachine (1.2.7)
eventmachine_httpserver (0.2.1)
excon (0.78.1)
execjs (2.7.0)
factory_bot (4.11.1)
activesupport (>= 3.0.0)
Expand All @@ -431,6 +437,14 @@ GEM
file_validators (2.3.0)
activemodel (>= 3.2)
mime-types (>= 1.0)
fog-core (2.2.3)
builder
excon (~> 0.71)
formatador (~> 0.2)
mime-types
fog-local (0.6.0)
fog-core (>= 1.27, < 3.0)
formatador (0.2.5)
foundation-rails (6.6.2.0)
railties (>= 3.1.0)
sass (>= 3.3.0)
Expand Down Expand Up @@ -480,6 +494,9 @@ GEM
ice_cube (~> 0.16)
ice_cube (0.16.3)
ice_nine (0.11.2)
image_processing (1.12.1)
mini_magick (>= 4.9.5, < 5)
ruby-vips (>= 2.0.17, < 3)
invisible_captcha (0.13.0)
rails (>= 3.2.0)
jquery-rails (4.4.0)
Expand Down Expand Up @@ -532,9 +549,9 @@ GEM
method_source (1.0.0)
mime-types (3.3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2020.0512)
mime-types-data (3.2020.1104)
mimemagic (0.3.5)
mini_magick (4.10.1)
mini_magick (4.11.0)
mini_mime (1.0.2)
mini_portile2 (2.5.0)
minitest (5.14.2)
Expand All @@ -554,7 +571,7 @@ GEM
nokogiri (1.11.1)
mini_portile2 (~> 2.5.0)
racc (~> 1.4)
oauth (0.5.4)
oauth (0.5.5)
oauth2 (1.4.4)
faraday (>= 0.8, < 2.0)
jwt (>= 1.0, < 3.0)
Expand All @@ -566,16 +583,17 @@ GEM
rack (>= 1.6.2, < 3)
omniauth-facebook (5.0.0)
omniauth-oauth2 (~> 1.2)
omniauth-google-oauth2 (0.8.0)
omniauth-google-oauth2 (0.8.1)
jwt (>= 2.0)
oauth2 (~> 1.1)
omniauth (>= 1.1.1)
omniauth-oauth2 (>= 1.6)
omniauth-oauth (1.1.0)
oauth
omniauth (~> 1.0)
omniauth-oauth2 (1.7.0)
omniauth-oauth2 (1.7.1)
oauth2 (~> 1.4)
omniauth (~> 1.9)
omniauth (>= 1.9, < 3)
omniauth-rails_csrf_protection (0.1.2)
actionpack (>= 4.2)
omniauth (>= 1.3.1)
Expand All @@ -592,7 +610,7 @@ GEM
parser (2.7.2.0)
ast (~> 2.4.1)
pg (1.1.4)
pg_search (2.3.3)
pg_search (2.3.5)
activerecord (>= 5.2)
activesupport (>= 5.2)
premailer (1.14.2)
Expand All @@ -603,7 +621,7 @@ GEM
actionmailer (>= 3)
premailer (~> 1.7, >= 1.7.9)
public_suffix (4.0.6)
puffing-billy (2.4.0)
puffing-billy (2.4.1)
addressable (~> 2.5)
em-http-request (~> 1.1, >= 1.1.0)
em-synchrony
Expand All @@ -615,7 +633,7 @@ GEM
nio4r (~> 2.0)
racc (1.5.2)
rack (2.2.3)
rack-attack (6.3.1)
rack-attack (6.4.0)
rack (>= 1.0, < 3)
rack-cors (1.1.1)
rack (>= 2.0.0)
Expand Down Expand Up @@ -669,7 +687,7 @@ GEM
virtus (~> 1.0.5)
wisper (>= 1.6.1)
redcarpet (3.5.1)
redis (4.2.2)
redis (4.2.5)
regexp_parser (1.8.1)
request_store (1.5.0)
rack (>= 1.4)
Expand Down Expand Up @@ -728,14 +746,16 @@ GEM
rubocop-faker (1.1.0)
faker (>= 2.12.0)
rubocop (>= 0.82.0)
rubocop-rails (2.8.1)
rubocop-rails (2.9.1)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 0.87.0)
rubocop (>= 0.90.0, < 2.0)
rubocop-rspec (1.43.2)
rubocop (~> 0.87)
ruby-ole (1.2.12.2)
ruby-progressbar (1.10.1)
ruby-vips (2.0.17)
ffi (~> 1.9)
rubyzip (2.3.0)
sass (3.7.4)
sass-listen (~> 4.0.0)
Expand Down Expand Up @@ -764,8 +784,8 @@ GEM
smart_properties (1.15.0)
social-share-button (1.2.3)
coffee-rails
spreadsheet (1.2.6)
ruby-ole (>= 1.0)
spreadsheet (1.2.7)
ruby-ole
spring (2.1.1)
spring-watcher-listen (2.0.1)
listen (>= 2.7, < 4.0)
Expand Down Expand Up @@ -821,7 +841,7 @@ GEM
activemodel (>= 5.0)
bindex (>= 0.4.0)
railties (>= 5.0)
webmock (3.11.0)
webmock (3.11.1)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
Expand Down
Expand Up @@ -10,6 +10,9 @@ class UpdateOrganizationAppearance < Rectify::Command
# organization - The Organization that will be updated.
# form - A form object with the params.
def initialize(organization, form)
image_fields.each do |field|
form.send("#{field}=".to_sym, organization.send(field)) if form.send(field).blank?
end
@organization = organization
@form = form
end
Expand All @@ -27,14 +30,19 @@ def call
update_organization
broadcast(:ok, organization)
rescue ActiveRecord::RecordInvalid
form.errors.add(:official_img_header, organization.errors[:official_img_header]) if organization.errors.include? :official_img_header
form.errors.add(:official_img_footer, organization.errors[:official_img_footer]) if organization.errors.include? :official_img_footer
image_fields.each do |field|
form.errors.add(field, organization.errors[field]) if organization.errors.include? field
end
broadcast(:invalid)
end
end

private

def image_fields
[:highlighted_content_banner_image, :logo, :favicon, :official_img_header, :official_img_footer]
end

attr_reader :form, :organization

def update_organization
Expand All @@ -50,6 +58,7 @@ def attributes
.merge(highlighted_content_banner_attributes)
.merge(omnipresent_banner_attributes)
.merge(colors_attributes)
.delete_if { |_k, val| val.is_a?(Decidim::ApplicationUploader) }
.tap do |attributes|
attributes[:header_snippets] = form.header_snippets if Decidim.enable_html_header_snippets
end
Expand Down
Expand Up @@ -56,7 +56,7 @@ module Decidim::Admin

context "when the image does not exist" do
it "creates the related image" do
expect(content_block.images).to be_empty
expect(content_block.images).to eq({ "background_image" => nil })

subject.call
content_block.reload
Expand Down
Expand Up @@ -41,8 +41,8 @@ def retrieve_comments_for_organization
user_ids = Decidim::User.where(organization: @resource.organization).pluck(:id)
Decidim::Comments::Comment.includes(:root_commentable).not_hidden
.where("decidim_comments_comments.created_at <= ?", end_time)
.where("decidim_comments_comments.decidim_author_id IN (?)", user_ids)
.where("decidim_comments_comments.decidim_author_type IN (?)", "Decidim::UserBaseEntity")
.where(decidim_comments_comments: { decidim_author_id: user_ids })
.where(decidim_comments_comments: { decidim_author_type: "Decidim::UserBaseEntity" })
end
end
end
Expand Down
Expand Up @@ -11,6 +11,7 @@ class UpdateConferenceSpeaker < Rectify::Command
# form - A form object with the params.
# conference_speaker - The ConferenceSpeaker to update
def initialize(form, conference_speaker)
form.avatar = conference_speaker.avatar if form.avatar.blank?
@form = form
@conference_speaker = conference_speaker
end
Expand Down Expand Up @@ -56,14 +57,19 @@ def attributes
:full_name,
:twitter_handle,
:personal_url,
:avatar,
:remove_avatar,
:position,
:affiliation,
:short_bio
).merge(
user: form.user
)
).merge(uploader_attributes)
end

def uploader_attributes
{
avatar: form.avatar,
remove_avatar: form.remove_avatar
}.delete_if { |_k, val| val.is_a?(Decidim::ApplicationUploader) }
end

def update_conference_speaker!
Expand Down
Expand Up @@ -11,6 +11,8 @@ class UpdatePartner < Rectify::Command
# form - A form object with the params.
# conference_partner - The ConferencePartner to update
def initialize(form, conference_partner)
form.logo = conference_partner.logo if form.logo.blank?

@form = form
@conference_partner = conference_partner
end
Expand Down
Expand Up @@ -47,7 +47,7 @@ def update
@partner = collection.find(params[:id])
enforce_permission_to :update, :partner, partner: @partner
@form = form(Decidim::Conferences::Admin::PartnerForm).from_params(params)
@form.logo = @partner.logo if @form.logo.blank?

UpdatePartner.call(@form, @partner) do
on(:ok) do
flash[:notice] = I18n.t("partners.update.success", scope: "decidim.admin")
Expand Down
Expand Up @@ -31,15 +31,16 @@ module Decidim::Conferences
full_name: "New name",
user: user,
errors: ActiveModel::Errors.new(Admin::ConferenceSpeakerForm),
avatar: avatar,
remove_avatar: false,
attributes: {
full_name: "New name",
position: { en: "new position" },
affiliation: { en: "new affiliation" },
short_bio: Decidim::Faker::Localized.sentence(word_count: 5),
twitter_handle: "full_name",
personal_url: Faker::Internet.url,
meeting_ids: meeting_ids,
avatar: avatar
meeting_ids: meeting_ids
}
)
end
Expand Down
4 changes: 3 additions & 1 deletion decidim-conferences/spec/commands/update_partner_spec.rb
Expand Up @@ -17,12 +17,14 @@ module Decidim::Conferences
current_user: current_user,
full_name: "New name",
errors: ActiveModel::Errors.new(Admin::PartnerForm),
logo: logo,
remove_logo: false,
attributes: {
name: "New name",
weight: 2,
partner_type: "collaborator",
logo: logo,
link: Faker::Internet.url,
logo: logo,
remove_logo: false
}
)
Expand Down
Expand Up @@ -11,6 +11,9 @@ class UpdateConsultation < Rectify::Command
# consultation - the Consultation to update
# form - A form object with the params.
def initialize(consultation, form)
form.banner_image = consultation.banner_image if form.banner_image.blank?
form.introductory_image = consultation.introductory_image if form.introductory_image.blank?

@consultation = consultation
@form = form
end
Expand Down

0 comments on commit fffd381

Please sign in to comment.