require 'test_helper' class RateLimitsControllerTest < ActionDispatch::IntegrationTest context "The rate limits controller" do context "index action" do setup do @user = create(:user) create(:rate_limit, key: @user.cache_key) end should "show all rate limits to the owner" do get_auth rate_limits_path, create(:owner_user) assert_response :success assert_select "tbody tr", count: 2 # 2 because the login action creates a second rate limit. end should "show the user their own rate limits" do get_auth rate_limits_path, @user assert_response :success assert_select "tbody tr", count: 1 end should "not show users rate limits belonging to other users" do get_auth rate_limits_path, create(:user) assert_response :success assert_select "tbody tr", count: 0 end end end end