From 7d35fc28577184c822139ae3cb3298aaa218527d Mon Sep 17 00:00:00 2001 From: Stella Rouzi Date: Thu, 14 Aug 2014 19:58:50 +0300 Subject: [PATCH] fix test and add test for roles view --- spec/features/ability_spec.rb | 8 +++--- .../admin/conference/roles.html.haml_spec.rb | 26 +++++++++++++++++++ 2 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 spec/views/admin/conference/roles.html.haml_spec.rb diff --git a/spec/features/ability_spec.rb b/spec/features/ability_spec.rb index b319a4c6..616fdf0e 100644 --- a/spec/features/ability_spec.rb +++ b/spec/features/ability_spec.rb @@ -19,7 +19,7 @@ feature 'Has correct abilities' do sign_in user visit admin_conference_path(conference1.short_title) - expect(page).to have_selector( 'li.nav-header.nav-header-bigger a', text: 'Dashboard') + expect(page).to have_selector('li.nav-header.nav-header-bigger a', text: 'Dashboard') expect(page).to have_link('Basics', href: "/admin/conference/#{conference1.short_title}/edit") expect(page).to have_link('Contact', href: "/admin/conference/#{conference1.short_title}/contact/edit") expect(page).to have_link('Commercials', href: "/admin/conference/#{conference1.short_title}/commercials") @@ -90,7 +90,7 @@ feature 'Has correct abilities' do sign_in user 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_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('Contact', href: "/admin/conference/#{conference2.short_title}/contact/edit") expect(page).to have_link('Commercials', href: "/admin/conference/#{conference2.short_title}/commercials") @@ -161,7 +161,7 @@ feature 'Has correct abilities' do sign_in user 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_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('Contact', href: "/admin/conference/#{conference3.short_title}/contact/edit") expect(page).to have_link('Commercials', href: "/admin/conference/#{conference3.short_title}/commercials") @@ -233,7 +233,7 @@ feature 'Has correct abilities' do sign_in user visit admin_conference_path(conference4.short_title) - expect(page).to have_selector( 'li.nav-header.nav-header-bigger a', text: 'Dashboard') + expect(page).to have_selector('li.nav-header.nav-header-bigger a', text: 'Dashboard') expect(page).to have_link('Basics', href: "/admin/conference/#{conference4.short_title}/edit") expect(page).to_not have_link('Contact', href: "/admin/conference/#{conference4.short_title}/contact/edit") expect(page).to have_link('Commercials', href: "/admin/conference/#{conference4.short_title}/commercials") diff --git a/spec/views/admin/conference/roles.html.haml_spec.rb b/spec/views/admin/conference/roles.html.haml_spec.rb new file mode 100644 index 00000000..ce6e63a1 --- /dev/null +++ b/spec/views/admin/conference/roles.html.haml_spec.rb @@ -0,0 +1,26 @@ +require 'spec_helper' + +describe 'admin/conference/roles' do + let(:conference) { create(:conference) } + let(:organizer_role) { create(:organizer_role, description: 'My description for organizer role', resource: conference) } + let(:organizer) { create(:user, name: 'test name', email: 'test@email.com', role_ids: [organizer_role.id]) } + + it 'renders the roles template for the conference' do + assign :conference, conference + assign :selection, 'organizer' + assign :role, [organizer_role] + assign :role_users, {'organizer' => [organizer]} + render + expect(rendered).to include('Show users for role:') + expect(rendered).to include(organizer_role.description) + expect(rendered).to include("Add role 'Organizer' to user:") + expect(rendered).to include('Add role') + expect(rendered).to include('Users with role Organizer') + expect(rendered).to have_selector("table thead th:nth-of-type(1)", text: 'ID') + expect(rendered).to have_selector("table thead th:nth-of-type(2)", text: 'Name') + expect(rendered).to have_selector("table thead th:nth-of-type(3)", text: 'Email') + expect(rendered).to have_selector("table tbody tr:nth-of-type(1) td:nth-of-type(1)", text: organizer.id) + expect(rendered).to have_selector("table tbody tr:nth-of-type(1) td:nth-of-type(2)", text: 'test name') + expect(rendered).to have_selector("table tbody tr:nth-of-type(1) td:nth-of-type(3)", text: 'test@email.com') + end +end