Mention organization name while creating a conference
This commit is contained in:
parent
c596a9fda7
commit
1a5aa14e2c
3 changed files with 7 additions and 3 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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'",
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue