Merge branch 'master' into redux-polling

This commit is contained in:
Juanjo Bazán
2016-12-27 18:22:06 +01:00
235 changed files with 3445 additions and 1099 deletions

View File

@@ -1,6 +1,7 @@
require 'rails_helper'
feature 'Admin banners magement' do
background do
login_as(create(:administrator).user)
end
@@ -12,40 +13,40 @@ feature 'Admin banners magement' do
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))
post_started_at: (Time.current + 4.days),
post_ended_at: (Time.current + 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))
post_started_at: (Time.current - 10.days),
post_ended_at: (Time.current - 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))
post_started_at: (Time.current - 1.days),
post_ended_at: (Time.current + 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))
post_started_at: (DateTime.current - 10.days),
post_ended_at: (DateTime.current + 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))
post_started_at: (DateTime.current - 10.days),
post_ended_at: (DateTime.current + 10.days))
end
scenario 'Index show active banners' do
@@ -86,8 +87,8 @@ feature 'Admin banners magement' do
fill_in 'banner_title', with: 'Such banner'
fill_in 'banner_description', with: 'many text wow link'
fill_in 'banner_target_url', with: 'https://www.url.com'
last_week = Time.now - 7.days
next_week = Time.now + 7.days
last_week = Time.current - 7.days
next_week = Time.current + 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")
@@ -107,8 +108,8 @@ feature 'Admin banners magement' do
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))
post_started_at: (Time.current + 4.days),
post_ended_at: (Time.current + 10.days))
visit admin_root_path
@@ -125,8 +126,8 @@ feature 'Admin banners magement' do
fill_in 'banner_description', with: 'Edited text'
within('div#js-banner-style') do
expect(page).to have_selector('h2', :text => 'Modified title')
expect(page).to have_selector('h3', :text => 'Edited text')
expect(page).to have_selector('h2', text: 'Modified title')
expect(page).to have_selector('h3', text: 'Edited text')
end
click_button 'Save changes'
@@ -140,13 +141,14 @@ feature 'Admin banners magement' do
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))
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.current + 4.days),
post_ended_at: (Time.current + 10.days))
visit admin_root_path
within("#side_menu") do
@@ -161,4 +163,4 @@ feature 'Admin banners magement' do
expect(page).to_not have_content 'Ugly banner'
end
end
end

View File

@@ -98,4 +98,4 @@ feature 'Admin comments' do
expect(current_url).to include('page=2')
end
end
end

View File

@@ -91,4 +91,4 @@ feature 'Admin debates' do
expect(current_url).to include('page=2')
end
end
end

View File

@@ -62,4 +62,5 @@ feature 'Admin feature flags' do
expect(page).to have_link "Spending proposals"
end
end
end

View File

@@ -0,0 +1,100 @@
require 'rails_helper'
feature 'Admin geozones' do
background do
login_as(create(:administrator).user)
end
scenario 'Show list of geozones' do
chamberi = create(:geozone, name: 'Chamberí')
retiro = create(:geozone, name: 'Retiro')
visit admin_geozones_path
expect(page).to have_content(chamberi.name)
expect(page).to have_content(retiro.name)
end
scenario 'Create new geozone' do
visit admin_root_path
within('#side_menu') { click_link 'Manage geozones' }
click_link 'Create geozone'
fill_in 'geozone_name', with: 'Fancy District'
fill_in 'geozone_external_code', with: 123
fill_in 'geozone_census_code', with: 44
click_button 'Save changes'
expect(page).to have_content 'Fancy District'
visit admin_geozones_path
expect(page).to have_content 'Fancy District'
end
scenario 'Edit geozone with no associated elements' do
geozone = create(:geozone, name: 'Edit me!', census_code: '012')
visit admin_geozones_path
within("#geozone_#{geozone.id}") { click_link 'Edit' }
fill_in 'geozone_name', with: 'New geozone name'
fill_in 'geozone_census_code', with: '333'
click_button 'Save changes'
within("#geozone_#{geozone.id}") do
expect(page).to have_content 'New geozone name'
expect(page).to have_content '333'
end
end
scenario 'Edit geozone with associated elements' do
geozone = create(:geozone, name: 'Edit me!')
create(:proposal, title: 'Proposal with geozone', geozone: geozone)
visit admin_geozones_path
within("#geozone_#{geozone.id}") { click_link 'Edit' }
fill_in 'geozone_name', with: 'New geozone name'
click_button 'Save changes'
within("#geozone_#{geozone.id}") do
expect(page).to have_content 'New geozone name'
end
end
scenario 'Delete geozone with no associated elements' do
geozone = create(:geozone, name: 'Delete me!')
visit admin_geozones_path
within("#geozone_#{geozone.id}") { click_link 'Delete' }
expect(page).to have_content 'Geozone successfully deleted'
expect(page).not_to have_content('Delete me!')
expect(Geozone.where(id: geozone.id)).to be_empty
end
scenario 'Delete geozone with associated element' do
geozone = create(:geozone, name: 'Delete me!')
create(:proposal, geozone: geozone)
visit admin_geozones_path
within("#geozone_#{geozone.id}") { click_link 'Delete' }
expect(page).to have_content "This geozone can't be deleted since there are elements attached to it"
within("#geozone_#{geozone.id}") do
expect(page).to have_content 'Delete me!'
end
end
end

