-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(public account share): add public account share (#69)
* feat(public account share): add public account share * feat(public account share): fixup! add public account share * feat(public account share): fixup! fixup! add public account share * feat(public account share): fixup! fixup! fixup! add public account share * feat(public account share): fixup! fixup! fixup! fixup! add public account share * feat(public account share): fixup! fixup! fixup! fixup! fixup! add public account share * feat(public account share): fixup! fixup! fixup! fixup! fixup! fixup! add public account share * feat(public account share): fixup! fixup! fixup! fixup! fixup! fixup! fixup! add public account share * feat(public account share): fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! add public account share * feat(public account share): fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! add public account share * feat(public account share): fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! add public account share * feat(public account share): fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! add public account share --------- Co-authored-by: VladislavSokov <[email protected]>
- Loading branch information
1 parent
153cea8
commit 51fbf37
Showing
16 changed files
with
156 additions
and
45 deletions.
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
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,12 @@ | ||
# frozen_string_literal: true | ||
|
||
class PublicAccountSharesController < ApplicationController | ||
before_action :authenticate_user! | ||
|
||
def new; end | ||
|
||
def create | ||
AccountShare.create!(user_id: current_user.id, account_id: account.id, accepted_at: Time.current) | ||
redirect_to account_shares_path account | ||
end | ||
end |
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
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
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
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
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,7 @@ | ||
.column | ||
= link_to 'Back', account_shares_path, class: 'button is-light' | ||
.column | ||
p Create a new Public Account Share | ||
|
||
= form_with(url: account_public_account_shares_path, method: :post) do |form| | ||
= form.submit 'Create', class: 'button is-primary' |
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
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,26 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe PublicAccountSharesController, type: :controller do | ||
let(:account) { create(:account, :parent) } | ||
let(:user) { create(:user, account: account) } | ||
|
||
before { sign_in user } | ||
|
||
describe '#new' do | ||
subject(:new) { get :new, params: { account_id: account.id } } | ||
|
||
it { is_expected.to have_http_status(:success) } | ||
it { is_expected.to render_template(:new) } | ||
end | ||
|
||
describe '#create' do | ||
subject { post :create, params: { account_id: account.id } } | ||
|
||
it { is_expected.to redirect_to(account_shares_path) } | ||
it { is_expected.to have_http_status(302) } | ||
it { expect { subject }.to change { AccountShare.where(user_id: user.id).count }.by(1) } | ||
it { expect { subject }.to change { AccountShare.count }.by(1) } | ||
end | ||
end |