Skip to content

Commit

Permalink
[move] add more specs to examine history/log
Browse files Browse the repository at this point in the history
  • Loading branch information
sunny4381 committed Mar 17, 2021
1 parent 024c100 commit 18151d4
Show file tree
Hide file tree
Showing 2 changed files with 336 additions and 0 deletions.
167 changes: 167 additions & 0 deletions spec/features/history/cms/logs/paste_thumb_on_free_column_spec.rb
Expand Up @@ -48,6 +48,75 @@
click_on I18n.t("ss.buttons.publish_save")
wait_for_notice I18n.t("ss.notice.saved")

item.reload
expect(item.column_values.count).to eq 1
expect(item.column_values.first.files.count).to eq 1
file_url = item.column_values.first.files.first.url
thumb_file_url = file_url.sub("/_/", "/_/thumb/")

History::Log.all.reorder(created: 1, id: 1).to_a.tap do |histories|
histories[0].tap do |history|
expect(history.user_id).to eq cms_user.id
expect(history.session_id).to be_present
expect(history.request_id).to be_present
expect(history.url).to eq sns_login_path
expect(history.controller).to eq "sns/login"
expect(history.action).to eq "login"
expect(history.target_id).to be_blank
expect(history.target_class).to be_blank
expect(history.page_url).to be_blank
expect(history.behavior).to be_blank
expect(history.ref_coll).to eq "ss_users"
expect(history.filename).to be_blank
end
histories[1].tap do |history|
expect(history.user_id).to eq cms_user.id
expect(history.session_id).to eq histories[0].session_id
expect(history.request_id).to be_present
expect(history.request_id).not_to eq histories[0].request_id
expect(history.url).to eq edit_path
expect(history.controller).to eq "article/pages"
expect(history.action).to eq "login"
expect(history.target_id).to be_blank
expect(history.target_class).to be_blank
expect(history.page_url).to be_blank
expect(history.behavior).to be_blank
expect(history.ref_coll).to eq "ss_sites"
expect(history.filename).to be_blank
end
histories[2].tap do |history|
expect(history.user_id).to eq cms_user.id
expect(history.session_id).to eq histories[0].session_id
expect(history.request_id).to be_present
expect(history.request_id).not_to eq histories[1].request_id
expect(history.url).to eq file_url
expect(history.controller).to eq "article/pages"
expect(history.action).to eq "update"
expect(history.target_id).to be_blank
expect(history.target_class).to be_blank
expect(history.page_url).to eq article_page_path(site: site, cid: node, id: item)
expect(history.behavior).to eq "attachment"
expect(history.ref_coll).to eq "ss_files"
expect(history.filename).to be_blank
end
histories[3].tap do |history|
expect(history.user_id).to eq cms_user.id
expect(history.session_id).to eq histories[0].session_id
expect(history.request_id).to eq histories[2].request_id
expect(history.url).to eq article_page_path(site: site, cid: node, id: item)
expect(history.controller).to eq "article/pages"
expect(history.action).to eq "update"
expect(history.target_id).to be_blank
expect(history.target_class).to be_blank
expect(history.page_url).to be_blank
expect(history.behavior).to be_blank
expect(history.ref_coll).to eq "cms_pages"
expect(history.filename).to be_blank
end
end
expect(History::Log.all.count).to eq 4
expect(History::Log.where(site_id: site.id).count).to eq 3

visit logs_path
expect(page).to have_css('.list-item', count: 3)

Expand All @@ -65,6 +134,54 @@
end
wait_for_notice I18n.t("ss.notice.saved")

