mirror of
https://github.com/openSUSE/osem.git
synced 2026-05-06 06:37:45 -04:00
View specs, added factories, fixed bugs
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
class Vposition < ActiveRecord::Base
|
||||
attr_accessible :title, :description, :date, :vday_ids
|
||||
attr_accessible :title, :description, :vday_ids
|
||||
|
||||
belongs_to :conference
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
.row
|
||||
.col-md-3
|
||||
= render 'admin/conference/sidebar'
|
||||
= render :partial => "sidebar"
|
||||
.col-md-9
|
||||
= semantic_form_for(@conference, :url => admin_conference_path(@conference.short_title),:html => {:multipart => true}) do |f|
|
||||
= f.input :title, :hint => "The full name of the conference, such as 'OpenSUSE Conference 2013'"
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
.col-md-3
|
||||
= render 'admin/conference/sidebar'
|
||||
.col-md-9
|
||||
= semantic_form_for(@conference, url: admin_conference_eventtypes_path) do |f|
|
||||
= semantic_form_for(@conference, url: admin_conference_eventtypes_path(@conference.short_title, @conference.event_types)) do |f|
|
||||
= dynamic_association :event_types, "Event Types", f
|
||||
= f.action :submit, :as => :button, :button_html => {:class => "btn btn-primary"}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<%= f.inputs do %>
|
||||
<%= f.input :title %>
|
||||
<%= f.input :description, :input_html => {:rows => 5} %>
|
||||
<%= f.date_select :date, as: :string %>
|
||||
<%= remove_association_link :social_event, f %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
= render 'layouts/admin_menu'
|
||||
%ul.nav.navbar-nav.navbar-right
|
||||
%li.dropdown
|
||||
%a.dropdown-toggle{"data-toggle" => "dropdown", :href => "#"}
|
||||
%a.dropdown-toggle{"data-toggle" => "dropdown", :href => "#", id: "current-user-detail"}
|
||||
- if not current_user.person.public_name.empty?
|
||||
#{current_user.person.public_name}
|
||||
-else
|
||||
|
||||
@@ -35,7 +35,7 @@ describe Admin::ConferenceController do
|
||||
it 'redirects to the updated conference' do
|
||||
patch :update, id: conference.short_title, conference:
|
||||
attributes_for(:conference, title: 'Example Con')
|
||||
|
||||
conference.reload
|
||||
expect(response).to redirect_to admin_conference_path(
|
||||
conference.short_title)
|
||||
end
|
||||
@@ -51,7 +51,7 @@ describe Admin::ConferenceController do
|
||||
expect(flash[:alert]).
|
||||
to eq("Updating conference failed. Short title can't be blank.")
|
||||
expect(conference.title).to eq('The dog and pony show')
|
||||
expect(conference.short_title).to eq('dps14')
|
||||
expect(conference.short_title).to eq("#{conference.short_title}")
|
||||
end
|
||||
|
||||
it 're-renders the #show template' do
|
||||
@@ -107,14 +107,14 @@ describe Admin::ConferenceController do
|
||||
conference
|
||||
expected = expect do
|
||||
post :create, conference:
|
||||
attributes_for(:conference)
|
||||
attributes_for(:conference, short_title: conference.short_title)
|
||||
end
|
||||
expected.to_not change { Conference.count }
|
||||
end
|
||||
|
||||
it 're-renders the new template' do
|
||||
conference
|
||||
post :create, conference: attributes_for(:conference)
|
||||
post :create, conference: attributes_for(:conference, short_title: conference.short_title)
|
||||
expect(response).to redirect_to new_admin_conference_path
|
||||
end
|
||||
end
|
||||
@@ -135,8 +135,7 @@ describe Admin::ConferenceController do
|
||||
describe 'GET #index' do
|
||||
context 'with more than 0 conferences' do
|
||||
it 'populates an array with conferences' do
|
||||
con2 = create(:conference, short_title: 'dps15',
|
||||
title: 'The dog and pony show 2015')
|
||||
con2 = create(:conference)
|
||||
get :index
|
||||
expect(assigns(:conferences)).to match_array([conference, con2])
|
||||
end
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
FactoryGirl.define do
|
||||
factory :conference do
|
||||
title 'The dog and pony show'
|
||||
short_title 'dps14'
|
||||
sequence(:short_title) { |n| "dps#{n}14"}
|
||||
social_tag 'dps14'
|
||||
timezone 'Amsterdam'
|
||||
contact_email 'admin@example.com'
|
||||
|
||||
8
spec/factories/difficulty_levels.rb
Normal file
8
spec/factories/difficulty_levels.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
FactoryGirl.define do
|
||||
factory :difficulty_level do
|
||||
title 'Example Difficulty Level'
|
||||
description 'Lorem Ipsum dolsum'
|
||||
color '#ffffff'
|
||||
conference
|
||||
end
|
||||
end
|
||||
@@ -2,9 +2,11 @@
|
||||
|
||||
FactoryGirl.define do
|
||||
factory :email_settings do
|
||||
send_on_registration false
|
||||
send_on_registration true
|
||||
send_on_accepted false
|
||||
send_on_rejected false
|
||||
send_on_confirmed_without_registration false
|
||||
registration_subject 'Lorem Ipsum Dolsum'
|
||||
registration_email_template 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -6,5 +6,6 @@ FactoryGirl.define do
|
||||
length 30
|
||||
minimum_abstract_length 0
|
||||
maximum_abstract_length 500
|
||||
conference
|
||||
end
|
||||
end
|
||||
7
spec/factories/rooms.rb
Normal file
7
spec/factories/rooms.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
FactoryGirl.define do
|
||||
factory :room do
|
||||
name 'Example Room'
|
||||
size 4
|
||||
conference
|
||||
end
|
||||
end
|
||||
8
spec/factories/social_events.rb
Normal file
8
spec/factories/social_events.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
FactoryGirl.define do
|
||||
factory :social_event do
|
||||
title 'Example Social Event'
|
||||
description 'Lorem Ipsum Dolsum'
|
||||
date Date.today
|
||||
conference
|
||||
end
|
||||
end
|
||||
7
spec/factories/supporter_levels.rb
Normal file
7
spec/factories/supporter_levels.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
FactoryGirl.define do
|
||||
factory :supporter_level do
|
||||
title 'Example Supporter Level'
|
||||
url 'www.example.com'
|
||||
conference
|
||||
end
|
||||
end
|
||||
8
spec/factories/tracks.rb
Normal file
8
spec/factories/tracks.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
FactoryGirl.define do
|
||||
factory :track do
|
||||
name 'Example Track'
|
||||
description 'Lorem Ipsum dolsum'
|
||||
color '#ffffff'
|
||||
conference
|
||||
end
|
||||
end
|
||||
7
spec/factories/vdays.rb
Normal file
7
spec/factories/vdays.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
FactoryGirl.define do
|
||||
factory :vday do
|
||||
day Date.today
|
||||
description 'Lorem Ipsum dolsum'
|
||||
conference
|
||||
end
|
||||
end
|
||||
11
spec/factories/vpositions.rb
Normal file
11
spec/factories/vpositions.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
FactoryGirl.define do
|
||||
factory :vposition do
|
||||
title 'Example Volunteer Position'
|
||||
description 'Lorem Ipsum dolsum'
|
||||
conference
|
||||
|
||||
after(:build) do |vposition|
|
||||
vposition.vdays << build(:vday, conference: vposition.conference)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -44,7 +44,9 @@ RSpec.configure do |config|
|
||||
# Enables devise sign_in function
|
||||
config.include Devise::TestHelpers, type: :controller
|
||||
|
||||
# Enables devise sign_in function
|
||||
config.include Devise::TestHelpers, type: :view
|
||||
|
||||
# Use capybara-webkit as default javascript driver
|
||||
Capybara.javascript_driver = :webkit
|
||||
|
||||
@@ -54,6 +56,8 @@ RSpec.configure do |config|
|
||||
# Includes support/flash for feature tests
|
||||
config.include Flash, type: :feature
|
||||
|
||||
config.include Sidebar, type: :view
|
||||
|
||||
# As we start from scratch in April 2014, let's forbid the old :should syntax
|
||||
config.expect_with :rspec do |c|
|
||||
c.syntax = :expect
|
||||
|
||||
9
spec/support/sidebar.rb
Normal file
9
spec/support/sidebar.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
module Sidebar
|
||||
def sidebar
|
||||
@conference = create(:conference)
|
||||
assign :conference, @conference
|
||||
assign :cfp, CallForPapers.new
|
||||
render
|
||||
expect(view).to render_template('admin/conference/_sidebar')
|
||||
end
|
||||
end
|
||||
18
spec/views/admin/callforpapers/show.html.haml_spec.rb
Normal file
18
spec/views/admin/callforpapers/show.html.haml_spec.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "admin/callforpapers/show" do
|
||||
it 'renders conference sidebar' do
|
||||
expect(sidebar).to be true
|
||||
end
|
||||
it 'renders callforpapers details' do
|
||||
@conference = create(:conference)
|
||||
assign :conference, @conference
|
||||
assign :cfp, stub_model(CallForPapers, start_date: Date.today,
|
||||
end_date: Date.today + 7.days,
|
||||
hard_deadline: Date.today + 6.days, description: "Lorem Ipsum Dolsum")
|
||||
render
|
||||
expect(rendered).to include("#{Date.today}")
|
||||
expect(rendered).to include("#{Date.today + 7.days}")
|
||||
expect(rendered).to include('Lorem Ipsum Dolsum')
|
||||
end
|
||||
end
|
||||
11
spec/views/admin/conference/index.html.haml_spec.rb
Normal file
11
spec/views/admin/conference/index.html.haml_spec.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "admin/conference/index" do
|
||||
it 'renders all conference names with links' do
|
||||
assign(:conferences, [create(:conference, title: 'OpenSUSE'),
|
||||
create(:conference)])
|
||||
render
|
||||
expect(rendered).to include('OpenSUSE')
|
||||
expect(rendered).to include("The dog and pony show")
|
||||
end
|
||||
end
|
||||
12
spec/views/admin/conference/new.html.haml_spec.rb
Normal file
12
spec/views/admin/conference/new.html.haml_spec.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "admin/conference/new" do
|
||||
it 'renders the new template for the conference' do
|
||||
assign(:conference, Conference.new)
|
||||
render
|
||||
expect(rendered).to include('Basic Information')
|
||||
assign(:conference, build(:conference))
|
||||
render
|
||||
expect(rendered).to include('The dog and pony show')
|
||||
end
|
||||
end
|
||||
14
spec/views/admin/conference/show.html.haml_spec.rb
Normal file
14
spec/views/admin/conference/show.html.haml_spec.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "admin/conference/show" do
|
||||
it 'renders conference sidebar' do
|
||||
expect(sidebar).to be true
|
||||
end
|
||||
it 'renders conference details which are editable' do
|
||||
@conference = create(:conference, title: 'OpenSUSE')
|
||||
assign :conference, @conference
|
||||
render
|
||||
expect(rendered).to include('OpenSUSE')
|
||||
expect(rendered).to include("#{@conference.contact_email}")
|
||||
end
|
||||
end
|
||||
15
spec/views/admin/difficulty_levels/index.html.haml_spec.rb
Normal file
15
spec/views/admin/difficulty_levels/index.html.haml_spec.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "admin/difficulty_levels/index" do
|
||||
it 'renders conference sidebar' do
|
||||
expect(sidebar).to be true
|
||||
end
|
||||
it 'renders difficulty levels' do
|
||||
@difficulty_level = create(:difficulty_level)
|
||||
assign :conference, @difficulty_level.conference
|
||||
render
|
||||
expect(rendered).to include('Example Difficulty Level')
|
||||
expect(rendered).to include('Lorem Ipsum dolsum')
|
||||
expect(rendered).to include('#ffffff')
|
||||
end
|
||||
end
|
||||
23
spec/views/admin/emails/index.html.haml_spec.rb
Normal file
23
spec/views/admin/emails/index.html.haml_spec.rb
Normal file
@@ -0,0 +1,23 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "admin/emails/index" do
|
||||
it 'renders conference sidebar' do
|
||||
assign :settings, create(:email_settings)
|
||||
expect(sidebar).to be true
|
||||
end
|
||||
|
||||
it 'renders email templates' do
|
||||
@conference = create(:conference)
|
||||
assign :conference, @conference
|
||||
@settings = create(:email_settings)
|
||||
assign :settings, @settings
|
||||
render
|
||||
expect(rendered).to have_selector("input[type='checkbox'][value='1']",
|
||||
:count=>4)
|
||||
expect(rendered).to have_selector(
|
||||
"input[checked='checked'][type='checkbox'][value='1']", :count=> 1)
|
||||
expect(rendered).to include('Lorem Ipsum Dolsum')
|
||||
expect(rendered).to include(
|
||||
'Lorem ipsum dolor sit amet, consectetuer adipiscing elit')
|
||||
end
|
||||
end
|
||||
17
spec/views/admin/eventtypes/index.html.haml_spec.rb
Normal file
17
spec/views/admin/eventtypes/index.html.haml_spec.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "admin/eventtypes/index" do
|
||||
it 'renders conference sidebar' do
|
||||
expect(sidebar).to be true
|
||||
end
|
||||
|
||||
it 'renders event types' do
|
||||
@event_type = create(:event_type)
|
||||
assign :conference, @event_type.conference
|
||||
render
|
||||
expect(rendered).to include('Example Event Type')
|
||||
expect(rendered).to include('30')
|
||||
expect(rendered).to include('0')
|
||||
expect(rendered).to include('500')
|
||||
end
|
||||
end
|
||||
14
spec/views/admin/rooms/index.html.haml_spec.rb
Normal file
14
spec/views/admin/rooms/index.html.haml_spec.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "admin/rooms/index" do
|
||||
it 'renders conference sidebar' do
|
||||
expect(sidebar).to be true
|
||||
end
|
||||
it 'renders rooms list' do
|
||||
@room = create(:room)
|
||||
assign :conference, @room.conference
|
||||
render
|
||||
expect(rendered).to include('Example Room')
|
||||
expect(rendered).to include('4')
|
||||
end
|
||||
end
|
||||
17
spec/views/admin/social_events/index.html.haml_spec.rb
Normal file
17
spec/views/admin/social_events/index.html.haml_spec.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "admin/social_events/index" do
|
||||
it 'renders conference sidebar' do
|
||||
expect(sidebar).to be true
|
||||
end
|
||||
it 'renders social events' do
|
||||
@social_event = create(:social_event)
|
||||
assign :conference, @social_event.conference
|
||||
render
|
||||
expect(rendered).to include('Example Social Event')
|
||||
expect(rendered).to include('Lorem Ipsum Dolsum')
|
||||
expect(rendered).to include("#{Date.today.strftime('%Y')}")
|
||||
expect(rendered).to include("#{Date.today.strftime('%B')}")
|
||||
expect(rendered).to include("#{Date.today.strftime('%d')}")
|
||||
end
|
||||
end
|
||||
14
spec/views/admin/supporter_levels/index.html.haml_spec.rb
Normal file
14
spec/views/admin/supporter_levels/index.html.haml_spec.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "admin/supporter_levels/index" do
|
||||
it 'renders conference sidebar' do
|
||||
expect(sidebar).to be true
|
||||
end
|
||||
it 'renders supporter levels' do
|
||||
@support_level = create(:supporter_level)
|
||||
assign :conference, @support_level.conference
|
||||
render
|
||||
expect(rendered).to include('Example Supporter Level')
|
||||
expect(rendered).to include('www.example.com')
|
||||
end
|
||||
end
|
||||
15
spec/views/admin/tracks/index.html.haml_spec.rb
Normal file
15
spec/views/admin/tracks/index.html.haml_spec.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "admin/tracks/index" do
|
||||
it 'renders conference sidebar' do
|
||||
expect(sidebar).to be true
|
||||
end
|
||||
it 'renders tracks' do
|
||||
@track = create(:track)
|
||||
assign :conference, @track.conference
|
||||
render
|
||||
expect(rendered).to include('Example Track')
|
||||
expect(rendered).to include('Lorem Ipsum dolsum')
|
||||
expect(rendered).to include('#ffffff')
|
||||
end
|
||||
end
|
||||
20
spec/views/admin/venue/venue_info.html.haml_spec.rb
Normal file
20
spec/views/admin/venue/venue_info.html.haml_spec.rb
Normal file
@@ -0,0 +1,20 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "admin/venue/venue_info" do
|
||||
it 'renders conference sidebar' do
|
||||
assign :venue, stub_model(Venue)
|
||||
expect(sidebar).to be true
|
||||
end
|
||||
it 'renders venue#show' do
|
||||
@conference = create(:conference)
|
||||
@venue = @conference.venue
|
||||
@venue.name = 'Croatia'
|
||||
@venue.description = 'Lorem ipsum dolsum'
|
||||
@venue.save!
|
||||
assign :conference, @conference
|
||||
assign :venue, @venue
|
||||
render
|
||||
expect(rendered).to include('Croatia')
|
||||
expect(rendered).to include('Lorem ipsum dolsum')
|
||||
end
|
||||
end
|
||||
31
spec/views/admin/volunteers/index.html.haml_spec.rb
Normal file
31
spec/views/admin/volunteers/index.html.haml_spec.rb
Normal file
@@ -0,0 +1,31 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "admin/volunteers/index" do
|
||||
it 'renders conference sidebar' do
|
||||
expect(sidebar).to be true
|
||||
end
|
||||
|
||||
it 'renders volunteers days as vdays' do
|
||||
@vday = create(:vday)
|
||||
@vday.conference.update_attributes(use_volunteers: true, use_vdays: true)
|
||||
assign :conference, @vday.conference
|
||||
render
|
||||
expect(rendered).to have_selector(
|
||||
"input[checked='checked'][type='checkbox'][value='1']", count: 2)
|
||||
expect(rendered).to include("#{Date.today.strftime('%Y')}")
|
||||
expect(rendered).to include("#{Date.today.strftime('%B')}")
|
||||
expect(rendered).to include("#{Date.today.strftime('%d')}")
|
||||
expect(rendered).to include('Lorem Ipsum dolsum')
|
||||
end
|
||||
|
||||
it 'renders volunteers positions as vpositions' do
|
||||
@vposition = create(:vposition)
|
||||
@vposition.conference.update_attributes(
|
||||
use_vpositions: true, use_volunteers: true, use_vdays: true)
|
||||
assign :conference, @vposition.conference
|
||||
render
|
||||
expect(rendered).to include("#{Date.today}")
|
||||
expect(rendered).to include('Example Volunteer Position')
|
||||
expect(rendered).to include('Lorem Ipsum dolsum')
|
||||
end
|
||||
end
|
||||
5
spec/views/admin/volunteers/show.html.haml_spec.rb
Normal file
5
spec/views/admin/volunteers/show.html.haml_spec.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "admin/volunteers/show" do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
9
spec/views/home/index.html.haml_spec.rb
Normal file
9
spec/views/home/index.html.haml_spec.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "home/index" do
|
||||
it "renders _conference partial for each conference" do
|
||||
assign(:current, [create(:conference), create(:conference)])
|
||||
render
|
||||
expect(view).to render_template(:partial => "_conference_details", :count => 2)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user