Module: Spree::Api::TestingSupport::Helpers
- Defined in:
- lib/spree/api/testing_support/helpers.rb
Instance Method Summary collapse
- #assert_unauthorized! ⇒ Object
-
#current_api_user ⇒ Object
This method can be overriden (with a let block) inside a context For instance, if you wanted to have an admin user instead.
- #image(filename) ⇒ Object
- #json_response ⇒ Object
- #stub_authentication! ⇒ Object
- #upload_image(filename) ⇒ Object
Instance Method Details
#assert_unauthorized! ⇒ Object
9 10 11 12 |
# File 'lib/spree/api/testing_support/helpers.rb', line 9 def json_response.should == { "error" => "You are not authorized to perform that action." } response.status.should == 401 end |
#current_api_user ⇒ Object
This method can be overriden (with a let block) inside a context For instance, if you wanted to have an admin user instead.
21 22 23 |
# File 'lib/spree/api/testing_support/helpers.rb', line 21 def current_api_user @current_api_user ||= stub_model(Spree::LegacyUser, :email => "[email protected]") end |
#image(filename) ⇒ Object
25 26 27 |
# File 'lib/spree/api/testing_support/helpers.rb', line 25 def image(filename) File.open(Spree::Api::Engine.root + "spec/fixtures" + filename) end |
#json_response ⇒ Object
5 6 7 |
# File 'lib/spree/api/testing_support/helpers.rb', line 5 def json_response JSON.parse(response.body) end |
#stub_authentication! ⇒ Object
14 15 16 17 |
# File 'lib/spree/api/testing_support/helpers.rb', line 14 def stub_authentication! controller.stub :check_for_user_or_api_key Spree::LegacyUser.stub :find_by_spree_api_key => current_api_user end |
#upload_image(filename) ⇒ Object
29 30 31 |
# File 'lib/spree/api/testing_support/helpers.rb', line 29 def upload_image(filename) fixture_file_upload(image(filename).path) end |