Guest User

Untitled

a guest
Jan 25th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.66 KB | None | 0 0
  1. diff --git a/spec/controllers/api/events_controller_spec.rb b/spec/controllers/api/events_controller_spec.rb
  2. index 32d0280..0f4872f 100644
  3. --- a/spec/controllers/api/events_controller_spec.rb
  4. +++ b/spec/controllers/api/events_controller_spec.rb
  5. @@ -7,7 +7,7 @@ describe Api::EventsController do
  6.  
  7. let(:api_user){ Factory.create(:user, :username => 'api_user', :password => 'Test1234') }
  8. let(:lab){ Factory.create(:lab, :code_name => SecureRandom.hex(4), :name => "Test Lab") }
  9. - let(:event){ Factory.create(:screening_event, :code => SecureRandom.hex(4), :secondary_code => SecureRandom.hex(4) ,:lab => lab, :starts_at => 1.day.from_now) }
  10. + let(:event){ Factory.create(:screening_event, :code => SecureRandom.hex(4), :secondary_code => SecureRandom.hex(4) ,:lab => lab, :starts_at => 1.day.from_now, :id => 123) }
  11.  
  12. describe "GET /api/events/metadata.json" do
  13. context "with no credentials" do
  14. @@ -48,10 +48,7 @@ describe Api::EventsController do
  15. before do
  16. controller.stub!(:current_user).and_return(api_user)
  17. api_user.stub!(:is_nurse_for_what).and_return([lab])
  18. - lab.stub_chain(:events, :find_by_code).and_return(nil)
  19. - lab.stub_chain(:events, :find_by_code).with(event.code).and_return(event)
  20. - lab.stub_chain(:events, :find_by_secondary_code).and_return(nil)
  21. - lab.stub_chain(:events, :find_by_secondary_code).with(event.secondary_code).and_return(event)
  22. + lab.stub_chain(:events, :map, :compact).and_return([event])
  23. end
  24.  
  25. context "without an event code" do
  26. @@ -107,7 +104,7 @@ describe Api::EventsController do
  27. before do
  28. controller.stub!(:current_user).and_return(api_user)
  29. api_user.stub!(:is_nurse_for_what).and_return([lab])
  30. - lab.stub_chain(:events, :find_by_id).and_return(event)
  31. + lab.stub_chain(:events, :map, :compact).and_return([event])
  32. end
  33.  
  34. it "returns a status of 200 and lists the participants" do
  35. @@ -149,7 +146,7 @@ describe Api::EventsController do
  36. before do
  37. controller.stub!(:current_user).and_return(api_user)
  38. api_user.stub!(:is_nurse_for_what).and_return([lab])
  39. - lab.stub_chain(:events, :find_by_id).and_return(event)
  40. + lab.stub_chain(:events, :map, :compact).and_return([event])
  41. end
  42.  
  43. it "returns a status of 200 and lists the participants matching 'Joe'" do
  44. @@ -205,6 +202,7 @@ describe Api::EventsController do
  45. before do
  46. controller.stub!(:current_user).and_return(api_user)
  47. api_user.stub!(:is_nurse_for_what).and_return([lab])
  48. + lab.stub_chain(:events, :map, :compact).and_return([event])
  49. lab.stub_chain(:events, :find).and_return([event])
  50. end
Add Comment
Please, Sign In to add comment