fix conflicts

This commit is contained in:
Stella Rouzi 2014-08-12 15:48:29 +03:00
parent e2fb434dc7
commit 71dfb3b7e4
34 changed files with 160 additions and 211 deletions

View file

@ -5,7 +5,7 @@ module Admin
def index def index
authorize! :update, Question.new(conference_id: @conference.id) authorize! :update, Question.new(conference_id: @conference.id)
@questions = Question.where(:global => true).all | Question.where(:conference_id => @conference.id) @questions = Question.where(global: true).all | Question.where(conference_id: @conference.id)
@questions_conference = @conference.questions @questions_conference = @conference.questions
@new_question = @conference.questions.new @new_question = @conference.questions.new
end end
@ -33,25 +33,25 @@ module Admin
# GET questions/1/edit # GET questions/1/edit
def edit def edit
if @question.global == true && !(current_user.has_role? :organizer, @conference) if @question.global == true && !(current_user.has_role? :organizer, @conference)
redirect_to(admin_conference_questions_path(:conference_id => @conference.short_title), :alert => "Sorry, you cannot edit global questions. Create a new one.") redirect_to(admin_conference_questions_path(conference_id: @conference.short_title), alert: "Sorry, you cannot edit global questions. Create a new one.")
end end
end end
# PUT questions/1 # PUT questions/1
def update def update
if @question.update_attributes(params[:question]) if @question.update_attributes(params[:question])
redirect_to(admin_conference_questions_path(:conference_id => @conference.short_title), :notice => "Question '#{@question.title}' for #{@conference.short_title} successfully updated.") redirect_to(admin_conference_questions_path(conference_id: @conference.short_title), notice: "Question '#{@question.title}' for #{@conference.short_title} successfully updated.")
else else
redirect_to(admin_conference_questions_path(:conference_id => @conference.short_title), :notice => "Update of questions for #{@conference.short_title} failed.") redirect_to(admin_conference_questions_path(conference_id: @conference.short_title), notice: "Update of questions for #{@conference.short_title} failed.")
end end
end end
# Update questions used for the conference # Update questions used for the conference
def update_conference def update_conference
if @conference.update_attributes(params[:conference]) if @conference.update_attributes(params[:conference])
redirect_to(admin_conference_questions_path(:conference_id => @conference.short_title), :notice => "Questions for #{@conference.short_title} successfully updated.") redirect_to(admin_conference_questions_path(conference_id: @conference.short_title), notice: "Questions for #{@conference.short_title} successfully updated.")
else else
redirect_to(admin_conference_questions_path(:conference_id => @conference.short_title), :notice => "Update of questions for #{@conference.short_title} failed.") redirect_to(admin_conference_questions_path(conference_id: @conference.short_title), notice: "Update of questions for #{@conference.short_title} failed.")
end end
end end
@ -82,7 +82,7 @@ module Admin
flash[:error] = "You must be an admin to delete a question." flash[:error] = "You must be an admin to delete a question."
end end
@questions = Question.where(:global => true).all | Question.where(:conference_id => @conference.id) @questions = Question.where(global: true).all | Question.where(conference_id: @conference.id)
@questions_conference = @conference.questions @questions_conference = @conference.questions
end end
end end

View file

@ -9,9 +9,9 @@ module Admin
def update def update
if @conference.update_attributes(params[:conference]) if @conference.update_attributes(params[:conference])
redirect_to(admin_conference_social_events_path(:conference_id => @conference.short_title), :notice => 'Social events were successfully updated.') redirect_to(admin_conference_social_events_path(conference_id: @conference.short_title), notice: 'Social events were successfully updated.')
else else
redirect_to(admin_conference_social_events_path(:conference_id => @conference.short_title), :notice => 'Social events update failed.') redirect_to(admin_conference_social_events_path(conference_id: @conference.short_title), notice: 'Social events update failed.')
end end
end end
end end

View file

@ -20,28 +20,16 @@ module Admin
end end
def update def update
params[:user].delete :roles_attributes if params[:user]
@user.update_attributes!(params[:user]) @user.update_attributes!(params[:user])
redirect_to admin_users_path, notice: "Updated #{@user.email}" redirect_to admin_users_path, notice: "Updated #{@user.email}"
end end
def add_role
role = params[:user][:roles_attributes][:"0"]
@user.add_role role['name'].parameterize.underscore.to_sym, Conference.find(role['resource_id'])
respond_to do |format|
format.html
format.js
end
end
def edit def edit
end end
def destroy def destroy
@user.destroy @user.destroy
redirect_to admin_users_path, notice: "User #{@user.name} (#{@user.email})got deleted" redirect_to admin_users_path, notice: "User got deleted"
end end
end end
end end

