Fix working api test
This commit is contained in:
parent
5ff29d2a1f
commit
cc07c17eff
|
@ -1,4 +1,14 @@
|
||||||
describe TransactionsController, type: :api do
|
describe TransactionsController, type: :api do
|
||||||
|
let(:api_attributes) do
|
||||||
|
{
|
||||||
|
debtor: create(:user).name,
|
||||||
|
creditor: create(:user).name,
|
||||||
|
message: Faker::Lorem.sentence,
|
||||||
|
euros: rand(2),
|
||||||
|
cents: 1 + rand(100)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
before :each do
|
before :each do
|
||||||
@client = Client.create name: "Tap"
|
@client = Client.create name: "Tap"
|
||||||
@key = @client.key
|
@key = @client.key
|
||||||
|
@ -11,7 +21,7 @@ describe TransactionsController, type: :api do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should work with valid key" do
|
it "should work with valid key" do
|
||||||
post '/transactions', { transaction: attributes_for(:transaction) }, { 'HTTP_ACCEPT' => "application/json", "X_API_KEY" => @key }
|
post '/transactions', { transaction: api_attributes }, { 'HTTP_ACCEPT' => "application/json", "X_API_KEY" => @key }
|
||||||
expect(last_response.status).to eq(201)
|
expect(last_response.status).to eq(201)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue