Allow change map image from admin site customization
Also adds on site customization image.rb jpeg content type to allow replace this image.
This commit is contained in:
@@ -4,13 +4,14 @@ class SiteCustomization::Image < ActiveRecord::Base
|
|||||||
"social_media_icon" => [470, 246],
|
"social_media_icon" => [470, 246],
|
||||||
"social_media_icon_twitter" => [246, 246],
|
"social_media_icon_twitter" => [246, 246],
|
||||||
"apple-touch-icon-200" => [200, 200],
|
"apple-touch-icon-200" => [200, 200],
|
||||||
"budget_execution_no_image" => [800, 600]
|
"budget_execution_no_image" => [800, 600],
|
||||||
|
"map" => [420, 500]
|
||||||
}
|
}
|
||||||
|
|
||||||
has_attached_file :image
|
has_attached_file :image
|
||||||
|
|
||||||
validates :name, presence: true, uniqueness: true, inclusion: { in: VALID_IMAGES.keys }
|
validates :name, presence: true, uniqueness: true, inclusion: { in: VALID_IMAGES.keys }
|
||||||
validates_attachment_content_type :image, content_type: ["image/png"]
|
validates_attachment_content_type :image, content_type: ["image/png", "image/jpeg"]
|
||||||
validate :check_image
|
validate :check_image
|
||||||
|
|
||||||
def self.all_images
|
def self.all_images
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<% @images.each do |image| %>
|
<% @images.each do |image| %>
|
||||||
<tr class="<%= image.name %>">
|
<tr id="image_<%= image.name %>">
|
||||||
<td class="small-12 medium-4">
|
<td class="small-12 medium-4">
|
||||||
<strong><%= image.name %></strong> (<%= image.required_width %>x<%= image.required_height %>)
|
<strong><%= image.name %></strong> (<%= image.required_width %>x<%= image.required_height %>)
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -2,5 +2,5 @@
|
|||||||
<h2 class="sidebar-title"><%= t("shared.tags_cloud.districts") %></h2>
|
<h2 class="sidebar-title"><%= t("shared.tags_cloud.districts") %></h2>
|
||||||
<br>
|
<br>
|
||||||
<%= link_to map_proposals_path, id: 'map', title: t("shared.tags_cloud.districts_list") do %>
|
<%= link_to map_proposals_path, id: 'map', title: t("shared.tags_cloud.districts_list") do %>
|
||||||
<%= image_tag("map.jpg", alt: t("shared.tags_cloud.districts_list")) %>
|
<%= image_tag(image_path_for("map.jpg"), alt: t("shared.tags_cloud.districts_list")) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -7,22 +7,57 @@ feature "Admin custom images" do
|
|||||||
login_as(admin.user)
|
login_as(admin.user)
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Upload valid image" do
|
scenario "Upload valid png image" do
|
||||||
visit admin_root_path
|
visit admin_root_path
|
||||||
|
|
||||||
within("#side_menu") do
|
within("#side_menu") do
|
||||||
click_link "Custom images"
|
click_link "Custom images"
|
||||||
end
|
end
|
||||||
|
|
||||||
within("tr.logo_header") do
|
within("tr#image_logo_header") do
|
||||||
attach_file "site_customization_image_image", "spec/fixtures/files/logo_header.png"
|
attach_file "site_customization_image_image", "spec/fixtures/files/logo_header.png"
|
||||||
click_button "Update"
|
click_button "Update"
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(page).to have_css("tr.logo_header img[src*='logo_header.png']")
|
expect(page).to have_css("tr#image_logo_header img[src*='logo_header.png']")
|
||||||
expect(page).to have_css("img[src*='logo_header.png']", count: 1)
|
expect(page).to have_css("img[src*='logo_header.png']", count: 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scenario "Upload valid jpg image" do
|
||||||
|
visit admin_root_path
|
||||||
|
|
||||||
|
within("#side_menu") do
|
||||||
|
click_link "Custom images"
|
||||||
|
end
|
||||||
|
|
||||||
|
within("tr#image_map") do
|
||||||
|
attach_file "site_customization_image_image", "spec/fixtures/files/custom_map.jpg"
|
||||||
|
click_button "Update"
|
||||||
|
end
|
||||||
|
|
||||||
|
expect(page).to have_css("tr#image_map img[src*='custom_map.jpg']")
|
||||||
|
expect(page).to have_css("img[src*='custom_map.jpg']", count: 1)
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "Image is replaced on front view" do
|
||||||
|
visit admin_root_path
|
||||||
|
|
||||||
|
within("#side_menu") do
|
||||||
|
click_link "Custom images"
|
||||||
|
end
|
||||||
|
|
||||||
|
within("tr#image_map") do
|
||||||
|
attach_file "site_customization_image_image", "spec/fixtures/files/custom_map.jpg"
|
||||||
|
click_button "Update"
|
||||||
|
end
|
||||||
|
|
||||||
|
visit proposals_path
|
||||||
|
|
||||||
|
within("#map") do
|
||||||
|
expect(page).to have_css("img[src*='custom_map.jpg']")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
scenario "Upload invalid image" do
|
scenario "Upload invalid image" do
|
||||||
visit admin_root_path
|
visit admin_root_path
|
||||||
|
|
||||||
@@ -30,7 +65,7 @@ feature "Admin custom images" do
|
|||||||
click_link "Custom images"
|
click_link "Custom images"
|
||||||
end
|
end
|
||||||
|
|
||||||
within("tr.social_media_icon") do
|
within("tr#image_social_media_icon") do
|
||||||
attach_file "site_customization_image_image", "spec/fixtures/files/logo_header.png"
|
attach_file "site_customization_image_image", "spec/fixtures/files/logo_header.png"
|
||||||
click_button "Update"
|
click_button "Update"
|
||||||
end
|
end
|
||||||
@@ -46,14 +81,14 @@ feature "Admin custom images" do
|
|||||||
click_link "Custom images"
|
click_link "Custom images"
|
||||||
end
|
end
|
||||||
|
|
||||||
within("tr.social_media_icon") do
|
within("tr#image_social_media_icon") do
|
||||||
attach_file "site_customization_image_image", "spec/fixtures/files/social_media_icon.png"
|
attach_file "site_customization_image_image", "spec/fixtures/files/social_media_icon.png"
|
||||||
click_button "Update"
|
click_button "Update"
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(page).to have_css("img[src*='social_media_icon.png']")
|
expect(page).to have_css("img[src*='social_media_icon.png']")
|
||||||
|
|
||||||
within("tr.social_media_icon") do
|
within("tr#image_social_media_icon") do
|
||||||
click_link "Delete"
|
click_link "Delete"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
BIN
spec/fixtures/files/custom_map.jpg
vendored
Normal file
BIN
spec/fixtures/files/custom_map.jpg
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 86 KiB |
Reference in New Issue
Block a user