View file

@ -15,7 +15,7 @@ module Admin
if @conference.use_vpositions if @conference.use_vpositions
@volunteers = @conference.registrations.joins(:vchoices).uniq @volunteers = @conference.registrations.joins(:vchoices).uniq
else else
@volunteers = @conference.registrations.where(:volunteer => true) @volunteers = @conference.registrations.where(volunteer: true)
end end
else else
authorize! :index, :volunteer authorize! :index, :volunteer
@ -26,9 +26,9 @@ module Admin
if (current_user.has_role? :organizer, @conference) || (current_user.has_role? :volunteer_coordinator, @conference) if (current_user.has_role? :organizer, @conference) || (current_user.has_role? :volunteer_coordinator, @conference)
begin begin
@conference.update_attributes!(params[:conference]) @conference.update_attributes!(params[:conference])
redirect_to(admin_conference_volunteers_info_path(:conference_id => params[:conference_id]), :notice => "Volunteering options were successfully updated.") redirect_to(admin_conference_volunteers_info_path(conference_id: params[:conference_id]), notice: "Volunteering options were successfully updated.")
rescue Exception => e rescue Exception => e
redirect_to(admin_conference_volunteers_info_path(:conference_id => params[:conference_id]), :alert => "Volunteering options update failed: #{e.message}") redirect_to(admin_conference_volunteers_info_path(conference_id: params[:conference_id]), alert: "Volunteering options update failed: #{e.message}")
end end
else else
authorize! :index, :volunteer authorize! :index, :volunteer

View file

@ -67,7 +67,6 @@ class EventAttachmentsController < ApplicationController
respond_to do |format| respond_to do |format|
if @upload.save if @upload.save
<<<<<<< HEAD
format.html do format.html do
render json: [@upload.to_jq_upload].to_json, render json: [@upload.to_jq_upload].to_json,
content_type: 'text/html', content_type: 'text/html',
@ -77,15 +76,6 @@ class EventAttachmentsController < ApplicationController
render json: [@upload.to_jq_upload].to_json, status: :created, render json: [@upload.to_jq_upload].to_json, status: :created,
location: conference_proposal_event_attachment_path(@upload.event.conference.short_title, @upload.event, @upload) location: conference_proposal_event_attachment_path(@upload.event.conference.short_title, @upload.event, @upload)
end end
=======
format.html {
render :json => [@upload.to_jq_upload].to_json,
:content_type => 'text/html',
:layout => false
}
format.json { render json: {files: [@upload.to_jq_upload]}, status: :created,
location: conference_proposal_event_attachment_path(@upload.event.conference.short_title, @upload.event, @upload) }
>>>>>>> authorization with cancancan
else else
format.html { render action: "new" } format.html { render action: "new" }
format.json { render json: @upload.errors, status: :unprocessable_entity } format.json { render json: @upload.errors, status: :unprocessable_entity }

View file

@ -1,8 +1,5 @@
class ScheduleController < ApplicationController class ScheduleController < ApplicationController
<<<<<<< HEAD
=======
authorize_resource class: false authorize_resource class: false
>>>>>>> authorization with cancancan
layout "application" layout "application"
def index def index

View file

@ -1,6 +1,6 @@
class Campaign < ActiveRecord::Base class Campaign < ActiveRecord::Base
attr_accessible :name, :target_ids, :conference_id, attr_accessible :name, :utm_source, :utm_medium, :utm_term,
:utm_source, :utm_medium, :utm_term, :utm_content, :utm_campaign :utm_content, :utm_campaign, :target_ids, :conference_id
validates :name, :utm_campaign, presence: true validates :name, :utm_campaign, presence: true

View file

