Skip to content

Commit

Permalink
chore: organize specs (#2777)
Browse files Browse the repository at this point in the history
* wip

* fix

* rm already extracted specs
  • Loading branch information
Paul-Bob committed May 17, 2024
1 parent 75f76a0 commit b65a734
Show file tree
Hide file tree
Showing 10 changed files with 149 additions and 645 deletions.
98 changes: 98 additions & 0 deletions spec/features/avo/belongs_to_polymorphic_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
require "rails_helper"

RSpec.feature "belongs_to", type: :feature do
let!(:user) { create :user }
let!(:project) { create :project }

before do
# Update admin so it doesn't come up in the search
admin.update(first_name: "Jim", last_name: "Johnes")
end

describe "not searchable" do
context "new" do
context "without an association" do
context "when not filling the poly association" do
it "creates the comment" do
visit "/admin/resources/comments/"

expect(page).to have_text "No record found"

click_on "Create new comment"
fill_in "comment_body", with: "Sample comment"
select user.name, from: "comment_user_id"
save

return_to_comment_page

expect(find_field_value_element("body")).to have_text "Sample comment"
expect(find_field_value_element("user")).to have_link user.name, href: "/admin/resources/compact_users/#{user.slug}?via_record_id=#{Comment.last.id}&via_resource_class=Avo%3A%3AResources%3A%3AComment"
expect(find_field_value_element("commentable")).to have_text empty_dash
end
end
end

context "with an association" do
let!(:comment) { create :comment, commentable: project }

describe "nullifying a polymorphic association" do
context "with selecting 'Choose an option'" do
let!(:project) { create :project }

it "empties the commentable association" do
visit "/admin/resources/comments/#{comment.id}/edit"

select "Choose an option", from: "comment_commentable_type"
save

return_to_comment_page

expect(find_field_value_element("commentable")).to have_text empty_dash
end
end
end
end
end

context "index" do
describe "without an association" do
let!(:comment) { create :comment }

it "displays an empty dash" do
visit "/admin/resources/comments"

expect(page.body).to have_text "Commentable"
expect(field_element_by_resource_id("commentable", comment.id)).to have_text empty_dash
end
end

describe "with a polymorphic relation" do
let!(:project) { create :project }
let!(:comment) { create :comment, commentable: project }

it "displays the commentable label" do
visit "/admin/resources/comments"

expect(page.body).to have_text "Commentable"
expect(field_element_by_resource_id("commentable", comment.id)).to have_link project.name, href: "/admin/resources/projects/#{project.id}"
end
end
end
end

describe "with namespaced model" do
let!(:course) { create :course }

it "has the prefilled association details" do
visit "/admin/resources/course_links/new?via_relation=course&via_relation_class=Course&via_record_id=#{course.id}"

expect(page).to have_field type: :select, name: "course/link[course_id]", disabled: true, text: course.name
expect(page).to have_field type: :hidden, name: "course/link[course_id]", visible: false, with: course.id
end
end
end

def return_to_comment_page
click_on Comment.first.id.to_s
wait_for_loaded
end
33 changes: 0 additions & 33 deletions spec/features/avo/dynamic_filters/boolean_filter_spec.rb

This file was deleted.

67 changes: 0 additions & 67 deletions spec/features/avo/dynamic_filters/date_filter_spec.rb

This file was deleted.

98 changes: 0 additions & 98 deletions spec/features/avo/dynamic_filters/number_filter_spec.rb

This file was deleted.

48 changes: 0 additions & 48 deletions spec/features/avo/dynamic_filters/select_filter_spec.rb

This file was deleted.

Loading

0 comments on commit b65a734

Please sign in to comment.