adds banner creation/edition/deletion specs

refactors admin banners specs
This commit is contained in:
Juanjo Bazán
2016-05-23 20:03:11 +02:00
parent 7c22c9d6fa
commit 1f1034a147
3 changed files with 147 additions and 98 deletions

View File

@@ -11,23 +11,23 @@ en:
unmark_featured: Unmark featured
banners:
index:
title: Post banners
create: Create a banner
edit: Edit a banner
delete: Delete a banner
title: Banners
create: Create banner
edit: Edit banner
delete: Delete banner
filters:
all: Todos
with_active: Actives
with_inactive: Inactives
all: All
with_active: Active
with_inactive: Inactive
banner:
title: Title
description: Description
target_url: Link
style: Style
image: Image
target_url: Link
style: Style
image: Image
post_started_at: Post started at
post_ended_at: Post ended at
edit:
post_ended_at: Post ended at
edit:
back: Back
editing: Edit banner
form:
@@ -39,7 +39,7 @@ en:
error:
one: "prevented this banner from being saved"
other: 'prevented this banner from being saved'
new:
new:
back: Back
creating: Create banner
activity:
@@ -92,7 +92,7 @@ en:
user_not_found: User not found
menu:
activity: Moderator activity
banner: Publish banner
banner: Manage banners
debate_topics: Debate topics
hidden_comments: Hidden comments
hidden_debates: Hidden debates
@@ -190,7 +190,7 @@ en:
updated: Value updated
index:
banners: Estilos de banners
banner_imgs: Imágenes para los banners
banner_imgs: Imágenes para los banners
title: Configuration settings
update_setting: Update
feature_flags: Features

View File

@@ -11,7 +11,7 @@ es:
unmark_featured: Quitar destacado
banners:
index:
title: Publicar anuncios
title: Anuncios
create: Crear un banner
edit: Editar banner
delete: Eliminar banner
@@ -22,12 +22,12 @@ es:
banner:
title: Título
description: Descripción
target_url: Enlace
target_url: Enlace
style: Estilo
image: Imagen
post_started_at: Inicio de publicación
post_ended_at: Fin de publicación
edit:
edit:
back: Volver
editing: Editar el banner
form:
@@ -37,7 +37,7 @@ es:
error:
one: "error impidió guardar el banner"
other: "errores impidieron guardar el banner."
new:
new:
back: Volver
creating: Crear banner
activity:
@@ -90,7 +90,7 @@ es:
user_not_found: Usuario no encontrado
menu:
activity: Actividad de moderadores
banner: Publicar banner
banner: Gestionar banners
debate_topics: Temas de debate
hidden_comments: Comentarios ocultos
hidden_debates: Debates ocultos

View File