@ -6,7 +6,6 @@ class EventAttachment < ActiveRecord::Base
has_attached_file :attachment, path: ":rails_root/storage/:rails_env/attachments/:id/:style/:basename.:extension" has_attached_file :attachment, path: ":rails_root/storage/:rails_env/attachments/:id/:style/:basename.:extension"
include Rails.application.routes.url_helpers include Rails.application.routes.url_helpers
do_not_validate_attachment_file_type :attachment
def to_jq_upload def to_jq_upload
{ {

View file

@ -3,12 +3,7 @@
= f.input :is_admin, hint: 'An admin can create a new conference, manage users and make other users admins.' = f.input :is_admin, hint: 'An admin can create a new conference, manage users and make other users admins.'
= f.input :name, :as => :string = f.input :name, :as => :string
= f.input :email = f.input :email
= f.input :affiliation, as: :string = f.input :affiliation, :as => :string
= f.input :biography, input_html: { rows: 5, "onkeyup" => "word_count(this, 'biography-count', 150)" } = f.input :biography, :input_html => {:rows => 10}
You have used
%span#biography-count #{@user.biography_word_count}
words. Biographies are limited to 150 words.
%br
%br
= f.actions do = f.actions do
= f.action :submit, button_html: { class: 'btn btn-primary' } = f.action :submit, :button_html => {:class => "btn btn-primary"}

View file

@ -71,7 +71,7 @@
data.formData = inputs.serializeArray(); data.formData = inputs.serializeArray();
}); });
$.getJSON($('#fileupload').prop('action'), function (files) { $.getJSON($('#fileupload').prop('action'), function (files) {
var fu = $('#fileupload').data('blueimpFileupload'), var fu = $('#fileupload').data('fileupload'),
template; template;
fu._adjustMaxNumberOfFiles(-files.length); fu._adjustMaxNumberOfFiles(-files.length);
template = fu._renderDownload(files) template = fu._renderDownload(files)

View file

@ -1,6 +1,6 @@
.row .row
.col-md-12 .col-md-12
= simple_format(@conference.call_for_papers.description) if @conference.call_for_papers = simple_format(@conference.call_for_papers.description)
.row .row
.col-md-12 .col-md-12
= render 'proposal_form' = render 'proposal_form'

View file

@ -1,5 +1,5 @@
class AddIsAdminToUsers < ActiveRecord::Migration class AddIsAdminToUsers < ActiveRecord::Migration
def change def change
add_column :users, :is_admin, :boolean add_column :users, :is_admin, :boolean, default: false
end end
end end

View file

@ -5,11 +5,10 @@ describe Admin::ConferenceController 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!(:first_user) { create(:user) } let!(:first_user) { create(:user) }
let!(:participant_role) { create(:participant_role) }
let!(:organizer_role) { create(:role, name: 'organizer', resource: conference) } let!(:organizer_role) { create(:role, name: 'organizer', resource: conference) }
let(:organizer) { create(:user, role_ids: organizer_role.id, is_admin: true) } let(:organizer) { create(:user, role_ids: organizer_role.id, is_admin: true) }
let(:participant) { create(:participant) } let(:participant) { create(:user) }
shared_examples 'access as administration' do shared_examples 'access as administration' do

View file

@ -1,18 +1,12 @@
FactoryGirl.define do FactoryGirl.define do
factory :role do factory :role do
factory :participant_role do
name 'participant'
end
factory :organizer_role do factory :organizer_role do
name 'organizer' name 'organizer'
end end
factory :organizer_conference_1_role do factory :cfp_role do
name 'organizer' name 'cfp'
resource_type 'Conference'
resource_id 1
end end
end end
end end

View file

@ -15,16 +15,12 @@ FactoryGirl.define do
gravida. gravida.
EOS EOS
factory :participant do
after(:create) { |user| user.role_ids = create(:participant_role).id }
end
factory :organizer_conference_1 do
after(:create) { |user| user.role_ids = create(:organizer_conference_1_role).id }
end
factory :admin do factory :admin do
is_admin true is_admin true
end end
factory :organizer do
after(:create) { |user| user.role_ids = create(:organizer_role).id }
end
end end
end end

View file

@ -2,15 +2,14 @@ require 'spec_helper'
feature Campaign do feature Campaign do
# It is necessary to use bang version of let to build roles before user let!(:conference) { create(:conference, short_title: 'osc14') }
let!(:participant_role) { create(:participant_role) } let!(:organizer_role) { create(:organizer_role, resource: conference) }
let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) } let!(:organizer) { create(:user, role_ids: [organizer_role.id]) }
shared_examples 'add and update campaign' do |user| shared_examples 'add and update campaign' do
scenario 'adds and update a campaign', feature: true, js: true do scenario 'adds and update a campaign', feature: true, js: true do
expected_count = Campaign.count + 1 expected_count = Campaign.count + 1
conference = create(:conference, short_title: 'osc14') sign_in organizer
sign_in create(user)
visit admin_conference_campaigns_path(conference.short_title) visit admin_conference_campaigns_path(conference.short_title)
@ -52,6 +51,6 @@ feature Campaign do
end end
describe 'organizer' do describe 'organizer' do
it_behaves_like 'add and update campaign', :organizer_conference_1 it_behaves_like 'add and update campaign'
end end
end end

View file

@ -2,15 +2,15 @@ require 'spec_helper'
feature Conference do feature Conference do
# It is necessary to use bang version of let to build roles before user let!(:conference) { create(:conference) }
let!(:participant_role) { create(:participant_role) } let!(:organizer_role) { create(:organizer_role, resource: conference) }
let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) } let!(:organizer) { create(:user, role_ids: [organizer_role.id]) }
shared_examples 'add and update cfp' do |user| shared_examples 'add and update cfp' do
scenario 'adds a new cfp', feature: true, js: true do scenario 'adds a new cfp', feature: true, js: true do
expected_count = CallForPapers.count + 1 expected_count = CallForPapers.count + 1
conference = create(:conference)
sign_in create(user) sign_in organizer
visit admin_conference_callforpapers_path(conference.short_title) visit admin_conference_callforpapers_path(conference.short_title)
@ -46,11 +46,10 @@ feature Conference do
end end
scenario 'update cfp', feature: true, js: true do scenario 'update cfp', feature: true, js: true do
conference = create(:conference)
conference.call_for_papers = create(:call_for_papers) conference.call_for_papers = create(:call_for_papers)
expected_count = CallForPapers.count expected_count = CallForPapers.count
sign_in create(user) sign_in organizer
visit admin_conference_callforpapers_path(conference.short_title) visit admin_conference_callforpapers_path(conference.short_title)
# Validate update with empty start date will not saved # Validate update with empty start date will not saved
@ -87,6 +86,6 @@ feature Conference do
end end
describe 'organizer' do describe 'organizer' do
it_behaves_like 'add and update cfp', :organizer_conference_1 it_behaves_like 'add and update cfp'
end end
end end

