Enforce RSpec expect(..).not_to over to_not

This commit is contained in:
Maikel Linke
2024-03-07 16:57:54 +11:00
parent b4385623b2
commit bd6b0ddbf3
163 changed files with 616 additions and 613 deletions

View File

@@ -182,7 +182,7 @@ module Admin
customer: { email: 'new.email@gmail.com' }
expect(response).to redirect_to unauthorized_path
expect(assigns(:customer)).to eq nil
expect(customer.email).to_not eq 'new.email@gmail.com'
expect(customer.email).not_to eq 'new.email@gmail.com'
end
end
end

View File

@@ -168,7 +168,7 @@ describe Admin::EnterprisesController, type: :controller do
spree_post :update, update_params
distributor.reload
expect(distributor.users).to_not include user
expect(distributor.users).not_to include user
end
it "updates the contact for notifications" do
@@ -190,7 +190,7 @@ describe Admin::EnterprisesController, type: :controller do
}
expect { spree_post :update, params }.
to_not change { distributor.contact }
not_to change { distributor.contact }
end
it "updates enterprise preferences" do
@@ -223,7 +223,7 @@ describe Admin::EnterprisesController, type: :controller do
expect(Spree::Property.count).to be 1
expect(ProducerProperty.count).to be 0
property_names = producer.reload.properties.map(&:name)
expect(property_names).to_not include 'a different name'
expect(property_names).not_to include 'a different name'
end
end
@@ -721,7 +721,7 @@ describe Admin::EnterprisesController, type: :controller do
it "scopes @collection to enterprises editable by the user" do
get :index, format: :json
expect(assigns(:collection)).to include enterprise1, enterprise2
expect(assigns(:collection)).to_not include enterprise3
expect(assigns(:collection)).not_to include enterprise3
end
end
end

View File

@@ -37,7 +37,7 @@ module Admin
context "where ransack conditions are specified" do
it "loads order cycles closed within past month, and orders w/o a close_at date" do
get :index, as: :json
expect(assigns(:collection)).to_not include oc1, oc2
expect(assigns(:collection)).not_to include oc1, oc2
expect(assigns(:collection)).to include oc3, oc4
end
end
@@ -47,7 +47,7 @@ module Admin
it "loads order cycles closed after specified date, and orders w/o a close_at date" do
get :index, as: :json, params: { q: }
expect(assigns(:collection)).to_not include oc1
expect(assigns(:collection)).not_to include oc1
expect(assigns(:collection)).to include oc2, oc3, oc4
end
@@ -56,7 +56,7 @@ module Admin
it "loads order cycles that meet all conditions" do
get :index, format: :json, params: { q: }
expect(assigns(:collection)).to_not include oc1, oc2, oc4
expect(assigns(:collection)).not_to include oc1, oc2, oc4
expect(assigns(:collection)).to include oc3
end
end
@@ -415,9 +415,9 @@ module Admin
} } }
oc.reload
expect(oc.name).to_not eq "Updated Order Cycle"
expect(oc.orders_open_at.to_date).to_not eq Date.current - 21.days
expect(oc.orders_close_at.to_date).to_not eq Date.current + 21.days
expect(oc.name).not_to eq "Updated Order Cycle"
expect(oc.orders_open_at.to_date).not_to eq Date.current - 21.days
expect(oc.orders_close_at.to_date).not_to eq Date.current + 21.days
end
end
end
@@ -505,8 +505,8 @@ module Admin
get :destroy, params: { id: cloned.id }
expect(OrderCycle.find_by(id: cloned.id)).to be nil
expect(OrderCycle.find_by(id: oc.id)).to_not be nil
expect(EnterpriseFee.find_by(id: enterprise_fee1.id)).to_not be nil
expect(OrderCycle.find_by(id: oc.id)).not_to be nil
expect(EnterpriseFee.find_by(id: enterprise_fee1.id)).not_to be nil
expect(response).to redirect_to admin_order_cycles_path
end
end

View File

@@ -162,7 +162,7 @@ describe Admin::ReportsController, type: :controller do
report_types = assigns(:reports).keys
expect(report_types).to include :orders_and_fulfillment,
:products_and_inventory, :packing # and others
expect(report_types).to_not include :sales_tax
expect(report_types).not_to include :sales_tax
end
end
@@ -365,7 +365,7 @@ describe Admin::ReportsController, type: :controller do
spree_get :show, report_type: :sales_tax, report_subtype: report_type
expect(response).to have_http_status(:ok)
expect(resulting_orders_prelim).to include(orderA1, orderB1)
expect(resulting_orders_prelim).to_not include(orderA2, orderB2)
expect(resulting_orders_prelim).not_to include(orderA2, orderB2)
end
end
end

View File