History::Log.all.reorder(created: 1, id: 1).to_a.tap do |histories|
histories[4].tap do |history|
expect(history.user_id).to eq cms_user.id
expect(history.session_id).to eq histories[0].session_id
expect(history.request_id).to be_present
expect(history.request_id).not_to eq histories[3].request_id
expect(history.url).to eq file_url
expect(history.controller).to eq "article/pages"
expect(history.action).to eq "update"
expect(history.target_id).to be_blank
expect(history.target_class).to be_blank
expect(history.page_url).to eq article_page_path(site: site, cid: node, id: item)
expect(history.behavior).to eq "paste"
expect(history.ref_coll).to eq "ss_files"
expect(history.filename).to be_blank
end
histories[5].tap do |history|
expect(history.user_id).to eq cms_user.id
expect(history.session_id).to eq histories[0].session_id
expect(history.request_id).to eq histories[4].request_id
expect(history.url).to eq thumb_file_url
expect(history.controller).to eq "article/pages"
expect(history.action).to eq "update"
expect(history.target_id).to be_blank
expect(history.target_class).to be_blank
expect(history.page_url).to eq article_page_path(site: site, cid: node, id: item)
expect(history.behavior).to eq "paste"
expect(history.ref_coll).to eq "ss_files"
expect(history.filename).to be_blank
end
histories[6].tap do |history|
expect(history.user_id).to eq cms_user.id
expect(history.session_id).to eq histories[0].session_id
expect(history.request_id).to eq histories[4].request_id
expect(history.url).to eq article_page_path(site: site, cid: node, id: item)
expect(history.controller).to eq "article/pages"
expect(history.action).to eq "update"
expect(history.target_id).to be_blank
expect(history.target_class).to be_blank
expect(history.page_url).to be_blank
expect(history.behavior).to be_blank
expect(history.ref_coll).to eq "cms_pages"
expect(history.filename).to be_blank
end
end
expect(History::Log.all.count).to eq 7
expect(History::Log.where(site_id: site.id).count).to eq 6

visit logs_path
expect(page).to have_css('.list-item', count: 6)

Expand All @@ -73,6 +190,56 @@
click_on I18n.t("ss.buttons.publish_save")
wait_for_notice I18n.t("ss.notice.saved")

History::Log.all.reorder(created: 1, id: 1).to_a.tap do |histories|
histories[7].tap do |history|
expect(history.user_id).to eq cms_user.id
expect(history.session_id).to eq histories[0].session_id
expect(history.request_id).to be_present
expect(history.request_id).not_to eq histories[6].request_id
expect(history.url).to eq file_url
expect(history.controller).to eq "article/pages"
expect(history.action).to eq "destroy"
expect(history.target_id).to be_blank
expect(history.target_class).to be_blank
expect(history.page_url).to eq article_page_path(site: site, cid: node, id: item)
expect(history.behavior).to eq "paste"
expect(history.ref_coll).to eq "ss_files"
expect(history.filename).to be_blank
end
histories[8].tap do |history|
expect(history.user_id).to eq cms_user.id
expect(history.session_id).to eq histories[0].session_id
expect(history.request_id).to be_present
expect(history.request_id).not_to eq histories[3].request_id
expect(history.url).to eq thumb_file_url
expect(history.controller).to eq "article/pages"
expect(history.action).to eq "destroy"
expect(history.target_id).to be_blank
expect(history.target_class).to be_blank
expect(history.page_url).to eq article_page_path(site: site, cid: node, id: item)
expect(history.behavior).to eq "paste"
expect(history.ref_coll).to eq "ss_files"
expect(history.filename).to be_blank
end
histories[9].tap do |history|
expect(history.user_id).to eq cms_user.id
expect(history.session_id).to eq histories[0].session_id
expect(history.request_id).to be_present
expect(history.request_id).not_to eq histories[3].request_id
expect(history.url).to eq article_page_path(site: site, cid: node, id: item)
expect(history.controller).to eq "article/pages"
expect(history.action).to eq "update"
expect(history.target_id).to be_blank
expect(history.target_class).to be_blank
expect(history.page_url).to be_blank
expect(history.behavior).to be_blank
expect(history.ref_coll).to eq "cms_pages"
expect(history.filename).to be_blank
end
end
expect(History::Log.all.count).to eq 10
expect(History::Log.where(site_id: site.id).count).to eq 9

visit logs_path
expect(page).to have_css('.list-item', count: 9)
end
Expand Down
169 changes: 169 additions & 0 deletions spec/features/history/cms/logs/paste_thumb_spec.rb
Expand Up @@ -40,6 +40,77 @@
click_on I18n.t("ss.buttons.publish_save")
wait_for_notice I18n.t("ss.notice.saved")

item.reload
expect(item.files.count).to eq 1
file_url = item.files.first.url
thumb_file_url = file_url.sub("/_/", "/_/thumb/")

History::Log.all.reorder(created: 1, id: 1).to_a.tap do |histories|
histories[0].tap do |history|
expect(history.user_id).to eq cms_user.id
expect(history.session_id).to be_present
expect(history.request_id).to be_present
expect(history.url).to eq sns_login_path
expect(history.controller).to eq "sns/login"
expect(history.action).to eq "login"
expect(history.target_id).to be_blank
expect(history.target_class).to be_blank
expect(history.page_url).to be_blank
expect(history.behavior).to be_blank
expect(history.ref_coll).to eq "ss_users"
expect(history.filename).to be_blank
end
histories[1].tap do |history|
expect(history.user_id).to eq cms_user.id
expect(history.session_id).to eq histories[0].session_id
expect(history.request_id).to be_present
expect(history.request_id).not_to eq histories[0].request_id
expect(history.url).to eq edit_path
expect(history.controller).to eq "article/pages"
expect(history.action).to eq "login"
expect(history.target_id).to be_blank
expect(history.target_class).to be_blank
expect(history.page_url).to be_blank
expect(history.behavior).to be_blank
expect(history.ref_coll).to eq "ss_sites"
expect(history.filename).to be_blank
end
histories[2].tap do |history|
expect(history.user_id).to eq cms_user.id
expect(history.session_id).to eq histories[0].session_id
expect(history.request_id).to be_present
expect(history.request_id).not_to eq histories[1].request_id
expect(history.url).to eq file_url
expect(history.controller).to eq "article/pages"
expect(history.action).to eq "update"
expect(history.target_id).to be_blank
expect(history.target_class).to be_blank
expect(history.page_url).to eq article_page_path(site: site, cid: node, id: item)
expect(history.behavior).to eq "attachment"
expect(history.ref_coll).to eq "ss_files"
expect(history.filename).to be_blank
end
histories[3].tap do |history|
expect(history.user_id).to eq cms_user.id
expect(history.session_id).to eq histories[0].session_id
expect(history.request_id).to eq histories[2].request_id
expect(history.url).to eq article_page_path(site: site, cid: node, id: item)
expect(history.controller).to eq "article/pages"
expect(history.action).to eq "update"
expect(history.target_id).to be_blank
expect(history.target_class).to be_blank
expect(history.page_url).to be_blank
expect(history.behavior).to be_blank
expect(history.ref_coll).to eq "cms_pages"
expect(history.filename).to be_blank
end
end
expect(History::Log.all.count).to eq 4
expect(History::Log.where(site_id: site.id).count).to eq 3

visit logs_path
expect(page).to have_css('.list-item', count: 3)

visit edit_path
ensure_addon_opened "#addon-cms-agents-addons-file"
within "#addon-cms-agents-addons-file" do
Expand All @@ -55,6 +126,54 @@
end
wait_for_notice I18n.t("ss.notice.saved")

History::Log.all.reorder(created: 1, id: 1).to_a.tap do |histories|
histories[4].tap do |history|
expect(history.user_id).to eq cms_user.id
expect(history.session_id).to eq histories[0].session_id
expect(history.request_id).to be_present
expect(history.request_id).not_to eq histories[3].request_id
expect(history.url).to eq file_url
expect(history.controller).to eq "article/pages"
expect(history.action).to eq "update"
expect(history.target_id).to be_blank
expect(history.target_class).to be_blank
expect(history.page_url).to eq article_page_path(site: site, cid: node, id: item)
expect(history.behavior).to eq "paste"
expect(history.ref_coll).to eq "ss_files"
expect(history.filename).to be_blank
end
histories[5].tap do |history|
expect(history.user_id).to eq cms_user.id
expect(history.session_id).to eq histories[0].session_id
expect(history.request_id).to eq histories[4].request_id
expect(history.url).to eq thumb_file_url
expect(history.controller).to eq "article/pages"
expect(history.action).to eq "update"
expect(history.target_id).to be_blank
expect(history.target_class).to be_blank
expect(history.page_url).to eq article_page_path(site: site, cid: node, id: item)
expect(history.behavior).to eq "paste"
expect(history.ref_coll).to eq "ss_files"
expect(history.filename).to be_blank
end
histories[6].tap do |history|
expect(history.user_id).to eq cms_user.id
expect(history.session_id).to eq histories[0].session_id
expect(history.request_id).to eq histories[4].request_id
expect(history.url).to eq article_page_path(site: site, cid: node, id: item)
expect(history.controller).to eq "article/pages"
expect(history.action).to eq "update"
expect(history.target_id).to be_blank
expect(history.target_class).to be_blank
expect(history.page_url).to be_blank
expect(history.behavior).to be_blank
expect(history.ref_coll).to eq "cms_pages"
expect(history.filename).to be_blank
end
end
expect(History::Log.all.count).to eq 7
expect(History::Log.where(site_id: site.id).count).to eq 6

visit logs_path
expect(page).to have_css('.list-item', count: 6)

Expand All @@ -63,6 +182,56 @@
click_on I18n.t("ss.buttons.publish_save")
wait_for_notice I18n.t("ss.notice.saved")

History::Log.all.reorder(created: 1, id: 1).to_a.tap do |histories|
histories[7].tap do |history|
expect(history.user_id).to eq cms_user.id
expect(history.session_id).to eq histories[0].session_id
expect(history.request_id).to be_present
expect(history.request_id).not_to eq histories[6].request_id
expect(history.url).to eq file_url
expect(history.controller).to eq "article/pages"
expect(history.action).to eq "destroy"
expect(history.target_id).to be_blank
expect(history.target_class).to be_blank
expect(history.page_url).to eq article_page_path(site: site, cid: node, id: item)
expect(history.behavior).to eq "paste"
expect(history.ref_coll).to eq "ss_files"
expect(history.filename).to be_blank
end
histories[8].tap do |history|
expect(history.user_id).to eq cms_user.id
expect(history.session_id).to eq histories[0].session_id
expect(history.request_id).to be_present
expect(history.request_id).not_to eq histories[3].request_id
expect(history.url).to eq thumb_file_url
expect(history.controller).to eq "article/pages"
expect(history.action).to eq "destroy"
expect(history.target_id).to be_blank
expect(history.target_class).to be_blank
expect(history.page_url).to eq article_page_path(site: site, cid: node, id: item)
expect(history.behavior).to eq "paste"
expect(history.ref_coll).to eq "ss_files"
expect(history.filename).to be_blank
end
histories[9].tap do |history|
expect(history.user_id).to eq cms_user.id
expect(history.session_id).to eq histories[0].session_id
expect(history.request_id).to be_present
expect(history.request_id).not_to eq histories[3].request_id
expect(history.url).to eq article_page_path(site: site, cid: node, id: item)
expect(history.controller).to eq "article/pages"
expect(history.action).to eq "update"
expect(history.target_id).to be_blank
expect(history.target_class).to be_blank
expect(history.page_url).to be_blank
expect(history.behavior).to be_blank
expect(history.ref_coll).to eq "cms_pages"
expect(history.filename).to be_blank
end
end
expect(History::Log.all.count).to eq 10
expect(History::Log.where(site_id: site.id).count).to eq 9

visit logs_path
expect(page).to have_css('.list-item', count: 9)
end
Expand Down

0 comments on commit 18151d4

Please sign in to comment.