blob: 65fe88b965ad101f2a5e194db7f45fbeb1e174d7 (
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
 | RSpec.describe LinesController, :type => :controller do
  login_user
  let(:line_referential) { create :line_referential, member: @user.organisation }
  let(:line) { create :line, line_referential: line_referential }
  describe 'PUT deactivate' do
    let(:request){ put :deactivate, id: line.id, line_referential_id: line_referential.id }
    it 'should redirect to 403' do
      expect(request).to redirect_to "/403"
    end
    with_permission "lines.change_status" do
      it 'returns HTTP success' do
        expect(request).to redirect_to [line_referential, line]
        expect(line.reload).to be_deactivated
      end
    end
  end
  describe 'PUT activate' do
    let(:request){ put :activate, id: line.id, line_referential_id: line_referential.id }
    before(:each){
      line.deactivate!
    }
    it 'should redirect to 403' do
       expect(request).to redirect_to "/403"
    end
    with_permission "lines.change_status" do
      it 'returns HTTP success' do
        expect(request).to redirect_to [line_referential, line]
        expect(line.reload).to be_activated
      end
    end
  end
end
 |