@@ -115,7 +115,7 @@ describe Admin::SchedulesController, type: :controller do
uncoordinated_order_cycle,
uncoordinated_order_cycle3
# coordinated_order_cycle is removed, uncoordinated_order_cycle2 is NOT added
expect(coordinated_schedule.reload.order_cycles).to_not include coordinated_order_cycle,
expect(coordinated_schedule.reload.order_cycles).not_to include coordinated_order_cycle,
uncoordinated_order_cycle2
end
@@ -145,7 +145,7 @@ describe Admin::SchedulesController, type: :controller do
schedule: { name: "my awesome schedule" }
expect(response).to redirect_to unauthorized_path
expect(assigns(:schedule)).to eq nil
expect(coordinated_schedule.name).to_not eq "my awesome schedule"
expect(coordinated_schedule.name).not_to eq "my awesome schedule"
end
end
end
@@ -173,7 +173,7 @@ describe Admin::SchedulesController, type: :controller do
context "where no order cycles ids are provided" do
it "does not allow me to create the schedule" do
expect { create_schedule params }.to_not change { Schedule.count }
expect { create_schedule params }.not_to change { Schedule.count }
end
end
@@ -187,7 +187,7 @@ describe Admin::SchedulesController, type: :controller do
expect { create_schedule params }.to change { Schedule.count }.by(1)
schedule = Schedule.last
expect(schedule.order_cycles).to include coordinated_order_cycle
expect(schedule.order_cycles).to_not include uncoordinated_order_cycle
expect(schedule.order_cycles).not_to include uncoordinated_order_cycle
end
it "sync proxy orders" do
@@ -205,7 +205,7 @@ describe Admin::SchedulesController, type: :controller do
end
it "prevents me from creating the schedule" do
expect { create_schedule params }.to_not change { Schedule.count }
expect { create_schedule params }.not_to change { Schedule.count }
end
end
end
@@ -257,7 +257,7 @@ describe Admin::SchedulesController, type: :controller do
let!(:subscription) { create(:subscription, schedule: coordinated_schedule) }
it "returns an error message and prevents me from deleting the schedule" do
expect { spree_delete :destroy, params }.to_not change { Schedule.count }
expect { spree_delete :destroy, params }.not_to change { Schedule.count }
json_response = JSON.parse(response.body)
expect(json_response["errors"])
.to include 'This schedule cannot be deleted ' \
@@ -270,7 +270,7 @@ describe Admin::SchedulesController, type: :controller do
before { params.merge!(id: uncoordinated_schedule.id) }
it "prevents me from destroying the schedule" do
expect { spree_delete :destroy, params }.to_not change { Schedule.count }
expect { spree_delete :destroy, params }.not_to change { Schedule.count }
end
end
end

View File

