Skip to content

Commit

Permalink
update linked researoch plan rspec
Browse files Browse the repository at this point in the history
  • Loading branch information
Mehreen committed Nov 8, 2023
1 parent 0d96667 commit 5ff53d8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
11 changes: 4 additions & 7 deletions spec/api/research_plan_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@
end

describe 'GET /api/v1/research_plans/linked' do
let!(:c) { create(:collection, label: 'C1', user: user) }
let!(:rp) { create(:research_plan, :with_linked) }
let(:c) { create(:collection, label: 'C1', user: user) }
let(:research_plan) { create(:research_plan, :with_linked) }

before do
get '/api/v1/research_plans/linked', params: { id: 100, element: 'reaction' }
Expand All @@ -124,11 +124,8 @@
end

it 'returns research_plans linked to an element' do
first_rp = JSON.parse(response.body).first
expect(first_rp).to include(
'id' => 1,
'name' => 'Research plan 1'
)
response_body = JSON.parse(response.body)
expect(response_body[0]['name']).to eq research_plan.name
end
end
end
Expand Down
9 changes: 6 additions & 3 deletions spec/factories/research_plans.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@
end

trait :with_linked do
name {'Linked Research Plan'}

body do
[
{ "id"=>SecureRandom.uuid,
"type"=>"reaction",
"value"=> {"reaction_id" => 100}
{
'id' => SecureRandom.uuid,
'type' => 'reaction',
'value' => { 'reaction_id' => 100 },
}
]
end
Expand Down

0 comments on commit 5ff53d8

Please sign in to comment.