@@ -1,105 +1,154 @@
require 'rails_helper'
feature 'Admin add banners' do
feature 'Admin banners magement' do
background do
@banner1 = create(:banner, title: "Banner number one",
description: "This is the text of banner number one and is not active yet",
target_url: "http://www.url.com",
style: "banner-style.banner-one",
image: "banner-img.banner-one",
post_started_at: (Time.now + 4.days),
post_ended_at: (Time.now + 10.days))
@banner2 = create(:banner, title: "Banner number two",
description: "This is the text of banner number two and is not longer active",
target_url: "http://www.url.com",
style: "banner-style.banner-two",
image: "banner-img.banner-two",
post_started_at: (Time.now - 10.days),
post_ended_at: (Time.now - 3.days))
@banner3 = create(:banner, title: "Banner number three",
description: "This is the text of banner number three and has style banner-three",
target_url: "http://www.url.com",
style: "banner-style.banner-three",
image: "banner-img.banner-three",
post_started_at: (Time.now - 1.days),
post_ended_at: (Time.now + 10.days))
@banner4 = create(:banner, title: "Banner number four",
description: "This is the text of banner number four and has style banner-one",
target_url: "http://www.url.com",
style: "banner-style.banner-one",
image: "banner-img.banner-one",
post_started_at: (DateTime.now - 10.days),
post_ended_at: (DateTime.now + 10.days))
@banner5 = create(:banner, title: "Banner number five",
description: "This is the text of banner number five and has style banner-two",
target_url: "http://www.url.com",
style: "banner-style.banner-one",
image: "banner-img.banner-one",
post_started_at: (DateTime.now - 10.days),
post_ended_at: (DateTime.now + 10.days))
login_as(create(:administrator).user)
end
scenario 'option publish banners is listed on admin menu' do
context "Index" do
background do
@banner1 = create(:banner, title: "Banner number one",
description: "This is the text of banner number one and is not active yet",
target_url: "http://www.url.com",
style: "banner-style.banner-one",
image: "banner-img.banner-one",
post_started_at: (Time.now + 4.days),
post_ended_at: (Time.now + 10.days))
@banner2 = create(:banner, title: "Banner number two",
description: "This is the text of banner number two and is not longer active",
target_url: "http://www.url.com",
style: "banner-style.banner-two",
image: "banner-img.banner-two",
post_started_at: (Time.now - 10.days),
post_ended_at: (Time.now - 3.days))
@banner3 = create(:banner, title: "Banner number three",
description: "This is the text of banner number three and has style banner-three",
target_url: "http://www.url.com",
style: "banner-style.banner-three",
image: "banner-img.banner-three",
post_started_at: (Time.now - 1.days),
post_ended_at: (Time.now + 10.days))
@banner4 = create(:banner, title: "Banner number four",
description: "This is the text of banner number four and has style banner-one",
target_url: "http://www.url.com",
style: "banner-style.banner-one",
image: "banner-img.banner-one",
post_started_at: (DateTime.now - 10.days),
post_ended_at: (DateTime.now + 10.days))
@banner5 = create(:banner, title: "Banner number five",
description: "This is the text of banner number five and has style banner-two",
target_url: "http://www.url.com",
style: "banner-style.banner-one",
image: "banner-img.banner-one",
post_started_at: (DateTime.now - 10.days),
post_ended_at: (DateTime.now + 10.days))
end
scenario 'Index show active banners' do
visit admin_banners_path(filter: 'with_active')
expect(page).to have_content("There are 3 banners")
end
scenario 'Index show inactive banners' do
visit admin_banners_path(filter: 'with_inactive')
expect(page).to have_content("There are 2 banners")
end
scenario 'Index show all banners' do
visit admin_banners_path
expect(page).to have_content("There are 5 banners")
end
end
scenario 'Banners publication is listed on admin menu' do
visit admin_root_path
within('#admin_menu') do
expect(page).to have_link "Publish banner"
expect(page).to have_link "Manage banners"
end
end
scenario 'index show active banners' do
visit admin_banners_path(filter: 'with_active')
expect(page).to have_content("There are 3 banners")
scenario 'Publish a banner' do
visit admin_root_path
click_link "Manage banners"
click_link "Create banner"
select 'Banner style 1', from: 'banner_style'
select 'Banner image 2', from: 'banner_image'
fill_in 'banner_title', with: 'Such banner'
fill_in 'banner_description', with: 'many text wow link'
fill_in 'banner_target_url', with: 'https://decide.madrid.es'
last_week = Time.now - 7.days
next_week = Time.now + 7.days
fill_in 'post_started_at', with: last_week.strftime("%d/%m/%Y")
fill_in 'post_ended_at', with: next_week.strftime("%d/%m/%Y")
click_button 'Save changes'
expect(page).to have_content 'Such banner'
visit proposals_path
expect(page).to have_content 'Such banner'
expect(page).to have_link 'Such banner many text wow link', href: 'https://decide.madrid.es'
end
scenario 'index show inactive banners' do
visit admin_banners_path(filter: 'with_inactive')
expect(page).to have_content("There are 2 banners")
end
scenario 'Edit banner with live refresh', :js do
banner1 = create(:banner, title: 'Hello',
description: 'Wrong text',
target_url: 'http://www.url.com',
style: 'banner-style.banner-one',
image: 'banner-img.banner-one',
post_started_at: (Time.now + 4.days),
post_ended_at: (Time.now + 10.days))
scenario 'index show all banners' do
visit admin_banners_path
expect(page).to have_content("There are 5 banners")
end
visit admin_root_path
click_link "Manage banners"
scenario 'refresh changes on edit banner', :js do
visit edit_admin_banner_path(@banner1)
click_link "Edit banner"
fill_in 'banner_title', with: 'Titulo modificado'
fill_in 'banner_description', with: 'Texto modificado'
select 'Banner style 1', from: 'banner_style'
select 'Banner image 2', from: 'banner_image'
fill_in 'banner_title', with: 'Modified title'
fill_in 'banner_description', with: 'Edited text'
within('div#js-banner-style') do
expect(page).to have_selector('h2', :text => 'Titulo modificado')
expect(page).to have_selector('h3', :text => 'Texto modificado')
expect(page).to have_selector('h2', :text => 'Modified title')
expect(page).to have_selector('h3', :text => 'Edited text')
end
end
scenario 'refresh changes on edit banner', :js do
visit edit_admin_banner_path(@banner1)
click_button 'Save changes'
fill_in 'banner_title', with: 'Titulo modificado'
fill_in 'banner_description', with: 'Texto modificado'
within('div#js-banner-style') do
expect(page).to have_selector('h2', :text => 'Titulo modificado')
expect(page).to have_selector('h3', :text => 'Texto modificado')
end
end
scenario 'option Publish banners is listed on admin menu' do
visit admin_banners_path
expect(page).to have_content 'Modified title'
expect(page).to have_content 'Edited text'
within('#admin_menu') do
expect(page).to have_link "Publish banner"
end
expect(page).to_not have_content 'Hello'
expect(page).to_not have_content 'Wrong text'
end
scenario 'Delete a banner' do
banner1 = create(:banner, title: 'Ugly banner',
description: 'Bad text',
target_url: 'http://www.url.com',
style: 'banner-style.banner-one',
image: 'banner-img.banner-one',
post_started_at: (Time.now + 4.days),
post_ended_at: (Time.now + 10.days))
visit admin_root_path
click_link "Manage banners"
expect(page).to have_content 'Ugly banner'
click_link "Delete banner"
visit admin_root_path
expect(page).to_not have_content 'Ugly banner'
end
end