@@ -81,7 +81,7 @@ describe Admin::SubscriptionsController, type: :controller do
expect(json_response.count).to be 1
ids = json_response.map{ |so| so['id'] }
expect(ids).to include subscription2.id
expect(ids).to_not include subscription.id
expect(ids).not_to include subscription.id
end
end
end
@@ -134,7 +134,7 @@ describe Admin::SubscriptionsController, type: :controller do
context 'when I submit insufficient params' do
it 'returns errors' do
expect{ spree_post :create, params }.to_not change{ Subscription.count }
expect{ spree_post :create, params }.not_to change{ Subscription.count }
json_response = JSON.parse(response.body)
expect(json_response['errors'].keys).to include 'schedule', 'customer', 'payment_method',
'shipping_method', 'begins_at'
@@ -168,7 +168,7 @@ describe Admin::SubscriptionsController, type: :controller do
end
it 'returns errors' do
expect{ spree_post :create, params }.to_not change{ Subscription.count }
expect{ spree_post :create, params }.not_to change{ Subscription.count }
json_response = JSON.parse(response.body)
expect(json_response['errors'].keys).to include 'schedule', 'customer', 'payment_method',
'shipping_method', 'ends_at'
@@ -197,7 +197,7 @@ describe Admin::SubscriptionsController, type: :controller do
context 'where the specified variants are not available from the shop' do
it 'returns an error' do
expect{ spree_post :create, params }.to_not change{ Subscription.count }
expect{ spree_post :create, params }.not_to change{ Subscription.count }
json_response = JSON.parse(response.body)
expect(json_response['errors']['subscription_line_items'])
.to eq ["#{variant.product.name} - #{variant.full_name} " \
@@ -343,7 +343,7 @@ describe Admin::SubscriptionsController, type: :controller do
end
it 'returns errors' do
expect{ spree_post :update, params }.to_not change{ Subscription.count }
expect{ spree_post :update, params }.not_to change{ Subscription.count }
json_response = JSON.parse(response.body)
expect(json_response['errors'].keys).to include 'payment_method', 'shipping_method'
subscription.reload
@@ -387,7 +387,7 @@ describe Admin::SubscriptionsController, type: :controller do
context 'where the specified variants are not available from the shop' do
it 'returns an error' do
expect{ spree_post :update, params }
.to_not change{ subscription.subscription_line_items.count }
.not_to change{ subscription.subscription_line_items.count }
json_response = JSON.parse(response.body)
expect(json_response['errors']['subscription_line_items'])
.to eq ["#{product2.name} - #{variant2.full_name} " \
@@ -478,7 +478,7 @@ describe Admin::SubscriptionsController, type: :controller do
it 'renders the cancelled subscription as json, and does not cancel the open order' do
spree_put :cancel, params
json_response = JSON.parse(response.body)
expect(json_response['canceled_at']).to_not be nil
expect(json_response['canceled_at']).not_to be nil
expect(json_response['id']).to eq subscription.id
expect(subscription.reload.canceled_at).to be_within(5.seconds).of Time.zone.now
expect(order.reload.state).to eq 'complete'
@@ -498,7 +498,7 @@ describe Admin::SubscriptionsController, type: :controller do
it 'renders the cancelled subscription as json, and cancels the open order' do
spree_put :cancel, params
json_response = JSON.parse(response.body)
expect(json_response['canceled_at']).to_not be nil
expect(json_response['canceled_at']).not_to be nil
expect(json_response['id']).to eq subscription.id
expect(subscription.reload.canceled_at).to be_within(5.seconds).of Time.zone.now
expect(order.reload.state).to eq 'canceled'
@@ -512,7 +512,7 @@ describe Admin::SubscriptionsController, type: :controller do
it 'renders the cancelled subscription as json' do
spree_put :cancel, params
json_response = JSON.parse(response.body)
expect(json_response['canceled_at']).to_not be nil
expect(json_response['canceled_at']).not_to be nil
expect(json_response['id']).to eq subscription.id
expect(subscription.reload.canceled_at).to be_within(5.seconds).of Time.zone.now
end
@@ -582,7 +582,7 @@ describe Admin::SubscriptionsController, type: :controller do
it 'renders the paused subscription as json, and does not cancel the open order' do
spree_put :pause, params
json_response = JSON.parse(response.body)
expect(json_response['paused_at']).to_not be nil
expect(json_response['paused_at']).not_to be nil
expect(json_response['id']).to eq subscription.id
expect(subscription.reload.paused_at).to be_within(5.seconds).of Time.zone.now
expect(order.reload.state).to eq 'complete'
@@ -602,7 +602,7 @@ describe Admin::SubscriptionsController, type: :controller do
it 'renders the paused subscription as json, and cancels the open order' do
spree_put :pause, params
json_response = JSON.parse(response.body)
expect(json_response['paused_at']).to_not be nil
expect(json_response['paused_at']).not_to be nil
expect(json_response['id']).to eq subscription.id
expect(subscription.reload.paused_at).to be_within(5.seconds).of Time.zone.now
expect(order.reload.state).to eq 'canceled'
@@ -616,7 +616,7 @@ describe Admin::SubscriptionsController, type: :controller do
it 'renders the paused subscription as json' do
spree_put :pause, params
json_response = JSON.parse(response.body)
expect(json_response['paused_at']).to_not be nil
expect(json_response['paused_at']).not_to be nil
expect(json_response['id']).to eq subscription.id
expect(subscription.reload.paused_at).to be_within(5.seconds).of Time.zone.now
end
@@ -708,7 +708,7 @@ describe Admin::SubscriptionsController, type: :controller do
expect(json_response['id']).to eq subscription.id
expect(subscription.reload.paused_at).to be nil
expect(order.reload.state).to eq 'canceled'
expect(proxy_order.reload.canceled_at).to_not be nil
expect(proxy_order.reload.canceled_at).not_to be nil
end
end
end
@@ -771,7 +771,7 @@ describe Admin::SubscriptionsController, type: :controller do
it "only loads Stripe and Cash payment methods" do
controller.send(:load_form_data)
expect(assigns(:payment_methods)).to include payment_method, stripe
expect(assigns(:payment_methods)).to_not include paypal
expect(assigns(:payment_methods)).not_to include paypal
end
end
end

View File

@@ -12,12 +12,12 @@ describe Admin::TermsOfServiceFilesController, type: :controller do
it "does not allow deletion" do
post :destroy
expect(TermsOfServiceFile).to_not receive(:current)
expect(TermsOfServiceFile).not_to receive(:current)
end
it "does not allow creation" do
post :create
expect(TermsOfServiceFile).to_not receive(:create!)
expect(TermsOfServiceFile).not_to receive(:create!)
end
end

View File

@@ -97,7 +97,7 @@ describe Admin::VariantOverridesController, type: :controller do
it "allows to update other variant overrides" do
put :bulk_update, as: format, params: { variant_overrides: variant_override_params }
expect(response).to_not redirect_to unauthorized_path
expect(response).not_to redirect_to unauthorized_path
variant_override.reload
expect(variant_override.price).to eq 123.45
end
@@ -193,7 +193,7 @@ describe Admin::VariantOverridesController, type: :controller do
it "does not reset count_on_hand for variant_overrides not in params" do
expect {
put :bulk_reset, params:
}.to_not change{ variant_override3.reload.count_on_hand }
}.not_to change{ variant_override3.reload.count_on_hand }
end
end
end