Merge branch 'master' into custom-domain
This commit is contained in:
commit
e3d41bcf7d
30 changed files with 271 additions and 21 deletions
|
|
@ -78,6 +78,7 @@ linters:
|
||||||
- "app/views/admin/resources/show.html.haml"
|
- "app/views/admin/resources/show.html.haml"
|
||||||
- "app/views/admin/roles/_form.html.haml"
|
- "app/views/admin/roles/_form.html.haml"
|
||||||
- "app/views/admin/roles/_users.html.haml"
|
- "app/views/admin/roles/_users.html.haml"
|
||||||
|
- "app/views/admin/roles/_users_with_org_admin_role.haml"
|
||||||
- "app/views/admin/roles/index.html.haml"
|
- "app/views/admin/roles/index.html.haml"
|
||||||
- "app/views/admin/roles/show.html.haml"
|
- "app/views/admin/roles/show.html.haml"
|
||||||
- "app/views/admin/rooms/_form.html.haml"
|
- "app/views/admin/rooms/_form.html.haml"
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,6 @@ $(function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function draw_line_chart(animation, $canvas){
|
function draw_line_chart(animation, $canvas){
|
||||||
var options = get_animation({}, animation);
|
|
||||||
var chart_data = create_dataset($canvas);
|
var chart_data = create_dataset($canvas);
|
||||||
var weeks = $canvas.parent().data('weeks');
|
var weeks = $canvas.parent().data('weeks');
|
||||||
var data = {
|
var data = {
|
||||||
|
|
@ -63,10 +62,27 @@ $(function() {
|
||||||
datasets : chart_data
|
datasets : chart_data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var options = get_animation(wholeNumberAxisFix(data), animation);
|
||||||
var ctx = $canvas.get(0).getContext("2d");
|
var ctx = $canvas.get(0).getContext("2d");
|
||||||
new Chart(ctx).Line(data, options);
|
new Chart(ctx).Line(data, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function wholeNumberAxisFix(data){
|
||||||
|
var maxValue = false;
|
||||||
|
for(datasetIndex = 0; datasetIndex < data.datasets.length; ++datasetIndex){
|
||||||
|
var setMax = Math.max.apply(null, data.datasets[datasetIndex].data);
|
||||||
|
if (maxValue === false || setMax > maxValue) maxValue = setMax;
|
||||||
|
}
|
||||||
|
|
||||||
|
var steps = maxValue;
|
||||||
|
var stepWidth = 1;
|
||||||
|
if (maxValue > 10) {
|
||||||
|
stepWidth = Math.floor(maxValue / 10);
|
||||||
|
steps = Math.ceil(maxValue / stepWidth);
|
||||||
|
}
|
||||||
|
return { scaleOverride: true, scaleSteps: steps, scaleStepWidth: stepWidth, scaleStartValue: 0 };
|
||||||
|
}
|
||||||
|
|
||||||
function create_dataset($canvas){
|
function create_dataset($canvas){
|
||||||
var selected = getSelectedConferences($canvas);
|
var selected = getSelectedConferences($canvas);
|
||||||
var chart_data = $canvas.parent().data('chart');
|
var chart_data = $canvas.parent().data('chart');
|
||||||
|
|
|
||||||
|
|
@ -94,3 +94,13 @@ p.comment-body {
|
||||||
.box{
|
.box{
|
||||||
height: 230px;
|
height: 230px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* sidebar hamburger btn */
|
||||||
|
.side-nav-btn{
|
||||||
|
margin-left: 10px;
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.qr-image{
|
||||||
|
margin-left: 120px;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,11 +72,12 @@ module Admin
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@conference = Conference.new
|
@conference = Conference.new
|
||||||
|
@organizations = Organization.accessible_by(current_ability, :update).pluck(:name, :id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@conference = Conference.new(conference_params)
|
@conference = Conference.new(conference_params)
|
||||||
@conference.organization = Organization.find_or_create_by(name: 'organization')
|
|
||||||
if @conference.save
|
if @conference.save
|
||||||
# user that creates the conference becomes organizer of that conference
|
# user that creates the conference becomes organizer of that conference
|
||||||
current_user.add_role :organizer, @conference
|
current_user.add_role :organizer, @conference
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
module Admin
|
module Admin
|
||||||
class OrganizationsController < Admin::BaseController
|
class OrganizationsController < Admin::BaseController
|
||||||
load_and_authorize_resource :organization
|
load_and_authorize_resource :organization
|
||||||
|
before_action :verify_user, only: [:assign_org_admins, :unassign_org_admins]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@organizations = Organization.all
|
@organizations = Organization.all
|
||||||
|
|
@ -43,8 +44,49 @@ module Admin
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def assign_org_admins
|
||||||
|
if @user.has_role? 'organization_admin', @organization
|
||||||
|
flash[:error] = "User #{@user.email} already has the role organization admin"
|
||||||
|
elsif @user.add_role 'organization_admin', @organization
|
||||||
|
flash[:notice] = "Successfully added role organization admin to user #{@user.email}"
|
||||||
|
else
|
||||||
|
flash[:error] = "Coud not add role organization admin to #{@user.email}"
|
||||||
|
end
|
||||||
|
|
||||||
|
redirect_to admins_admin_organization_path(@organization)
|
||||||
|
end
|
||||||
|
|
||||||
|
def unassign_org_admins
|
||||||
|
if @user.remove_role 'organization_admin', @organization
|
||||||
|
flash[:notice] = "Successfully removed role organization admin from user #{@user.email}"
|
||||||
|
else
|
||||||
|
flash[:error] = "Could not remove role organization admin from user #{@user.email}"
|
||||||
|
end
|
||||||
|
|
||||||
|
redirect_to admins_admin_organization_path(@organization)
|
||||||
|
end
|
||||||
|
|
||||||
|
def admins
|
||||||
|
@role = @organization.roles.first
|
||||||
|
@users = @role.users
|
||||||
|
render 'show_org_admins'
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def user_params
|
||||||
|
params.require(:user).permit(:email)
|
||||||
|
end
|
||||||
|
|
||||||
|
def verify_user
|
||||||
|
@user = User.find_by(email: user_params[:email])
|
||||||
|
unless @user
|
||||||
|
redirect_to admins_admin_organization_path(@organization),
|
||||||
|
error: 'Could not find user. Please provide a valid email!'
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def organization_params
|
def organization_params
|
||||||
params.require(:organization).permit(:name, :description, :picture)
|
params.require(:organization).permit(:name, :description, :picture)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ class PhysicalTicketController < ApplicationController
|
||||||
@file_name = "ticket_for_#{@conference.short_title}"
|
@file_name = "ticket_for_#{@conference.short_title}"
|
||||||
@user = @physical_ticket.user
|
@user = @physical_ticket.user
|
||||||
@ticket_layout = @conference.ticket_layout.to_sym
|
@ticket_layout = @conference.ticket_layout.to_sym
|
||||||
|
@qrcode_image = RQRCode::QRCode.new(@physical_ticket.token).as_png(size: 180, border_modules: 0)
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
format.pdf do
|
format.pdf do
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ class TicketPurchasesController < ApplicationController
|
||||||
before_filter :authenticate_user!
|
before_filter :authenticate_user!
|
||||||
load_resource :conference, find_by: :short_title
|
load_resource :conference, find_by: :short_title
|
||||||
authorize_resource :conference_registrations, class: Registration
|
authorize_resource :conference_registrations, class: Registration
|
||||||
|
authorize_resource
|
||||||
|
|
||||||
def create
|
def create
|
||||||
current_user.ticket_purchases.by_conference(@conference).unpaid.destroy_all
|
current_user.ticket_purchases.by_conference(@conference).unpaid.destroy_all
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ class AdminAbility
|
||||||
conference.registration_open? && !conference.registration_limit_exceeded? || conference.program.speakers.confirmed.include?(user)
|
conference.registration_open? && !conference.registration_limit_exceeded? || conference.program.speakers.confirmed.include?(user)
|
||||||
end
|
end
|
||||||
|
|
||||||
can :index, Organization
|
can [:index, :admins], Organization
|
||||||
can :index, Ticket
|
can :index, Ticket
|
||||||
can :manage, TicketPurchase, user_id: user.id
|
can :manage, TicketPurchase, user_id: user.id
|
||||||
can [:new, :create], Payment, user_id: user.id
|
can [:new, :create], Payment, user_id: user.id
|
||||||
|
|
@ -96,13 +96,11 @@ class AdminAbility
|
||||||
org_ids_for_organization_admin = Organization.with_role(:organization_admin, user).pluck(:id)
|
org_ids_for_organization_admin = Organization.with_role(:organization_admin, user).pluck(:id)
|
||||||
conf_ids_for_organization_admin = Conference.where(organization_id: org_ids_for_organization_admin).pluck(:id)
|
conf_ids_for_organization_admin = Conference.where(organization_id: org_ids_for_organization_admin).pluck(:id)
|
||||||
|
|
||||||
can [:read, :update, :destroy], Organization, id: org_ids_for_organization_admin
|
can [:read, :update, :destroy, :assign_org_admins, :unassign_org_admins, :admins], Organization, id: org_ids_for_organization_admin
|
||||||
can :new, Conference
|
can :new, Conference
|
||||||
can :manage, Conference, organization_id: org_ids_for_organization_admin
|
can :manage, Conference, organization_id: org_ids_for_organization_admin
|
||||||
can [:index, :show], Role
|
can [:index, :show], Role
|
||||||
can [:edit, :update], Role do |role|
|
|
||||||
role.resource_type == 'Organization' && (org_ids_for_organization_admin.include? role.resource_id)
|
|
||||||
end
|
|
||||||
signed_in_with_organizer_role(user, conf_ids_for_organization_admin)
|
signed_in_with_organizer_role(user, conf_ids_for_organization_admin)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -123,7 +121,10 @@ class AdminAbility
|
||||||
can :manage, Commercial, commercialable_type: 'Conference',
|
can :manage, Commercial, commercialable_type: 'Conference',
|
||||||
commercialable_id: conf_ids
|
commercialable_id: conf_ids
|
||||||
can :manage, Registration, conference_id: conf_ids
|
can :manage, Registration, conference_id: conf_ids
|
||||||
can :manage, RegistrationPeriod, conference_id: conf_ids
|
can :manage, RegistrationPeriod do |registration_period|
|
||||||
|
conference = registration_period.conference
|
||||||
|
conf_ids.include?(conference.id) && conference.tickets.for_registration.any?
|
||||||
|
end
|
||||||
can :manage, Booth, conference_id: conf_ids
|
can :manage, Booth, conference_id: conf_ids
|
||||||
can :manage, Question, conference_id: conf_ids
|
can :manage, Question, conference_id: conf_ids
|
||||||
can :manage, Question do |question|
|
can :manage, Question do |question|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,11 @@ class Conference < ActiveRecord::Base
|
||||||
has_many :ticket_purchases, dependent: :destroy
|
has_many :ticket_purchases, dependent: :destroy
|
||||||
has_many :payments, dependent: :destroy
|
has_many :payments, dependent: :destroy
|
||||||
has_many :supporters, through: :ticket_purchases, source: :user
|
has_many :supporters, through: :ticket_purchases, source: :user
|
||||||
has_many :tickets, dependent: :destroy
|
has_many :tickets, dependent: :destroy do
|
||||||
|
def for_registration
|
||||||
|
where(registration_ticket: true)
|
||||||
|
end
|
||||||
|
end
|
||||||
has_many :resources, dependent: :destroy
|
has_many :resources, dependent: :destroy
|
||||||
has_many :booths, dependent: :destroy
|
has_many :booths, dependent: :destroy
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -77,5 +77,9 @@ class TicketPdf < Prawn::Document
|
||||||
move_up 180
|
move_up 180
|
||||||
end
|
end
|
||||||
|
|
||||||
def draw_fourth_square; end
|
def draw_fourth_square
|
||||||
|
x = @mid_horizontal + (@right - @mid_horizontal - 180) / 2
|
||||||
|
y = cursor - (bounds.top - @mid_vertical - 180) / 2
|
||||||
|
print_qr_code(@physical_ticket.token, pos: [x, y], extent: 180, stroke: false)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
.col-md-8
|
.col-md-8
|
||||||
= semantic_form_for(@conference, url: admin_conferences_path) do |f|
|
= semantic_form_for(@conference, url: admin_conferences_path) do |f|
|
||||||
= f.inputs 'Basic Information' do
|
= f.inputs 'Basic Information' do
|
||||||
|
= f.input :organization, as: :select, collection: @organizations
|
||||||
= f.input :title, hint: "The name of your conference as it shall appear throughout the site. Example: 'OpenSUSE Conference 2013'",
|
= f.input :title, hint: "The name of your conference as it shall appear throughout the site. Example: 'OpenSUSE Conference 2013'",
|
||||||
input_html: { required: 'required' }
|
input_html: { required: 'required' }
|
||||||
= f.input :short_title, hint: "A short and unique handle for your conference, using only letters, numbers, underscores, and dashes. This will be used to identify your conference in URLs etc. Example: 'froscon2011'",
|
= f.input :short_title, hint: "A short and unique handle for your conference, using only letters, numbers, underscores, and dashes. This will be used to identify your conference in URLs etc. Example: 'froscon2011'",
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
.page-header
|
||||||
|
%h3 Users (#{users.length})
|
||||||
|
- if users.present?
|
||||||
|
%table.table.table-striped.table-bordered.table-hover.datatable#users
|
||||||
|
%thead
|
||||||
|
%th Name
|
||||||
|
%th Email
|
||||||
|
- if ( can? :unassign_org_admins, organization )
|
||||||
|
%th
|
||||||
|
Actions
|
||||||
|
%tbody
|
||||||
|
- users.each do |user|
|
||||||
|
%tr
|
||||||
|
%td= user.name
|
||||||
|
%td= user.email
|
||||||
|
- if ( can? :unassign_org_admins, organization )
|
||||||
|
%td
|
||||||
|
= link_to 'Remove from organization admin',
|
||||||
|
unassign_org_admins_admin_organization_path(organization.id,
|
||||||
|
role.name,
|
||||||
|
user: {email: user.email}),
|
||||||
|
method: :delete,
|
||||||
|
class: 'btn btn-danger'
|
||||||
|
- else
|
||||||
|
%h5 No users found!
|
||||||
|
|
@ -25,6 +25,8 @@
|
||||||
= organization.conferences.past.count
|
= organization.conferences.past.count
|
||||||
%td
|
%td
|
||||||
.btn-group
|
.btn-group
|
||||||
|
= link_to 'Admins', admins_admin_organization_path(organization),
|
||||||
|
method: :get, class: 'btn btn-success'
|
||||||
= link_to 'Edit', edit_admin_organization_path(organization),
|
= link_to 'Edit', edit_admin_organization_path(organization),
|
||||||
method: :get, class: 'btn btn-primary'
|
method: :get, class: 'btn btn-primary'
|
||||||
= link_to 'Delete', admin_organization_path(organization),
|
= link_to 'Delete', admin_organization_path(organization),
|
||||||
|
|
|
||||||
24
app/views/admin/organizations/show_org_admins.haml
Normal file
24
app/views/admin/organizations/show_org_admins.haml
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
.row
|
||||||
|
.col-md-12
|
||||||
|
.page-header
|
||||||
|
%h2
|
||||||
|
Organization admins for #{@organization.name}
|
||||||
|
.text-muted
|
||||||
|
= @role.description
|
||||||
|
|
||||||
|
.row.col-md-3
|
||||||
|
- if ( can? :assign_org_admins, @organization )
|
||||||
|
= semantic_form_for :user,
|
||||||
|
url: assign_org_admins_admin_organization_path(@organization,
|
||||||
|
@role.name), method: :post do |u|
|
||||||
|
|
||||||
|
= u.label 'Add user by email: '
|
||||||
|
.input-group
|
||||||
|
= u.input :email, label: false, placeholder: "User's email"
|
||||||
|
.input-group-btn
|
||||||
|
= u.submit 'Add', id: 'user-add', class: 'btn btn-primary'
|
||||||
|
|
||||||
|
.row
|
||||||
|
.col-md-12
|
||||||
|
= render partial: 'users_with_org_admin_role',
|
||||||
|
locals: { users: @users, organization: @organization, role: @role }
|
||||||
|
|
@ -25,5 +25,12 @@
|
||||||
= link_to 'Delete', admin_conference_registration_period_path,
|
= link_to 'Delete', admin_conference_registration_period_path,
|
||||||
method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger'
|
method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger'
|
||||||
- else
|
- else
|
||||||
|
- unless @conference.tickets.for_registration.empty?
|
||||||
- if can? :create, @conference.build_registration_period
|
- if can? :create, @conference.build_registration_period
|
||||||
= link_to 'New Registration Period', new_admin_conference_registration_period_path, class: 'btn btn-primary'
|
= link_to 'New Registration Period', new_admin_conference_registration_period_path, class: 'btn btn-primary'
|
||||||
|
- else
|
||||||
|
.h3.text-left
|
||||||
|
No Registration Tickets!
|
||||||
|
%small
|
||||||
|
= link_to 'Create registration tickets', new_admin_conference_ticket_path
|
||||||
|
before creating the registration period.
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
%ul.nav.nav-stacked.nav-pills.mySidebar
|
%ul.nav.nav-stacked.nav-pills.mySidebar.collapse.navbar-collapse#side-nav
|
||||||
.btn-group
|
.btn-group
|
||||||
%button{type:'button', class: 'btn btn-default btn-link dropdown-toggle', 'data-toggle'=>'dropdown'}
|
%button{type:'button', class: 'btn btn-default btn-link dropdown-toggle', 'data-toggle'=>'dropdown'}
|
||||||
%span.fa.fa-cog
|
%span.fa.fa-cog
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,13 @@
|
||||||
.navbar.navbar-default.navbar-fixed-top.nav-osem{role: 'navigation'}
|
.navbar.navbar-default.navbar-fixed-top.nav-osem{role: 'navigation'}
|
||||||
.container
|
.container
|
||||||
.navbar-header
|
.navbar-header
|
||||||
%button{"data-target"=>".navbar-collapse", "data-toggle"=>"collapse", class: 'navbar-toggle', type: 'button'}
|
- if @conference && @conference.short_title.present?
|
||||||
|
%button{ "data-target"=>"#side-nav", "data-toggle"=>"collapse", class: 'navbar-toggle side-nav-btn', type: 'button' }
|
||||||
|
%span.sr-only Toggle navigation
|
||||||
|
%span.icon-bar
|
||||||
|
%span.icon-bar
|
||||||
|
%span.icon-bar
|
||||||
|
%button{"data-target"=>"#main-nav", "data-toggle"=>"collapse", class: 'navbar-toggle', type: 'button'}
|
||||||
%span.sr-only
|
%span.sr-only
|
||||||
Toggle navigation
|
Toggle navigation
|
||||||
%span.icon-bar
|
%span.icon-bar
|
||||||
|
|
@ -11,7 +17,7 @@
|
||||||
= link_to (ENV['OSEM_NAME'] || 'OSEM'), root_path, class: 'navbar-brand', title: 'Open Source Event Manager'
|
= link_to (ENV['OSEM_NAME'] || 'OSEM'), root_path, class: 'navbar-brand', title: 'Open Source Event Manager'
|
||||||
- else
|
- else
|
||||||
= link_to conference.organization.name, organizations_path, class: 'navbar-brand', title: 'Open Source Event Manager'
|
= link_to conference.organization.name, organizations_path, class: 'navbar-brand', title: 'Open Source Event Manager'
|
||||||
.collapse.navbar-collapse
|
.collapse.navbar-collapse#main-nav
|
||||||
- if content_for :splash_nav
|
- if content_for :splash_nav
|
||||||
%ul.nav.navbar-nav#splash-nav
|
%ul.nav.navbar-nav#splash-nav
|
||||||
= content_for :splash_nav
|
= content_for :splash_nav
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,7 @@
|
||||||
= @physical_ticket.ticket_purchase.id
|
= @physical_ticket.ticket_purchase.id
|
||||||
%br
|
%br
|
||||||
.col-md-5.col-md-offset-2.box.well
|
.col-md-5.col-md-offset-2.box.well
|
||||||
|
= image_tag(@qrcode_image.to_data_url, class: 'img-responsive qr-image')
|
||||||
.row
|
.row
|
||||||
.col-md-12
|
.col-md-12
|
||||||
%p.text-left
|
%p.text-left
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,13 @@ Osem::Application.routes.draw do
|
||||||
end
|
end
|
||||||
|
|
||||||
namespace :admin do
|
namespace :admin do
|
||||||
resources :organizations
|
resources :organizations do
|
||||||
|
member do
|
||||||
|
get :admins
|
||||||
|
post :assign_org_admins
|
||||||
|
delete :unassign_org_admins
|
||||||
|
end
|
||||||
|
end
|
||||||
resources :users do
|
resources :users do
|
||||||
member do
|
member do
|
||||||
patch :toggle_confirmation
|
patch :toggle_confirmation
|
||||||
|
|
|
||||||
|
|
@ -167,5 +167,32 @@ describe Admin::OrganizationsController do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'POST #assign_org_admins' do
|
||||||
|
let(:org_admin_role) { Role.find_by(name: 'organization_admin', resource: organization) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
post :assign_org_admins, id: organization.id,
|
||||||
|
user: { email: user.email }
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'assigns organization_admin role' do
|
||||||
|
expect(user.roles).to eq [org_admin_role]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'DELETE #unassign_org_admins' do
|
||||||
|
let(:org_admin_role) { Role.find_by(name: 'organization_admin', resource: organization) }
|
||||||
|
let!(:org_admin_user) { create(:user, role_ids: [org_admin_role.id]) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
delete :unassign_org_admins, id: organization.id,
|
||||||
|
user: { email: org_admin_user.email }
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'unassigns organization_admin role' do
|
||||||
|
expect(org_admin_user.reload.roles).to eq []
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ describe Admin::RegistrationPeriodsController do
|
||||||
# It is necessary to use bang version of let to build roles before user
|
# It is necessary to use bang version of let to build roles before user
|
||||||
let(:conference) { create(:conference) }
|
let(:conference) { create(:conference) }
|
||||||
let!(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) }
|
let!(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) }
|
||||||
|
let!(:registration_ticket) { create(:registration_ticket, conference: conference) }
|
||||||
let(:organizer) { create(:user, role_ids: organizer_role.id) }
|
let(:organizer) { create(:user, role_ids: organizer_role.id) }
|
||||||
let(:organizer2) { create(:user, email: 'organizer2@email.osem', role_ids: organizer_role.id) }
|
let(:organizer2) { create(:user, email: 'organizer2@email.osem', role_ids: organizer_role.id) }
|
||||||
let(:participant) { create(:user) }
|
let(:participant) { create(:user) }
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe Admin::RolesController do
|
describe Admin::RolesController do
|
||||||
|
|
||||||
let(:conference) { create(:conference) }
|
let(:conference) { create(:conference) }
|
||||||
let(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) }
|
let(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) }
|
||||||
let(:cfp_role) { Role.find_by(name: 'cfp', resource: conference) }
|
let(:cfp_role) { Role.find_by(name: 'cfp', resource: conference) }
|
||||||
|
|
|
||||||
|
|
@ -3,5 +3,8 @@ FactoryGirl.define do
|
||||||
title { "#{Faker::Hipster.word} Ticket" }
|
title { "#{Faker::Hipster.word} Ticket" }
|
||||||
price_cents 1000
|
price_cents 1000
|
||||||
price_currency 'USD'
|
price_currency 'USD'
|
||||||
|
factory :registration_ticket do
|
||||||
|
registration_ticket true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,15 @@ require 'spec_helper'
|
||||||
|
|
||||||
feature Conference do
|
feature Conference do
|
||||||
let!(:user) { create(:admin) }
|
let!(:user) { create(:admin) }
|
||||||
|
let!(:organization) { create(:organization) }
|
||||||
shared_examples 'add and update conference' do
|
shared_examples 'add and update conference' do
|
||||||
scenario 'adds a new conference', feature: true, js: true do
|
scenario 'adds a new conference', feature: true, js: true do
|
||||||
expected_count = Conference.count + 1
|
expected_count = Conference.count + 1
|
||||||
sign_in user
|
sign_in user
|
||||||
|
|
||||||
visit new_admin_conference_path
|
visit new_admin_conference_path
|
||||||
|
|
||||||
|
select organization.name, from: 'conference_organization_id'
|
||||||
fill_in 'conference_title', with: 'Example Con'
|
fill_in 'conference_title', with: 'Example Con'
|
||||||
fill_in 'conference_short_title', with: 'ExCon'
|
fill_in 'conference_short_title', with: 'ExCon'
|
||||||
|
|
||||||
|
|
@ -27,7 +29,7 @@ feature Conference do
|
||||||
expect(flash)
|
expect(flash)
|
||||||
.to eq('Conference was successfully created.')
|
.to eq('Conference was successfully created.')
|
||||||
expect(Conference.count).to eq(expected_count)
|
expect(Conference.count).to eq(expected_count)
|
||||||
|
expect(Conference.last.organization).to eq(organization)
|
||||||
expect(user.has_role? :organizer, Conference.last).to eq(true)
|
expect(user.has_role? :organizer, Conference.last).to eq(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ feature 'Has correct abilities' do
|
||||||
let(:conference) { create(:full_conference, organization: organization) }
|
let(:conference) { create(:full_conference, organization: organization) }
|
||||||
let(:role_organization_admin) { Role.find_by(name: 'organization_admin', resource: organization) }
|
let(:role_organization_admin) { Role.find_by(name: 'organization_admin', resource: organization) }
|
||||||
let(:user_organization_admin) { create(:user, role_ids: [role_organization_admin.id]) }
|
let(:user_organization_admin) { create(:user, role_ids: [role_organization_admin.id]) }
|
||||||
|
let!(:registration_ticket) { create(:registration_ticket, conference: conference) }
|
||||||
|
|
||||||
context 'when user is organization_admin' do
|
context 'when user is organization_admin' do
|
||||||
before do
|
before do
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ feature 'Has correct abilities' do
|
||||||
let(:role_organizer_conf) { Role.find_by(name: 'organizer', resource: conference) }
|
let(:role_organizer_conf) { Role.find_by(name: 'organizer', resource: conference) }
|
||||||
let(:role_organizer_other_conf) { Role.find_by(name: 'organizer', resource: other_conference) }
|
let(:role_organizer_other_conf) { Role.find_by(name: 'organizer', resource: other_conference) }
|
||||||
let(:user_organizer) { create(:user, role_ids: [role_organizer_conf.id, role_organizer_other_conf.id]) }
|
let(:user_organizer) { create(:user, role_ids: [role_organizer_conf.id, role_organizer_other_conf.id]) }
|
||||||
|
let!(:registration_ticket) { create(:registration_ticket, conference: conference) }
|
||||||
|
|
||||||
context 'when user is organizer' do
|
context 'when user is organizer' do
|
||||||
before do
|
before do
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ feature RegistrationPeriod do
|
||||||
let!(:conference) { create(:conference) }
|
let!(:conference) { create(:conference) }
|
||||||
let!(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) }
|
let!(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) }
|
||||||
let!(:organizer) { create(:user, email: 'admin@example.com', role_ids: [organizer_role.id]) }
|
let!(:organizer) { create(:user, email: 'admin@example.com', role_ids: [organizer_role.id]) }
|
||||||
|
let!(:registration_ticket) { create(:registration_ticket, conference: conference) }
|
||||||
|
|
||||||
shared_examples 'successfully' do
|
shared_examples 'successfully' do
|
||||||
scenario 'create and update registration period', js: true do
|
scenario 'create and update registration period', js: true do
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,51 @@ feature Role do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'organization_admin' do
|
||||||
|
let!(:organization) { create(:organization) }
|
||||||
|
let!(:org_admin_role) { Role.find_by(name: 'organization_admin', resource: organization) }
|
||||||
|
let!(:organization_admin) { create(:user, role_ids: [org_admin_role.id]) }
|
||||||
|
let(:user_with_no_role) { create :user }
|
||||||
|
let!(:other_organization) { create(:organization) }
|
||||||
|
|
||||||
|
before do
|
||||||
|
sign_in organization_admin
|
||||||
|
visit admin_organizations_path
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'for the organization it belongs to' do
|
||||||
|
scenario 'successfully adds role organization_admin' do
|
||||||
|
click_link('Admins', href: admins_admin_organization_path(organization.id))
|
||||||
|
|
||||||
|
fill_in 'user_email', with: user_with_no_role.email
|
||||||
|
click_button 'Add'
|
||||||
|
user_with_no_role.reload
|
||||||
|
|
||||||
|
expect(user_with_no_role.has_role?('organization_admin', organization)).to eq true
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'successfully removes role organization_admin' do
|
||||||
|
click_link('Admins', href: admins_admin_organization_path(organization.id))
|
||||||
|
|
||||||
|
first('tr').find('.btn-danger').click
|
||||||
|
expect(organization_admin.has_role?('organization_admin', organization)).to eq false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'for the organizations it does not belong to' do
|
||||||
|
scenario 'does not successfully add role organization_admin' do
|
||||||
|
click_link('Admins', href: admins_admin_organization_path(other_organization.id))
|
||||||
|
|
||||||
|
expect(page.has_field?('user_email')).to eq false
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'does not successfully removes role organization_admin' do
|
||||||
|
click_link('Admins', href: admins_admin_organization_path(other_organization.id))
|
||||||
|
expect(page.has_css?('.btn-danger')).to eq false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'organizer' do
|
context 'organizer' do
|
||||||
Role.all.each.map(&:name).each do |role|
|
Role.all.each.map(&:name).each do |role|
|
||||||
it_behaves_like 'successfully', role, 'organizer'
|
it_behaves_like 'successfully', role, 'organizer'
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ describe 'User with admin role' do
|
||||||
|
|
||||||
let!(:organization) { create(:organization) }
|
let!(:organization) { create(:organization) }
|
||||||
let!(:my_conference) { create(:full_conference, organization: organization) }
|
let!(:my_conference) { create(:full_conference, organization: organization) }
|
||||||
|
let!(:registration_ticket) { create(:registration_ticket, conference: my_conference) }
|
||||||
let(:my_venue) { my_conference.venue || create(:venue, conference: my_conference) }
|
let(:my_venue) { my_conference.venue || create(:venue, conference: my_conference) }
|
||||||
let(:my_registration) { create(:registration, conference: my_conference, user: admin) }
|
let(:my_registration) { create(:registration, conference: my_conference, user: admin) }
|
||||||
|
|
||||||
|
|
@ -62,7 +63,7 @@ describe 'User with admin role' do
|
||||||
|
|
||||||
it{ should_not be_able_to(:update, Role.find_by(name: 'organization_admin', resource: other_organization)) }
|
it{ should_not be_able_to(:update, Role.find_by(name: 'organization_admin', resource: other_organization)) }
|
||||||
it{ should_not be_able_to(:edit, Role.find_by(name: 'organization_admin', resource: other_organization)) }
|
it{ should_not be_able_to(:edit, Role.find_by(name: 'organization_admin', resource: other_organization)) }
|
||||||
it{ should_not be_able_to(:show, Role.find_by(name: 'organization_admin', resource: other_organization)) }
|
it{ should be_able_to(:admins, organization) }
|
||||||
|
|
||||||
it{ should_not be_able_to(:new, User.new) }
|
it{ should_not be_able_to(:new, User.new) }
|
||||||
it{ should_not be_able_to(:create, User.new) }
|
it{ should_not be_able_to(:create, User.new) }
|
||||||
|
|
@ -126,6 +127,8 @@ describe 'User with admin role' do
|
||||||
let(:other_organization) { create(:organization) }
|
let(:other_organization) { create(:organization) }
|
||||||
let(:other_conference) { create(:conference, organization: other_organization) }
|
let(:other_conference) { create(:conference, organization: other_organization) }
|
||||||
|
|
||||||
|
it{ should be_able_to(:assign_org_admins, organization) }
|
||||||
|
it{ should be_able_to(:unassign_org_admins, organization) }
|
||||||
it{ should be_able_to(:manage, my_conference) }
|
it{ should be_able_to(:manage, my_conference) }
|
||||||
it{ should be_able_to(:read, organization) }
|
it{ should be_able_to(:read, organization) }
|
||||||
it{ should be_able_to(:update, organization) }
|
it{ should be_able_to(:update, organization) }
|
||||||
|
|
@ -136,6 +139,8 @@ describe 'User with admin role' do
|
||||||
it{ should_not be_able_to(:create, Conference.new(organization_id: other_organization.id)) }
|
it{ should_not be_able_to(:create, Conference.new(organization_id: other_organization.id)) }
|
||||||
it{ should_not be_able_to(:new, Organization.new) }
|
it{ should_not be_able_to(:new, Organization.new) }
|
||||||
it{ should_not be_able_to(:create, Organization.new) }
|
it{ should_not be_able_to(:create, Organization.new) }
|
||||||
|
|
||||||
|
it_behaves_like 'user with any role'
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when user has the role organizer' do
|
context 'when user has the role organizer' do
|
||||||
|
|
@ -213,6 +218,9 @@ describe 'User with admin role' do
|
||||||
|
|
||||||
it{ should be_able_to(:manage, resource) }
|
it{ should be_able_to(:manage, resource) }
|
||||||
|
|
||||||
|
it{ should_not be_able_to(:assign_org_admins, organization) }
|
||||||
|
it{ should_not be_able_to(:unassign_org_admins, organization) }
|
||||||
|
|
||||||
%w[organizer cfp info_desk volunteers_coordinator].each do |role|
|
%w[organizer cfp info_desk volunteers_coordinator].each do |role|
|
||||||
it{ should be_able_to(:toggle_user, Role.find_by(name: role, resource: my_conference)) }
|
it{ should be_able_to(:toggle_user, Role.find_by(name: role, resource: my_conference)) }
|
||||||
it{ should be_able_to(:edit, Role.find_by(name: role, resource: my_conference)) }
|
it{ should be_able_to(:edit, Role.find_by(name: role, resource: my_conference)) }
|
||||||
|
|
@ -298,6 +306,8 @@ describe 'User with admin role' do
|
||||||
it{ should be_able_to(:index, resource) }
|
it{ should be_able_to(:index, resource) }
|
||||||
it{ should be_able_to(:show, resource) }
|
it{ should be_able_to(:show, resource) }
|
||||||
it{ should be_able_to(:update, resource) }
|
it{ should be_able_to(:update, resource) }
|
||||||
|
it{ should_not be_able_to(:assign_org_admins, organization) }
|
||||||
|
it{ should_not be_able_to(:unassign_org_admins, organization) }
|
||||||
|
|
||||||
it_behaves_like 'user with any role'
|
it_behaves_like 'user with any role'
|
||||||
it_behaves_like 'user with non-organizer role', 'cfp'
|
it_behaves_like 'user with non-organizer role', 'cfp'
|
||||||
|
|
@ -365,6 +375,8 @@ describe 'User with admin role' do
|
||||||
it{ should be_able_to(:index, resource) }
|
it{ should be_able_to(:index, resource) }
|
||||||
it{ should be_able_to(:show, resource) }
|
it{ should be_able_to(:show, resource) }
|
||||||
it{ should be_able_to(:update, resource) }
|
it{ should be_able_to(:update, resource) }
|
||||||
|
it{ should_not be_able_to(:assign_org_admins, organization) }
|
||||||
|
it{ should_not be_able_to(:unassign_org_admins, organization) }
|
||||||
|
|
||||||
it_behaves_like 'user with any role'
|
it_behaves_like 'user with any role'
|
||||||
it_behaves_like 'user with non-organizer role', 'info_desk'
|
it_behaves_like 'user with non-organizer role', 'info_desk'
|
||||||
|
|
@ -432,6 +444,8 @@ describe 'User with admin role' do
|
||||||
it{ should be_able_to(:index, resource) }
|
it{ should be_able_to(:index, resource) }
|
||||||
it{ should be_able_to(:show, resource) }
|
it{ should be_able_to(:show, resource) }
|
||||||
it{ should be_able_to(:update, resource) }
|
it{ should be_able_to(:update, resource) }
|
||||||
|
it{ should_not be_able_to(:assign_org_admins, organization) }
|
||||||
|
it{ should_not be_able_to(:unassign_org_admins, organization) }
|
||||||
|
|
||||||
it 'should be_able to :manage Vposition'
|
it 'should be_able to :manage Vposition'
|
||||||
it 'should be_able to :manage Vday'
|
it 'should be_able to :manage Vday'
|
||||||
|
|
@ -508,6 +522,9 @@ describe 'User with admin role' do
|
||||||
it{ should_not be_able_to(:edit, my_self_organized_track) }
|
it{ should_not be_able_to(:edit, my_self_organized_track) }
|
||||||
it{ should_not be_able_to(:update, my_self_organized_track) }
|
it{ should_not be_able_to(:update, my_self_organized_track) }
|
||||||
|
|
||||||
|
it{ should_not be_able_to(:assign_org_admins, organization) }
|
||||||
|
it{ should_not be_able_to(:unassign_org_admins, organization) }
|
||||||
|
|
||||||
it_behaves_like 'user with any role'
|
it_behaves_like 'user with any role'
|
||||||
it_behaves_like 'user with non-organizer role', 'track_organizer'
|
it_behaves_like 'user with non-organizer role', 'track_organizer'
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ require 'spec_helper'
|
||||||
|
|
||||||
describe RegistrationPeriod do
|
describe RegistrationPeriod do
|
||||||
let!(:conference) { create(:conference, start_date: Date.today, end_date: Date.today + 6) }
|
let!(:conference) { create(:conference, start_date: Date.today, end_date: Date.today + 6) }
|
||||||
|
let!(:registration_ticket) { create(:registration_ticket, conference: conference) }
|
||||||
let!(:registration_period) { create(:registration_period, start_date: Date.today - 2, end_date: Date.today - 1, conference: conference) }
|
let!(:registration_period) { create(:registration_period, start_date: Date.today - 2, end_date: Date.today - 1, conference: conference) }
|
||||||
|
|
||||||
describe 'validations' do
|
describe 'validations' do
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue