Skip to content

Commit

Permalink
add project key to project view
Browse files Browse the repository at this point in the history
  • Loading branch information
kaiomagalhaes committed Jun 13, 2024
1 parent 16bb53d commit ca067cc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Project < ApplicationRecord
has_many :issues, dependent: :destroy
has_many :statement_of_works, dependent: :destroy
has_many :dynamic_datasets, dependent: :destroy
has_one :project_report
has_one :project_report, dependent: :destroy

validates :name, presence: true, uniqueness: { case_sensitive: false }
validates :billable, inclusion: { in: [true, false] }
Expand Down
2 changes: 2 additions & 0 deletions app/views/projects/_project.json.jbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ end
json.extract! project, :id, :name, :billable, :slack_channel, :metadata, :slug, :logo_url,
:sync_source_control, :sync_ticket_tracking_system, :logo_background_color,
:display_code_metrics, :display_tasks_metrics

json.report_key project.project_report&.key
8 changes: 8 additions & 0 deletions spec/controllers/projects_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@

expect(response.parsed_body['customer']['id']).to eq(project.customer.id)
end

it 'returns a report key if it has a project_report' do
project = Project.create! valid_attributes
project.project_report = ProjectReport.create!(project:, key: '123')

get :show, params: { id: project.to_param }, format: :json
expect(response.parsed_body['report_key']).to eq('123')
end
end

describe 'POST #create' do
Expand Down

0 comments on commit ca067cc

Please sign in to comment.