Skip to content

Commit

Permalink
Merge tool-collections into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
stage-branch-merger[bot] authored Jul 17, 2023
2 parents edb9629 + 948347a commit df7cf5f
Showing 1 changed file with 38 additions and 8 deletions.
46 changes: 38 additions & 8 deletions spec/acceptance/rule_praxis_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,51 @@

post "tool-groups/:id/rule-praxis" do
requires_authorization
let(:tool_group_id) {ToolGroup.first.id}
let(:openness) {[1, 2]}
let(:confidence) {[4, 5]}

let(:attrs) do
let(:valid_attrs) do
{
tool_group_id: ToolGroup.first.id,
openness: [123, 456],
confidence: [8, 9],
tool_group_id: tool_group_id,
openness: openness,
confidence: confidence,
negative_rule: "true"
}
end

it "create rule praxis" do
do_request data: {type: "tool-group-rule-praxis", attributes: attrs}
let(:repeated_attrs) do
{
tool_group_id: tool_group_id,
openness: openness,
confidence: confidence,
negative_rule: "true"
}
end

context "with valid openness and confidence values" do
it "create rule praxis" do
do_request data: {type: "tool-group-rule-praxis", attributes: valid_attrs}

expect(status).to eq(201)
expect(JSON.parse(response_body)["data"]).not_to be_nil
end
end

context "with repeated openness and confidence values" do
before do
FactoryBot.create(:rule_praxi, tool_group_id: tool_group_id,
openness: openness,
confidence: confidence)
end

it "returns an error" do
do_request data: {type: "tool-group-rule-praxis", attributes: repeated_attrs}

expect(status).to eq(201)
expect(JSON.parse(response_body)["data"]).not_to be_nil
expect(status).to eq(422)
expect(JSON.parse(response_body)["data"]).to be_nil
expect(JSON.parse(response_body)["error"]["tool_group_id"][0]).to eql "combination already exists"
end
end
end

Expand Down

0 comments on commit df7cf5f

Please sign in to comment.