Skip to content

Commit

Permalink
adding basic tests
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Simpson committed Jul 11, 2024
1 parent 782fabe commit 19fffe2
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions spec/dummy/app/avo/resources/store.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class Avo::Resources::Store < Avo::BaseResource
self.includes = [:location]
self.confirm_on_save = true

def fields
field :id, as: :id
Expand Down
33 changes: 33 additions & 0 deletions spec/features/avo/confirm_on_save_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
require "rails_helper"

RSpec.feature "ConfirmOnSave", type: :feature do
context "edit" do
let!(:store) { create :store , name: nil}

Check failure on line 5 in spec/features/avo/confirm_on_save_spec.rb

View workflow job for this annotation

GitHub Actions / lint / runner / standardrb

[rubocop] reported by reviewdog 🐶 [Corrected] Layout/SpaceBeforeComma: Space found before comma. Raw Output: spec/features/avo/confirm_on_save_spec.rb:5:33: C: [Corrected] Layout/SpaceBeforeComma: Space found before comma. let!(:store) { create :store , name: nil} ^

Check failure on line 5 in spec/features/avo/confirm_on_save_spec.rb

View workflow job for this annotation

GitHub Actions / lint / runner / standardrb

[rubocop] reported by reviewdog 🐶 [Corrected] Layout/SpaceInsideBlockBraces: Space missing inside }. Raw Output: spec/features/avo/confirm_on_save_spec.rb:5:45: C: [Corrected] Layout/SpaceInsideBlockBraces: Space missing inside }. let!(:store) { create :store , name: nil} ^

describe "when saving the record" do
it "confirms the operation" do
visit "/admin/resources/stores/#{store.id}/edit"

save

Check failure on line 12 in spec/features/avo/confirm_on_save_spec.rb

View workflow job for this annotation

GitHub Actions / lint / runner / standardrb

[rubocop] reported by reviewdog 🐶 [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. Raw Output: spec/features/avo/confirm_on_save_spec.rb:12:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
expect(page).to have_selector('#turbo-confirm button[value="confirm"]')
end

it "completes the operation on confirmation" do
visit "/admin/resources/stores/#{store.id}/edit"

expect(page).to have_field "store[name]"

fill_in "store[name]", with: "Changed Name"

save

accept_custom_alert do
click_on "Yes, I'm sure"
end

Check failure on line 28 in spec/features/avo/confirm_on_save_spec.rb

View workflow job for this annotation

GitHub Actions / lint / runner / standardrb

[rubocop] reported by reviewdog 🐶 [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected. Raw Output: spec/features/avo/confirm_on_save_spec.rb:28:1: C: [Corrected] Layout/TrailingWhitespace: Trailing whitespace detected.
expect(find_field_value_element("name")).to have_text "Changed Name"
end
end
end
end

Check failure on line 33 in spec/features/avo/confirm_on_save_spec.rb

View workflow job for this annotation

GitHub Actions / lint / runner / standardrb

[rubocop] reported by reviewdog 🐶 [Corrected] Layout/TrailingEmptyLines: Final newline missing. Raw Output: spec/features/avo/confirm_on_save_spec.rb:33:4: C: [Corrected] Layout/TrailingEmptyLines: Final newline missing. end

0 comments on commit 19fffe2

Please sign in to comment.