mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Every campaign has an end.
Drop ahoy, because it's more trouble than it's worth. This means dropping visits, campaigns, targets. Campaigns are better run to analytics, such as: * https://matomo.org/docs/tracking-campaigns/ * https://matomo.org/docs/tracking-goals-web-analytics/ * https://support.google.com/analytics/answer/1012040?hl=en
This commit is contained in:
parent
62056fc044
commit
b11001cdba
47 changed files with 19 additions and 1420 deletions
|
|
@ -1,170 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Admin::TargetsController, type: :controller do
|
||||
let(:admin) { create(:admin) }
|
||||
let(:conference) { create(:conference) }
|
||||
let(:target) { create(:target, conference: conference, target_count: 100) }
|
||||
|
||||
context 'user is admin' do
|
||||
before { sign_in admin }
|
||||
|
||||
describe 'GET #index' do
|
||||
before { get :index, conference_id: conference.short_title }
|
||||
|
||||
it 'renders index template' do
|
||||
expect(response).to render_template('index')
|
||||
end
|
||||
|
||||
it 'assigns targets and conference variables' do
|
||||
expect(assigns(:conference)).to eq conference
|
||||
expect(assigns(:targets)).to eq [target]
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #new' do
|
||||
before { get :new, conference_id: conference.short_title }
|
||||
|
||||
it 'renders new template' do
|
||||
expect(response).to render_template('new')
|
||||
end
|
||||
|
||||
it 'assigns target variable' do
|
||||
expect(assigns(:target)).to be_instance_of(Target)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'POST #create' do
|
||||
context 'saves successfuly' do
|
||||
before do
|
||||
post :create, target: attributes_for(:target), conference_id: conference.short_title
|
||||
end
|
||||
|
||||
it 'redirects to admin target index path' do
|
||||
expect(response).to redirect_to admin_conference_targets_path(conference_id: conference.short_title)
|
||||
end
|
||||
|
||||
it 'shows success message in flash notice' do
|
||||
expect(flash[:notice]).to match('Target successfully created.')
|
||||
end
|
||||
|
||||
it 'creates new target' do
|
||||
expect(Target.count).to eq 1
|
||||
end
|
||||
end
|
||||
|
||||
context 'save fails' do
|
||||
before do
|
||||
allow_any_instance_of(Target).to receive(:save).and_return(false)
|
||||
post :create, target: attributes_for(:target), conference_id: conference.short_title
|
||||
end
|
||||
|
||||
it 'renders new template' do
|
||||
expect(response).to render_template('new')
|
||||
end
|
||||
|
||||
it 'shows error in flash message' do
|
||||
expect(flash[:error]).to match("Creating target failed: #{target.errors.full_messages.join('. ')}.")
|
||||
end
|
||||
|
||||
it 'does not create new target' do
|
||||
expect(Target.count).to eq 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #edit' do
|
||||
before { get :edit, conference_id: conference.short_title, id: target.id }
|
||||
|
||||
it 'renders edit template' do
|
||||
expect(response).to render_template('edit')
|
||||
end
|
||||
|
||||
it 'assigns target variable' do
|
||||
expect(assigns(:target)).to eq target
|
||||
end
|
||||
end
|
||||
|
||||
describe 'PATCH #update' do
|
||||
context 'updates successfully' do
|
||||
before do
|
||||
patch :update, target: attributes_for(:target, target_count: 2),
|
||||
conference_id: conference.short_title,
|
||||
id: target.id
|
||||
end
|
||||
|
||||
it 'redirects to admin target index path' do
|
||||
expect(response).to redirect_to admin_conference_targets_path(conference_id: conference.short_title)
|
||||
end
|
||||
|
||||
it 'shows success message in flash notice' do
|
||||
expect(flash[:notice]).to match('Target successfully updated.')
|
||||
end
|
||||
|
||||
it 'updates the target' do
|
||||
target.reload
|
||||
expect(target.target_count).to eq 2
|
||||
end
|
||||
end
|
||||
|
||||
context 'update fails' do
|
||||
before do
|
||||
allow_any_instance_of(Target).to receive(:save).and_return(false)
|
||||
patch :update, target: attributes_for(:target, target_count: 2),
|
||||
conference_id: conference.short_title,
|
||||
id: target.id
|
||||
end
|
||||
|
||||
it 'renders edit template' do
|
||||
expect(response).to render_template('edit')
|
||||
end
|
||||
|
||||
it 'shows error in flash message' do
|
||||
expect(flash[:error]).to match("Target update failed: #{target.errors.full_messages.join('. ')}.")
|
||||
end
|
||||
|
||||
it 'does not update target' do
|
||||
expect(target.target_count).to eq 100
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'DELETE #destroy' do
|
||||
context 'deletes successfully' do
|
||||
before { delete :destroy, conference_id: conference.short_title, id: target.id }
|
||||
|
||||
it 'redirects to admin target index path' do
|
||||
expect(response).to redirect_to admin_conference_targets_path(conference_id: conference.short_title)
|
||||
end
|
||||
|
||||
it 'shows success message in flash notice' do
|
||||
expect(flash[:notice]).to match('Target successfully destroyed.')
|
||||
end
|
||||
|
||||
it 'deletes target' do
|
||||
expect(Target.count).to eq 0
|
||||
end
|
||||
end
|
||||
|
||||
context 'delete fails' do
|
||||
before do
|
||||
allow_any_instance_of(Target).to receive(:destroy).and_return(false)
|
||||
delete :destroy, conference_id: conference.short_title, id: target.id
|
||||
end
|
||||
|
||||
it 'redirects to admin target index path' do
|
||||
expect(response).to redirect_to admin_conference_targets_path(conference_id: conference.short_title)
|
||||
end
|
||||
|
||||
it 'shows error in flash message' do
|
||||
expect(flash[:error]).to match("Could not delete target for #{conference.title}: #{target.errors.full_messages.join('. ')}.")
|
||||
end
|
||||
|
||||
it 'does not delete target' do
|
||||
expect(Target.count).to eq 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Read about factories at https://github.com/thoughtbot/factory_bot
|
||||
|
||||
FactoryBot.define do
|
||||
factory :campaign do
|
||||
name { 'Test Campaign' }
|
||||
utm_campaign { 'testcampaign' }
|
||||
conference
|
||||
end
|
||||
end
|
||||
|
|
@ -46,8 +46,6 @@ FactoryBot.define do
|
|||
create_list(:sponsor, 2, sponsorship_level: conference.sponsorship_levels.second, conference: conference)
|
||||
create_list(:sponsor, 3, sponsorship_level: conference.sponsorship_levels.third, conference: conference)
|
||||
|
||||
create(:campaign, conference: conference)
|
||||
create(:target, conference: conference)
|
||||
create(:question, conferences: [conference])
|
||||
|
||||
# Logo...
|
||||
|
|
|
|||
|
|
@ -1,12 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Read about factories at https://github.com/thoughtbot/factory_bot
|
||||
|
||||
FactoryBot.define do
|
||||
factory :target do
|
||||
due_date { 14.days.from_now }
|
||||
target_count { 100 }
|
||||
unit { Target.units[:submissions] }
|
||||
conference
|
||||
end
|
||||
end
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Read about factories at https://github.com/thoughtbot/factory_bot
|
||||
|
||||
FactoryBot.define do
|
||||
factory :visit do
|
||||
end
|
||||
end
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
feature Campaign do
|
||||
|
||||
let!(:conference) { create(:conference, short_title: 'osc14') }
|
||||
let!(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) }
|
||||
let!(:organizer) { create(:user, role_ids: [organizer_role.id]) }
|
||||
|
||||
shared_examples 'add and update campaign' do
|
||||
scenario 'adds and update a campaign', feature: true, js: true do
|
||||
expected_count = Campaign.count + 1
|
||||
sign_in organizer
|
||||
|
||||
visit admin_conference_campaigns_path(conference.short_title)
|
||||
|
||||
click_link 'New Campaign'
|
||||
|
||||
click_button 'Create Campaign'
|
||||
|
||||
expect(flash).to eq("Campaign creation failed. Name can't be blank and Utm campaign can't be blank")
|
||||
|
||||
fill_in 'campaign_name', with: 'Test Campaign'
|
||||
fill_in 'campaign_utm_campaign', with: 'campaign'
|
||||
fill_in 'campaign_utm_source', with: 'source'
|
||||
fill_in 'campaign_utm_medium', with: 'medium'
|
||||
fill_in 'campaign_utm_term', with: 'term'
|
||||
fill_in 'campaign_utm_content', with: 'content'
|
||||
|
||||
click_button 'Create Campaign'
|
||||
|
||||
# Validations
|
||||
expect(flash).to eq('Campaign successfully created.')
|
||||
|
||||
expect(page).to have_selector('[id^="name_"]', text: 'Test Campaign')
|
||||
expect(page).to have_selector('[id^="visits_"]', text: '0')
|
||||
expect(page).to have_selector('[id^="registrations_"]', text: '0')
|
||||
expect(page).to have_selector('[id^="submissions_"]', text: '0')
|
||||
|
||||
expect(Campaign.count).to eq(expected_count)
|
||||
|
||||
campaign = Campaign.where('name' => 'Test Campaign').first
|
||||
visit edit_admin_conference_campaign_path(conference.short_title, campaign.id)
|
||||
|
||||
fill_in 'campaign_name', with: 'Test Campaign 42'
|
||||
click_button 'Update Campaign'
|
||||
expect(flash).to eq("Campaign 'Test Campaign 42' successfully updated.")
|
||||
end
|
||||
end
|
||||
|
||||
describe 'organizer' do
|
||||
it_behaves_like 'add and update campaign'
|
||||
end
|
||||
end
|
||||
|
|
@ -43,9 +43,6 @@ feature 'Has correct abilities' do
|
|||
expect(page).to_not have_link('Sponsorship Levels', href: "/admin/conferences/#{conference.short_title}/sponsorship_levels")
|
||||
expect(page).to_not have_link('Sponsors', href: "/admin/conferences/#{conference.short_title}/sponsors")
|
||||
expect(page).to_not have_link('Tickets', href: "/admin/conferences/#{conference.short_title}/tickets")
|
||||
expect(page).to_not have_text('Objectives')
|
||||
expect(page).to_not have_link('Campaigns', href: "/admin/conferences/#{conference.short_title}/campaigns")
|
||||
expect(page).to_not have_link('Goals', href: "/admin/conferences/#{conference.short_title}/targets")
|
||||
expect(page).to have_link('Roles', href: "/admin/conferences/#{conference.short_title}/roles")
|
||||
expect(page).to have_link('Resources', href: "/admin/conferences/#{conference.short_title}/resources")
|
||||
expect(page).to_not have_link('New Conference', href: '/admin/conferences/new')
|
||||
|
|
@ -250,26 +247,6 @@ feature 'Has correct abilities' do
|
|||
visit edit_admin_conference_ticket_path(conference.short_title, conference.tickets.first)
|
||||
expect(current_path).to eq(root_path)
|
||||
|
||||
visit admin_conference_campaigns_path(conference.short_title)
|
||||
expect(current_path).to eq(root_path)
|
||||
|
||||
visit new_admin_conference_campaign_path(conference.short_title)
|
||||
expect(current_path).to eq(root_path)
|
||||
|
||||
create(:campaign, conference: conference)
|
||||
visit edit_admin_conference_campaign_path(conference.short_title, conference.campaigns.first)
|
||||
expect(current_path).to eq(root_path)
|
||||
|
||||
visit admin_conference_targets_path(conference.short_title)
|
||||
expect(current_path).to eq(root_path)
|
||||
|
||||
visit new_admin_conference_target_path(conference.short_title)
|
||||
expect(current_path).to eq(root_path)
|
||||
|
||||
create(:target, conference: conference)
|
||||
visit edit_admin_conference_target_path(conference.short_title, conference.targets.first)
|
||||
expect(current_path).to eq(root_path)
|
||||
|
||||
visit admin_conference_roles_path(conference.short_title)
|
||||
expect(current_path).to eq(admin_conference_roles_path(conference.short_title))
|
||||
|
||||
|
|
|
|||
|
|
@ -29,9 +29,6 @@ feature 'Has correct abilities' do
|
|||
expect(page).to_not have_link('Sponsorship Levels', href: "/admin/conferences/#{conference.short_title}/sponsorship_levels")
|
||||
expect(page).to_not have_link('Sponsors', href: "/admin/conferences/#{conference.short_title}/sponsors")
|
||||
expect(page).to_not have_link('Tickets', href: "/admin/conferences/#{conference.short_title}/tickets")
|
||||
expect(page).to_not have_text('Objectives')
|
||||
expect(page).to_not have_link('Campaigns', href: "/admin/conferences/#{conference.short_title}/campaigns")
|
||||
expect(page).to_not have_link('Goals', href: "/admin/conferences/#{conference.short_title}/targets")
|
||||
expect(page).to have_link('Roles', href: "/admin/conferences/#{conference.short_title}/roles")
|
||||
expect(page).to have_link('Resources', href: "/admin/conferences/#{conference.short_title}/resources")
|
||||
expect(page).to have_selector('li.nav-header.nav-header-bigger a', text: 'Dashboard')
|
||||
|
|
@ -128,26 +125,6 @@ feature 'Has correct abilities' do
|
|||
visit edit_admin_conference_ticket_path(conference.short_title, conference.tickets.first)
|
||||
expect(current_path).to eq(root_path)
|
||||
|
||||
visit admin_conference_campaigns_path(conference.short_title)
|
||||
expect(current_path).to eq(root_path)
|
||||
|
||||
visit new_admin_conference_campaign_path(conference.short_title)
|
||||
expect(current_path).to eq(root_path)
|
||||
|
||||
create(:campaign, conference: conference)
|
||||
visit edit_admin_conference_campaign_path(conference.short_title, conference.campaigns.first)
|
||||
expect(current_path).to eq(root_path)
|
||||
|
||||
visit admin_conference_targets_path(conference.short_title)
|
||||
expect(current_path).to eq(root_path)
|
||||
|
||||
visit new_admin_conference_target_path(conference.short_title)
|
||||
expect(current_path).to eq(root_path)
|
||||
|
||||
create(:target, conference: conference)
|
||||
visit edit_admin_conference_target_path(conference.short_title, conference.targets.first)
|
||||
expect(current_path).to eq(root_path)
|
||||
|
||||
visit admin_conference_roles_path(conference.short_title)
|
||||
expect(current_path).to eq(admin_conference_roles_path(conference.short_title))
|
||||
|
||||
|
|
|
|||
|
|
@ -52,9 +52,6 @@ feature 'Has correct abilities' do
|
|||
expect(page).to have_link('Sponsorship Levels', href: "/admin/conferences/#{conference.short_title}/sponsorship_levels")
|
||||
expect(page).to have_link('Sponsors', href: "/admin/conferences/#{conference.short_title}/sponsors")
|
||||
expect(page).to have_link('Tickets', href: "/admin/conferences/#{conference.short_title}/tickets")
|
||||
expect(page).to have_text('Objectives')
|
||||
expect(page).to have_link('Campaigns', href: "/admin/conferences/#{conference.short_title}/campaigns")
|
||||
expect(page).to have_link('Goals', href: "/admin/conferences/#{conference.short_title}/targets")
|
||||
expect(page).to have_link('E-Mails', href: "/admin/conferences/#{conference.short_title}/emails")
|
||||
expect(page).to have_link('Roles', href: "/admin/conferences/#{conference.short_title}/roles")
|
||||
expect(page).to have_link('Resources', href: "/admin/conferences/#{conference.short_title}/resources")
|
||||
|
|
@ -236,26 +233,6 @@ feature 'Has correct abilities' do
|
|||
visit edit_admin_conference_ticket_path(conference.short_title, conference.tickets.first)
|
||||
expect(current_path).to eq(edit_admin_conference_ticket_path(conference.short_title, conference.tickets.first))
|
||||
|
||||
visit admin_conference_campaigns_path(conference.short_title)
|
||||
expect(current_path).to eq(admin_conference_campaigns_path(conference.short_title))
|
||||
|
||||
visit new_admin_conference_campaign_path(conference.short_title)
|
||||
expect(current_path).to eq(new_admin_conference_campaign_path(conference.short_title))
|
||||
|
||||
create(:campaign, conference: conference)
|
||||
visit edit_admin_conference_campaign_path(conference.short_title, conference.campaigns.first)
|
||||
expect(current_path).to eq(edit_admin_conference_campaign_path(conference.short_title, conference.campaigns.first))
|
||||
|
||||
visit admin_conference_targets_path(conference.short_title)
|
||||
expect(current_path).to eq(admin_conference_targets_path(conference.short_title))
|
||||
|
||||
visit new_admin_conference_target_path(conference.short_title)
|
||||
expect(current_path).to eq(new_admin_conference_target_path(conference.short_title))
|
||||
|
||||
create(:target, conference: conference)
|
||||
visit edit_admin_conference_target_path(conference.short_title, conference.targets.first)
|
||||
expect(current_path).to eq(edit_admin_conference_target_path(conference.short_title, conference.targets.first))
|
||||
|
||||
visit admin_conference_program_tracks_path(conference.short_title)
|
||||
expect(current_path).to eq(admin_conference_program_tracks_path(conference.short_title))
|
||||
|
||||
|
|
|
|||
|
|
@ -55,9 +55,6 @@ feature 'Has correct abilities' do
|
|||
expect(page).to have_link('Sponsorship Levels', href: "/admin/conferences/#{conference.short_title}/sponsorship_levels")
|
||||
expect(page).to have_link('Sponsors', href: "/admin/conferences/#{conference.short_title}/sponsors")
|
||||
expect(page).to have_link('Tickets', href: "/admin/conferences/#{conference.short_title}/tickets")
|
||||
expect(page).to have_text('Objectives')
|
||||
expect(page).to have_link('Campaigns', href: "/admin/conferences/#{conference.short_title}/campaigns")
|
||||
expect(page).to have_link('Goals', href: "/admin/conferences/#{conference.short_title}/targets")
|
||||
expect(page).to have_link('E-Mails', href: "/admin/conferences/#{conference.short_title}/emails")
|
||||
expect(page).to have_link('Roles', href: "/admin/conferences/#{conference.short_title}/roles")
|
||||
expect(page).to have_link('Resources', href: "/admin/conferences/#{conference.short_title}/resources")
|
||||
|
|
@ -242,26 +239,6 @@ feature 'Has correct abilities' do
|
|||
visit edit_admin_conference_ticket_path(conference.short_title, conference.tickets.first)
|
||||
expect(current_path).to eq(edit_admin_conference_ticket_path(conference.short_title, conference.tickets.first))
|
||||
|
||||
visit admin_conference_campaigns_path(conference.short_title)
|
||||
expect(current_path).to eq(admin_conference_campaigns_path(conference.short_title))
|
||||
|
||||
visit new_admin_conference_campaign_path(conference.short_title)
|
||||
expect(current_path).to eq(new_admin_conference_campaign_path(conference.short_title))
|
||||
|
||||
create(:campaign, conference: conference)
|
||||
visit edit_admin_conference_campaign_path(conference.short_title, conference.campaigns.first)
|
||||
expect(current_path).to eq(edit_admin_conference_campaign_path(conference.short_title, conference.campaigns.first))
|
||||
|
||||
visit admin_conference_targets_path(conference.short_title)
|
||||
expect(current_path).to eq(admin_conference_targets_path(conference.short_title))
|
||||
|
||||
visit new_admin_conference_target_path(conference.short_title)
|
||||
expect(current_path).to eq(new_admin_conference_target_path(conference.short_title))
|
||||
|
||||
create(:target, conference: conference)
|
||||
visit edit_admin_conference_target_path(conference.short_title, conference.targets.first)
|
||||
expect(current_path).to eq(edit_admin_conference_target_path(conference.short_title, conference.targets.first))
|
||||
|
||||
visit admin_conference_booths_path(conference.short_title)
|
||||
expect(current_path).to eq(admin_conference_booths_path(conference.short_title))
|
||||
|
||||
|
|
|
|||
|
|
@ -43,9 +43,6 @@ feature 'Has correct abilities' do
|
|||
expect(page).to_not have_link('Sponsorship Levels', href: "/admin/conferences/#{conference.short_title}/sponsorship_levels")
|
||||
expect(page).to_not have_link('Sponsors', href: "/admin/conferences/#{conference.short_title}/sponsors")
|
||||
expect(page).to_not have_link('Tickets', href: "/admin/conferences/#{conference.short_title}/tickets")
|
||||
expect(page).to_not have_text('Objectives')
|
||||
expect(page).to_not have_link('Campaigns', href: "/admin/conferences/#{conference.short_title}/campaigns")
|
||||
expect(page).to_not have_link('Goals', href: "/admin/conferences/#{conference.short_title}/targets")
|
||||
expect(page).to_not have_link('E-Mails', href: "/admin/conferences/#{conference.short_title}/emails")
|
||||
expect(page).to have_link('Roles', href: "/admin/conferences/#{conference.short_title}/roles")
|
||||
expect(page).to_not have_link('Resources', href: "/admin/conferences/#{conference.short_title}/resources")
|
||||
|
|
@ -192,26 +189,6 @@ feature 'Has correct abilities' do
|
|||
visit edit_admin_conference_ticket_path(conference.short_title, conference.tickets.first)
|
||||
expect(current_path).to eq root_path
|
||||
|
||||
visit admin_conference_campaigns_path(conference.short_title)
|
||||
expect(current_path).to eq root_path
|
||||
|
||||
visit new_admin_conference_campaign_path(conference.short_title)
|
||||
expect(current_path).to eq root_path
|
||||
|
||||
create(:campaign, conference: conference)
|
||||
visit edit_admin_conference_campaign_path(conference.short_title, conference.campaigns.first)
|
||||
expect(current_path).to eq root_path
|
||||
|
||||
visit admin_conference_targets_path(conference.short_title)
|
||||
expect(current_path).to eq root_path
|
||||
|
||||
visit new_admin_conference_target_path(conference.short_title)
|
||||
expect(current_path).to eq root_path
|
||||
|
||||
create(:target, conference: conference)
|
||||
visit edit_admin_conference_target_path(conference.short_title, conference.targets.first)
|
||||
expect(current_path).to eq root_path
|
||||
|
||||
visit admin_conference_program_tracks_path(conference.short_title)
|
||||
expect(current_path).to eq admin_conference_program_tracks_path(conference.short_title)
|
||||
|
||||
|
|
|
|||
|
|
@ -374,18 +374,6 @@ feature 'Version' do
|
|||
expect(page).to have_text("Someone (probably via the console) unregistered #{organizer.name} from event #{event.title} in conference #{conference.short_title}")
|
||||
end
|
||||
|
||||
scenario 'display changes in target', feature: true, versioning: true, js: true do
|
||||
target = create(:target, conference: conference)
|
||||
target.update_attributes(due_date: Date.today, target_count: 1000)
|
||||
target_id = target.id
|
||||
target.destroy
|
||||
|
||||
visit admin_revision_history_path
|
||||
expect(page).to have_text("Someone (probably via the console) created new target 1000 Submissions by #{Date.today} with ID #{target_id} in conference #{conference.short_title}")
|
||||
expect(page).to have_text("Someone (probably via the console) updated due date and target count of target 1000 Submissions by #{Date.today} with ID #{target_id} in conference #{conference.short_title}")
|
||||
expect(page).to have_text("Someone (probably via the console) deleted target 1000 Submissions by #{Date.today} with ID #{target_id} in conference #{conference.short_title}")
|
||||
end
|
||||
|
||||
scenario 'display changes in comment', feature: true, versioning: true, js: true do
|
||||
create(:event, program: conference.program, title: 'My first event')
|
||||
event = create(:event, program: conference.program, title: 'My second event')
|
||||
|
|
@ -416,18 +404,6 @@ feature 'Version' do
|
|||
expect(page).to have_text("Someone (probably via the console) re-added #{organizer.name}'s vote on event #{event.title} in conference #{conference.short_title}")
|
||||
end
|
||||
|
||||
scenario 'display changes in campaign', feature: true, versioning: true, js: true do
|
||||
campaign = create(:campaign, conference: conference, name: 'Test Campaign', utm_campaign: 'campaign')
|
||||
campaign.update_attributes(utm_source: 'source', utm_medium: 'medium', utm_term: 'term', utm_content: 'content')
|
||||
campaign_id = campaign.id
|
||||
campaign.destroy
|
||||
|
||||
visit admin_revision_history_path
|
||||
expect(page).to have_text("Someone (probably via the console) created new campaign Test Campaign with ID #{campaign_id} in conference #{conference.short_title}")
|
||||
expect(page).to have_text("Someone (probably via the console) updated utm source, utm medium, utm term and utm content of campaign Test Campaign with ID #{campaign_id} in conference #{conference.short_title}")
|
||||
expect(page).to have_text("Someone (probably via the console) deleted campaign Test Campaign with ID #{campaign_id} in conference #{conference.short_title}")
|
||||
end
|
||||
|
||||
scenario 'display password reset requests', feature: true, versioning: true, js: true do
|
||||
user = create(:user)
|
||||
user.send_reset_password_instructions
|
||||
|
|
|
|||
|
|
@ -1,73 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
require 'ahoy'
|
||||
|
||||
describe Campaign do
|
||||
describe 'validations' do
|
||||
it 'has a valid factory' do
|
||||
expect(build(:campaign)).to be_valid
|
||||
end
|
||||
|
||||
it 'is not valid without a name' do
|
||||
should validate_presence_of(:name)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#url_parameters' do
|
||||
it 'returns the parameters in the correct format' do
|
||||
campaign = create(:campaign, utm_source: 'google+', utm_medium: 'advertisement',
|
||||
utm_term: 'opensource', utm_content: 'content', utm_campaign: '20percent')
|
||||
campaign.conference = create(:conference)
|
||||
|
||||
result = '?utm_source=google+&utm_medium=advertisement&utm_term=opensource&utm_content=content&utm_campaign=20percent'
|
||||
expect(campaign.url_parameters).to eq(result)
|
||||
end
|
||||
|
||||
it 'returns only utm_campaign parameter if there are no parameters' do
|
||||
campaign = create(:campaign)
|
||||
campaign.conference = create(:conference)
|
||||
expect(campaign.url_parameters).to eq('?utm_campaign=testcampaign')
|
||||
end
|
||||
end
|
||||
|
||||
describe '#visits' do
|
||||
it 'returns one if there is one visit' do
|
||||
campaign = create(:campaign, utm_source: 'google+', utm_medium: 'advertisement',
|
||||
utm_term: 'opensource', utm_content: 'content', utm_campaign: '20percent')
|
||||
campaign.conference = build(:conference)
|
||||
|
||||
create(:visit, utm_source: 'google+', utm_medium: 'advertisement',
|
||||
utm_term: 'opensource', utm_content: 'content', utm_campaign: '20percent', started_at: Time.now + 1.hour)
|
||||
expect(campaign.visits_count).to eq(1)
|
||||
end
|
||||
|
||||
it 'returns zero if there are no visits' do
|
||||
campaign = create(:campaign, utm_source: 'google+', utm_medium: 'advertisement',
|
||||
utm_term: 'opensource', utm_content: 'content', utm_campaign: '20percent')
|
||||
campaign.conference = create(:conference)
|
||||
|
||||
expect(campaign.visits_count).to eq(0)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#registrations' do
|
||||
it 'returns zero if there are no registration' do
|
||||
campaign = build(:campaign, utm_source: 'google+', utm_medium: 'advertisement',
|
||||
utm_term: 'opensource', utm_content: 'content', utm_campaign: '20percent')
|
||||
campaign.conference = build(:conference)
|
||||
|
||||
expect(campaign.registrations_count).to eq(0)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#submissions' do
|
||||
it 'returns zero if there are no submissions' do
|
||||
campaign = build(:campaign, utm_source: 'google+', utm_medium: 'advertisement',
|
||||
utm_term: 'opensource', utm_content: 'content', utm_campaign: '20percent')
|
||||
campaign.conference = build(:conference)
|
||||
|
||||
expect(campaign.submissions_count).to eq(0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -302,69 +302,6 @@ describe Conference do
|
|||
|
||||
end
|
||||
|
||||
describe '#get_targets' do
|
||||
it 'returns 0 if there is no registration' do
|
||||
target = build(:target, target_count: 10, unit: Target.units[:registrations])
|
||||
subject.targets = [target]
|
||||
result = {
|
||||
"10 Registrations by #{target.due_date}" => '0'
|
||||
}
|
||||
expect(subject.get_targets(Target.units[:registrations])).to eq(result)
|
||||
end
|
||||
|
||||
it 'returns 10 if there is 1 registration of 10' do
|
||||
target = build(:target, target_count: 10, unit: Target.units[:registrations])
|
||||
subject.targets = [target]
|
||||
subject.registrations = [create(:registration)]
|
||||
result = {
|
||||
"10 Registrations by #{target.due_date}" => '10'
|
||||
}
|
||||
expect(subject.get_targets(Target.units[:registrations])).to eq(result)
|
||||
end
|
||||
|
||||
it 'returns an empty hash if there is no target' do
|
||||
expect(subject.get_targets(Target.units[:registrations])).to eq({})
|
||||
end
|
||||
|
||||
it 'returns 0 if there is no submission' do
|
||||
target = build(:target, target_count: 10, unit: Target.units[:submissions])
|
||||
subject.targets = [target]
|
||||
result = {
|
||||
"10 Submissions by #{target.due_date}" => '0'
|
||||
}
|
||||
expect(subject.get_targets(Target.units[:submissions])).to eq(result)
|
||||
end
|
||||
|
||||
it 'returns 10 if there is 1 submissions of 10' do
|
||||
target = build(:target, target_count: 10, unit: Target.units[:submissions])
|
||||
subject.targets = [target]
|
||||
subject.program.events = [create(:event)]
|
||||
result = {
|
||||
"10 Submissions by #{target.due_date}" => '10'
|
||||
}
|
||||
expect(subject.get_targets(Target.units[:submissions])).to eq(result)
|
||||
end
|
||||
|
||||
it 'returns 0 if there is no program minute' do
|
||||
target = build(:target, target_count: 300, unit: Target.units[:program_minutes])
|
||||
subject.targets = [target]
|
||||
result = {
|
||||
"300 Program minutes by #{target.due_date}" => '0'
|
||||
}
|
||||
expect(subject.get_targets(Target.units[:program_minutes])).to eq(result)
|
||||
end
|
||||
|
||||
it 'returns 10 if there is 30 program minutes of 300' do
|
||||
target = build(:target, target_count: 300, unit: Target.units[:program_minutes])
|
||||
subject.targets = [target]
|
||||
subject.program.events = [create(:event)]
|
||||
result = {
|
||||
"300 Program minutes by #{target.due_date}" => '10'
|
||||
}
|
||||
expect(subject.get_targets(Target.units[:program_minutes])).to eq(result)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'program hours and minutes' do
|
||||
before(:each) do
|
||||
@long = create(:event_type, length: 120)
|
||||
|
|
|
|||
|
|
@ -1,166 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe Target do
|
||||
let(:registration_target) { create(:target, target_count: 10, unit: Target.units[:registrations]) }
|
||||
let(:submission_target) { create(:target, target_count: 10, unit: Target.units[:submissions]) }
|
||||
let(:program_minutes_target) { create(:target, target_count: 300, unit: Target.units[:program_minutes]) }
|
||||
|
||||
describe 'validation' do
|
||||
it 'has a valid factory' do
|
||||
expect(build(:target)).to be_valid
|
||||
end
|
||||
|
||||
it 'is not valid without a due date' do
|
||||
should validate_presence_of(:due_date)
|
||||
end
|
||||
|
||||
it 'is not valid without a target_count' do
|
||||
should validate_presence_of(:target_count)
|
||||
end
|
||||
|
||||
it 'is not valid without a unit' do
|
||||
should validate_presence_of(:unit)
|
||||
end
|
||||
|
||||
it 'is valid with a target_count greater than zero' do
|
||||
should allow_value(10).for(:target_count)
|
||||
end
|
||||
|
||||
it 'is not valid with a target_count equals zero' do
|
||||
should_not allow_value(0).for(:target_count)
|
||||
end
|
||||
|
||||
it 'is not valid with a target_count smaller than zero' do
|
||||
should_not allow_value(-10).for(:target_count)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'default scope' do
|
||||
before do
|
||||
@first_target = create(:target, due_date: 2.days.from_now)
|
||||
@second_target = create(:target, due_date: 3.days.from_now)
|
||||
end
|
||||
|
||||
it 'orders by ascending due_date' do
|
||||
expect(Target.all).to match_array [@first_target, @second_target]
|
||||
end
|
||||
end
|
||||
|
||||
describe 'association' do
|
||||
it { should belong_to(:conference) }
|
||||
it { should belong_to(:campaign) }
|
||||
end
|
||||
|
||||
describe '#get_progress' do
|
||||
it 'returns zero, when there are no registrations' do
|
||||
expect(registration_target.get_progress).to eq('0')
|
||||
end
|
||||
|
||||
it 'returns 10, when there is 1 registration and the target is 10' do
|
||||
create(:registration, conference: registration_target.conference)
|
||||
|
||||
expect(registration_target.get_progress).to eq('10')
|
||||
end
|
||||
|
||||
it 'returns zero, when there are no submissions' do
|
||||
expect(submission_target.get_progress).to eq('0')
|
||||
end
|
||||
|
||||
it 'returns 10, when there is 1 submission and the target is 10' do
|
||||
create(:event, program: submission_target.conference.program)
|
||||
|
||||
expect(submission_target.get_progress).to eq('10')
|
||||
end
|
||||
|
||||
it 'returns zero, when there are no program minutes' do
|
||||
expect(program_minutes_target.get_progress).to eq('0')
|
||||
end
|
||||
|
||||
it 'returns 10, when there are 30 program minutes and the target is 300' do
|
||||
create(:event, program: program_minutes_target.conference.program)
|
||||
|
||||
expect(program_minutes_target.get_progress).to eq('10')
|
||||
end
|
||||
end
|
||||
|
||||
describe '#get_campaign' do
|
||||
context 'submissions' do
|
||||
before do
|
||||
submission_target.campaign = create(:campaign, name: 'Submission Campaign', conference: submission_target.conference)
|
||||
submission_target.created_at = Time.utc(2014, 5, 10)
|
||||
submission_target.due_date = Date.today + 4.days
|
||||
allow(submission_target.campaign).to receive(:submissions_count) { 20 }
|
||||
end
|
||||
|
||||
it 'returns a hash with values of the corresponding campaign submissions' do
|
||||
result = {
|
||||
'target_name' => "10 Submissions by #{Date.today + 4.days}",
|
||||
'campaign_name' => 'Submission Campaign',
|
||||
'value' => 20,
|
||||
'unit' => 'Submission',
|
||||
'created_at' => Time.utc(2014, 5, 10).in_time_zone,
|
||||
'progress' => '200',
|
||||
'days_left' => 4
|
||||
}
|
||||
|
||||
expect(submission_target.get_campaign).to eq result
|
||||
end
|
||||
end
|
||||
|
||||
context 'registrations' do
|
||||
before do
|
||||
registration_target.campaign = create(:campaign, name: 'Registration Campaign', conference: registration_target.conference)
|
||||
registration_target.created_at = Time.utc(2014, 5, 10)
|
||||
registration_target.due_date = Date.today + 4.days
|
||||
allow(registration_target.campaign).to receive(:registrations_count) { 20 }
|
||||
end
|
||||
|
||||
it 'returns a hash with values of the corresponding campaign registrations' do
|
||||
result = {
|
||||
'target_name' => "10 Registrations by #{Date.today + 4.days}",
|
||||
'campaign_name' => 'Registration Campaign',
|
||||
'value' => 20,
|
||||
'unit' => 'Registration',
|
||||
'created_at' => Time.utc(2014, 5, 10).in_time_zone,
|
||||
'progress' => '200',
|
||||
'days_left' => 4
|
||||
}
|
||||
|
||||
expect(registration_target.get_campaign).to eq result
|
||||
end
|
||||
end
|
||||
|
||||
context 'program_minutes' do
|
||||
before do
|
||||
program_minutes_target.campaign = create(:campaign, name: 'Program Campaign', conference: program_minutes_target.conference)
|
||||
program_minutes_target.created_at = Time.utc(2014, 5, 10)
|
||||
program_minutes_target.due_date = Date.today + 4.days
|
||||
allow(program_minutes_target.conference).to receive(:current_program_minutes) { 20 }
|
||||
end
|
||||
|
||||
it 'returns a hash with values of the corresponding campaign program minutes' do
|
||||
result = {
|
||||
'target_name' => "300 Program minutes by #{Date.today + 4.days}",
|
||||
'campaign_name' => 'Program Campaign',
|
||||
'value' => 20,
|
||||
'unit' => 'Program minute',
|
||||
'created_at' => Time.utc(2014, 5, 10).in_time_zone,
|
||||
'progress' => '7',
|
||||
'days_left' => 4
|
||||
}
|
||||
|
||||
expect(program_minutes_target.get_campaign).to eq result
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#to_s' do
|
||||
it 'returns a string in the correct format' do
|
||||
result = "10 Registrations by #{14.days.from_now.to_date}"
|
||||
|
||||
expect(registration_target.to_s).to eq(result)
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue