blob: bd94a3aa12316b9b7bb8751afc3855a6fa87b46b (
plain)
| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
 | # -*- coding: utf-8 -*-
require 'spec_helper'
describe "TimeTables", :type => :feature do
  login_user
  let(:time_table) { create :time_table }
  describe 'permissions' do
    before do
      allow_any_instance_of(TimeTablePolicy).to receive(:duplicate?).and_return permission
      visit path
    end
    context 'on show' do
      let(:path){ referential_time_table_path(referential, time_table)}
      context "if permission's absent → " do
        let(:permission){ false }
        it 'does not show the corresponsing button' do
          expect(page).not_to have_link('Dupliquer ce calendrier')
        end
      end
      context "if permission's present → " do
        let(:permission){ true }
        it 'shows the corresponsing button' do
          expected_href = duplicate_referential_time_table_path(referential, time_table)
          expect(page).to have_link('Dupliquer', href: expected_href)
        end
      end
    end
  end
end
 |