Skip to content

Commit

Permalink
[fix][cms] history/log's controller and ref_coll (#3871)
Browse files Browse the repository at this point in the history
* [modify] refactor w/ Rubocop

* [modify] add examinations to history/log

* [fix] invalid value is set to #controller and "#ref_coll" of history/log

* [modify] this modification could stabilize specs up

* [modify] move spec file to appropriate directory and split into individual specs

* [modify] add more specs to examine history/log

* [modify^2] add more specs to examine history/log
  • Loading branch information
sunny4381 committed Apr 2, 2021
1 parent 67ebdea commit 3275aa4
Show file tree
Hide file tree
Showing 15 changed files with 1,132 additions and 313 deletions.
8 changes: 4 additions & 4 deletions app/models/cms/column/value/free.rb
Expand Up @@ -131,10 +131,10 @@ def create_history_log(file)
user_id: user_id,
session_id: Rails.application.current_session_id,
request_id: Rails.application.current_request_id,
controller: self.model_name.i18n_key,
controller: Rails.application.current_controller,
url: file.try(:url),
page_url: Rails.application.current_path_info,
ref_coll: file.try(:collection_name)
ref_coll: file.try(:collection_name).to_s
)
end

Expand All @@ -145,7 +145,7 @@ def put_contains_urls_logs
item.url = file
item.action = "update"
item.behavior = "paste"
item.ref_coll = ":ss_files"
item.ref_coll = "ss_files"
item.save
end

Expand All @@ -155,7 +155,7 @@ def put_contains_urls_logs
item.url = file
item.action = "destroy"
item.behavior = "paste"
item.ref_coll = ":ss_files"
item.ref_coll = "ss_files"
item.save
end
end
Expand Down
8 changes: 4 additions & 4 deletions app/models/concerns/cms/addon/file.rb
Expand Up @@ -148,10 +148,10 @@ def create_history_log(file)
user_id: user_id,
session_id: Rails.application.current_session_id,
request_id: Rails.application.current_request_id,
controller: self.model_name.i18n_key,
controller: Rails.application.current_controller,
url: file.try(:url),
page_url: Rails.application.current_path_info,
ref_coll: file.try(:collection_name)
ref_coll: file.try(:collection_name).to_s
)
end

Expand All @@ -162,7 +162,7 @@ def put_contains_urls_logs
item.url = file
item.action = "update"
item.behavior = "paste"
item.ref_coll = ":ss_files"
item.ref_coll = "ss_files"
item.save
end

Expand All @@ -172,7 +172,7 @@ def put_contains_urls_logs
item.url = file
item.action = "destroy"
item.behavior = "paste"
item.ref_coll = ":ss_files"
item.ref_coll = "ss_files"
item.save
end
end
Expand Down
5 changes: 5 additions & 0 deletions config/application.rb
Expand Up @@ -91,6 +91,11 @@ def current_request_id
end
end

def current_controller
return if current_request.nil?
current_request.params[:controller]
end

def current_path_info
return if current_env.nil?
current_env["PATH_INFO"]
Expand Down
4 changes: 4 additions & 0 deletions spec/features/article/pages/attach_file_spec.rb
Expand Up @@ -50,6 +50,7 @@

it "#edit file name" do
visit edit_path
ensure_addon_opened("#addon-cms-agents-addons-file")
within "form#item-form" do
within "#addon-cms-agents-addons-file" do
wait_cbox_open do
Expand Down Expand Up @@ -84,6 +85,7 @@

it do
visit edit_path
ensure_addon_opened("#addon-cms-agents-addons-file")
within "form#item-form" do
within "#addon-cms-agents-addons-file" do
wait_cbox_open do
Expand Down Expand Up @@ -130,6 +132,7 @@
login_user(user2)

visit edit_path
ensure_addon_opened("#addon-cms-agents-addons-file")
within "form#item-form" do
within "#addon-cms-agents-addons-file" do
wait_cbox_open do
Expand Down Expand Up @@ -185,6 +188,7 @@
it do
login_user(user2)
visit edit_path
ensure_addon_opened("#addon-cms-agents-addons-file")
within "form#item-form" do
within "#addon-cms-agents-addons-file" do
wait_cbox_open do
Expand Down
3 changes: 3 additions & 0 deletions spec/features/article/pages/contrast_ratio_spec.rb
Expand Up @@ -18,6 +18,7 @@
it do
visit article_page_path(site: site, cid: node, id: item)

ensure_addon_opened("#addon-cms-agents-addons-file")
within "#addon-cms-agents-addons-file" do
expect(page).to have_css(".file-view[data-file-id='#{file1.id}']", text: file1.name)
wait_cbox_open do
Expand Down Expand Up @@ -126,6 +127,7 @@
it do
visit edit_article_page_path(site: site, cid: node, id: item)

ensure_addon_opened("#addon-cms-agents-addons-file")
within "#addon-cms-agents-addons-file" do
expect(page).to have_css(".file-view[data-file-id='#{file1.id}']", text: file1.name)
wait_cbox_open do
Expand All @@ -147,6 +149,7 @@
it do
visit edit_article_page_path(site: site, cid: node, id: item)

ensure_addon_opened("#addon-cms-agents-addons-file")
within "#addon-cms-agents-addons-file" do
expect(page).to have_css(".file-view[data-file-id='#{file1.id}']", text: file1.name)
wait_cbox_open do
Expand Down

0 comments on commit 3275aa4

Please sign in to comment.