aboutsummaryrefslogtreecommitdiffstats
path: root/spec/controllers/lines_controller_spec.rb
blob: ce5adbbdd33b1e72088fa4c95c328412fe56bdd0 (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 }
  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