View file

@ -3,7 +3,7 @@ require 'spec_helper'
feature Commercial do feature Commercial 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) { create(:role, name: 'organizer', resource: conference) } let!(:organizer_role) { create(:organizer_role, resource: conference) }
let!(:organizer) { create(:user, role_ids: [organizer_role.id]) } let!(:organizer) { create(:user, role_ids: [organizer_role.id]) }
shared_examples 'adds and updates a commercial' do shared_examples 'adds and updates a commercial' do

View file

@ -1,15 +1,12 @@
require 'spec_helper' require 'spec_helper'
feature Conference do feature Conference do
let!(:user) { create(:admin) }
# It is necessary to use bang version of let to build roles before user shared_examples 'add and update conference' do
let!(:participant_role) { create(:participant_role) }
let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) }
shared_examples 'add and update conference' do |user|
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 create(user) sign_in user
visit new_admin_conference_path visit new_admin_conference_path
fill_in 'conference_title', with: 'Example Con' fill_in 'conference_title', with: 'Example Con'
@ -30,12 +27,18 @@ 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(user.has_role? :organizer, Conference.last).to eq(true)
end end
scenario 'update conference', feature: true, js: true do scenario 'update conference', feature: true, js: true do
conference = create(:conference) conference = create(:conference)
organizer_role = create(:organizer_role, resource: conference)
organizer = create(:user, role_ids: [organizer_role.id])
expected_count = Conference.count expected_count = Conference.count
sign_in create(:organizer_conference_1)
sign_in organizer
visit edit_admin_conference_path(conference.short_title) visit edit_admin_conference_path(conference.short_title)
click_link 'Edit' click_link 'Edit'
@ -62,6 +65,6 @@ feature Conference do
end end
describe 'admin' do describe 'admin' do
it_behaves_like 'add and update conference', :admin it_behaves_like 'add and update conference'
end end
end end

View file

@ -1,14 +1,14 @@
require 'spec_helper' require 'spec_helper'
feature DifficultyLevel do feature DifficultyLevel do
# It is necessary to use bang version of let to build roles before user let!(:conference) { create(:conference) }
let!(:participant_role) { create(:participant_role) } let!(:organizer_role) { create(:organizer_role, resource: conference) }
let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) } let!(:organizer) { create(:user, role_ids: [organizer_role.id]) }
shared_examples 'difficulty levels' do |user| shared_examples 'difficulty levels' do
scenario 'adds and updates difficulty level', feature: true, js: true do scenario 'adds and updates difficulty level', feature: true, js: true do
conference = create(:conference)
sign_in create(user) sign_in organizer
visit admin_conference_difficulty_levels_path( visit admin_conference_difficulty_levels_path(
conference_id: conference.short_title) conference_id: conference.short_title)
@ -50,6 +50,6 @@ feature DifficultyLevel do
end end
describe 'organizer' do describe 'organizer' do
it_behaves_like 'difficulty levels', :organizer_conference_1 it_behaves_like 'difficulty levels'
end end
end end

View file

