updated rails to 4.2.4

This commit is contained in:
raluka 2015-09-17 12:12:51 +02:00
parent 37697517df
commit 42e8bb11ea
55 changed files with 766 additions and 365 deletions

View file

@ -0,0 +1,59 @@
require 'spec_helper'
describe Admin::CommentsController, type: :controller 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!(:organizer_role) { create(:role, name: 'organizer', resource: conference) }
let(:organizer) { create(:user, role_ids: organizer_role.id, last_sign_in_at: Time.now - 1.day) }
let(:participant) { create(:user) }
let(:event) { create(:event, conference: conference) }
let(:comment) { create(:comment, commentable_type: 'Event', commentable_id: event.id) }
context 'not logged in user' do
describe 'GET #index' do
it 'renders the :index template' do
comment
get :index
expect(response).to redirect_to(user_session_path)
end
end
end
context 'logged in as admin, organizer or cfp' do
before :each do
sign_in(organizer)
comment
end
describe 'GET #index' do
it 'populates a hash with comments' do
get :index
expect(assigns(:comments)).to be_a(Hash)
# assigns(:comments).first returns an array of first pair key-value from hash.
# Calling again 'first' returns the key, meaning the Conference object.
expect(assigns(:comments).first.first.title).to eq(comment.commentable.conference.title)
end
it 'has status 200: OK' do
get :index
expect(response).to have_http_status(:ok)
end
it 'renders the :index template' do
get :index
expect(response).to render_template(:index)
end
end
end
context 'logged in with any other role or normal user' do
describe 'GET#index' do
it 'requires organizer privileges' do
sign_in(participant)
comment
get :index
expect(response).to redirect_to(root_path)
expect(flash[:alert]).to match('You are not authorized to access this area!')
end
end
end
end

View file

@ -0,0 +1,9 @@
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :comment do
body 'Most interresting comment ever, created by a girl.'
user
association :commentable, factory: :event
end
end

View file

@ -47,6 +47,7 @@ FactoryGirl.define do
event.difficulty_level = build(:difficulty_level, conference: event.conference)
event.track = build(:track, conference: event.conference)
event.room = build(:room, conference: event.conference)
event.comment_threads << build(:comment, commentable: event)
end
end

View file

@ -105,7 +105,8 @@ feature 'Has correct abilities' do
visit admin_conference_path(conference2.short_title)
expect(page).to have_selector('li.nav-header.nav-header-bigger a', text: 'Dashboard')
expect(page).to have_link('Basics', href: "/admin/conference/#{conference2.short_title}/edit")
expect(page).to_not have_link('Basics', href: "/admin/conference/#{conference2.short_title}/edit")
expect(page).to have_text('Basics')
expect(page).to_not have_link('Contact', href: "/admin/conference/#{conference2.short_title}/contact/edit")
expect(page).to have_link('Commercials', href: "/admin/conference/#{conference2.short_title}/commercials")
expect(page).to have_link('Events', href: "/admin/conference/#{conference2.short_title}/events")
@ -176,7 +177,8 @@ feature 'Has correct abilities' do
visit admin_conference_path(conference3.short_title)
expect(page).to have_selector('li.nav-header.nav-header-bigger a', text: 'Dashboard')
expect(page).to have_link('Basics', href: "/admin/conference/#{conference3.short_title}/edit")
expect(page).to_not have_link('Basics', href: "/admin/conference/#{conference2.short_title}/edit")
expect(page).to have_text('Basics')
expect(page).to_not have_link('Contact', href: "/admin/conference/#{conference3.short_title}/contact/edit")
expect(page).to have_link('Commercials', href: "/admin/conference/#{conference3.short_title}/commercials")
expect(page).to_not have_link('Events', href: "/admin/conference/#{conference3.short_title}/events")

View file

@ -141,6 +141,8 @@ describe 'User' do
it{ should_not be_able_to(:manage, other_event.difficulty_level) }
it{ should be_able_to(:manage, event.commercials.first) }
it{ should_not be_able_to(:manage, other_event.commercials.first) }
it{ should be_able_to(:index, event.comment_threads.first) }
it{ should_not be_able_to(:index, other_event.comment_threads.first) }
end
context 'when user has the role cfp' do
@ -198,6 +200,8 @@ describe 'User' do
it{ should_not be_able_to(:manage, other_event.difficulty_level) }
it{ should be_able_to(:manage, event.commercials.first) }
it{ should_not be_able_to(:manage, other_event.commercials.first) }
it{ should be_able_to(:index, event.comment_threads.first) }
it{ should_not be_able_to(:index, other_event.comment_threads.first) }
end
context 'when user has the role info_desk' do
@ -255,6 +259,8 @@ describe 'User' do
it{ should_not be_able_to(:manage, other_event.difficulty_level) }
it{ should_not be_able_to(:manage, event.commercials.first) }
it{ should_not be_able_to(:manage, other_event.commercials.first) }
it{ should_not be_able_to(:index, event.comment_threads.first) }
it{ should_not be_able_to(:index, other_event.comment_threads.first) }
end
context 'when user has the role volunteers_coordinator' do
@ -312,6 +318,8 @@ describe 'User' do
it{ should_not be_able_to(:manage, other_event.difficulty_level) }
it{ should_not be_able_to(:manage, event.commercials.first) }
it{ should_not be_able_to(:manage, other_event.commercials.first) }
it{ should_not be_able_to(:index, event.comment_threads.first) }
it{ should_not be_able_to(:index, other_event.comment_threads.first) }
it 'should be_able to :manage Vposition'
it 'should be_able to :manage Vday'
end