| 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
 | RSpec.describe "TimeTables", :type => :feature do
  login_user
  let!(:time_tables) { Array.new(2) { create(:time_table) } }
  let(:time_table) { time_tables.first }
  subject { time_tables.first }
  describe "index" do
    before(:each) { visit referential_time_tables_path(referential) }
    it "displays time_tables" do
      expect(page).to have_content(time_tables.first.comment)
      expect(page).to have_content(time_tables.last.comment)
    end
    context 'user has permission to create time tables' do
      it 'shows a create link for time tables' do
        expect(page).to have_content(I18n.t('actions.add'))
      end
    end
    context 'user does not have permission to create time tables' do
      it 'does not show a create link for time tables' do
        @user.update_attribute(:permissions, [])
        visit referential_time_tables_path(referential)
        expect(page).not_to have_content(I18n.t('actions.add'))
      end
    end
    context 'user has permission to edit time tables' do
      it 'shows an edit button for time tables' do
        expect(page).to have_content(I18n.t('actions.edit'))
      end
    end
    context 'user does not have permission to edit time tables' do
      it 'does not show a edit link for time tables' do
        @user.update_attribute(:permissions, [])
        visit referential_time_tables_path(referential)
        expect(page).not_to have_content(I18n.t('actions.add'))
      end
    end
    context 'user has permission to destroy time tables' do
      it 'shows a destroy button for time tables' do
        expect(page).to have_content(I18n.t('actions.delete'))
      end
    end
    context 'user does not have permission to destroy time tables' do
      it 'does not show a destroy button for time tables' do
        @user.update_attribute(:permissions, [])
        visit referential_time_tables_path(referential)
        expect(page).not_to have_content(I18n.t('actions.delete'))
      end
    end
  end
  describe "show" do
    before(:each) { visit referential_time_table_path(referential, time_table) }
    it "displays time_table" do
      expect(page).to have_content(time_tables.first.comment)
    end
    it 'should not show actualize link on time_tabl without calendar' do
      expect(page).not_to have_content(I18n.t('time_tables.actions.actualize'))
    end
    # context 'user has permission to create time tables' do
    #   it 'shows a create link for time tables' do
    #     expect(page).to have_content(I18n.t('time_tables.actions.new'))
    #   end
    #
    #   it 'does not show link to duplicate the time table' do
    #     expect(page).to have_content(I18n.t('time_tables.actions.duplicate'))
    #   end
    # end
    context 'user does not have permission to create time tables' do
      it 'does not show a create link for time tables' do
        @user.update_attribute(:permissions, [])
        visit referential_time_table_path(referential, time_table)
        expect(page).not_to have_content(I18n.t('actions.add'))
      end
      it 'does not show link to duplicate the time table' do
        @user.update_attribute(:permissions, [])
        visit referential_time_table_path(referential, time_table)
        expect(page).not_to have_content(I18n.t('actions.duplicate'))
      end
    end
    context 'user has permission to edit time tables' do
      it 'shows the edit link for time table' do
        expect(page).to have_content(I18n.t('actions.edit'))
      end
    end
    context 'user does not have permission to edit time tables' do
      it 'does not show the edit link for time table' do
        @user.update_attribute(:permissions, [])
        visit referential_time_table_path(referential, time_table)
        expect(page).not_to have_content(I18n.t('actions.edit'))
      end
    end
    context 'user has permission to destroy time tables' do
      it 'shows the destroy link for time table' do
        expect(page).to have_content(I18n.t('actions.destroy'))
      end
    end
    context 'user does not have permission to destroy time tables' do
      it 'does not show a destroy link for time table' do
        @user.update_attribute(:permissions, [])
        visit referential_time_table_path(referential, time_table)
        expect(page).not_to have_content(I18n.t('actions.destroy'))
      end
    end
  end
  # No more test for the form, as it is now managed by React/Redux.
end
 |