-
Notifications
You must be signed in to change notification settings - Fork 335
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: continue to incorporate feedback feature stage, criterion, crit…
…erion_option, feedback_comment, and feedback_comment_template.
- Loading branch information
1 parent
54296e6
commit 5a56346
Showing
20 changed files
with
269 additions
and
43 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
app/api/entities/feedback_entities/feedback_comment_entity.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module Entities | ||
class FeedbackCommentEntity < Grape::Entity | ||
expose :id | ||
expose :comment | ||
end | ||
end |
7 changes: 7 additions & 0 deletions
7
app/api/entities/feedback_entities/feedback_comment_template_entity.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module Entities | ||
class FeedbackCommentTemplateEntity < Grape::Entity | ||
expose :id | ||
expose :comment_text_situation | ||
expose :comment_text_next_action | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
FactoryBot.define do | ||
factory :criterion do | ||
transient do | ||
number_of_criterion_options {0} | ||
end | ||
|
||
stage | ||
|
||
sequence(:order) { |n| n } | ||
description { Faker::Lorem.sentence } | ||
help_text { Faker::Lorem.sentence } | ||
|
||
after(:create) do |criterion, evaluator| | ||
create_list(:criterion_option, evaluator.number_of_criterion_options, criterion: criterion) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
FactoryBot.define do | ||
factory :criterion_option do | ||
transient do | ||
number_of_feedback_comment_templates {0} | ||
end | ||
|
||
association :criterion # associates according to relationship within models | ||
task_status { TaskStatus.all.sample } | ||
|
||
# outcome_status | ||
resolved_message_text { Faker::Lorem.sentence } | ||
unresolved_message_text { Faker::Lorem.sentence } | ||
|
||
after(:create) do |criterion_option, evaluator| | ||
create_list(:feedback_comment_template, evaluator.number_of_feedback_comment_templates, criterion_option: criterion_option) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
FactoryBot.define do | ||
factory :feedback_comment do | ||
|
||
association :feedback_comment_template | ||
association :criterion_option | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
FactoryBot.define do | ||
factory :feedback_comment_template do | ||
criterion_option | ||
|
||
comment_text_situation { Faker::Lorem.sentence } | ||
comment_text_next_action { Faker::Lorem.sentence } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,25 @@ | ||
# Read about factories at https://github.com/thoughtbot/factory_bot | ||
|
||
FactoryBot.define do | ||
|
||
factory :stage do | ||
transient do | ||
number_of_criterion {0} | ||
end | ||
|
||
task_definition | ||
association :task_definition | ||
|
||
transient do # transient: not persisted to database | ||
number_of_criterion {0} # `0` criteria created unless otherwise specified | ||
# E.g., "FactoryBot.create(:stage, number_of_criterion: 3)" | ||
end | ||
|
||
sequence(:order) { |n| n } | ||
sequence(:title) { |n| "Stage-#{n}" } | ||
|
||
help_text { Faker::Lorem.sentence } | ||
entry_message { Faker::Lorem.sentence } | ||
exit_message_good { Faker::Lorem.sentence } | ||
exit_message_resubmit { Faker::Lorem.sentence } | ||
|
||
after(:build) do |stage, eval| | ||
# Create a list of criterion that refer to the created stage | ||
create_list(:criteria, eval.number_of_criterion, stage: stage) | ||
after(:create) do |stage, evaluator| | ||
create_list(:criteria, evaluator.number_of_criterion, stage: stage) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
require 'test_helper' | ||
|
||
# | ||
# Tests for CriterionOption model objects - not accessed via API | ||
# | ||
class CriterionOptionModelTest < ActiveSupport::TestCase | ||
|
||
# Setup objects for testing | ||
setup do | ||
DatabaseCleaner.start | ||
@criterion = FactoryBot.create(:criterion) | ||
@task_status = TaskStatus.new | ||
end | ||
|
||
# Test you can create a valid criterion option | ||
def test_valid_criterion_option_creation | ||
criterion_option = CriterionOption.create(criterion: @criterion, task_status: @task_status) | ||
assert criterion_option.valid? | ||
criterion_option.resolved_message_text = Faker::Lorem.sentence | ||
assert criterion_option.valid? | ||
criterion_option.unresolved_message_text = Faker::Lorem.sentence | ||
assert criterion_option.valid? | ||
end | ||
|
||
# Test you cannot create an invalid criterion option | ||
def test_invalid_criterion_option_creation | ||
criterion_option = CriterionOption.new | ||
|
||
refute criterion_option.valid? | ||
criterion_option.resolved_message_text = Faker::Lorem.sentence | ||
refute criterion_option.valid? | ||
criterion_option.unresolved_message_text = Faker::Lorem.sentence | ||
refute criterion_option.valid? | ||
|
||
criterion_option.task_status = @task_status | ||
refute criterion_option.valid? | ||
criterion_option.criterion = @criterion | ||
assert criterion_option.valid? | ||
criterion_option.task_status = nil | ||
refute criterion_option.valid? | ||
|
||
refute criterion_option.save | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
require 'test_helper' | ||
|
||
# | ||
# Contains tests for FeedbackComment model objects - not accessed via API | ||
# | ||
class FeedbackCommentModelTest < ActiveSupport::TestCase | ||
|
||
# Setup objects for testing | ||
def setup | ||
DatabaseCleaner.start | ||
criterion = FactoryBot.create(:criterion) | ||
task_status = TaskStatus.new | ||
@criterion_option = CriterionOption.create(criterion: criterion, task_status: task_status) | ||
|
||
@task = Task.new | ||
@user = FactoryBot.create(:user) | ||
@recipient = FactoryBot.create(:user) | ||
end | ||
|
||
# Test the creation of a valid feedback comment | ||
def test_valid_feedback_comment_creation | ||
feedback_comment = FeedbackComment.new(task: @task, user: @user, recipient: @recipient, comment: 'Test Comment', criterion_option: @criterion_option) | ||
assert feedback_comment.valid? | ||
end | ||
|
||
# Test the creation of an invalid feedback comment | ||
def test_invalid_feedback_comment_creation | ||
feedback_comment = FeedbackComment.new | ||
refute feedback_comment.valid? | ||
|
||
feedback_comment.task = @task | ||
refute feedback_comment.valid? | ||
|
||
feedback_comment.user = @user | ||
refute feedback_comment.valid? | ||
|
||
feedback_comment.recipient = @recipient | ||
refute feedback_comment.valid? | ||
|
||
feedback_comment.comment = 'Test Comment' | ||
refute feedback_comment.valid? | ||
|
||
feedback_comment.criterion_option = @criterion_option | ||
assert feedback_comment.valid? | ||
|
||
feedback_comment.task = nil | ||
refute feedback_comment.valid? | ||
|
||
feedback_comment.task = @task | ||
feedback_comment.user = nil | ||
|
||
refute feedback_comment.save | ||
end | ||
end |
41 changes: 41 additions & 0 deletions
41
test/models/feedback/feedback_comment_template_model_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
require 'test_helper' | ||
|
||
# | ||
# Contains tests for FeedbackCommentTemplate model objects - not accessed via API | ||
# | ||
class FeedbackCommentTemplateModelTest < ActiveSupport::TestCase | ||
|
||
# Setup objects for testing | ||
def setup | ||
DatabaseCleaner.start | ||
task_status = TaskStatus.new | ||
@criterion_option = CriterionOption.create(task_status: task_status) | ||
end | ||
|
||
# Test you can create a valid feedback comment template | ||
def test_valid_feedback_comment_template_creation | ||
feedback_comment_template = FeedbackCommentTemplate.create(criterion_option: @criterion_option, comment_text_situation: 'This is the situation') | ||
|
||
assert feedback_comment_template.valid? | ||
|
||
assert feedback_comment_template.criterion_option == @criterion_option | ||
assert feedback_comment_template.comment_text_situation == 'This is the situation' | ||
end | ||
|
||
# Test you cannot create an invalid feedback comment template | ||
def test_invalid_feedback_comment_template_creation | ||
feedback_comment_template = FeedbackCommentTemplate.new | ||
refute feedback_comment_template.valid? | ||
|
||
feedback_comment_template.comment_text_situation = 'This is a comment' | ||
refute feedback_comment_template.valid? | ||
|
||
feedback_comment_template.criterion_option = @criterion_option | ||
assert feedback_comment_template.valid? | ||
|
||
feedback_comment_template.comment_text_situation = nil | ||
refute feedback_comment_template.valid? | ||
|
||
refute feedback_comment_template.save | ||
end | ||
end |
Oops, something went wrong.