Skip to content

Improve project and personal snippet show_spec

What does this MR do?

In this MR we align and improve the specs spec/features/projects/snippets/show_spec.rb and spec/features/snippets/show_spec.rb.

spec/features/projects/snippets/show_spec.rb missed some specs that spec/features/snippets/show_spec.rb has, and since both specs basically check the same, it was refactored into a shared_examples block.

In local, spec/features/projects/snippets/show_spec.rb the time before the changes is 1 min and 10 seconds. Even though we're now introducing one more spec, the current time is 56 seconds. Therefore, the improvement is 14 seconds.

In local, spec/features/snippets/show_spec.rb the time went from 1 minute and 32 seconds down to 55 seconds. This is an improvement of 37 seconds

Refs #228690 (closed) and #228691 (closed)

Screenshots

spec/features/projects/snippets/show_spec.rb bfore

Top 6 slowest examples (35.51 seconds, 50.1% of total time):
  Projects > Snippets > Project snippet Markdown file visiting directly switching to the simple viewer displays the blob using the simple viewer
    8.97 seconds ./spec/features/projects/snippets/show_spec.rb:87
  Projects > Snippets > Project snippet Ruby file displays the blob
    7.49 seconds ./spec/features/projects/snippets/show_spec.rb:26
  Projects > Snippets > Project snippet Markdown file visiting with a line number anchor displays the blob using the simple viewer
    6.1 seconds ./spec/features/projects/snippets/show_spec.rb:129
  Projects > Snippets > Project snippet Markdown file visiting directly switching to the simple viewer switching to the rich viewer again displays the blob using the rich viewer
    5.57 seconds ./spec/features/projects/snippets/show_spec.rb:108
  Projects > Snippets > Project snippet Markdown file visiting directly displays the blob using the rich viewer
    4.44 seconds ./spec/features/projects/snippets/show_spec.rb:57
  Projects > Snippets > Project snippet behaves like showing user status shows the status
    2.94 seconds ./spec/support/shared_examples/features/showing_user_status_shared_examples.rb:6

Finished in 1 minute 10.89 seconds (files took 4.2 seconds to load)

spec/features/projects/snippets/show_spec.rb after

Top 7 slowest examples (26.83 seconds, 47.9% of total time):
  Projects > Snippets > Project snippet behaves like show and render proper snippet blob Ruby file displays the blob
    6.88 seconds ./spec/support/shared_examples/features/snippets_shared_examples.rb:76
  Projects > Snippets > Project snippet behaves like show and render proper snippet blob Markdown file visiting directly switching to the simple viewer displays the blob using the simple viewer
    6.02 seconds ./spec/support/shared_examples/features/snippets_shared_examples.rb:136
  Projects > Snippets > Project snippet behaves like show and render proper snippet blob Markdown file visiting with a line number anchor displays the blob using the simple viewer
    4.62 seconds ./spec/support/shared_examples/features/snippets_shared_examples.rb:174
  Projects > Snippets > Project snippet behaves like show and render proper snippet blob Markdown file visiting directly switching to the simple viewer switching to the rich viewer again displays the blob using the rich viewer
    3.92 seconds ./spec/support/shared_examples/features/snippets_shared_examples.rb:157
  Projects > Snippets > Project snippet behaves like show and render proper snippet blob Markdown file visiting directly displays the blob using the rich viewer
    3.3 seconds ./spec/support/shared_examples/features/snippets_shared_examples.rb:106
  Projects > Snippets > Project snippet behaves like showing user status shows the status
    1.53 seconds ./spec/support/shared_examples/features/showing_user_status_shared_examples.rb:6
  Projects > Snippets > Project snippet behaves like does not show New Snippet button is expected not to have visible link "New snippet"
    0.5688 seconds ./spec/support/shared_examples/features/snippets_shared_examples.rb:57

Finished in 56.05 seconds (files took 6.53 seconds to load)

spec/features/snippets/show_spec.rb before

Top 8 slowest examples (48.96 seconds, 52.9% of total time):
  Snippet Markdown file visiting directly switching to the simple viewer displays the blob using the simple viewer
    10.85 seconds ./spec/features/snippets/show_spec.rb:97
  Snippet Ruby file displays the blob
    10.47 seconds ./spec/features/snippets/show_spec.rb:23
  Snippet Markdown file visiting with a line number anchor displays the blob using the simple viewer
    7.62 seconds ./spec/features/snippets/show_spec.rb:139
  Snippet Markdown file visiting directly switching to the simple viewer switching to the rich viewer again displays the blob using the rich viewer
    7.24 seconds ./spec/features/snippets/show_spec.rb:118
  Snippet Markdown file visiting directly displays the blob using the rich viewer
    6.01 seconds ./spec/features/snippets/show_spec.rb:54
  Snippet when user cannot create snippets does not show the "New Snippet" button
    2.44 seconds ./spec/features/snippets/show_spec.rb:178
  Snippet Markdown file visiting directly Markdown rendering when rendering default markdown renders using CommonMark
    2.28 seconds ./spec/features/snippets/show_spec.rb:83
  Snippet behaves like showing user status shows the status
    2.04 seconds ./spec/support/shared_examples/features/showing_user_status_shared_examples.rb:6

Finished in 1 minute 32.49 seconds (files took 6.99 seconds to load)

spec/features/snippets/show_spec.rb after

Top 7 slowest examples (26.57 seconds, 47.6% of total time):
  Projects > Snippets > Project snippet behaves like show and render proper snippet blob Ruby file displays the blob
    6.3 seconds ./spec/support/shared_examples/features/snippets_shared_examples.rb:76
  Projects > Snippets > Project snippet behaves like show and render proper snippet blob Markdown file visiting directly switching to the simple viewer displays the blob using the simple viewer
    6.25 seconds ./spec/support/shared_examples/features/snippets_shared_examples.rb:136
  Projects > Snippets > Project snippet behaves like show and render proper snippet blob Markdown file visiting with a line number anchor displays the blob using the simple viewer
    4.63 seconds ./spec/support/shared_examples/features/snippets_shared_examples.rb:174
  Projects > Snippets > Project snippet behaves like show and render proper snippet blob Markdown file visiting directly switching to the simple viewer switching to the rich viewer again displays the blob using the rich viewer
    3.87 seconds ./spec/support/shared_examples/features/snippets_shared_examples.rb:157
  Projects > Snippets > Project snippet behaves like show and render proper snippet blob Markdown file visiting directly displays the blob using the rich viewer
    3.43 seconds ./spec/support/shared_examples/features/snippets_shared_examples.rb:106
  Projects > Snippets > Project snippet behaves like showing user status shows the status
    1.54 seconds ./spec/support/shared_examples/features/showing_user_status_shared_examples.rb:6
  Projects > Snippets > Project snippet behaves like does not show New Snippet button is expected not to have visible link "New snippet"
    0.55543 seconds ./spec/support/shared_examples/features/snippets_shared_examples.rb:57

Finished in 55.81 seconds (files took 6.26 seconds to load)

Does this MR meet the acceptance criteria?

Conformity

Merge request reports