Module: BeyondTheApiTestHelpers::Request::UpdateAssertions

Defined in:
lib/beyond_the_api_test_helpers/request/update_assertions.rb

Instance Method Summary collapse

Instance Method Details

#assert_request_update_missing_param(url, options = {}) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/beyond_the_api_test_helpers/request/update_assertions.rb', line 17

def assert_request_update_missing_param(url, options = {})
  request_instance_variables_set options
  @headers.merge!(logged_in_headers) if 
  patch(url, params: {}, headers: @headers)
  assert_parameter_missing_request
  put(url, params: {}, headers: @headers)
  assert_parameter_missing_request
end

#assert_request_update_not_found(urls_not_found, options = {}) ⇒ Object



39
40
41
42
43
44
45
46
# File 'lib/beyond_the_api_test_helpers/request/update_assertions.rb', line 39

def assert_request_update_not_found(urls_not_found, options = {})
  request_instance_variables_set options
  @headers.merge!(logged_in_headers) if 

  urls_not_found.each do |url_not_found|
    assert_request_update_not_found_i18n_all(url_not_found)
  end
end

#assert_request_update_valid(url, options = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/beyond_the_api_test_helpers/request/update_assertions.rb', line 4

def assert_request_update_valid(url, options = {})
  request_instance_variables_set options
  if 
    assert_request_needs_to_be_logged(url, :put)
    assert_request_needs_to_be_logged(url, :patch)
    @headers.merge!(logged_in_headers)
  end

  assert_i18n_for_all_locales do
    do_update_request_with_transaction(url)
  end
end

#assert_request_update_with_errors(url, invalid_params, params = {}) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/beyond_the_api_test_helpers/request/update_assertions.rb', line 26

def assert_request_update_with_errors(url, invalid_params, params = {})
  request_instance_variables_set params
  # pp @headers
  # pp user_authorizations(:logged)
  # abort
  @headers.merge!(logged_in_headers) if 

  ActiveRecord::Base.transaction do
    do_update_request_and_assert_invalid(url, invalid_params)
    raise ActiveRecord::Rollback
  end
end