View File

@@ -33,5 +33,5 @@ feature 'Admin managers' do
expect(page).to_not have_content @manager.name
end
end
end
end

View File

@@ -27,4 +27,5 @@ feature 'Admin settings' do
expect(page).to have_content 'Value updated'
end
end

View File

@@ -0,0 +1,71 @@
require 'rails_helper'
feature 'Signature sheets' do
background do
admin = create(:administrator)
login_as(admin.user)
end
scenario "Index" do
3.times { create(:signature_sheet) }
visit admin_signature_sheets_path
expect(page).to have_css(".signature_sheet", count: 3)
SignatureSheet.all.each do |signature_sheet|
expect(page).to have_content signature_sheet.name
end
end
scenario 'Create' do
proposal = create(:proposal)
visit new_admin_signature_sheet_path
select "Citizen proposal", from: "signature_sheet_signable_type"
fill_in "signature_sheet_signable_id", with: proposal.id
fill_in "signature_sheet_document_numbers", with: "12345678Z, 99999999Z"
click_button "Create signature sheet"
expect(page).to have_content "Signature sheet created successfully"
visit proposal_path(proposal)
expect(page).to have_content "1 support"
end
scenario 'Errors on create' do
visit new_admin_signature_sheet_path
click_button "Create signature sheet"
expect(page).to have_content error_message
end
scenario 'Show' do
proposal = create(:proposal)
user = Administrator.first.user
signature_sheet = create(:signature_sheet,
signable: proposal,
document_numbers: "12345678Z, 123A, 123B",
author: user)
signature_sheet.verify_signatures
visit admin_signature_sheet_path(signature_sheet)
expect(page).to have_content "Citizen proposal #{proposal.id}"
expect(page).to have_content "12345678Z, 123A, 123B"
expect(page).to have_content signature_sheet.created_at.strftime("%d %b %H:%M")
expect(page).to have_content user.name
within("#verified_signatures") do
expect(page).to have_content 1
end
within("#unverified_signatures") do
expect(page).to have_content 2
end
end
end

View File

@@ -669,4 +669,4 @@ feature 'Admin spending proposals' do
end
end
end

View File

@@ -51,7 +51,7 @@ feature 'Incomplete verifications' do
end
scenario "Phone not given" do
incompletely_verified_user = create(:user, residence_verified_at: Time.now, unconfirmed_phone: nil)
incompletely_verified_user = create(:user, residence_verified_at: Time.current, unconfirmed_phone: nil)
visit admin_verifications_path
@@ -61,7 +61,7 @@ feature 'Incomplete verifications' do
end
scenario "SMS code not confirmed" do
incompletely_verified_user = create(:user, residence_verified_at: Time.now,
incompletely_verified_user = create(:user, residence_verified_at: Time.current,
unconfirmed_phone: "611111111",
sms_confirmation_code: "1234",
confirmed_phone: nil)