@ -1,18 +1,17 @@
require 'spec_helper' require 'spec_helper'
feature EmailSettings do feature EmailSettings do
# It is necessary to use bang version of let to build roles before user let!(:conference) { create(:conference) }
let!(:participant_role) { create(:participant_role) } let!(:organizer_role) { create(:organizer_role, resource: conference) }
let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) } let!(:organizer) { create(:user, role_ids: [organizer_role.id]) }
shared_examples 'email settings' do |user| shared_examples 'email settings' do
scenario 'updates email settings', scenario 'updates email settings',
feature: true, js: true do feature: true, js: true do
conference = create(:conference)
expected_count = EmailSettings.count expected_count = EmailSettings.count
sign_in create(user) sign_in organizer
visit admin_conference_emails_path(conference.short_title) visit admin_conference_emails_path(conference.short_title)
@ -91,6 +90,6 @@ feature EmailSettings do
end end
describe 'organizer' do describe 'organizer' do
it_behaves_like 'email settings', :organizer_conference_1 it_behaves_like 'email settings'
end end
end end

View file

@ -1,14 +1,14 @@
require 'spec_helper' require 'spec_helper'
feature EventType do feature EventType do
# It is necessary to use bang version of let to build roles before user let!(:conference) { create(:conference) }
let!(:participant_role) { create(:participant_role) } let!(:organizer_role) { create(:organizer_role, resource: conference) }
let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) } let!(:organizer) { create(:user, role_ids: [organizer_role.id]) }
shared_examples 'event types' do |user| shared_examples 'event types' do
scenario 'adds and updates event type', feature: true, js: true do scenario 'adds and updates event type', feature: true, js: true do
conference = create(:conference)
sign_in create(user) sign_in organizer
visit admin_conference_event_types_path( visit admin_conference_event_types_path(
conference_id: conference.short_title) conference_id: conference.short_title)
@ -55,6 +55,6 @@ feature EventType do
end end
describe 'organizer' do describe 'organizer' do
it_behaves_like 'event types', :organizer_conference_1 it_behaves_like 'event types'
end end
end end

View file

@ -1,16 +1,16 @@
require 'spec_helper' require 'spec_helper'
feature Lodging do feature Lodging do
# It is necessary to use bang version of let to build roles before user let!(:conference) { create(:conference) }
let!(:participant_role) { create(:participant_role) } let!(:organizer_role) { create(:organizer_role, resource: conference) }
let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) } let!(:organizer) { create(:user, role_ids: [organizer_role.id]) }
shared_examples 'lodgings' do |user| shared_examples 'lodgings' do
scenario 'adds and updates lodgings', feature: true, js: true do scenario 'adds and updates lodgings', feature: true, js: true do
path = "#{Rails.root}/app/assets/images/rails.png" path = "#{Rails.root}/app/assets/images/rails.png"
conference = create(:conference)
conference.venue = create(:venue) conference.venue = create(:venue)
sign_in create(user) sign_in organizer
visit admin_conference_lodgings_path( visit admin_conference_lodgings_path(
conference_id: conference.short_title) conference_id: conference.short_title)
# Add lodging # Add lodging
@ -56,6 +56,6 @@ feature Lodging do
end end
describe 'organizer' do describe 'organizer' do
it_behaves_like 'lodgings', :organizer_conference_1 it_behaves_like 'lodgings'
end end
end end

View file

@ -1,8 +1,6 @@
require 'spec_helper' require 'spec_helper'
feature Openid do feature Openid do
let!(:participant_role) { create(:participant_role) }
shared_examples 'sign in with openid' do shared_examples 'sign in with openid' do
scenario 'has option to log in with Google account' do scenario 'has option to log in with Google account' do
@ -26,7 +24,7 @@ feature Openid do
end end
scenario 'signs in an existing user' do scenario 'signs in an existing user' do
create(:participant, email: 'test-participant-1@google.com') create(:user, email: 'test-participant-1@google.com')
expected_count_openid = Openid.count + 1 expected_count_openid = Openid.count + 1
expected_count_user = User.count expected_count_user = User.count
visit '/accounts/sign_in' visit '/accounts/sign_in'
@ -53,7 +51,7 @@ feature Openid do
scenario 'adds openid to existing user' do scenario 'adds openid to existing user' do
# Sign in user # Sign in user
user = create(:participant, email: 'test-participant-1@google.com') user = create(:user, email: 'test-participant-1@google.com')
sign_in user sign_in user
# Add openID to current user # Add openID to current user
@ -73,7 +71,7 @@ feature Openid do
scenario 'signs in with openID using the same email as another associated openid' do scenario 'signs in with openID using the same email as another associated openid' do
# Sign in user # Sign in user
create(:participant, email: 'test-participant-1@google.com') create(:user, email: 'test-participant-1@google.com')
expected_count_openid = Openid.count + 1 expected_count_openid = Openid.count + 1
expected_count_user = User.count expected_count_user = User.count
visit '/accounts/sign_in' visit '/accounts/sign_in'

