Merge pull request #2523 from hennevogel/bugfix/gigitty_link

Bugfix/gigitty link
This commit is contained in:
Henne Vogelsang 2019-05-24 15:32:43 +02:00 committed by GitHub
commit dcd10f170f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 31 additions and 640 deletions

View file

@ -228,7 +228,7 @@ linters:
- "app/views/schedules/_schedule.html.haml"
- "app/views/schedules/_schedule_item.html.haml"
- "app/views/schedules/_schedule_tabs.html.haml"
- "app/views/schedules/_qr_code_modal.html.haml"
- "app/views/schedules/app.html.haml"
- "app/views/schedules/events.html.haml"
- "app/views/schedules/show.html.haml"
- "app/views/schedules/show.xml.haml"

607
34
View file

@ -1,607 +0,0 @@
# frozen_string_literal: true
require 'spec_helper'
describe ProposalsController do
let(:user) { create(:user) }
let(:conference) { create(:conference, short_title: 'lama101') }
let(:event) { create(:event, program: conference.program) }
let(:event_type) { create :event_type }
context 'user is not signed in' do
describe 'GET #new' do
before do
# We allow new proposal only if program has open cfp
create(:cfp, program: conference.program)
get :new, params: { conference_id: conference.short_title }
end
it 'assigns user and url variables' do
expect(assigns(:user)).to be_instance_of(User)
expect(assigns(:url)).to eq '/conferences/lama101/program/proposals'
end
it 'renders new template' do
expect(response).to render_template('new')
end
end
describe 'POST #create' do
# We allow proposal create only if program has open cfp
before { create(:cfp, program: conference.program) }
it 'assigns url variables' do
post :create, params: { event: attributes_for(:event, event_type_id: event_type.id), }
conference_id: conference.short_title,
user: attributes_for(:user)
expect(assigns(:url)).to eq '/conferences/lama101/program/proposals'
end
context 'user is saved successfully' do
describe 'user related actions' do
before do
@new_user = attributes_for(:user)
post :create, params: { event: attributes_for(:event, event_type_id: event_type.id),
conference_id: conference.short_title,
user: @new_user
}
end
it 'creates new user' do
expect(User.last.username).to eq @new_user[:username]
end
it 'signs in new user' do
expect(controller.current_user.username).to eq @new_user[:username]
end
end
context 'creates proposal successfully' do
before(:each, run: true) do
@new_user = attributes_for(:user)
post :create, params: { event: attributes_for(:event, event_type_id: event_type.id),
conference_id: conference.short_title,
user: @new_user
}
end
it 'assigns event variable', run: true do
expect(assigns(:event)).not_to be_nil
end
it 'assigns program to event', run: true do
expect(assigns(:event).program).to eq conference.program
end
it 'assigns submitter and speaker to event', run: true do
expect(assigns(:event).submitter.username).to eq @new_user[:username]
expect(assigns(:event).speakers.first.username).to eq @new_user[:username]
end
it 'redirects to proposal index path', run: true do
expect(response).to redirect_to conference_program_proposals_path conference.short_title
end
it 'shows success message in flash notice', run: true do
expect(flash[:notice]).to match('Proposal was successfully submitted.')
end
it 'creates new event' do
expect do
post :create, params: { event: attributes_for(:event, event_type_id: event_type.id),
conference_id: conference.short_title,
user: attributes_for(:user)
}
end.to change{ Event.count }.by 1
end
end
context 'proposal save fails' do
before(:each, run: true) do
allow_any_instance_of(Event).to receive(:save).and_return(false)
post :create, params: { event: attributes_for(:event, event_type_id: event_type.id),
conference_id: conference.short_title,
user: attributes_for(:user)
}
end
it 'renders new template', run: true do
expect(response).to render_template('new')
end
it 'shows error in flash message', run: true do
expect(flash[:error]).to match("Could not submit proposal: #{event.errors.full_messages.join(', ')}")
end
it 'does not create new proposal' do
allow_any_instance_of(Event).to receive(:save).and_return(false)
expect do
post :create, params: { event: attributes_for(:event, event_type_id: event_type.id),
conference_id: conference.short_title,
user: attributes_for(:user)
}
end.not_to change{ Event.count }
end
end
end
context 'user save fails' do
before { allow_any_instance_of(User).to receive(:save).and_return(false) }
it 'does not create new user' do
expect do
post :create, params: { event: attributes_for(:event, event_type_id: event_type.id),
conference_id: conference.short_title,
user: attributes_for(:user)
}
end.not_to change { User.count }
end
it 'does not create new event' do
expect do
post :create, params: { event: attributes_for(:event, event_type_id: event_type.id),
conference_id: conference.short_title,
user: attributes_for(:user)
}
end.not_to change { Event.count }
end
describe 'response' do
before do
post :create, params: { event: attributes_for(:event, event_type_id: event_type.id),
conference_id: conference.short_title,
user: attributes_for(:user)
}
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 "Could not save user: #{user.errors.full_messages.join(', ')}"
end
end
end
end
end
context 'event submitter is signed in' do
before do
sign_in event.submitter
end
describe 'GET #index' do
before { get :index, params: { conference_id: conference.short_title } }
it 'assigns conference, program and events variables' do
expect(assigns(:conference)).to eq conference
expect(assigns(:program)).to eq conference.program
expect(assigns(:events)).to eq [event]
end
it 'renders index template' do
expect(response).to render_template('index')
end
end
describe 'GET #show' do
before do
get :show, params: { conference_id: conference.short_title, id: event.id }
end
it 'assigns event variable' do
expect(assigns(:event)).to eq event
end
it 'renders show template' do
expect(response).to render_template('show')
end
end
describe 'GET #new' do
before do
# We allow new proposal only if program has open cfp
create(:cfp, program: conference.program)
get :new, params: { conference_id: conference.short_title }
end
it 'assigns user and url variables' do
expect(assigns(:user)).to be_instance_of(User)
expect(assigns(:url)).to eq '/conferences/lama101/program/proposals'
end
it 'renders new template' do
expect(response).to render_template('new')
end
end
describe 'GET #edit' do
before do
get :edit, params: { conference_id: conference.short_title, id: event.id }
end
it 'assigns event and url variables' do
expect(assigns(:event)).to eq event
expect(assigns(:url)).to eq "/conferences/lama101/program/proposals/#{event.id}"
end
it 'renders edit template' do
expect(response).to render_template('edit')
end
end
describe 'POST #create' do
# We allow proposal create only if program has open cfp
before { create(:cfp, program: conference.program) }
it 'assigns url variables' do
post :create, params: { event: attributes_for(:event, event_type_id: event_type.id),
conference_id: conference.short_title
}
expect(assigns(:url)).to eq '/conferences/lama101/program/proposals'
end
context 'creates proposal successfully' do
before(:each, run: true) do
post :create, params: { event: attributes_for(:event, event_type_id: event_type.id),
conference_id: conference.short_title
}
end
it 'assigns event variable', run: true do
expect(assigns(:event)).not_to be_nil
end
it 'assigns program to event', run: true do
expect(assigns(:event).program).to eq conference.program
end
it 'assigns submitter and speaker to event', run: true do
expect(assigns(:event).submitter).to eq event.submitter
expect(assigns(:event).speakers.first).to eq event.submitter
end
it 'redirects to proposal index path', run: true do
expect(response).to redirect_to conference_program_proposals_path conference.short_title
end
it 'shows success message in flash notice', run: true do
expect(flash[:notice]).to match('Proposal was successfully submitted.')
end
it 'creates new event' do
expect do
post :create, params: { event: attributes_for(:event, event_type_id: event_type.id),
conference_id: conference.short_title
}
end.to change{ Event.count }.by 1
end
end
context 'proposal save fails' do
before(:each, run: true) do
allow_any_instance_of(Event).to receive(:save).and_return(false)
post :create, params: { event: attributes_for(:event, event_type_id: event_type.id),
conference_id: conference.short_title
}
end
it 'renders new template', run: true do
expect(response).to render_template('new')
end
it 'shows error in flash message', run: true do
expect(flash[:error]).to match("Could not submit proposal: #{event.errors.full_messages.join(', ')}")
end
it 'does not create new proposal' do
allow_any_instance_of(Event).to receive(:save).and_return(false)
expect do
post :create, params: { event: attributes_for(:event, event_type_id: event_type.id),
conference_id: conference.short_title
}
end.not_to change{ Event.count }
end
end
end
describe 'PATCH #update' do
it 'assigns url variable' do
patch :update, params: { event: attributes_for(:event, title: 'some title', event_type_id: event_type.id),
conference_id: conference.short_title,
id: event.id
}
expect(assigns(:url)).to eq "/conferences/lama101/program/proposals/#{event.id}"
end
context 'updates successfully' do
before do
patch :update, params: { event: attributes_for(:event, title: 'some title', event_type_id: event_type.id),
conference_id: conference.short_title,
id: event.id
}
end
it 'updates the proposal' do
event.reload
expect(event.title).to eq 'some title'
end
it 'redirects to proposal index path' do
expect(response).to redirect_to conference_program_proposals_path conference.short_title
end
it 'shows success message in flash notice' do
expect(flash[:notice]).to match('Proposal was successfully updated.')
end
end
context 'update fails' do
before do
allow_any_instance_of(Event).to receive(:save).and_return(false)
patch :update, params: { event: attributes_for(:event, title: 'some title', event_type_id: event_type.id),
conference_id: conference.short_title,
id: event.id
}
end
it 'does not update the proposal' do
event.reload
expect(event.title).not_to eq 'some title'
end
it 'renders edit template' do
expect(response).to render_template('edit')
end
it 'shows error in flash message', run: true do
expect(flash[:error]).to match("Could not update proposal: #{event.errors.full_messages.join(', ')}")
end
end
end
describe 'PATCH #withdraw' do
it 'assigns url variable' do
patch :withdraw, params: { conference_id: conference.short_title, id: event.id }
expect(assigns(:url)).to eq "/conferences/lama101/program/proposals/#{event.id}"
end
context 'withdraws successfully' do
before do
patch :withdraw, params: { conference_id: conference.short_title, id: event.id }
end
it 'changes state of event to withdrawn' do
event.reload
expect(event.withdrawn?).to be true
end
it 'redirects to proposal index path' do
expect(response).to redirect_to conference_program_proposals_path conference.short_title
end
it 'shows success message in flash notice' do
expect(flash[:notice]).to match('Proposal was successfully withdrawn.')
end
end
context 'event withdraw fails' do
before do
request.env['HTTP_REFERER'] = '/'
allow_any_instance_of(Event).to receive(:withdraw).and_raise(Transitions::InvalidTransition)
patch :withdraw, params: { conference_id: conference.short_title, id: event.id }
end
it 'does not withdraw event' do
event.reload
expect(event.withdrawn?).to be false
end
it 'redirects to previous path' do
expect(response).to redirect_to '/'
end
it 'shows error in flash message' do
expect(flash[:error]).to match("Event can't be withdrawn")
end
end
context 'event save fails' do
before do
allow_any_instance_of(Event).to receive(:save).and_return(false)
patch :withdraw, params: { conference_id: conference.short_title, id: event.id }
end
it 'does not withdraw event' do
event.reload
expect(event.withdrawn?).to be false
end
it 'redirects to proposal index path' do
expect(response).to redirect_to conference_program_proposals_path conference.short_title
end
it 'shows error in flash message' do
expect(flash[:error]).to match("Could not withdraw proposal: #{event.errors.full_messages.join(', ')}")
end
end
end
describe 'PATCH #confirm' do
before { event.update_attributes(state: 'unconfirmed') }
context 'confirmed successfully' do
describe 'when require_registration is set' do
before :each do
event.require_registration = true
event.max_attendees = nil
event.save!
patch :confirm, params: { conference_id: conference.short_title, id: event.id }
end
it 'assigns url variable' do
expect(assigns(:url)).to eq "/conferences/lama101/program/proposals/#{event.id}"
end
it 'change state of event to confirmed' do
event.reload
expect(event.confirmed?).to be true
end
end
describe 'general actions' do
before { patch :confirm, params: { conference_id: conference.short_title, id: event.id } }
it 'assigns url variable' do
expect(assigns(:url)).to eq "/conferences/lama101/program/proposals/#{event.id}"
end
it 'change state of event to confirmed' do
event.reload
expect(event.confirmed?).to be true
end
end
context 'user has registered for the conference' do
before do
create(:registration, conference: conference, user: event.submitter)
patch :confirm, params: { conference_id: conference.short_title, id: event.id }
end
it 'redirects to proposal index path' do
expect(response).to redirect_to conference_program_proposals_path conference.short_title
end
it 'shows success message in flash notice' do
expect(flash[:notice]).to match('The proposal was confirmed.')
end
end
context 'user has not registered for the conference' do
before do
patch :confirm, params: { conference_id: conference.short_title, id: event.id }
end
it 'redirects to new registration path' do
expect(response).to redirect_to new_conference_conference_registration_path conference.short_title
end
it 'shows flash alert asking user to register' do
expect(flash[:alert]).to match('The proposal was confirmed. Please register to attend the conference.')
end
end
end
context 'event confirm fails' do
before do
request.env['HTTP_REFERER'] = '/'
allow_any_instance_of(Event).to receive(:confirm).and_raise(Transitions::InvalidTransition)
patch :confirm, params: { conference_id: conference.short_title, id: event.id }
end
it 'does not confirm event' do
expect(event.confirmed?).to be false
end
it 'redirects to previous path' do
expect(response).to redirect_to '/'
end
it 'shows error in flash message' do
expect(flash[:error]).to match("Event can't be confirmed")
end
end
context 'event save fails' do
before do
event.update_attributes(state: 'unconfirmed')
allow_any_instance_of(Event).to receive(:save).and_return(false)
patch :confirm, params: { conference_id: conference.short_title, id: event.id }
end
it 'does not confirm event' do
expect(event.confirmed?).to be false
end
it 'redirects to proposal index path' do
expect(response).to redirect_to conference_program_proposals_path conference.short_title
end
it 'shows error in flash message' do
expect(flash[:error]).to match("Could not confirm proposal: #{event.errors.full_messages.join(', ')}")
end
end
end
describe 'PATCH #restart' do
before { event.update_attributes(state: 'withdrawn') }
it 'assigns url variable' do
patch :restart, params: { conference_id: conference.short_title, id: event.id }
expect(assigns(:url)).to eq "/conferences/lama101/program/proposals/#{event.id}"
end
context 'resubmits successfully' do
before do
patch :restart, params: { conference_id: conference.short_title, id: event.id }
end
it 'changes state of event to new' do
event.reload
expect(event.new?).to be true
end
it 'redirects to proposal index path' do
expect(response).to redirect_to conference_program_proposals_path conference.short_title
end
it 'shows success message in flash notice' do
expect(flash[:notice]).to match("The proposal was re-submitted. The #{conference.short_title} organizers will review it again.")
end
end
context 'event resubmission fails' do
before do
allow_any_instance_of(Event).to receive(:restart).and_raise(Transitions::InvalidTransition)
patch :restart, params: { conference_id: conference.short_title, id: event.id }
end
it 'does not change state of event to new' do
event.reload
expect(event.new?).to be false
end
it 'redirects to proposal index path' do
expect(response).to redirect_to conference_program_proposals_path conference.short_title
end
it 'shows error in flash message' do
expect(flash[:error]).to match("The proposal can't be re-submitted.")
end
end
context 'event save fails' do
before do
allow_any_instance_of(Event).to receive(:save).and_return(false)
patch :restart, params: { conference_id: conference.short_title, id: event.id }
end
it 'does not change state of event to new' do
event.reload
expect(event.new?).to be false
end
it 'redirects to proposal index path' do
expect(response).to redirect_to conference_program_proposals_path conference.short_title
end
it 'shows error in flash message' do
expect(flash[:error]).to match("Could not re-submit proposal: #{event.errors.full_messages.join(', ')}")
end
end
end
end
end

