Last active
July 23, 2020 22:40
-
-
Save philippegirard/fc0881ba83358eed635dbb3364aff794 to your computer and use it in GitHub Desktop.
Any Controller test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test_helper' | |
class ProductsControllerTest < ActionDispatch::IntegrationTest | |
# This methods gets called before each test. | |
def setup | |
@shop = shops(:regular_shop) | |
login_shop(@shop) | |
end | |
test "post should work" do | |
post products_path, params: product_data | |
end | |
test "get should work" do | |
get products_path | |
end | |
private | |
# Be extra careful to not add a parameter "shop" in data hash you send as POST params, because it is verified in shopify omniauth and will redirect to login page if it does not match the shopify domain you try to log in (ShopifyApp::login_protection.rb L71) (ex: do not do "{shop: @shop, ...}") | |
def product_data | |
{ | |
product: { | |
shopify_product_id: 100, | |
secret_link: "https://secret-link.com", | |
datetime: DateTime.now, | |
enable_mail: true | |
} | |
} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment