Skip to content

Commit

Permalink
Remove unneeded tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gazayas committed Aug 3, 2023
1 parent 6ae9507 commit 7966296
Showing 1 changed file with 0 additions and 50 deletions.
50 changes: 0 additions & 50 deletions test/system/super_scaffolding_partial_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,54 +188,4 @@ def setup
assert_equal partial_test.number_field_test, 47
end
end

if defined?(PartialTest)
test "developers can pass custom format to date and date_and_time partials" do
display_details = @@test_devices[:macbook_pro_15_inch]
resize_for(display_details)

login_as(@jane, scope: :user)
visit account_team_path(@jane.current_team)

click_on "Add New Partial Test"

find("#partial_test_date_test").click
find(".daterangepicker").click_on("apply") # Chooses today's date.

# We should be able to create a new record without passing any format options.
click_on "Create Partial Test"
assert page.has_content?("Partial Test was successfully created.")
assert page.has_content?(Date.today.strftime("%B %-d"))

# Edit the index partial.
custom_date_format = "\"%m/%d\"" # i.e. - 04/07 for April 4th
custom_time_format = "\"%I %p\"" # i.e. - 11 P.M. (cuts off the minutes)

file_path = "#{Rails.root}/app/views/account/partial_tests/_index.html.erb"
transformed_content = []
File.open(file_path, "r") do |file|
original_content = file.readlines

# For these regular expressions, we take the space at the end of the embedded ruby and replace it with our option.
transformed_content = original_content.map do |line|
if line.match?(/attribute: :date_test/)
line.gsub(/(.*url: \[:account, partial_test\])(\s)(%><\/td>\n$)/, '\1' + ", date_format: #{custom_date_format} " + '\3')
elsif line.match?(/attribute: :created_at/)
line.gsub(/(.*:created_at)(\s)(%><\/td>\n$)/, '\1' + ", date_format: #{custom_date_format}, time_format: #{custom_time_format} " + '\3')
else
line
end
end
end

File.write(file_path, transformed_content.join(""))

# Should show properly on the index partial.
visit account_team_partial_tests_path(@jane.current_team)

# TODO: The system test isn't reflect the changes to the index partial made above.
# assert page.has_content?(Date.today.strftime("%m/%d"))
# assert page.has_content?(Time.now.strftime("%H %p"))
end
end
end

0 comments on commit 7966296

Please sign in to comment.