View file

@ -43,9 +43,6 @@ class SchedulesController < ApplicationController
end
@selected_schedules_ids.compact!
@event_schedules_by_room_id = event_schedules.select { |s| @selected_schedules_ids.include?(s.schedule_id) }.group_by(&:room_id)
@qr_code = RQRCode::QRCode.new(conference_schedule_url).as_svg(offset: 20, color: '000',
shape_rendering: 'crispEdges',
module_size: 11)
end
end
end
@ -63,6 +60,10 @@ class SchedulesController < ApplicationController
@tag = day.strftime('%Y-%m-%d') if day
end
def app
@qr_code = RQRCode::QRCode.new(conference_schedule_url).as_svg(offset: 20, color: '000', shape_rendering: 'crispEdges', module_size: 11)
end
private
def respond_to_options

View file

@ -31,7 +31,7 @@ class Ability
event.state == 'confirmed'
end
can [:show, :events], Schedule do |schedule|
can [:show, :events, :app], Schedule do |schedule|
schedule.program.schedule_public
end

View file

@ -1,27 +0,0 @@
/ Button trigger modal
%button.btn.btn-link.btn-lg.pull-right{ 'data-target': '#schedule-modal',
'data-toggle': 'modal',
type: 'button' }
Get the mobile app!
/ Modal
.modal.fade#schedule-modal{ 'aria-labelledby': 'schedule-modal-label', role: 'dialog', tabindex: '-1' }
.modal-dialog{ role: 'document' }
.modal-content
.modal-header
%button.close{ 'aria-label': 'Close', 'data-dismiss': 'modal', type: 'button' }
%span{ 'aria-hidden': 'true' }
%h4.modal-title#schedule-modal-label
Get the schedule on your mobile with Giggity!
.modal-body.center-block.text-center
= link_to 'https://f-droid.org/packages/net.gaast.giggity' do
%img.img-responsive{ alt: 'Get it on F-Droid', src: 'https://fdroid.gitlab.io/artwork/badge/get-it-on.png' }
%p
\...and point your phone at the QR code...
.img-responsive
= raw qr_code
.modal-footer
%p.small.text-muted.pull-left
Not free of surveilance capitalism yet? Try the
= link_to 'https://play.google.com/store/apps/details?id=net.gaast.giggity' do
google play store...
%button.btn.btn-default{ 'data-dismiss': 'modal', type: 'button' } Close

