mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
mending failing tests
This commit is contained in:
parent
ad3d6f2f95
commit
8839a928ed
5 changed files with 16 additions and 20 deletions
|
|
@ -72,14 +72,11 @@ module Admin
|
|||
|
||||
def new
|
||||
@conference = Conference.new
|
||||
@organizations = {}
|
||||
Organization.all.each do |organization|
|
||||
@organizations.store(organization.name, organization.id) if can? :create, Conference.new(organization: organization)
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@conference = Conference.new(conference_params)
|
||||
@conference.organization = Organization.find_or_create_by(name: 'organization')
|
||||
if @conference.save
|
||||
# user that creates the conference becomes organizer of that conference
|
||||
current_user.add_role :organizer, @conference
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ class Ability
|
|||
org_ids_for_organization_admin = Organization.with_role(:organization_admin, user).pluck(:id)
|
||||
|
||||
can :manage, Organization, id: org_ids_for_organization_admin
|
||||
can [:new], Conference
|
||||
can :new, Conference
|
||||
can :manage, Conference, organization_id: org_ids_for_organization_admin
|
||||
conf_ids_for_organization_admin = []
|
||||
org_ids_for_organization_admin.each do |org_id|
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
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'",
|
||||
input_html: { required: 'required', pattern: '[a-zA-Z0-9_-]+', title: 'Only letters, numbers, underscores, and dashes.' }, prepend: conferences_url + '/'
|
||||
= f.input :organization, as: :select, collection: @organizations
|
||||
= f.inputs 'Scheduling' do
|
||||
= f.input :timezone, as: :time_zone, default: Time.zone.name, hint: 'Please select in what time zone your conference will take place.'
|
||||
= f.input :start_date, as: :string, input_html: { id: 'conference-start-datepicker', required: 'required' }
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ require 'spec_helper'
|
|||
describe Admin::ConferencesController do
|
||||
|
||||
# It is necessary to use bang version of let to build roles before user
|
||||
let(:organization) { create(:organization) }
|
||||
let(:conference) { create(:conference, organization: organization, end_date: Date.new(2014, 05, 26) + 15) }
|
||||
let!(:organization) { create(:organization, name: 'organization') }
|
||||
let!(:conference) { create(:conference, organization: organization, end_date: Date.new(2014, 05, 26) + 15) }
|
||||
let!(:organizer_role) { Role.find_by(name: 'organizer', resource: conference) }
|
||||
let!(:organization_admin_role) { Role.find_by(name: 'organization_admin', resource: organization) }
|
||||
let(:organization_admin) { create(:user, role_ids: organization_admin_role.id) }
|
||||
|
|
@ -143,14 +143,14 @@ describe Admin::ConferencesController do
|
|||
it 'saves the conference to the database' do
|
||||
expected = expect do
|
||||
post :create, conference:
|
||||
attributes_for(:conference, short_title: 'dps15', organization: organization)
|
||||
attributes_for(:conference, short_title: 'dps15', organization_id: organization.id)
|
||||
end
|
||||
expected.to change { Conference.count }.by 1
|
||||
end
|
||||
|
||||
it 'redirects to conference#show' do
|
||||
post :create, conference:
|
||||
attributes_for(:conference, short_title: 'dps15', organization: organization)
|
||||
attributes_for(:conference, short_title: 'dps15', organization_id: organization.id)
|
||||
|
||||
expect(response).to redirect_to admin_conference_path(
|
||||
assigns[:conference].short_title)
|
||||
|
|
@ -174,14 +174,14 @@ describe Admin::ConferencesController do
|
|||
it 'does not save the conference to the database' do
|
||||
expected = expect do
|
||||
post :create, conference:
|
||||
attributes_for(:conference, short_title: nil, organization: organization)
|
||||
attributes_for(:conference, short_title: nil, organization_id: organization.id)
|
||||
end
|
||||
expected.to_not change { Conference.count }
|
||||
end
|
||||
|
||||
it 're-renders the new template' do
|
||||
post :create, conference:
|
||||
attributes_for(:conference, short_title: nil, organization: organization)
|
||||
attributes_for(:conference, short_title: nil, organization_id: organization.id)
|
||||
expect(response).to be_success
|
||||
end
|
||||
end
|
||||
|
|
@ -191,14 +191,14 @@ describe Admin::ConferencesController do
|
|||
conference
|
||||
expected = expect do
|
||||
post :create, conference:
|
||||
attributes_for(:conference, short_title: conference.short_title, organization: organization)
|
||||
attributes_for(:conference, short_title: conference.short_title, organization_id: organization.id)
|
||||
end
|
||||
expected.to_not change { Conference.count }
|
||||
end
|
||||
|
||||
it 're-renders the new template' do
|
||||
conference
|
||||
post :create, conference: attributes_for(:conference, short_title: conference.short_title, organization: organization)
|
||||
post :create, conference: attributes_for(:conference, short_title: conference.short_title, organization_id: organization.id)
|
||||
expect(response).to be_success
|
||||
end
|
||||
end
|
||||
|
|
@ -240,7 +240,7 @@ describe Admin::ConferencesController do
|
|||
describe 'POST #create' do
|
||||
it 'requires organizer privileges' do
|
||||
post :create, conference: attributes_for(:conference,
|
||||
short_title: 'ExCon')
|
||||
short_title: 'ExCon', organization_id: organization.id)
|
||||
expect(response).to redirect_to(send(path))
|
||||
if message
|
||||
expect(flash[:alert]).to match(/#{message}/)
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ describe Admin::OrganizationsController do
|
|||
end
|
||||
|
||||
it 'redirects to root' do
|
||||
expect(flash[:alert]).to eq('You are not authorized to access this area!')
|
||||
expect(flash[:alert]).to eq('You are not authorized to access this page.')
|
||||
expect(response).to redirect_to(root_path)
|
||||
end
|
||||
end
|
||||
|
|
@ -27,7 +27,7 @@ describe Admin::OrganizationsController do
|
|||
end
|
||||
|
||||
it 'redirects to root' do
|
||||
expect(flash[:alert]).to eq('You are not authorized to access this area!')
|
||||
expect(flash[:alert]).to eq('You are not authorized to access this page.')
|
||||
expect(response).to redirect_to(root_path)
|
||||
end
|
||||
end
|
||||
|
|
@ -43,7 +43,7 @@ describe Admin::OrganizationsController do
|
|||
it 'redirects to root' do
|
||||
post :create, organization: attributes_for(:organization)
|
||||
|
||||
expect(flash[:alert]).to eq('You are not authorized to access this area!')
|
||||
expect(flash[:alert]).to eq('You are not authorized to access this page.')
|
||||
expect(response).to redirect_to(root_path)
|
||||
end
|
||||
end
|
||||
|
|
@ -55,7 +55,7 @@ describe Admin::OrganizationsController do
|
|||
|
||||
organization.reload
|
||||
expect(organization.name).to eq(old_name)
|
||||
expect(flash[:alert]).to eq('You are not authorized to access this area!')
|
||||
expect(flash[:alert]).to eq('You are not authorized to access this page.')
|
||||
expect(response).to redirect_to(root_path)
|
||||
end
|
||||
end
|
||||
|
|
@ -72,7 +72,7 @@ describe Admin::OrganizationsController do
|
|||
it 'redirects to root' do
|
||||
delete :destroy, id: organization.id
|
||||
|
||||
expect(flash[:alert]).to eq('You are not authorized to access this area!')
|
||||
expect(flash[:alert]).to eq('You are not authorized to access this page.')
|
||||
expect(response).to redirect_to(root_path)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue