-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathreports_controller_spec.rb
More file actions
48 lines (37 loc) · 1.25 KB
/
reports_controller_spec.rb
File metadata and controls
48 lines (37 loc) · 1.25 KB
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
require 'rails_helper'
module Rp
RSpec.describe ReportsController, type: :controller do
# let(:user) { FactoryGirl.create(:rp_user) }
before do
# @request.env["devise.mapping"] = Devise.mappings[:user]
# sign_in user
# allow(controller).to receive(:current_user).and_return(user)
user = FactoryGirl.create(:user)
end
describe "GET #index" do
let(:report) { FactoryGirl.create(:rp_report) }
it "assigns all reports as @reports" do
get :index
expect(assigns(:reports)).to eq([report])
end
end
describe "POST #create" do
let(:available_report) { FactoryGirl.create(:rp_available_report) }
let(:report) { FactoryGirl.attributes_for(:rp_report, rp_available_reports_id: available_report.id) }
it "creates a new Report" do
expect {
post :create, report
}.to change(Report, :count).by(1)
end
it "assigns a newly created report as @report" do
post :create, report
expect(assigns(:report)).to be_a(Report)
expect(assigns(:report)).to be_persisted
end
it "redirects to the reports list" do
post :create, report
expect(response).to redirect_to reports_path
end
end
end
end