Ruby on rails 5 轨道与cypress形成_,给出CSRF错误
我在这个问题上纠缠了将近两天 这是我正在使用的表单Ruby on rails 5 轨道与cypress形成_,给出CSRF错误,ruby-on-rails-5,integration-testing,cypress,cypress-cucumber-preprocessor,Ruby On Rails 5,Integration Testing,Cypress,Cypress Cucumber Preprocessor,我在这个问题上纠缠了将近两天 这是我正在使用的表单 <%= component "modal", title: "Remove Vessel", content_only: true do |c| %> <% c.body do %> <%= form_for @vessel, url: { controller: controller_n
<%= component "modal", title: "Remove Vessel", content_only: true do |c| %>
<% c.body do %>
<%= form_for @vessel,
url: {
controller: controller_name,
action: :remove
},
builder: WrappedFormBuilder,
remote: true, authenticity_token: true do |f| %>
<div class="modal__body">
<p>Do you want to move the users to another vessel?</p>
</br>
<p><b>Move Users to Vessel:</b></p>
<%= select_tag "vessel_id", options_from_collection_for_select((Vessel.all.where.not(id: @vessel.id)), "id", "name"), include_blank: 'Do not move users' %>
</div>
<div class="modal__footer">
<%= button_tag "Cancel",
type: :button,
class: "btn--link u-mr u-text-muted",
data: { cy: "vessel-removal-cancel", target: "form-activation.action", action: "modal#hide" } %>
<%= f.submit "Save",
class: "btn btn--primary",
data: {
cy: "vessel-submit",
disable_with: "Removing"
}
%>
</div>
<% end %>
<% end %>
<% end %>
最后给出了测试代码
it("remove an existing vessel with users", () => {
cy.get("[data-cy=vessel-1-remove]").click();
cy.wait(2000);
cy.get("[data-cy=vessel-submit]").click();
cy.wait(4000);
cy.get("[data-cy=vessel-1]").should("not.exist");
});
塞浦路斯显示了这一错误
CypressError:Cypress检测到页面加载时发生跨原点错误:
用“原点”阻止帧http://localhost:3000“从访问交叉原点帧
在页面加载之前,您已绑定到源策略:
http://localhost:3000
当应用程序导航到与上述源策略不匹配的新超域时,会发生跨源错误
这通常以以下三种方式之一发生:
@vessel = scope.find(params[:id])
authorize([:manage, :settings, @vessel])
if @vessel.move_users_and_delete(params[:vessel_id])
redirect_to edit_manage_organization_settings_meta_data_path,
flash: { success: "Users Moved and Vessel updated" }
else
render "delete", flash: { danger: "There were issues updating the vessel" }
end
it("remove an existing vessel with users", () => {
cy.get("[data-cy=vessel-1-remove]").click();
cy.wait(2000);
cy.get("[data-cy=vessel-submit]").click();
cy.wait(4000);
cy.get("[data-cy=vessel-1]").should("not.exist");
});