diff --git a/app/controllers/admin/widget/cards_controller.rb b/app/controllers/admin/widget/cards_controller.rb
index 15bb5d49f..1b452df87 100644
--- a/app/controllers/admin/widget/cards_controller.rb
+++ b/app/controllers/admin/widget/cards_controller.rb
@@ -39,7 +39,7 @@ class Admin::Widget::CardsController < Admin::BaseController
private
def card_params
- params.require(:widget_card).permit(:title, :description, :link_text, :link_url,
+ params.require(:widget_card).permit(:label, :title, :description, :link_text, :link_url,
:button_text, :button_url, :alignment, :header,
image_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy])
end
diff --git a/app/views/admin/homepage/_card.html.erb b/app/views/admin/homepage/_card.html.erb
index 449bdbad5..5d2031f62 100644
--- a/app/views/admin/homepage/_card.html.erb
+++ b/app/views/admin/homepage/_card.html.erb
@@ -1,5 +1,8 @@
- | <%= card.title %> |
+
+ <%= card.label %>
+ <%= card.title %>
+ |
<%= card.description %> |
<%= card.link_text %>
diff --git a/app/views/admin/widget/cards/_form.html.erb b/app/views/admin/widget/cards/_form.html.erb
index ec10bd0f9..271f7d206 100644
--- a/app/views/admin/widget/cards/_form.html.erb
+++ b/app/views/admin/widget/cards/_form.html.erb
@@ -1,4 +1,8 @@
<%= form_for [:admin, @card] do |f| %>
+
+ <%= f.text_field :label %>
+
+
<%= f.text_field :title %>
<%= f.text_area :description, rows: 5 %>
diff --git a/app/views/welcome/_card.html.erb b/app/views/welcome/_card.html.erb
index 473138e53..0ae4a153a 100644
--- a/app/views/welcome/_card.html.erb
+++ b/app/views/welcome/_card.html.erb
@@ -5,7 +5,7 @@
<%= image_tag(card.image_url(:large), alt: card.image.title) %>
<% end %>
- LABEL
+ <%= card.label %>
<%= card.title %>
diff --git a/config/locales/en/activerecord.yml b/config/locales/en/activerecord.yml
index b26e0552b..6bad6d150 100644
--- a/config/locales/en/activerecord.yml
+++ b/config/locales/en/activerecord.yml
@@ -246,6 +246,7 @@ en:
from: From
body: Email content
widget/card:
+ label: Label
title: Title
description: Description
link_text: Link text
diff --git a/config/locales/es/activerecord.yml b/config/locales/es/activerecord.yml
index 0b247f4be..e7e3c3761 100644
--- a/config/locales/es/activerecord.yml
+++ b/config/locales/es/activerecord.yml
@@ -242,6 +242,7 @@ es:
from: Enviado por
body: Contenido del email
widget/card:
+ label: Etiqueta
title: Título
description: Descripción
link_text: Texto del enlace
diff --git a/db/migrate/20180516091302_create_widget_cards.rb b/db/migrate/20180516091302_create_widget_cards.rb
index 540523e2e..f957ae231 100644
--- a/db/migrate/20180516091302_create_widget_cards.rb
+++ b/db/migrate/20180516091302_create_widget_cards.rb
@@ -5,10 +5,8 @@ class CreateWidgetCards < ActiveRecord::Migration
t.text :description
t.string :link_text
t.string :link_url
- t.string :button_text
- t.string :button_url
+ t.string :label
t.boolean :header, default: false
- t.string :alignment
t.timestamps null: false
end
end
diff --git a/db/schema.rb b/db/schema.rb
index 1c4a93747..be1baa18b 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -1231,10 +1231,8 @@ ActiveRecord::Schema.define(version: 20180519132715) do
t.text "description"
t.string "link_text"
t.string "link_url"
- t.string "button_text"
- t.string "button_url"
+ t.string "label"
t.boolean "header", default: false
- t.string "alignment"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
diff --git a/spec/features/admin/homepage/homepage_spec.rb b/spec/features/admin/homepage/homepage_spec.rb
index d047546a0..089b7fd5f 100644
--- a/spec/features/admin/homepage/homepage_spec.rb
+++ b/spec/features/admin/homepage/homepage_spec.rb
@@ -76,33 +76,37 @@ feature 'Homepage' do
end
scenario "Cards" do
- card1 = create(:widget_card, title: "Card text",
- description: "Card description",
- link_text: "Link text",
- link_url: "consul.dev")
+ card1 = create(:widget_card, label: "Card1 label",
+ title: "Card1 text",
+ description: "Card1 description",
+ link_text: "Link1 text",
+ link_url: "consul1.dev")
- card2 = create(:widget_card, title: "Card text2",
- description: "Card description2",
- link_text: "Link text2",
- link_url: "consul.dev2")
+ card2 = create(:widget_card, label: "Card2 label",
+ title: "Card2 text",
+ description: "Card2 description",
+ link_text: "Link2 text",
+ link_url: "consul2.dev")
visit root_path
expect(page).to have_css(".card", count: 2)
within("#widget_card_#{card1.id}") do
- expect(page).to have_content("Card text")
- expect(page).to have_content("Card description")
- expect(page).to have_content("Link text")
- expect(page).to have_link(href: "consul.dev")
+ expect(page).to have_content("Card1 label")
+ expect(page).to have_content("Card1 text")
+ expect(page).to have_content("Card1 description")
+ expect(page).to have_content("Link1 text")
+ expect(page).to have_link(href: "consul1.dev")
expect(page).to have_css("img[alt='#{card1.image.title}']")
end
within("#widget_card_#{card2.id}") do
- expect(page).to have_content("Card text2")
- expect(page).to have_content("Card description2")
- expect(page).to have_content("Link text2")
- expect(page).to have_link(href: "consul.dev2")
+ expect(page).to have_content("Card2 label")
+ expect(page).to have_content("Card2 text")
+ expect(page).to have_content("Card2 description")
+ expect(page).to have_content("Link2 text")
+ expect(page).to have_link(href: "consul2.dev")
expect(page).to have_css("img[alt='#{card2.image.title}']")
end
end
diff --git a/spec/features/admin/widgets/cards_spec.rb b/spec/features/admin/widgets/cards_spec.rb
index ac5d3b9fd..3509b99a8 100644
--- a/spec/features/admin/widgets/cards_spec.rb
+++ b/spec/features/admin/widgets/cards_spec.rb
@@ -11,6 +11,7 @@ feature 'Cards' do
visit admin_homepage_path
click_link "Create card"
+ fill_in "widget_card_label", with: "Card label"
fill_in "widget_card_title", with: "Card text"
fill_in "widget_card_description", with: "Card description"
fill_in "widget_card_link_text", with: "Link text"
@@ -23,6 +24,7 @@ feature 'Cards' do
card = Widget::Card.last
within("#widget_card_#{card.id}") do
+ expect(page).to have_content "Card label"
expect(page).to have_content "Card text"
expect(page).to have_content "Card description"
expect(page).to have_content "Link text"
@@ -57,6 +59,7 @@ feature 'Cards' do
click_link "Edit"
end
+ fill_in "widget_card_label", with: "Card label updated"
fill_in "widget_card_title", with: "Card text updated"
fill_in "widget_card_description", with: "Card description updated"
fill_in "widget_card_link_text", with: "Link text updated"
@@ -67,6 +70,7 @@ feature 'Cards' do
expect(page).to have_css(".card", count: 1)
within("#widget_card_#{Widget::Card.last.id}") do
+ expect(page).to have_content "Card label updated"
expect(page).to have_content "Card text updated"
expect(page).to have_content "Card description updated"
expect(page).to have_content "Link text updated"
@@ -95,8 +99,9 @@ feature 'Cards' do
visit admin_homepage_path
click_link "Create header"
- fill_in "widget_card_title", with: "Card text"
- fill_in "widget_card_description", with: "Card description"
+ fill_in "widget_card_label", with: "Header label"
+ fill_in "widget_card_title", with: "Header text"
+ fill_in "widget_card_description", with: "Header description"
fill_in "widget_card_link_text", with: "Link text"
fill_in "widget_card_link_url", with: "consul.dev"
click_button "Create header"
@@ -105,8 +110,9 @@ feature 'Cards' do
within("#header") do
expect(page).to have_css(".card", count: 1)
- expect(page).to have_content "Card text"
- expect(page).to have_content "Card description"
+ expect(page).to have_content "Header label"
+ expect(page).to have_content "Header text"
+ expect(page).to have_content "Header description"
expect(page).to have_content "Link text"
expect(page).to have_content "consul.dev"
end
|