mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-17 04:34:24 +00:00
Replace spree_get with simple call to get
This commit is contained in:
@@ -15,7 +15,7 @@ describe Admin::StripeAccountsController, type: :controller do
|
||||
end
|
||||
|
||||
it "redirects to Stripe Authorization url constructed OAuth" do
|
||||
spree_get :connect, enterprise_id: 1 # A deterministic id results in a deterministic state JWT token
|
||||
get :connect, enterprise_id: 1 # A deterministic id results in a deterministic state JWT token
|
||||
|
||||
expect(response).to redirect_to("https://connect.stripe.com/oauth/authorize?state=eyJhbGciOiJIUzI1NiJ9.eyJlbnRlcnByaXNlX2lkIjoiMSJ9.jSSFGn0bLhwuiQYK5ORmHWW7aay1l030bcfGwn1JbFg&scope=read_write&client_id=some_id&response_type=code")
|
||||
end
|
||||
@@ -98,7 +98,7 @@ describe Admin::StripeAccountsController, type: :controller do
|
||||
end
|
||||
|
||||
it "redirects to unauthorized" do
|
||||
spree_get :status, params
|
||||
get :status, params
|
||||
expect(response).to redirect_to unauthorized_path
|
||||
end
|
||||
end
|
||||
@@ -110,7 +110,7 @@ describe Admin::StripeAccountsController, type: :controller do
|
||||
|
||||
context "when Stripe is not enabled" do
|
||||
it "returns with a status of 'stripe_disabled'" do
|
||||
spree_get :status, params
|
||||
get :status, params
|
||||
json_response = JSON.parse(response.body)
|
||||
expect(json_response["status"]).to eq "stripe_disabled"
|
||||
end
|
||||
@@ -121,7 +121,7 @@ describe Admin::StripeAccountsController, type: :controller do
|
||||
|
||||
context "when no stripe account is associated with the specified enterprise" do
|
||||
it "returns with a status of 'account_missing'" do
|
||||
spree_get :status, params
|
||||
get :status, params
|
||||
json_response = JSON.parse(response.body)
|
||||
expect(json_response["status"]).to eq "account_missing"
|
||||
end
|
||||
@@ -136,7 +136,7 @@ describe Admin::StripeAccountsController, type: :controller do
|
||||
end
|
||||
|
||||
it "returns with a status of 'access_revoked'" do
|
||||
spree_get :status, params
|
||||
get :status, params
|
||||
json_response = JSON.parse(response.body)
|
||||
expect(json_response["status"]).to eq "access_revoked"
|
||||
end
|
||||
@@ -157,7 +157,7 @@ describe Admin::StripeAccountsController, type: :controller do
|
||||
end
|
||||
|
||||
it "returns with a status of 'connected'" do
|
||||
spree_get :status, params
|
||||
get :status, params
|
||||
json_response = JSON.parse(response.body)
|
||||
expect(json_response["status"]).to eq "connected"
|
||||
# serializes required attrs
|
||||
|
||||
@@ -17,7 +17,7 @@ describe Admin::StripeConnectSettingsController, type: :controller do
|
||||
before { allow(controller).to receive(:spree_current_user) { user } }
|
||||
|
||||
it "does not allow access" do
|
||||
spree_get :edit
|
||||
get :edit
|
||||
expect(response).to redirect_to unauthorized_path
|
||||
end
|
||||
end
|
||||
@@ -34,7 +34,7 @@ describe Admin::StripeConnectSettingsController, type: :controller do
|
||||
end
|
||||
|
||||
it "sets the account status to :empty_api_key_error_html" do
|
||||
spree_get :edit
|
||||
get :edit
|
||||
expect(assigns(:stripe_account)[:status]).to eq :empty_api_key_error_html
|
||||
expect(assigns(:settings).stripe_connect_enabled).to be true
|
||||
end
|
||||
@@ -52,7 +52,7 @@ describe Admin::StripeConnectSettingsController, type: :controller do
|
||||
end
|
||||
|
||||
it "sets the account status to :auth_fail_error" do
|
||||
spree_get :edit
|
||||
get :edit
|
||||
expect(assigns(:stripe_account)[:status]).to eq :auth_fail_error
|
||||
expect(assigns(:settings).stripe_connect_enabled).to be true
|
||||
end
|
||||
@@ -65,7 +65,7 @@ describe Admin::StripeConnectSettingsController, type: :controller do
|
||||
end
|
||||
|
||||
it "sets the account status to :ok, loads settings into Struct" do
|
||||
spree_get :edit
|
||||
get :edit
|
||||
expect(assigns(:stripe_account)[:status]).to eq :ok
|
||||
expect(assigns(:obfuscated_secret_key)).to eq "sk_test_****xxxx"
|
||||
expect(assigns(:settings).stripe_connect_enabled).to be true
|
||||
@@ -82,7 +82,7 @@ describe Admin::StripeConnectSettingsController, type: :controller do
|
||||
before { allow(controller).to receive(:spree_current_user) { user } }
|
||||
|
||||
it "does not allow access" do
|
||||
spree_get :update, params
|
||||
get :update, params
|
||||
expect(response).to redirect_to unauthorized_path
|
||||
end
|
||||
end
|
||||
@@ -95,7 +95,7 @@ describe Admin::StripeConnectSettingsController, type: :controller do
|
||||
|
||||
it "sets global config to the specified values" do
|
||||
expect(Spree::Config.stripe_connect_enabled).to be true
|
||||
spree_get :update, params
|
||||
get :update, params
|
||||
expect(Spree::Config.stripe_connect_enabled).to be false
|
||||
end
|
||||
end
|
||||
|
||||
@@ -19,7 +19,7 @@ describe Admin::SubscriptionsController, type: :controller do
|
||||
|
||||
context 'as a regular user' do
|
||||
it 'redirects to unauthorized' do
|
||||
spree_get :index, params
|
||||
get :index, params
|
||||
expect(response).to redirect_to unauthorized_path
|
||||
end
|
||||
end
|
||||
@@ -32,7 +32,7 @@ describe Admin::SubscriptionsController, type: :controller do
|
||||
let!(:subscription) { create(:subscription, shop: shop) }
|
||||
|
||||
it 'renders the index page with appropriate data' do
|
||||
spree_get :index, params
|
||||
get :index, params
|
||||
expect(response).to render_template 'index'
|
||||
expect(assigns(:collection)).to eq [] # No collection loaded
|
||||
expect(assigns(:shops)).to eq [shop] # Shops are loaded
|
||||
@@ -41,7 +41,7 @@ describe Admin::SubscriptionsController, type: :controller do
|
||||
|
||||
context "where I don't manage a shop that is set up for subscriptions" do
|
||||
it 'renders the setup_explanation page' do
|
||||
spree_get :index, params
|
||||
get :index, params
|
||||
expect(response).to render_template 'setup_explanation'
|
||||
expect(assigns(:collection)).to eq [] # No collection loaded
|
||||
expect(assigns(:shop)).to eq shop # First SO enabled shop is loaded
|
||||
@@ -56,7 +56,7 @@ describe Admin::SubscriptionsController, type: :controller do
|
||||
|
||||
context 'as a regular user' do
|
||||
it 'redirects to unauthorized' do
|
||||
spree_get :index, params
|
||||
get :index, params
|
||||
expect(response).to redirect_to unauthorized_path
|
||||
end
|
||||
end
|
||||
@@ -67,7 +67,7 @@ describe Admin::SubscriptionsController, type: :controller do
|
||||
let!(:subscription2) { create(:subscription, shop: shop2) }
|
||||
|
||||
it 'renders the collection as json' do
|
||||
spree_get :index, params
|
||||
get :index, params
|
||||
json_response = JSON.parse(response.body)
|
||||
expect(json_response.count).to be 2
|
||||
expect(json_response.map{ |so| so['id'] }).to include subscription.id, subscription2.id
|
||||
@@ -77,7 +77,7 @@ describe Admin::SubscriptionsController, type: :controller do
|
||||
before { params.merge!(q: { shop_id_eq: shop2.id }) }
|
||||
|
||||
it "restricts the list of subscriptions" do
|
||||
spree_get :index, params
|
||||
get :index, params
|
||||
json_response = JSON.parse(response.body)
|
||||
expect(json_response.count).to be 1
|
||||
ids = json_response.map{ |so| so['id'] }
|
||||
@@ -99,7 +99,7 @@ describe Admin::SubscriptionsController, type: :controller do
|
||||
|
||||
it 'loads the preloads the necessary data' do
|
||||
expect(controller).to receive(:load_form_data)
|
||||
spree_get :new, subscription: { shop_id: shop.id }
|
||||
get :new, subscription: { shop_id: shop.id }
|
||||
expect(assigns(:subscription)).to be_a_new Subscription
|
||||
expect(assigns(:subscription).shop).to eq shop
|
||||
end
|
||||
@@ -238,7 +238,7 @@ describe Admin::SubscriptionsController, type: :controller do
|
||||
|
||||
it 'loads the preloads the necessary data' do
|
||||
expect(controller).to receive(:load_form_data)
|
||||
spree_get :edit, id: subscription.id
|
||||
get :edit, id: subscription.id
|
||||
expect(assigns(:subscription)).to eq subscription
|
||||
end
|
||||
end
|
||||
|
||||
@@ -19,7 +19,7 @@ module Api
|
||||
end
|
||||
|
||||
it "lists customers associated with the current user" do
|
||||
spree_get :index
|
||||
get :index
|
||||
expect(response.status).to eq 200
|
||||
expect(json_response.length).to eq 1
|
||||
expect(json_response.first[:id]).to eq customer1.id
|
||||
|
||||
@@ -26,7 +26,7 @@ module Api
|
||||
let(:products_relation) { Spree::Product.where("1=0") }
|
||||
|
||||
it "handles it gracefully" do
|
||||
spree_get :index, exchange_id: exchange.id
|
||||
get :index, exchange_id: exchange.id
|
||||
expect(json_response["products"].length).to eq 0
|
||||
end
|
||||
end
|
||||
@@ -36,7 +36,7 @@ module Api
|
||||
|
||||
describe "when an exchange id param is provided" do
|
||||
it "uses exchange order_cycle, incoming and enterprise to fetch products" do
|
||||
spree_get :index, exchange_id: exchange.id, order_cycle_id: 666, enterprise_id: 666, incoming: false
|
||||
get :index, exchange_id: exchange.id, order_cycle_id: 666, enterprise_id: 666, incoming: false
|
||||
expect(json_response["products"].first["supplier_name"]).to eq exchange.variants.first.product.supplier.name
|
||||
end
|
||||
end
|
||||
@@ -59,7 +59,7 @@ module Api
|
||||
|
||||
describe "when a specific page is requested" do
|
||||
it "returns the requested page with paginated data" do
|
||||
spree_get :index, exchange_id: exchange.id, page: 1
|
||||
get :index, exchange_id: exchange.id, page: 1
|
||||
|
||||
expect(json_response["products"].size).to eq 1
|
||||
expect(json_response["pagination"]["results"]).to eq 2
|
||||
@@ -69,7 +69,7 @@ module Api
|
||||
|
||||
describe "when no specific page is requested" do
|
||||
it "returns all results without paginating" do
|
||||
spree_get :index, exchange_id: exchange.id
|
||||
get :index, exchange_id: exchange.id
|
||||
|
||||
expect(json_response["products"].size).to eq 2
|
||||
expect(json_response["pagination"]).to be nil
|
||||
|
||||
@@ -23,7 +23,7 @@ describe Api::ShopsController, type: :controller do
|
||||
|
||||
describe "#show" do
|
||||
it "returns shopfront data for an enterprise" do
|
||||
spree_get :show, id: producer.id
|
||||
get :show, id: producer.id
|
||||
|
||||
expect(json_response['name']).to eq 'Shopfront Test Producer'
|
||||
expect(json_response['hubs'][0]['name']).to eq 'Shopfront Test Hub'
|
||||
@@ -33,7 +33,7 @@ describe Api::ShopsController, type: :controller do
|
||||
|
||||
describe "#closed_shops" do
|
||||
it "returns data for all closed shops" do
|
||||
spree_get :closed_shops, {}
|
||||
get :closed_shops, {}
|
||||
|
||||
expect(json_response).not_to match hub.name
|
||||
|
||||
|
||||
@@ -9,21 +9,21 @@ module Api
|
||||
describe "job queue status" do
|
||||
it "returns alive when up to date" do
|
||||
Spree::Config.last_job_queue_heartbeat_at = Time.now.in_time_zone
|
||||
spree_get :job_queue
|
||||
get :job_queue
|
||||
expect(response).to be_success
|
||||
expect(response.body).to eq({ alive: true }.to_json)
|
||||
end
|
||||
|
||||
it "returns dead otherwise" do
|
||||
Spree::Config.last_job_queue_heartbeat_at = 10.minutes.ago
|
||||
spree_get :job_queue
|
||||
get :job_queue
|
||||
expect(response).to be_success
|
||||
expect(response.body).to eq({ alive: false }.to_json)
|
||||
end
|
||||
|
||||
it "returns dead when no heartbeat recorded" do
|
||||
Spree::Config.last_job_queue_heartbeat_at = nil
|
||||
spree_get :job_queue
|
||||
get :job_queue
|
||||
expect(response).to be_success
|
||||
expect(response.body).to eq({ alive: false }.to_json)
|
||||
end
|
||||
|
||||
@@ -26,7 +26,7 @@ describe Api::VariantsController, type: :controller do
|
||||
end
|
||||
|
||||
it "retrieves a list of variants with appropriate attributes" do
|
||||
spree_get :index, format: :json
|
||||
get :index, format: :json
|
||||
|
||||
keys = json_response.first.keys.map(&:to_sym)
|
||||
expect(attributes.all?{ |attr| keys.include? attr }).to eq(true)
|
||||
|
||||
@@ -8,7 +8,7 @@ describe ShopController, type: :controller do
|
||||
let(:distributor) { create(:distributor_enterprise, payment_methods: [pm], shipping_methods: [sm]) }
|
||||
|
||||
it "redirects to the home page if no distributor is selected" do
|
||||
spree_get :show
|
||||
get :show
|
||||
expect(response).to redirect_to root_path
|
||||
end
|
||||
|
||||
@@ -20,14 +20,14 @@ describe ShopController, type: :controller do
|
||||
describe "selecting an order cycle" do
|
||||
it "should select an order cycle when only one order cycle is open" do
|
||||
oc1 = create(:simple_order_cycle, distributors: [distributor])
|
||||
spree_get :show
|
||||
get :show
|
||||
expect(controller.current_order_cycle).to eq(oc1)
|
||||
end
|
||||
|
||||
it "should not set an order cycle when multiple order cycles are open" do
|
||||
oc1 = create(:simple_order_cycle, distributors: [distributor])
|
||||
oc2 = create(:simple_order_cycle, distributors: [distributor])
|
||||
spree_get :show
|
||||
get :show
|
||||
expect(controller.current_order_cycle).to be_nil
|
||||
end
|
||||
|
||||
@@ -55,7 +55,7 @@ describe ShopController, type: :controller do
|
||||
it "should return the current order cycle when hit with GET" do
|
||||
oc1 = create(:simple_order_cycle, distributors: [distributor])
|
||||
allow(controller).to receive(:current_order_cycle).and_return oc1
|
||||
spree_get :order_cycle
|
||||
get :order_cycle
|
||||
expect(response.body).to have_content oc1.id
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user