diff --git a/spec/features/avo/belongs_to_polymorphic_spec.rb b/spec/features/avo/belongs_to_polymorphic_spec.rb new file mode 100644 index 0000000000..83351783ba --- /dev/null +++ b/spec/features/avo/belongs_to_polymorphic_spec.rb @@ -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 diff --git a/spec/features/avo/dynamic_filters/boolean_filter_spec.rb b/spec/features/avo/dynamic_filters/boolean_filter_spec.rb deleted file mode 100644 index 86c736e570..0000000000 --- a/spec/features/avo/dynamic_filters/boolean_filter_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -# EXTRACT: -# require "rails_helper" - -# RSpec.feature "boolean dynamic filter", type: :feature do -# let!(:slab_city) { create :city, name: "Slab city", population: nil, is_capital: false } -# let!(:vatican) { create :city, name: "Vatican city", population: 450, is_capital: false } -# let!(:barcelona) { create :city, name: "Barcelona", population: 1_600_000, is_capital: true } -# let!(:new_york) { create :city, name: "New York", population: 8_500_000, is_capital: false } - -# let(:filters_path) { "/admin/resources/cities" } - -# describe "is_true" do -# it "applies the filter" do -# visit_with_filters([["is_capital", "is_true", ""]]) - -# expect_record_not_present "Vatican city" -# expect_record_present "Barcelona" -# expect_record_not_present "New York" -# expect(page).to have_text "Is capital true", normalize_ws: true -# end -# end - -# describe "is_false" do -# it "applies the filter" do -# visit_with_filters([["is_capital", "is_false", ""]]) - -# expect_record_present "Vatican city" -# expect_record_not_present "Barcelona" -# expect_record_present "New York" -# expect(page).to have_text "Is capital false", normalize_ws: true -# end -# end -# end diff --git a/spec/features/avo/dynamic_filters/date_filter_spec.rb b/spec/features/avo/dynamic_filters/date_filter_spec.rb deleted file mode 100644 index bd91382702..0000000000 --- a/spec/features/avo/dynamic_filters/date_filter_spec.rb +++ /dev/null @@ -1,67 +0,0 @@ -# EXTRACT: -# require "rails_helper" - -# RSpec.feature "date dynamic filter", type: :feature do -# let!(:slab_city) { create :city, name: "Slab city", population: nil, created_at: Date.new(1972) } -# let!(:vatican) { create :city, name: "Vatican city", population: 450, created_at: Date.new(1929, 2, 11) } -# let!(:barcelona) { create :city, name: "Barcelona", population: 1_600_000, created_at: Date.new(100) } -# let!(:new_york) { create :city, name: "New York", population: 8_500_000, created_at: Date.new(1624) } - -# let(:filters_path) { "/admin/resources/cities" } - -# describe "is" do -# it "applies the filter" do -# visit_with_filters([["created_at", "is", "0100-01-01"]]) - -# expect_record_not_present "Vatican city" -# expect_record_present "Barcelona" -# expect_record_not_present "New York" -# expect(page).to have_text 'Created at is "0100-01-01"', normalize_ws: true -# end -# end - -# describe "is_not" do -# it "applies the filter" do -# visit_with_filters([["created_at", "is_not", "0100-01-01"]]) - -# expect_record_present "Vatican city" -# expect_record_not_present "Barcelona" -# expect_record_present "New York" -# expect(page).to have_text 'Created at is not "0100-01-01"', normalize_ws: true -# end -# end - -# describe "lte" do -# it "applies the filter" do -# visit_with_filters([["created_at", "lte", "0100-01-01"]]) - -# expect_record_not_present "Vatican city" -# expect_record_present "Barcelona" -# expect_record_not_present "New York" -# expect(page).to have_text 'Created at <= "0100-01-01"', normalize_ws: true -# end -# end - -# describe "gte" do -# it "applies the figter" do -# visit_with_filters([["created_at", "gte", "0100-01-01"]]) - -# expect_record_present "Vatican city" -# expect_record_present "Barcelona" -# expect_record_present "New York" -# expect(page).to have_text 'Created at >= "0100-01-01"', normalize_ws: true -# end -# end - -# describe "is_within" do -# it "applies the figter" do -# visit_with_filters([["created_at", "is_within", "0100-01-01 to 1625-01-01"]]) - -# expect_record_not_present "Vatican city" -# expect_record_present "Barcelona" -# expect_record_present "New York" -# expect_record_not_present "Slab city" -# expect(page).to have_text 'Created at is within "0100-01-01 to 1625-01-01"', normalize_ws: true -# end -# end -# end diff --git a/spec/features/avo/dynamic_filters/number_filter_spec.rb b/spec/features/avo/dynamic_filters/number_filter_spec.rb deleted file mode 100644 index 401ba06d1e..0000000000 --- a/spec/features/avo/dynamic_filters/number_filter_spec.rb +++ /dev/null @@ -1,98 +0,0 @@ -# EXTRACT: -# require "rails_helper" - -# RSpec.feature "Number dynamic filter", type: :feature do -# let!(:slab_city) { create :city, name: "Slab city", population: nil } -# let!(:vatican) { create :city, name: "Vatican city", population: 450 } -# let!(:barcelona) { create :city, name: "Barcelona", population: 1_600_000 } -# let!(:new_york) { create :city, name: "New York", population: 8_500_000 } - -# let(:filters_path) { "/admin/resources/cities" } - -# describe "is" do -# it "applies the filter" do -# visit_with_filters([["population", "is", "450"]]) - -# expect_record_present "Vatican city" -# expect_record_not_present "Barcelona" -# expect_record_not_present "New York" -# expect(page).to have_text 'Population is "450"', normalize_ws: true -# end -# end - -# describe "is_not" do -# it "applies the filter" do -# visit_with_filters([["population", "is_not", "450"]]) - -# expect_record_not_present "Vatican city" -# expect_record_present "Barcelona" -# expect_record_present "New York" -# expect(page).to have_text 'Population is not "450"', normalize_ws: true -# end -# end - -# describe "gt" do -# it "applies the filter" do -# visit_with_filters([["population", "gt", "450"]]) - -# expect_record_not_present "Vatican city" -# expect_record_present "Barcelona" -# expect_record_present "New York" -# expect(page).to have_text 'Population > "450"', normalize_ws: true -# end -# end - -# describe "gte" do -# it "applies the filter" do -# visit_with_filters([["population", "gte", "450"]]) - -# expect_record_present "Vatican city" -# expect_record_present "Barcelona" -# expect_record_present "New York" -# expect(page).to have_text 'Population >= "450"', normalize_ws: true -# end -# end - -# describe "lt" do -# it "applies the filter" do -# visit_with_filters([["population", "lt", "1600000"]]) - -# expect_record_present "Vatican city" -# expect_record_not_present "Barcelona" -# expect_record_not_present "New York" -# expect(page).to have_text 'Population < "1600000"', normalize_ws: true -# end -# end - -# describe "lte" do -# it "applies the filter" do -# visit_with_filters([["population", "lte", "1600000"]]) - -# expect_record_present "Vatican city" -# expect_record_present "Barcelona" -# expect_record_not_present "New York" -# expect(page).to have_text 'Population <= "1600000"', normalize_ws: true -# end -# end - -# describe "is_present" do -# it "applies the filter" do -# visit_with_filters([["population", "is_present", "1"]]) - -# expect_missing_component("avo/index/resource_table_component") -# expect(page).to have_text "Population present", normalize_ws: true -# end -# end - -# describe "is_blank" do -# it "applies the filter" do -# visit_with_filters([["population", "is_blank", ""]]) - -# expect_record_present "Slab city" -# expect_record_not_present "Vatican city" -# expect_record_not_present "Barcelona" -# expect_record_not_present "New York" -# expect(page).to have_text "Population blank", normalize_ws: true -# end -# end -# end diff --git a/spec/features/avo/dynamic_filters/select_filter_spec.rb b/spec/features/avo/dynamic_filters/select_filter_spec.rb deleted file mode 100644 index 81ca07d6c3..0000000000 --- a/spec/features/avo/dynamic_filters/select_filter_spec.rb +++ /dev/null @@ -1,48 +0,0 @@ -# EXTRACT: -# require "rails_helper" - -# RSpec.feature "select dynamic filter", type: :feature do -# let!(:airpods) { create :project, name: "AirPods", stage: :Idea } -# let!(:iphone) { create :project, name: "iPhone", stage: :Cancelled } - -# let(:filters_path) { "/admin/resources/projects" } - -# describe "is" do -# it "applies the filter" do -# visit_with_filters([["stage", "is", "idea"]]) - -# expect_record_present "AirPods" -# expect_record_not_present "iPhone" -# expect(page).to have_text 'Stage is "Idea"', normalize_ws: true -# end -# end - -# describe "is_not" do -# it "applies the filter" do -# visit_with_filters([["stage", "is_not", "idea"]]) - -# expect_record_not_present "AirPods" -# expect_record_present "iPhone" -# expect(page).to have_text 'Stage is not "Idea"', normalize_ws: true -# end -# end - -# describe "is_present" do -# it "applies the filter" do -# visit_with_filters([["stage", "is_present", ""]]) - -# expect_record_present "AirPods" -# expect_record_present "iPhone" -# expect(page).to have_text "Stage present", normalize_ws: true -# end -# end - -# describe "is_blank" do -# it "applies the filter" do -# visit_with_filters([["stage", "is_blank", ""]]) - -# expect_missing_component("avo/index/resource_table_component") -# expect(page).to have_text "Stage blank", normalize_ws: true -# end -# end -# end diff --git a/spec/features/avo/dynamic_filters/text_filter_spec.rb b/spec/features/avo/dynamic_filters/text_filter_spec.rb deleted file mode 100644 index b07b82d66c..0000000000 --- a/spec/features/avo/dynamic_filters/text_filter_spec.rb +++ /dev/null @@ -1,99 +0,0 @@ -# EXTRACT: -# require "rails_helper" - -# RSpec.feature "Text dynamic filter", type: :feature do -# let!(:apple) { create :team, name: "Apple", team_members: [admin] } -# let!(:tesla) { create :team, name: "Tesla", team_members: [admin] } -# let!(:amazon) { create :team, name: "Amazon", team_members: [admin] } -# let!(:netflix) { create :team, name: "Netflix", team_members: [admin] } - -# let(:filters_path) { "/admin/resources/teams" } - -# describe "contains" do -# it "applies the filter" do -# visit_with_filters([["name", "contains", "a"]]) - -# expect_record_present "Apple" -# expect_record_not_present "Netflix" -# expect(page).to have_text 'Name contains "a"', normalize_ws: true -# end -# end - -# describe "does_not_contain" do -# it "applies the filter" do -# visit_with_filters([["name", "does_not_contain", "flix"]]) - -# expect_record_present "Apple" -# expect_record_not_present "Netflix" -# expect(page).to have_text 'Name does not contain "flix"', normalize_ws: true -# end -# end - -# describe "is" do -# it "applies the filter" do -# visit_with_filters([["name", "is", "Amazon"]]) - -# expect_record_present "Amazon" -# expect_record_not_present "Apple" -# expect_record_not_present "Netflix" -# expect(page).to have_text 'Name is "Amazon"', normalize_ws: true -# end -# end - -# describe "is_not" do -# it "applies the filter" do -# visit_with_filters([["name", "is_not", "Amazon"]]) - -# expect(find_component("avo/index/resource_table_component")).not_to have_text "Amazon" -# expect_record_present "Apple" -# expect_record_present "Netflix" -# expect(page).to have_text 'Name is not "Amazon"', normalize_ws: true -# end -# end - -# describe "starts_with" do -# it "applies the filter" do -# visit_with_filters([["name", "starts_with", "t"]]) - -# expect_record_not_present "Apple" -# expect_record_present "Tesla" -# expect_record_not_present "Amazon" -# expect_record_not_present "Netflix" -# expect(page).to have_text 'Name starts with "t"', normalize_ws: true -# end -# end - -# describe "ends_with" do -# it "applies the filter" do -# visit_with_filters([["name", "ends_with", "x"]]) - -# expect_record_not_present "Apple" -# expect_record_not_present "Tesla" -# expect_record_not_present "Amazon" -# expect_record_present "Netflix" -# expect(page).to have_text 'Name ends with "x"', normalize_ws: true -# end -# end - -# describe "is_present" do -# it "applies the filter" do -# visit_with_filters([["name", "is_present", ""]]) - -# expect_record_present "Apple" -# expect_record_present "Tesla" -# expect_record_present "Amazon" -# expect_record_present "Netflix" -# expect(page).to have_text "Name present", normalize_ws: true -# end -# end - -# describe "is_blank" do -# it "applies the filter" do -# visit_with_filters([["name", "is_blank", ""]]) - -# expect_missing_component("avo/index/resource_table_component") -# expect(page).to have_text "Name blank", normalize_ws: true -# end -# end -# end - diff --git a/spec/features/avo/exposed_methods_base_controller_spec.rb b/spec/features/avo/exposed_methods_base_controller_spec.rb new file mode 100644 index 0000000000..f18015df90 --- /dev/null +++ b/spec/features/avo/exposed_methods_base_controller_spec.rb @@ -0,0 +1,50 @@ +require "rails_helper" + +RSpec.feature "ExposedMethodsBaseController", type: :feature do + describe "message" do + let(:new_course_url) { "/admin/resources/courses/new" } + + it "create_fail_message" do + visit new_course_url + + save + + expect(page).to have_text "Course not created!" + end + + it "create_success_message" do + visit new_course_url + + fill_in "course_name", with: "Great Course" + save + + expect(current_path).to eq "/admin/resources/courses/#{Course.last.prefix_id}" + expect(page).to have_text "Course created!" + end + + let(:course) { create :course } + let(:edit_course_url) { "/admin/resources/courses/#{course.prefix_id}/edit" } + + it "update_fail_message" do + visit edit_course_url + + fill_in "course_name", with: "" + save + + expect(page).to have_text "Course not updated!" + expect(page).to have_text "Validation failed: Name can't be blank" + end + + let(:course_url) { "/admin/resources/courses/#{course.prefix_id}" } + + it "update_success_message" do + visit edit_course_url + + fill_in "course_name", with: "Guitar Course" + save + + expect(current_path).to eq course_url + expect(page).to have_text "Course updated!" + end + end +end diff --git a/spec/system/avo/avo_dynamic_filters_spec.rb b/spec/system/avo/avo_dynamic_filters_spec.rb deleted file mode 100644 index f9dbb7561b..0000000000 --- a/spec/system/avo/avo_dynamic_filters_spec.rb +++ /dev/null @@ -1,188 +0,0 @@ -# EXTRACT: -# require "rails_helper" - -# RSpec.describe "DynamicFilters", type: :system do -# let!(:apple) { create :team, name: "Apple", team_members: [admin] } -# let!(:tesla) { create :team, name: "Tesla", team_members: [admin] } -# let!(:amazon) { create :team, name: "Amazon", team_members: [admin] } -# let!(:netflix) { create :team, name: "Netflix", team_members: [admin] } - -# describe "with filters bar expanded" do -# around do |example| -# initial_value = Avo::DynamicFilters.configuration.always_expanded -# Avo::DynamicFilters.configuration.always_expanded = true -# Avo::DynamicFilters.configuration.button_label = "Feelters" -# example.run -# Avo::DynamicFilters.configuration.always_expanded = initial_value -# end - -# it "keeps the filters panel expanded" do -# visit "/admin/resources/teams" - -# expect(page).not_to have_text "Feelters" -# expect(page).to have_text "Add filter" -# expect(page).to have_css '[data-avo-filters-target="add-filter-button"]' -# end -# end -# describe "with filters bar collapsed" do -# around do |example| -# initial_value = Avo::DynamicFilters.configuration.always_expanded -# Avo::DynamicFilters.configuration.always_expanded = false -# Avo::DynamicFilters.configuration.button_label = "Feelters" -# example.run -# Avo::DynamicFilters.configuration.always_expanded = initial_value -# end - -# describe "the button label is visible" do -# it "shows the filters button" do -# visit "/admin/resources/teams" - -# expect(page).to have_text "Feelters" - -# expect(page).to have_text "Apple" -# expect(page).to have_text "Tesla" -# expect(page).to have_text "Amazon" -# expect(page).to have_text "Netflix" -# end - -# it "expands the filters bar" do -# visit "/admin/resources/teams" - -# expect(page).not_to have_text "Add filter" - -# # Test opening of the panel -# click_on "Feelters" - -# expect(page).to have_text "Add filter" -# expect(page).to have_css '[data-avo-filters-target="add-filter-button"]' - -# # Test filters panel open -# within(filters_dropdown_panel) do -# expect(page).to have_link "Id" -# expect(page).to have_link "Name" -# expect(page).to have_link "Created at" -# expect(page).to have_link "Description" -# expect(page).to have_link "Memberships" -# end - -# # Test adding a filter -# add_filter "Id" - -# within(filters_holder) do -# expect(page).to have_text "Id" -# expect(page).to have_text "Filter by Id" -# expect(page).to have_select "condition" -# expect(page).to have_css 'input[data-action="keydown.enter->avo-filters#apply"]' -# end - -# # Test updating the filter value and applying it -# fill_filter_value "id", with: amazon.id -# apply_filter "id" - -# expect(page).to have_text "Amazon" -# expect(page).not_to have_text "Apple" -# expect(page).not_to have_text "Tesla" -# expect(page).not_to have_text "Netflix" - -# # Test filter pill content -# expect(filter_pill("Id")).to have_text "Id\nis \"#{amazon.id}\"" - -# # Test removing a filter -# remove_filter "Id" - -# expect(page).to have_text "Apple" -# expect(page).to have_text "Tesla" -# expect(page).to have_text "Amazon" -# expect(page).to have_text "Netflix" - -# # The filter panel will be collapsed now because there are no filters present -# click_on "Feelters" - -# expect(filters_holder.text).to eq "" - -# add_filter "Name" -# fill_filter_value "Name", with: "Netflix" -# apply_filter "Name" - -# expect(page).not_to have_text "Apple" -# expect(page).not_to have_text "Tesla" -# expect(page).not_to have_text "Amazon" -# expect(page).to have_text "Netflix" - -# click_on "Reset filters" - -# expect(page).to have_text "Apple" -# expect(page).to have_text "Tesla" -# expect(page).to have_text "Amazon" -# expect(page).to have_text "Netflix" -# end -# end -# end - -# describe "with filters bar visible" do -# around do |example| -# initial_value = Avo::DynamicFilters.configuration.always_expanded -# Avo::DynamicFilters.configuration.always_expanded = true -# Avo::DynamicFilters.configuration.button_label = "Feelters" -# example.run -# Avo::DynamicFilters.configuration.always_expanded = initial_value -# end - -# describe "the button label is visible" do -# it "hehe" do -# visit "/admin/resources/teams" -# expect(page).not_to have_text "Feelters" -# end -# end -# end -# end - -# def filters_dropdown_panel -# find ".filters-dropdown-selector" -# end - -# def add_filter(id) -# within(filters_dropdown_panel) do -# click_on id -# end - -# wait_for_loaded -# end - -# def filter_component(id) -# find("[data-component='avo_filters/filter_component'][data-field-id='#{id.underscore}']") -# end - -# def filter_pill(id) -# filter_component(id).find(".pill") -# end - -# def filter_panel(id) -# filter_component(id).find("[data-toggle-target='panel']") -# end - -# def fill_filter_value(id, with: "") -# within(filter_panel(id)) do -# find('input[data-control="value"]').set(with) -# end -# end - -# def apply_filter(id) -# within(filter_panel(id)) do -# click_on "Apply" -# end - -# wait_for_loaded -# end - -# def remove_filter(id) -# within filter_pill(id) do -# find('[data-action="avo-filters#removeFilter"]').click -# end - -# wait_for_loaded -# end - -# def filters_holder -# page.find("turbo-frame#avo_filters_holder") -# end diff --git a/spec/system/avo/belongs_to_polymorphic_spec.rb b/spec/system/avo/belongs_to_polymorphic_spec.rb index a8c7cdb8f3..a0932d2bc4 100644 --- a/spec/system/avo/belongs_to_polymorphic_spec.rb +++ b/spec/system/avo/belongs_to_polymorphic_spec.rb @@ -25,25 +25,6 @@ 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 - context "when filling the poly association" do describe "creating a polymorphic association" do it "creates the comment" do @@ -106,21 +87,6 @@ end 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 - context "with just selecting a different association" do let!(:project) { create :project } let!(:comment) { create :comment, commentable: project } @@ -158,31 +124,6 @@ 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 - describe "within a parent model" do let!(:project) { create :project } let!(:comment) { create :comment, body: "hey there", user: user, commentable: project } @@ -230,17 +171,6 @@ 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 diff --git a/spec/system/avo/exposed_methods_base_controller_spec.rb b/spec/system/avo/exposed_methods_base_controller_spec.rb index cef3c47a14..b682ee0923 100644 --- a/spec/system/avo/exposed_methods_base_controller_spec.rb +++ b/spec/system/avo/exposed_methods_base_controller_spec.rb @@ -3,49 +3,8 @@ RSpec.feature "ExposedMethodsBaseController", type: :system do describe "message" do let(:new_course_url) { "/admin/resources/courses/new" } - - it "create_fail_message" do - visit new_course_url - - save - - expect(page).to have_text "Course not created!" - end - - it "create_success_message" do - visit new_course_url - - fill_in "course_name", with: "Great Course" - save - - expect(current_path).to eq "/admin/resources/courses/#{Course.last.prefix_id}" - expect(page).to have_text "Course created!" - end - - let(:course) { create :course } - let(:edit_course_url) { "/admin/resources/courses/#{course.prefix_id}/edit" } - - it "update_fail_message" do - visit edit_course_url - - fill_in "course_name", with: "" - save - - expect(page).to have_text "Course not updated!" - expect(page).to have_text "Validation failed: Name can't be blank" - end - let(:course_url) { "/admin/resources/courses/#{course.prefix_id}" } - - it "update_success_message" do - visit edit_course_url - - fill_in "course_name", with: "Guitar Course" - save - - expect(current_path).to eq course_url - expect(page).to have_text "Course updated!" - end + let(:course) { create :course } it "after_destroy_path && destroy_success_message" do visit course_url