lib/ocean-rails.rb
#
# For stubbing successful authorisation calls. Makes <tt>Api.permitted?</tt> return
# the status, and a body containing a partial authentication containing the +user_id+ 
# and +creator_uri+ given by the parameters. It also allows the value of 'right' to
# be specified: this will restrict all SQL queries accordingly.
#
For stubbing successful authorisation calls. Makes Api.permitted? return
the status, and a body containing a partial authentication containing the +user_id+
and +creator_uri+ given by the parameters. It also allows the value of 'right' to
be specified: this will restrict all SQL queries accordingly.
For stubbing successful authorisation calls . Makes Api . permitted? return the status and a body containing a partial authentication containing the + user_id + and + creator_uri + given by the parameters . It also allows the value of ' right ' to be specified : this will restrict all SQL queries accordingly .
def permit_with(status, user_id: 123, creator_uri: "https://api.example.com/v1/api_users/#{user_id}",
                        right: nil, group_names: [])
  allow(Api).to receive(:permitted?).
    and_return(double(:status => status, 
                      :body => {'authentication' => 
                                 {'user_id' => user_id,
                                  'right' => right,
                                  'group_names' => group_names,
                                  '_links' => { 'creator' => {'href' => creator_uri,
                                                              'type' => 'application/json'}}}}))
end
def permit_with ( status , user_id : 123 , creator_uri : "https://api.example.com/v1/api_users/#{user_id}" , right : nil , group_names : [ ] ) allow ( Api ) . to receive ( :permitted? ) . and_return ( double ( :status => status , :body => { 'authentication' => { 'user_id' => user_id , 'right' => right , 'group_names' => group_names , '_links' => { 'creator' => { 'href' => creator_uri , 'type' => 'application/json' } } } } ) ) end
For stubbing successful authorisation calls.
For stubbing successful authorisation calls .
status
user_id
creator_uri
right
group_names