-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(CE): add feedback model (#403)
Co-authored-by: afthab vp <[email protected]>
- Loading branch information
1 parent
c1494db
commit 0737717
Showing
6 changed files
with
65 additions
and
1 deletion.
There are no files selected for viewing
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,14 @@ | ||
# frozen_string_literal: true | ||
|
||
class Feedback < ApplicationRecord | ||
validates :data_app_id, presence: true | ||
validates :visual_component_id, presence: true | ||
validates :model_id, presence: true | ||
validates :reaction, presence: true | ||
|
||
belongs_to :data_app | ||
belongs_to :visual_component | ||
belongs_to :model | ||
|
||
enum reaction: { positive: 0, negative: 1 } | ||
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,14 @@ | ||
class CreateFeedbacks < ActiveRecord::Migration[7.1] | ||
def change | ||
create_table :feedbacks do |t| | ||
t.integer :workspace_id, null: false | ||
t.integer :data_app_id, null: false | ||
t.integer :visual_component_id, null: false | ||
t.integer :model_id, null: false | ||
t.integer :reaction, null: false | ||
t.text :feedback_content | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,22 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rails_helper" | ||
|
||
RSpec.describe Feedback, type: :model do | ||
describe "associations" do | ||
it { should belong_to(:data_app) } | ||
it { should belong_to(:visual_component) } | ||
it { should belong_to(:model) } | ||
end | ||
|
||
describe "validations" do | ||
it { should validate_presence_of(:data_app_id) } | ||
it { should validate_presence_of(:visual_component_id) } | ||
it { should validate_presence_of(:model_id) } | ||
it { should validate_presence_of(:reaction) } | ||
end | ||
|
||
describe "enum" do | ||
it { should define_enum_for(:reaction).with_values(positive: 0, negative: 1) } | ||
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