Skip to content

Commit

Permalink
Merge pull request #457 from UffizziCloud/feature/275_project_created…
Browse files Browse the repository at this point in the history
…_from_cli_not_visible_to_other_users

[275] add all members to project created from cli
  • Loading branch information
moklidia authored Jul 31, 2023
2 parents fb6a4ca + b79d6ad commit 4e32fd6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
- main
pull_request:
types: [opened,synchronize,reopened]
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

jobs:
lint:
Expand Down Expand Up @@ -49,7 +52,7 @@ jobs:
with:
images: uffizzi/app
tags: |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
type=raw,value=latest,enable=${{ github.ref_name == 'main' }}
type=ref,event=branch,enable=${{ github.ref_name == 'qa' || github.ref_name == 'develop' }}
type=ref,event=pr
- name: Build and Push Image to Docker Hub
Expand Down
4 changes: 2 additions & 2 deletions core/app/services/uffizzi_core/project_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ def update_compose_secret_errors(project, secret)
end

def add_users_to_project!(project, account)
user_projects = account.memberships.where(role: UffizziCore::Membership.role.admin).map do |membership|
{ project: project, user: membership.user, role: UffizziCore::UserProject.role.admin }
user_projects = account.memberships.map do |membership|
{ project: project, user: membership.user, role: membership.role }
end

UffizziCore::UserProject.create!(user_projects)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

class UffizziCore::Api::Cli::V1::Accounts::ProjectsControllerTest < ActionController::TestCase
setup do
@user = create(:user, :with_personal_account)
@account = @user.personal_account
sign_in @user
@admin = create(:user, :with_organizational_account)
@account = @admin.accounts.organizational.first
sign_in(@admin)
end

test '#index' do
create(:project, :with_members, account: @account, members: [@user])
create(:project, :with_members, account: @account, members: [@admin])

get :index, params: { account_id: @account.id }, format: :json

Expand All @@ -21,10 +21,11 @@ class UffizziCore::Api::Cli::V1::Accounts::ProjectsControllerTest < ActionContro

test '#create' do
attributes = attributes_for(:project)
create(:user, :developer_in_organization, organization: @account)

differences = {
-> { UffizziCore::Project.count } => 1,
-> { UffizziCore::UserProject.count } => 1,
-> { UffizziCore::UserProject.count } => 2,
}

assert_difference differences do
Expand Down

0 comments on commit 4e32fd6

Please sign in to comment.