adds banner creation/edition/deletion specs
refactors admin banners specs
This commit is contained in:
@@ -11,14 +11,14 @@ en:
|
|||||||
unmark_featured: Unmark featured
|
unmark_featured: Unmark featured
|
||||||
banners:
|
banners:
|
||||||
index:
|
index:
|
||||||
title: Post banners
|
title: Banners
|
||||||
create: Create a banner
|
create: Create banner
|
||||||
edit: Edit a banner
|
edit: Edit banner
|
||||||
delete: Delete a banner
|
delete: Delete banner
|
||||||
filters:
|
filters:
|
||||||
all: Todos
|
all: All
|
||||||
with_active: Actives
|
with_active: Active
|
||||||
with_inactive: Inactives
|
with_inactive: Inactive
|
||||||
banner:
|
banner:
|
||||||
title: Title
|
title: Title
|
||||||
description: Description
|
description: Description
|
||||||
@@ -92,7 +92,7 @@ en:
|
|||||||
user_not_found: User not found
|
user_not_found: User not found
|
||||||
menu:
|
menu:
|
||||||
activity: Moderator activity
|
activity: Moderator activity
|
||||||
banner: Publish banner
|
banner: Manage banners
|
||||||
debate_topics: Debate topics
|
debate_topics: Debate topics
|
||||||
hidden_comments: Hidden comments
|
hidden_comments: Hidden comments
|
||||||
hidden_debates: Hidden debates
|
hidden_debates: Hidden debates
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ es:
|
|||||||
unmark_featured: Quitar destacado
|
unmark_featured: Quitar destacado
|
||||||
banners:
|
banners:
|
||||||
index:
|
index:
|
||||||
title: Publicar anuncios
|
title: Anuncios
|
||||||
create: Crear un banner
|
create: Crear un banner
|
||||||
edit: Editar banner
|
edit: Editar banner
|
||||||
delete: Eliminar banner
|
delete: Eliminar banner
|
||||||
@@ -90,7 +90,7 @@ es:
|
|||||||
user_not_found: Usuario no encontrado
|
user_not_found: Usuario no encontrado
|
||||||
menu:
|
menu:
|
||||||
activity: Actividad de moderadores
|
activity: Actividad de moderadores
|
||||||
banner: Publicar banner
|
banner: Gestionar banners
|
||||||
debate_topics: Temas de debate
|
debate_topics: Temas de debate
|
||||||
hidden_comments: Comentarios ocultos
|
hidden_comments: Comentarios ocultos
|
||||||
hidden_debates: Debates ocultos
|
hidden_debates: Debates ocultos
|
||||||
|
|||||||
@@ -1,105 +1,154 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
feature 'Admin add banners' do
|
feature 'Admin banners magement' do
|
||||||
|
|
||||||
background 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)
|
login_as(create(:administrator).user)
|
||||||
end
|
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
|
visit admin_root_path
|
||||||
|
|
||||||
within('#admin_menu') do
|
within('#admin_menu') do
|
||||||
expect(page).to have_link "Publish banner"
|
expect(page).to have_link "Manage banners"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'index show active banners' do
|
scenario 'Publish a banner' do
|
||||||
visit admin_banners_path(filter: 'with_active')
|
visit admin_root_path
|
||||||
expect(page).to have_content("There are 3 banners")
|
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
|
end
|
||||||
|
|
||||||
scenario 'index show inactive banners' do
|
scenario 'Edit banner with live refresh', :js do
|
||||||
visit admin_banners_path(filter: 'with_inactive')
|
banner1 = create(:banner, title: 'Hello',
|
||||||
expect(page).to have_content("There are 2 banners")
|
description: 'Wrong text',
|
||||||
end
|
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_root_path
|
||||||
visit admin_banners_path
|
click_link "Manage banners"
|
||||||
expect(page).to have_content("There are 5 banners")
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario 'refresh changes on edit banner', :js do
|
click_link "Edit banner"
|
||||||
visit edit_admin_banner_path(@banner1)
|
|
||||||
|
|
||||||
fill_in 'banner_title', with: 'Titulo modificado'
|
select 'Banner style 1', from: 'banner_style'
|
||||||
fill_in 'banner_description', with: 'Texto modificado'
|
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
|
within('div#js-banner-style') do
|
||||||
expect(page).to have_selector('h2', :text => 'Titulo modificado')
|
expect(page).to have_selector('h2', :text => 'Modified title')
|
||||||
expect(page).to have_selector('h3', :text => 'Texto modificado')
|
expect(page).to have_selector('h3', :text => 'Edited text')
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
scenario 'refresh changes on edit banner', :js do
|
click_button 'Save changes'
|
||||||
visit edit_admin_banner_path(@banner1)
|
|
||||||
|
|
||||||
|
|
||||||
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
|
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_not have_content 'Hello'
|
||||||
expect(page).to have_link "Publish banner"
|
expect(page).to_not have_content 'Wrong text'
|
||||||
end
|
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
|
||||||
|
|
||||||
end
|
end
|
||||||
Reference in New Issue
Block a user