View file

@ -1,19 +1,17 @@
require 'spec_helper' require 'spec_helper'
feature Event do feature Event do
# It is necessary to use bang version of let to build roles before user let!(:conference) { create(:conference) }
let!(:participant_role) { create(:participant_role) } let!(:organizer_role) { create(:organizer_role, resource: conference) }
let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) } let!(:organizer) { create(:user, email: 'admin@example.com', role_ids: [organizer_role.id]) }
let!(:participant) { create(:user, biography: '') }
shared_examples 'proposal workflow' do shared_examples 'proposal workflow' do
scenario 'submitts a proposal, accepts and confirms', scenario 'submitts a proposal, accepts and confirms',
feature: true, js: true do feature: true, js: true do
organizer = create(:organizer_conference_1, email: 'admin@example.com')
participant = create(:user, email: 'participant@example.com', biography: '')
expected_count = Event.count + 1 expected_count = Event.count + 1
conference = create(:conference)
conference.call_for_papers = create(:call_for_papers) conference.call_for_papers = create(:call_for_papers)
conference.email_settings = create(:email_settings) conference.email_settings = create(:email_settings)
conference.event_types = [create(:event_type)] conference.event_types = [create(:event_type)]

View file

@ -1,14 +1,14 @@
require 'spec_helper' require 'spec_helper'
feature Room do feature Room do
# It is necessary to use bang version of let to build roles before user let!(:conference) { create(:conference) }
let!(:participant_role) { create(:participant_role) } let!(:organizer_role) { create(:organizer_role, resource: conference) }
let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) } let!(:organizer) { create(:user, role_ids: [organizer_role.id]) }
shared_examples 'rooms' do |user| shared_examples 'rooms' do
scenario 'adds and updates rooms', feature: true, js: true do scenario 'adds and updates rooms', feature: true, js: true do
conference = create(:conference)
sign_in create(user) sign_in organizer
visit admin_conference_rooms_path( visit admin_conference_rooms_path(
conference_id: conference.short_title) conference_id: conference.short_title)
@ -43,6 +43,6 @@ feature Room do
end end
describe 'organizer' do describe 'organizer' do
it_behaves_like 'rooms', :organizer_conference_1 it_behaves_like 'rooms'
end end
end end

View file

@ -1,16 +1,16 @@
require 'spec_helper' require 'spec_helper'
feature Sponsor do feature Sponsor do
# It is necessary to use bang version of let to build roles before user let!(:conference) { create(:conference) }
let!(:participant_role) { create(:participant_role) } let!(:organizer_role) { create(:organizer_role, resource: conference) }
let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) } let!(:organizer) { create(:user, role_ids: [organizer_role.id]) }
shared_examples 'sponsors' do |user| shared_examples 'sponsors' do
scenario 'adds and updates sponsors', feature: true, js: true do scenario 'adds and updates sponsors', feature: true, js: true do
path = "#{Rails.root}/app/assets/images/rails.png" path = "#{Rails.root}/app/assets/images/rails.png"
conference = create(:conference)
conference.sponsorship_levels << create(:sponsorship_level, conference: conference) conference.sponsorship_levels << create(:sponsorship_level, conference: conference)
sign_in create(user) sign_in organizer
visit admin_conference_sponsors_path( visit admin_conference_sponsors_path(
conference_id: conference.short_title) conference_id: conference.short_title)
@ -69,6 +69,6 @@ feature Sponsor do
end end
describe 'organizer' do describe 'organizer' do
it_behaves_like 'sponsors', :organizer_conference_1 it_behaves_like 'sponsors'
end end
end end

View file

@ -1,14 +1,14 @@
require 'spec_helper' require 'spec_helper'
feature SponsorshipLevel do feature SponsorshipLevel do
# It is necessary to use bang version of let to build roles before user let!(:conference) { create(:conference) }
let!(:participant_role) { create(:participant_role) } let!(:organizer_role) { create(:organizer_role, resource: conference) }
let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) } let!(:organizer) { create(:user, role_ids: [organizer_role.id]) }
shared_examples 'sponsorship levels' do |user| shared_examples 'sponsorship levels' do
scenario 'adds and updates sponsorship level', feature: true, js: true do scenario 'adds and updates sponsorship level', feature: true, js: true do
conference = create(:conference)
sign_in create(user) sign_in organizer
visit admin_conference_sponsorship_levels_path( visit admin_conference_sponsorship_levels_path(
conference_id: conference.short_title) conference_id: conference.short_title)
# Add sponsorship level # Add sponsorship level
@ -36,6 +36,6 @@ feature SponsorshipLevel do
end end
describe 'organizer' do describe 'organizer' do
it_behaves_like 'sponsorship levels', :organizer_conference_1 it_behaves_like 'sponsorship levels'
end end
end end