View file

@ -0,0 +1,19 @@
.container
.page-header
%h1
Get the schedule on your mobile with Giggity!
= link_to 'https://f-droid.org/packages/net.gaast.giggity' do
%img.img-responsive.center-block{ alt: 'Get it on F-Droid', src: 'https://fdroid.gitlab.io/artwork/badge/get-it-on.png' }
%p
The schedule URL:
%p.lead.text-center
= link_to conference_schedule_url(format: :xml) do
= conference_schedule_url(format: :xml)
%p
Or point your phone at the QR code:
.img-responsive.text-center
= raw @qr_code
%p.text-muted
Not free of surveilance capitalism yet? Use the
= link_to 'https://play.google.com/store/apps/details?id=net.gaast.giggity' do
google play store...

View file

@ -26,7 +26,9 @@
.visible-md-inline.visible-lg-inline
= render partial: 'carousel', locals: { date: date, hrs_per_slide: 3 }
= render partial: 'qr_code_modal', locals: { qr_code: @qr_code }
%p.pull-right
= link_to app_conference_schedule_path do
Get the mobile app!
:javascript
// change of active tab and the button title when a date is clicked

View file

@ -193,6 +193,9 @@ Osem::Application.routes.draw do
resources :physical_tickets, only: [:index, :show]
resource :subscriptions, only: [:create, :destroy]
resource :schedule, only: [:show] do
collection do
get 'app'
end
member do
get :events
end