-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure only current user gets client_reference_id
- Loading branch information
1 parent
b052ee0
commit c2d1036
Showing
2 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe "Citizenships", type: :request do | ||
let(:signed_in_user) { create(:user) } | ||
before do | ||
sign_in signed_in_user | ||
end | ||
|
||
describe "GET #show" do | ||
context "with multiple users in the system" do | ||
let!(:other_user) { create(:user) } | ||
|
||
it "sets up the signed_in user with a random client reference id" do | ||
get choose_plan_path | ||
|
||
signed_in_user.reload | ||
other_user.reload | ||
|
||
expect(signed_in_user.last_checkout_reference).not_to be_nil | ||
expect(other_user.last_checkout_reference).to be_nil | ||
end | ||
end | ||
|
||
context "if the user already has a linked stripe accont" do | ||
before do | ||
signed_in_user.update!(stripe_customer_id: "foobar") | ||
end | ||
|
||
it "redirects to the profile page" do | ||
get choose_plan_path | ||
|
||
expect(response.status).to eq 302 | ||
expect(response.location).to eq profile_url | ||
end | ||
end | ||
end | ||
end |