Class: CmQuiz::Review::DeleteIdea

Inherits:
BaseReview show all
Defined in:
lib/cm_quiz/review/delete_idea.rb

Instance Attribute Summary

Attributes inherited from BaseReview

#options, #path, #verb

Instance Method Summary collapse

Methods inherited from BaseReview

#build_test_result, #perform, #test_request

Methods included from CmQuiz::ReviewHelper

#be, #be_nil, #be_within, #eq, #expect

Constructor Details

#initialize(project_api:) ⇒ DeleteIdea

Returns a new instance of DeleteIdea.



4
5
6
7
8
# File 'lib/cm_quiz/review/delete_idea.rb', line 4

def initialize(project_api:)
  @project_api = project_api
  @verb = :delete
  @path = '/ideas/:idea_id'
end

Instance Method Details

#runObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/cm_quiz/review/delete_idea.rb', line 10

def run
  jwt, _ = Factory::User.new({
    project_api: @project_api
  }).create
  idea_payload = Factory::Idea.new({
    project_api: @project_api,
    jwt: jwt
  }).create
  idea_id = idea_payload['id']

  send_delete_idea_request(jwt: jwt, idea_id: idea_id)

  res = send_get_ideas_request(jwt: jwt)
  res_hash = JSON.parse(res.body)
  idea = res_hash.find { |item| item['id'] == idea_id }
  expect(idea).to be_nil
end