View file

@ -1,14 +1,15 @@
require 'spec_helper' require 'spec_helper'
feature Track do feature Track do
# It is necessary to use bang version of let to build roles before user let!(:conference) { create(:conference) }
let!(:participant_role) { create(:participant_role) } let!(:organizer_role) { create(:organizer_role, resource: conference) }
let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) } let!(:organizer) { create(:user, role_ids: [organizer_role.id]) }
shared_examples 'tracks' do |user| shared_examples 'tracks' do
scenario 'adds and updates tracks', feature: true, js: true do scenario 'adds and updates tracks', feature: true, js: true do
conference = create(:conference)
sign_in create(user) sign_in organizer
visit admin_conference_tracks_path( visit admin_conference_tracks_path(
conference_id: conference.short_title) conference_id: conference.short_title)
@ -50,6 +51,6 @@ feature Track do
end end
describe 'organizer' do describe 'organizer' do
it_behaves_like 'tracks', :organizer_conference_1 it_behaves_like 'tracks'
end end
end end

View file

@ -1,16 +1,15 @@
require 'spec_helper' require 'spec_helper'
feature Conference do feature Conference do
let!(:conference) { create(:conference) }
let!(:organizer_role) { create(:organizer_role, resource: conference) }
let!(:organizer) { create(:user, role_ids: [organizer_role.id]) }
# It is necessary to use bang version of let to build roles before user shared_examples 'venue' do
let!(:participant_role) { create(:participant_role) }
let!(:organizer_role) { create(:organizer_conference_1_role) }
shared_examples 'venue' do |user|
scenario 'adds and updates venue' do scenario 'adds and updates venue' do
conference = create(:conference)
sign_in create(user) sign_in organizer
visit admin_conference_venue_info_path( visit admin_conference_venue_info_path(
conference_id: conference.short_title) conference_id: conference.short_title)
@ -59,7 +58,7 @@ feature Conference do
end end
describe 'organizer' do describe 'organizer' do
it_behaves_like 'venue', :organizer_conference_1 it_behaves_like 'venue'
end end
end end

View file

@ -1,11 +1,9 @@
require 'spec_helper' require 'spec_helper'
feature Conference do feature Conference do
# It is necessary to use bang version of let to build roles before user let!(:conference) { create(:conference) }
let!(:participant_role) { create(:participant_role) } let!(:organizer_role) { create(:organizer_role, resource: conference) }
let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) } let!(:organizer) { create(:user, role_ids: [organizer_role.id]) }
let(:organizer) { create(:organizer_conference_1) }
let(:conference) { create(:conference) }
shared_examples 'volunteer' do shared_examples 'volunteer' do
scenario 'adds and updates vdays', feature: true, js: true do scenario 'adds and updates vdays', feature: true, js: true do

View file

@ -28,7 +28,7 @@ describe 'User' do
end end
context 'when user is a Signed In User' do # Test abilities for signed in users (without any role) context 'when user is a Signed In User' do # Test abilities for signed in users (without any role)
let(:user) { create(:participant) } let(:user) { create(:user) }
let(:registration1) { create(:registration, conference: conference_public, user: user) } let(:registration1) { create(:registration, conference: conference_public, user: user) }
let(:registration2) { create(:registration, conference: conference_not_public, user: user) } let(:registration2) { create(:registration, conference: conference_not_public, user: user) }
@ -52,8 +52,8 @@ describe 'User' do
end end
context 'signed in users can manage their events' do context 'signed in users can manage their events' do
let(:user) { create(:participant) } let(:user) { create(:user) }
let(:user2) { create(:participant) } let(:user2) { create(:user) }
let(:myevent) { create(:event, users: [user]) } let(:myevent) { create(:event, users: [user]) }
let(:someevent) { create(:event, users: [user2]) } let(:someevent) { create(:event, users: [user2]) }
let(:commercial_myevent) { create(:commercial, commercialable: myevent) } let(:commercial_myevent) { create(:commercial, commercialable: myevent) }

View file

