From 4bfdc922e9e9b79fef0821df58a4bbc4e2a86878 Mon Sep 17 00:00:00 2001 From: Michael Glass Date: Tue, 12 Nov 2024 15:35:10 +0100 Subject: [PATCH] add @mfonism's tests (thanks) --- spec/rails_edge_test/dsl_spec.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/spec/rails_edge_test/dsl_spec.rb b/spec/rails_edge_test/dsl_spec.rb index 4a1f402..0c78dbe 100644 --- a/spec/rails_edge_test/dsl_spec.rb +++ b/spec/rails_edge_test/dsl_spec.rb @@ -180,6 +180,29 @@ def another expect(test_value[2].body).to eq({this: 'deletes'}.to_json) end + it "can set authenticity token for the request" do + test_request = nil + + Module.new do + extend RailsEdgeTest::Dsl + + controller MyController do + action :simple do + edge "set the authenticity token" do + test_request = request + + set_authenticity_token + end + end + end + end + + allow_any_instance_of(MyController).to receive(:form_authenticity_token).and_return('a_test_token') + RailsEdgeTest::Dsl.execute! + + expect(test_request.headers['X-CSRF-Token']).to eq 'a_test_token' + end + it "can incorporate request, session, and params when making a request" do test_value = nil expected_value = {