Fix tests
This commit is contained in:
parent
9e7e793941
commit
0a3c949d09
1 changed files with 49 additions and 32 deletions
|
@ -1,4 +1,9 @@
|
||||||
describe TransactionsController, type: :api do
|
describe TransactionsController, type: :api do
|
||||||
|
def post_transaction(extra_attributes = {})
|
||||||
|
post '/transactions', { transaction: @api_attributes.merge(extra_attributes) },
|
||||||
|
{ 'HTTP_ACCEPT' => "application/json", "HTTP_AUTHORIZATION" => "Token token=#{@key}" }
|
||||||
|
end
|
||||||
|
|
||||||
before :each do
|
before :each do
|
||||||
@debtor = create :user
|
@debtor = create :user
|
||||||
@creditor = create :user
|
@creditor = create :user
|
||||||
|
@ -14,6 +19,11 @@ describe TransactionsController, type: :api do
|
||||||
@key = @client.key
|
@key = @client.key
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'with key' do
|
||||||
|
before :each do
|
||||||
|
@client.add_role :create_transactions
|
||||||
|
end
|
||||||
|
|
||||||
def post_transaction(extra_attributes = {})
|
def post_transaction(extra_attributes = {})
|
||||||
post '/transactions', { transaction: @api_attributes.merge(extra_attributes) },
|
post '/transactions', { transaction: @api_attributes.merge(extra_attributes) },
|
||||||
{ 'HTTP_ACCEPT' => "application/json", "HTTP_AUTHORIZATION" => "Token token=#{@key}" }
|
{ 'HTTP_ACCEPT' => "application/json", "HTTP_AUTHORIZATION" => "Token token=#{@key}" }
|
||||||
|
@ -54,3 +64,10 @@ describe TransactionsController, type: :api do
|
||||||
# end
|
# end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'without key' do
|
||||||
|
it "should not create a transaction" do
|
||||||
|
expect { post_transaction }.to_not change { Transaction.count }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in a new issue