@ -273,9 +273,9 @@ describe Conference do
end end
describe '#get_top_submitter' do describe '#get_top_submitter' do
# It is necessary to use bang version of let to build roles before user let!(:conference) { create(:conference) }
let!(:participant_role) { create(:participant_role) } let!(:organizer_role) { create(:organizer_role, resource: conference) }
let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) } let!(:organizer) { create(:user, role_ids: [organizer_role.id]) }
it 'calculates correct hash with top submitters' do it 'calculates correct hash with top submitters' do
event = create(:event, conference: subject) event = create(:event, conference: subject)
@ -895,9 +895,9 @@ describe Conference do
end end
describe 'self#event_distribution' do describe 'self#event_distribution' do
# It is necessary to use bang version of let to build roles before user let!(:conference) { create(:conference) }
let!(:participant_role) { create(:participant_role) } let!(:organizer_role) { create(:organizer_role, resource: conference) }
let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) } let!(:organizer) { create(:user, role_ids: [organizer_role.id]) }
it 'self#event_distribution calculates correct values with user' do it 'self#event_distribution calculates correct values with user' do
create(:user, last_sign_in_at: Date.today - 3.months) # active create(:user, last_sign_in_at: Date.today - 3.months) # active
@ -1424,8 +1424,9 @@ describe Conference do
describe '#user_registered?' do describe '#user_registered?' 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!(:participant_role) { create(:participant_role) } let!(:conference) { create(:conference) }
let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) } let!(:organizer_role) { create(:organizer_role, resource: conference) }
let!(:organizer) { create(:user, role_ids: [organizer_role.id]) }
let(:user) { create(:user) } let(:user) { create(:user) }

View file

@ -3,55 +3,51 @@ require 'spec_helper'
describe User do describe User 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!(:user_admin) { create(:user) }
let!(:admin) { create(:admin) } let!(:admin) { create(:admin) }
let!(:participant) { create(:participant) } let!(:participant) { create(:user) }
let!(:organizer_conference_1) { create(:organizer_conference_1 ) } let!(:conference) { create(:conference) }
let!(:organizer_conference_1_role) { Role.where(resource_type: 'Conference', resource_id: 1).first } let!(:organizer_role) { create(:organizer_role, resource: conference) }
let!(:cfp_role) { create(:cfp_role, resource: conference) }
let!(:organizer) { create(:user, role_ids: [organizer_role.id]) }
it 'returns the correct role' do it 'returns the correct role' do
expect(organizer_conference_1.roles.first).to eq(organizer_conference_1_role) expect(user_admin.is_admin).to eq(true)
expect(organizer.roles.first).to eq(organizer_role)
end end
it 'returns the correct roles' do it 'returns the correct roles' do
participant_role = create(:participant_role) roles = [organizer_role.id, cfp_role.id]
roles = [participant_role.id, organizer_conference_1_role.id] another_user = create(:user, email: 'participant@example.de')
user_with_all_roles = create(:user, email: 'participant@example.de') another_user.role_ids = roles
user_with_all_roles.role_ids = roles another_user.save
user_with_all_roles.save
expect(user_with_all_roles.roles.length).to eq(2) expect(another_user.roles.length).to eq(2)
expect(user_with_all_roles.roles[0]).to eq(participant_role) expect(another_user.roles[0]).to eq(organizer_role)
expect(user_with_all_roles.roles[1]).to eq(organizer_conference_1_role ) expect(another_user.roles[1]).to eq(cfp_role)
end end
describe '#has_role?' do describe '#has_role?' do
shared_examples '#role?' do |user, role, expected| shared_examples '#role?' do |user, role, expected|
it "returns #{expected} for #{role}" do it "returns #{expected} for #{role}" do
user_obj = create(user, email: 'e@example.com') user_obj = create(user)
expect(user_obj.has_role?(role.downcase, :any)).to be expected expect(user_obj.has_role?(role.downcase, conference)).to be expected
end end
end end
context 'organizer' do context 'organizer' do
it_behaves_like '#role?', :organizer_conference_1, 'organizer', true it_behaves_like '#role?', :organizer, 'organizer', true
it_behaves_like '#role?', :organizer_conference_1, 'participant', false it_behaves_like '#role?', :organizer, 'participant', false
end end
context 'admin' do context 'admin' do
it 'assigns first user admin role' do it 'assigns first user admin role' do
expect(User.first.is_admin).to be true expect(User.first.is_admin).to be true
expect(admin.is_admin).to eq(true)
end end
end end
context 'participant' do context 'participant' do
it_behaves_like '#role?', :participant, 'adMin', false it_behaves_like '#role?', :user, 'adMin', false
it_behaves_like '#role?', :participant, 'participant', true
# it 'assigns second user participant role' do
# participant = create(:user, email: 'participant@example.de')
# expect(participant.role_ids).to match_array([participant_role.id])
# end
end end
end end
end end