diff --git a/app/controllers/admin/questions_controller.rb b/app/controllers/admin/questions_controller.rb index d2f63cf2..a422d6db 100644 --- a/app/controllers/admin/questions_controller.rb +++ b/app/controllers/admin/questions_controller.rb @@ -5,7 +5,7 @@ module Admin def index 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 @new_question = @conference.questions.new end @@ -33,25 +33,25 @@ module Admin # GET questions/1/edit def edit 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 # PUT questions/1 def update 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 - 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 # Update questions used for the conference def update_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 - 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 @@ -82,7 +82,7 @@ module Admin flash[:error] = "You must be an admin to delete a question." 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 end end diff --git a/app/controllers/admin/social_events_controller.rb b/app/controllers/admin/social_events_controller.rb index 05881371..47bbeceb 100644 --- a/app/controllers/admin/social_events_controller.rb +++ b/app/controllers/admin/social_events_controller.rb @@ -9,9 +9,9 @@ module Admin def update 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 - 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 diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index 7d2faaa0..6945cddf 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -20,28 +20,16 @@ module Admin end def update - params[:user].delete :roles_attributes if params[:user] @user.update_attributes!(params[:user]) redirect_to admin_users_path, notice: "Updated #{@user.email}" 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 end def 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 diff --git a/app/controllers/admin/volunteers_controller.rb b/app/controllers/admin/volunteers_controller.rb index fb34f78e..970ec1e1 100644 --- a/app/controllers/admin/volunteers_controller.rb +++ b/app/controllers/admin/volunteers_controller.rb @@ -15,7 +15,7 @@ module Admin if @conference.use_vpositions @volunteers = @conference.registrations.joins(:vchoices).uniq else - @volunteers = @conference.registrations.where(:volunteer => true) + @volunteers = @conference.registrations.where(volunteer: true) end else authorize! :index, :volunteer @@ -26,9 +26,9 @@ module Admin if (current_user.has_role? :organizer, @conference) || (current_user.has_role? :volunteer_coordinator, @conference) begin @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 - 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 else authorize! :index, :volunteer diff --git a/app/controllers/event_attachments_controller.rb b/app/controllers/event_attachments_controller.rb index c8bf54c1..3116b22b 100644 --- a/app/controllers/event_attachments_controller.rb +++ b/app/controllers/event_attachments_controller.rb @@ -67,7 +67,6 @@ class EventAttachmentsController < ApplicationController respond_to do |format| if @upload.save -<<<<<<< HEAD format.html do render json: [@upload.to_jq_upload].to_json, content_type: 'text/html', @@ -77,15 +76,6 @@ class EventAttachmentsController < ApplicationController render json: [@upload.to_jq_upload].to_json, status: :created, location: conference_proposal_event_attachment_path(@upload.event.conference.short_title, @upload.event, @upload) 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 format.html { render action: "new" } format.json { render json: @upload.errors, status: :unprocessable_entity } diff --git a/app/controllers/schedule_controller.rb b/app/controllers/schedule_controller.rb index f5fc9914..e9d60d1a 100644 --- a/app/controllers/schedule_controller.rb +++ b/app/controllers/schedule_controller.rb @@ -1,8 +1,5 @@ class ScheduleController < ApplicationController -<<<<<<< HEAD -======= authorize_resource class: false ->>>>>>> authorization with cancancan layout "application" def index diff --git a/app/models/campaign.rb b/app/models/campaign.rb index 5d9ab7ed..77ff94f2 100644 --- a/app/models/campaign.rb +++ b/app/models/campaign.rb @@ -1,6 +1,6 @@ class Campaign < ActiveRecord::Base - attr_accessible :name, :target_ids, :conference_id, - :utm_source, :utm_medium, :utm_term, :utm_content, :utm_campaign + attr_accessible :name, :utm_source, :utm_medium, :utm_term, + :utm_content, :utm_campaign, :target_ids, :conference_id validates :name, :utm_campaign, presence: true diff --git a/app/models/event_attachment.rb b/app/models/event_attachment.rb index 819f3b6d..41915248 100644 --- a/app/models/event_attachment.rb +++ b/app/models/event_attachment.rb @@ -6,7 +6,6 @@ class EventAttachment < ActiveRecord::Base has_attached_file :attachment, path: ":rails_root/storage/:rails_env/attachments/:id/:style/:basename.:extension" include Rails.application.routes.url_helpers - do_not_validate_attachment_file_type :attachment def to_jq_upload { diff --git a/app/views/admin/users/_form.html.haml b/app/views/admin/users/_form.html.haml index f8278bee..afec4b32 100644 --- a/app/views/admin/users/_form.html.haml +++ b/app/views/admin/users/_form.html.haml @@ -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 :name, :as => :string = f.input :email - = f.input :affiliation, as: :string - = f.input :biography, input_html: { rows: 5, "onkeyup" => "word_count(this, 'biography-count', 150)" } - You have used - %span#biography-count #{@user.biography_word_count} - words. Biographies are limited to 150 words. - %br - %br + = f.input :affiliation, :as => :string + = f.input :biography, :input_html => {:rows => 10} = f.actions do - = f.action :submit, button_html: { class: 'btn btn-primary' } + = f.action :submit, :button_html => {:class => "btn btn-primary"} diff --git a/app/views/proposal/_form.html.haml b/app/views/proposal/_form.html.haml index b30497e4..0b78cbdb 100644 --- a/app/views/proposal/_form.html.haml +++ b/app/views/proposal/_form.html.haml @@ -71,7 +71,7 @@ data.formData = inputs.serializeArray(); }); $.getJSON($('#fileupload').prop('action'), function (files) { - var fu = $('#fileupload').data('blueimpFileupload'), + var fu = $('#fileupload').data('fileupload'), template; fu._adjustMaxNumberOfFiles(-files.length); template = fu._renderDownload(files) diff --git a/app/views/proposal/new.html.haml b/app/views/proposal/new.html.haml index 69e5bf4e..a6325a98 100644 --- a/app/views/proposal/new.html.haml +++ b/app/views/proposal/new.html.haml @@ -1,6 +1,6 @@ .row .col-md-12 - = simple_format(@conference.call_for_papers.description) if @conference.call_for_papers + = simple_format(@conference.call_for_papers.description) .row .col-md-12 = render 'proposal_form' diff --git a/db/migrate/20140718103856_add_is_admin_to_users.rb b/db/migrate/20140718103856_add_is_admin_to_users.rb index def2bbb0..1511d822 100644 --- a/db/migrate/20140718103856_add_is_admin_to_users.rb +++ b/db/migrate/20140718103856_add_is_admin_to_users.rb @@ -1,5 +1,5 @@ class AddIsAdminToUsers < ActiveRecord::Migration def change - add_column :users, :is_admin, :boolean + add_column :users, :is_admin, :boolean, default: false end end diff --git a/spec/controllers/admin/conferences_controller_spec.rb b/spec/controllers/admin/conferences_controller_spec.rb index 18eba58a..cb4ac8ea 100644 --- a/spec/controllers/admin/conferences_controller_spec.rb +++ b/spec/controllers/admin/conferences_controller_spec.rb @@ -5,11 +5,10 @@ describe Admin::ConferenceController do # It is necessary to use bang version of let to build roles before user let(:conference) { create(:conference) } let!(:first_user) { create(:user) } - let!(:participant_role) { create(:participant_role) } let!(:organizer_role) { create(:role, name: 'organizer', resource: conference) } 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 diff --git a/spec/factories/roles.rb b/spec/factories/roles.rb index 19ec8969..15f6d23e 100644 --- a/spec/factories/roles.rb +++ b/spec/factories/roles.rb @@ -1,18 +1,12 @@ FactoryGirl.define do factory :role do - factory :participant_role do - name 'participant' - end - factory :organizer_role do name 'organizer' end - factory :organizer_conference_1_role do - name 'organizer' - resource_type 'Conference' - resource_id 1 + factory :cfp_role do + name 'cfp' end end end diff --git a/spec/factories/users.rb b/spec/factories/users.rb index 5b029441..d404aefb 100644 --- a/spec/factories/users.rb +++ b/spec/factories/users.rb @@ -15,16 +15,12 @@ FactoryGirl.define do gravida. 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 is_admin true end + + factory :organizer do + after(:create) { |user| user.role_ids = create(:organizer_role).id } + end end end diff --git a/spec/features/campaign_spec.rb b/spec/features/campaign_spec.rb index 6580d736..21382655 100644 --- a/spec/features/campaign_spec.rb +++ b/spec/features/campaign_spec.rb @@ -2,15 +2,14 @@ require 'spec_helper' feature Campaign do - # It is necessary to use bang version of let to build roles before user - let!(:participant_role) { create(:participant_role) } - let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) } + let!(:conference) { create(:conference, short_title: 'osc14') } + let!(:organizer_role) { create(:organizer_role, resource: conference) } + 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 expected_count = Campaign.count + 1 - conference = create(:conference, short_title: 'osc14') - sign_in create(user) + sign_in organizer visit admin_conference_campaigns_path(conference.short_title) @@ -52,6 +51,6 @@ feature Campaign do end describe 'organizer' do - it_behaves_like 'add and update campaign', :organizer_conference_1 + it_behaves_like 'add and update campaign' end end diff --git a/spec/features/cfp_spec.rb b/spec/features/cfp_spec.rb index e024e11b..23f2458a 100644 --- a/spec/features/cfp_spec.rb +++ b/spec/features/cfp_spec.rb @@ -2,15 +2,15 @@ require 'spec_helper' feature Conference do - # It is necessary to use bang version of let to build roles before user - let!(:participant_role) { create(:participant_role) } - let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) } + let!(:conference) { create(:conference) } + let!(:organizer_role) { create(:organizer_role, resource: conference) } + 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 expected_count = CallForPapers.count + 1 - conference = create(:conference) - sign_in create(user) + + sign_in organizer visit admin_conference_callforpapers_path(conference.short_title) @@ -46,11 +46,10 @@ feature Conference do end scenario 'update cfp', feature: true, js: true do - conference = create(:conference) conference.call_for_papers = create(:call_for_papers) expected_count = CallForPapers.count - sign_in create(user) + sign_in organizer visit admin_conference_callforpapers_path(conference.short_title) # Validate update with empty start date will not saved @@ -87,6 +86,6 @@ feature Conference do end describe 'organizer' do - it_behaves_like 'add and update cfp', :organizer_conference_1 + it_behaves_like 'add and update cfp' end end diff --git a/spec/features/commercials_spec.rb b/spec/features/commercials_spec.rb index 39b69ad0..e53524b7 100644 --- a/spec/features/commercials_spec.rb +++ b/spec/features/commercials_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' feature Commercial do # It is necessary to use bang version of let to build roles before user 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]) } shared_examples 'adds and updates a commercial' do diff --git a/spec/features/conference_spec.rb b/spec/features/conference_spec.rb index fdd37748..45977092 100644 --- a/spec/features/conference_spec.rb +++ b/spec/features/conference_spec.rb @@ -1,15 +1,12 @@ require 'spec_helper' feature Conference do + let!(:user) { create(:admin) } - # It is necessary to use bang version of let to build roles before user - let!(:participant_role) { create(:participant_role) } - let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) } - - shared_examples 'add and update conference' do |user| + shared_examples 'add and update conference' do scenario 'adds a new conference', feature: true, js: true do expected_count = Conference.count + 1 - sign_in create(user) + sign_in user visit new_admin_conference_path fill_in 'conference_title', with: 'Example Con' @@ -30,12 +27,18 @@ feature Conference do expect(flash). to eq('Conference was successfully created.') expect(Conference.count).to eq(expected_count) + + expect(user.has_role? :organizer, Conference.last).to eq(true) end scenario 'update conference', feature: true, js: true do conference = create(:conference) + organizer_role = create(:organizer_role, resource: conference) + organizer = create(:user, role_ids: [organizer_role.id]) + expected_count = Conference.count - sign_in create(:organizer_conference_1) + + sign_in organizer visit edit_admin_conference_path(conference.short_title) click_link 'Edit' @@ -62,6 +65,6 @@ feature Conference do end describe 'admin' do - it_behaves_like 'add and update conference', :admin + it_behaves_like 'add and update conference' end end diff --git a/spec/features/difficulty_levels_spec.rb b/spec/features/difficulty_levels_spec.rb index c5ef30a4..b81f9d00 100644 --- a/spec/features/difficulty_levels_spec.rb +++ b/spec/features/difficulty_levels_spec.rb @@ -1,14 +1,14 @@ require 'spec_helper' feature DifficultyLevel do - # It is necessary to use bang version of let to build roles before user - let!(:participant_role) { create(:participant_role) } - let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) } + let!(:conference) { create(:conference) } + let!(:organizer_role) { create(:organizer_role, resource: conference) } + 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 - conference = create(:conference) - sign_in create(user) + + sign_in organizer visit admin_conference_difficulty_levels_path( conference_id: conference.short_title) @@ -50,6 +50,6 @@ feature DifficultyLevel do end describe 'organizer' do - it_behaves_like 'difficulty levels', :organizer_conference_1 + it_behaves_like 'difficulty levels' end end diff --git a/spec/features/email_spec.rb b/spec/features/email_spec.rb index 0918e67f..7ba66e17 100644 --- a/spec/features/email_spec.rb +++ b/spec/features/email_spec.rb @@ -1,18 +1,17 @@ require 'spec_helper' feature EmailSettings do - # It is necessary to use bang version of let to build roles before user - let!(:participant_role) { create(:participant_role) } - let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) } + let!(:conference) { create(:conference) } + let!(:organizer_role) { create(:organizer_role, resource: conference) } + let!(:organizer) { create(:user, role_ids: [organizer_role.id]) } - shared_examples 'email settings' do |user| + shared_examples 'email settings' do scenario 'updates email settings', feature: true, js: true do - conference = create(:conference) expected_count = EmailSettings.count - sign_in create(user) + sign_in organizer visit admin_conference_emails_path(conference.short_title) @@ -91,6 +90,6 @@ feature EmailSettings do end describe 'organizer' do - it_behaves_like 'email settings', :organizer_conference_1 + it_behaves_like 'email settings' end end diff --git a/spec/features/event_types_spec.rb b/spec/features/event_types_spec.rb index f417ac34..a71aacfa 100644 --- a/spec/features/event_types_spec.rb +++ b/spec/features/event_types_spec.rb @@ -1,14 +1,14 @@ require 'spec_helper' feature EventType do - # It is necessary to use bang version of let to build roles before user - let!(:participant_role) { create(:participant_role) } - let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) } + let!(:conference) { create(:conference) } + let!(:organizer_role) { create(:organizer_role, resource: conference) } + 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 - conference = create(:conference) - sign_in create(user) + + sign_in organizer visit admin_conference_event_types_path( conference_id: conference.short_title) @@ -55,6 +55,6 @@ feature EventType do end describe 'organizer' do - it_behaves_like 'event types', :organizer_conference_1 + it_behaves_like 'event types' end end diff --git a/spec/features/lodgings_spec.rb b/spec/features/lodgings_spec.rb index a52d8ed4..89a73ea8 100644 --- a/spec/features/lodgings_spec.rb +++ b/spec/features/lodgings_spec.rb @@ -1,16 +1,16 @@ require 'spec_helper' feature Lodging do - # It is necessary to use bang version of let to build roles before user - let!(:participant_role) { create(:participant_role) } - let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) } + let!(:conference) { create(:conference) } + let!(:organizer_role) { create(:organizer_role, resource: conference) } + 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 path = "#{Rails.root}/app/assets/images/rails.png" - conference = create(:conference) + conference.venue = create(:venue) - sign_in create(user) + sign_in organizer visit admin_conference_lodgings_path( conference_id: conference.short_title) # Add lodging @@ -56,6 +56,6 @@ feature Lodging do end describe 'organizer' do - it_behaves_like 'lodgings', :organizer_conference_1 + it_behaves_like 'lodgings' end end diff --git a/spec/features/omniauth_spec.rb b/spec/features/omniauth_spec.rb index 206060d1..3d343a8f 100644 --- a/spec/features/omniauth_spec.rb +++ b/spec/features/omniauth_spec.rb @@ -1,8 +1,6 @@ require 'spec_helper' feature Openid do - let!(:participant_role) { create(:participant_role) } - shared_examples 'sign in with openid' do scenario 'has option to log in with Google account' do @@ -26,7 +24,7 @@ feature Openid do end 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_user = User.count visit '/accounts/sign_in' @@ -53,7 +51,7 @@ feature Openid do scenario 'adds openid to existing user' do # Sign in user - user = create(:participant, email: 'test-participant-1@google.com') + user = create(:user, email: 'test-participant-1@google.com') sign_in 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 # 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_user = User.count visit '/accounts/sign_in' diff --git a/spec/features/proposal_spec.rb b/spec/features/proposal_spec.rb index dd7f9adf..1f4aa796 100644 --- a/spec/features/proposal_spec.rb +++ b/spec/features/proposal_spec.rb @@ -1,19 +1,17 @@ require 'spec_helper' feature Event do - # It is necessary to use bang version of let to build roles before user - let!(:participant_role) { create(:participant_role) } - let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) } + let!(:conference) { create(:conference) } + let!(:organizer_role) { create(:organizer_role, resource: conference) } + let!(:organizer) { create(:user, email: 'admin@example.com', role_ids: [organizer_role.id]) } + let!(:participant) { create(:user, biography: '') } shared_examples 'proposal workflow' do scenario 'submitts a proposal, accepts and confirms', 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 - conference = create(:conference) + conference.call_for_papers = create(:call_for_papers) conference.email_settings = create(:email_settings) conference.event_types = [create(:event_type)] diff --git a/spec/features/rooms_spec.rb b/spec/features/rooms_spec.rb index 0025267e..23911004 100644 --- a/spec/features/rooms_spec.rb +++ b/spec/features/rooms_spec.rb @@ -1,14 +1,14 @@ require 'spec_helper' feature Room do - # It is necessary to use bang version of let to build roles before user - let!(:participant_role) { create(:participant_role) } - let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) } + let!(:conference) { create(:conference) } + let!(:organizer_role) { create(:organizer_role, resource: conference) } + 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 - conference = create(:conference) - sign_in create(user) + + sign_in organizer visit admin_conference_rooms_path( conference_id: conference.short_title) @@ -43,6 +43,6 @@ feature Room do end describe 'organizer' do - it_behaves_like 'rooms', :organizer_conference_1 + it_behaves_like 'rooms' end end diff --git a/spec/features/sponsor_spec.rb b/spec/features/sponsor_spec.rb index c09a093e..2269d50d 100644 --- a/spec/features/sponsor_spec.rb +++ b/spec/features/sponsor_spec.rb @@ -1,16 +1,16 @@ require 'spec_helper' feature Sponsor do - # It is necessary to use bang version of let to build roles before user - let!(:participant_role) { create(:participant_role) } - let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) } + let!(:conference) { create(:conference) } + let!(:organizer_role) { create(:organizer_role, resource: conference) } + 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 path = "#{Rails.root}/app/assets/images/rails.png" - conference = create(:conference) + conference.sponsorship_levels << create(:sponsorship_level, conference: conference) - sign_in create(user) + sign_in organizer visit admin_conference_sponsors_path( conference_id: conference.short_title) @@ -69,6 +69,6 @@ feature Sponsor do end describe 'organizer' do - it_behaves_like 'sponsors', :organizer_conference_1 + it_behaves_like 'sponsors' end end diff --git a/spec/features/sponsorship_level_spec.rb b/spec/features/sponsorship_level_spec.rb index 0974d770..229cb926 100644 --- a/spec/features/sponsorship_level_spec.rb +++ b/spec/features/sponsorship_level_spec.rb @@ -1,14 +1,14 @@ require 'spec_helper' feature SponsorshipLevel do - # It is necessary to use bang version of let to build roles before user - let!(:participant_role) { create(:participant_role) } - let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) } + let!(:conference) { create(:conference) } + let!(:organizer_role) { create(:organizer_role, resource: conference) } + 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 - conference = create(:conference) - sign_in create(user) + + sign_in organizer visit admin_conference_sponsorship_levels_path( conference_id: conference.short_title) # Add sponsorship level @@ -36,6 +36,6 @@ feature SponsorshipLevel do end describe 'organizer' do - it_behaves_like 'sponsorship levels', :organizer_conference_1 + it_behaves_like 'sponsorship levels' end end diff --git a/spec/features/tracks_spec.rb b/spec/features/tracks_spec.rb index d625bbae..3d2949e2 100644 --- a/spec/features/tracks_spec.rb +++ b/spec/features/tracks_spec.rb @@ -1,14 +1,15 @@ require 'spec_helper' feature Track do - # It is necessary to use bang version of let to build roles before user - let!(:participant_role) { create(:participant_role) } - let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) } + let!(:conference) { create(:conference) } + let!(:organizer_role) { create(:organizer_role, resource: conference) } + 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 - conference = create(:conference) - sign_in create(user) + + sign_in organizer + visit admin_conference_tracks_path( conference_id: conference.short_title) @@ -50,6 +51,6 @@ feature Track do end describe 'organizer' do - it_behaves_like 'tracks', :organizer_conference_1 + it_behaves_like 'tracks' end end diff --git a/spec/features/venue_spec.rb b/spec/features/venue_spec.rb index 3c838312..ac28a55a 100644 --- a/spec/features/venue_spec.rb +++ b/spec/features/venue_spec.rb @@ -1,16 +1,15 @@ require 'spec_helper' 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 - let!(:participant_role) { create(:participant_role) } - let!(:organizer_role) { create(:organizer_conference_1_role) } - - shared_examples 'venue' do |user| + shared_examples 'venue' do scenario 'adds and updates venue' do - conference = create(:conference) - sign_in create(user) + sign_in organizer + visit admin_conference_venue_info_path( conference_id: conference.short_title) @@ -59,7 +58,7 @@ feature Conference do end describe 'organizer' do - it_behaves_like 'venue', :organizer_conference_1 + it_behaves_like 'venue' end end diff --git a/spec/features/volunteers_spec.rb b/spec/features/volunteers_spec.rb index 907e4e69..20242781 100644 --- a/spec/features/volunteers_spec.rb +++ b/spec/features/volunteers_spec.rb @@ -1,11 +1,9 @@ require 'spec_helper' feature Conference do - # It is necessary to use bang version of let to build roles before user - let!(:participant_role) { create(:participant_role) } - let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) } - let(:organizer) { create(:organizer_conference_1) } - let(:conference) { create(:conference) } + let!(:conference) { create(:conference) } + let!(:organizer_role) { create(:organizer_role, resource: conference) } + let!(:organizer) { create(:user, role_ids: [organizer_role.id]) } shared_examples 'volunteer' do scenario 'adds and updates vdays', feature: true, js: true do diff --git a/spec/models/ability_spec.rb b/spec/models/ability_spec.rb index bf543fb1..a95613ba 100644 --- a/spec/models/ability_spec.rb +++ b/spec/models/ability_spec.rb @@ -28,7 +28,7 @@ describe 'User' do end 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(:registration2) { create(:registration, conference: conference_not_public, user: user) } @@ -52,8 +52,8 @@ describe 'User' do end context 'signed in users can manage their events' do - let(:user) { create(:participant) } - let(:user2) { create(:participant) } + let(:user) { create(:user) } + let(:user2) { create(:user) } let(:myevent) { create(:event, users: [user]) } let(:someevent) { create(:event, users: [user2]) } let(:commercial_myevent) { create(:commercial, commercialable: myevent) } diff --git a/spec/models/conference_spec.rb b/spec/models/conference_spec.rb index 2ad64f83..4336ef80 100644 --- a/spec/models/conference_spec.rb +++ b/spec/models/conference_spec.rb @@ -273,9 +273,9 @@ describe Conference do end describe '#get_top_submitter' do - # It is necessary to use bang version of let to build roles before user - let!(:participant_role) { create(:participant_role) } - let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) } + let!(:conference) { create(:conference) } + let!(:organizer_role) { create(:organizer_role, resource: conference) } + let!(:organizer) { create(:user, role_ids: [organizer_role.id]) } it 'calculates correct hash with top submitters' do event = create(:event, conference: subject) @@ -895,9 +895,9 @@ describe Conference do end describe 'self#event_distribution' do - # It is necessary to use bang version of let to build roles before user - let!(:participant_role) { create(:participant_role) } - let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) } + let!(:conference) { create(:conference) } + let!(:organizer_role) { create(:organizer_role, resource: conference) } + let!(:organizer) { create(:user, role_ids: [organizer_role.id]) } it 'self#event_distribution calculates correct values with user' do create(:user, last_sign_in_at: Date.today - 3.months) # active @@ -1424,8 +1424,9 @@ describe Conference do describe '#user_registered?' do # It is necessary to use bang version of let to build roles before user - let!(:participant_role) { create(:participant_role) } - let!(:organizer_conference_1_role) { create(:organizer_conference_1_role) } + let!(:conference) { create(:conference) } + let!(:organizer_role) { create(:organizer_role, resource: conference) } + let!(:organizer) { create(:user, role_ids: [organizer_role.id]) } let(:user) { create(:user) } diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 5d599c35..be110312 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -3,55 +3,51 @@ require 'spec_helper' describe User do # It is necessary to use bang version of let to build roles before user + let!(:user_admin) { create(:user) } let!(:admin) { create(:admin) } - let!(:participant) { create(:participant) } - let!(:organizer_conference_1) { create(:organizer_conference_1 ) } - let!(:organizer_conference_1_role) { Role.where(resource_type: 'Conference', resource_id: 1).first } + let!(:participant) { create(:user) } + let!(:conference) { create(:conference) } + 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 - 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 it 'returns the correct roles' do - participant_role = create(:participant_role) - roles = [participant_role.id, organizer_conference_1_role.id] - user_with_all_roles = create(:user, email: 'participant@example.de') - user_with_all_roles.role_ids = roles - user_with_all_roles.save + roles = [organizer_role.id, cfp_role.id] + another_user = create(:user, email: 'participant@example.de') + another_user.role_ids = roles + another_user.save - expect(user_with_all_roles.roles.length).to eq(2) - expect(user_with_all_roles.roles[0]).to eq(participant_role) - expect(user_with_all_roles.roles[1]).to eq(organizer_conference_1_role ) + expect(another_user.roles.length).to eq(2) + expect(another_user.roles[0]).to eq(organizer_role) + expect(another_user.roles[1]).to eq(cfp_role) end describe '#has_role?' do shared_examples '#role?' do |user, role, expected| it "returns #{expected} for #{role}" do - user_obj = create(user, email: 'e@example.com') - expect(user_obj.has_role?(role.downcase, :any)).to be expected + user_obj = create(user) + expect(user_obj.has_role?(role.downcase, conference)).to be expected end end context 'organizer' do - it_behaves_like '#role?', :organizer_conference_1, 'organizer', true - it_behaves_like '#role?', :organizer_conference_1, 'participant', false + it_behaves_like '#role?', :organizer, 'organizer', true + it_behaves_like '#role?', :organizer, 'participant', false end context 'admin' do it 'assigns first user admin role' do expect(User.first.is_admin).to be true - expect(admin.is_admin).to eq(true) end end context 'participant' do - it_behaves_like '#role?', :participant, '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 + it_behaves_like '#role?', :user, 'adMin', false end end end