Skip to content
This repository has been archived by the owner on Sep 6, 2022. It is now read-only.

Commit

Permalink
Add data service test and make rebuild respond with summary
Browse files Browse the repository at this point in the history
  • Loading branch information
nakhbari committed Jun 25, 2018
1 parent b2c9db2 commit 83c8e86
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
5 changes: 3 additions & 2 deletions app/features-json/build_json_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require_relative "api_controller"
require_relative "./view_models/build_summary_view_model"
require_relative "./view_models/build_view_model"

module FastlaneCI
Expand Down Expand Up @@ -85,8 +86,8 @@ class BuildJSONController < APIController
build_runner.setup(parameters: nil)
Services.build_runner_service.add_build_runner(build_runner: build_runner)

build_view_model = BuildViewModel.new(build: build_runner.current_build)
json(build_view_model)
build_summary_view_model = BuildSummaryViewModel.new(build: build_runner.current_build)
json(build_summary_view_model)
end

def current_project
Expand Down
21 changes: 20 additions & 1 deletion web/app/services/data.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import {fakeAsync, TestBed, tick} from '@angular/core/testing';
import {Observable} from 'rxjs/Observable';

import {BuildStatus} from '../common/constants';
import {mockBuildResponse} from '../common/test_helpers/mock_build_data';
import {mockBuildResponse, mockBuildSummary_success} from '../common/test_helpers/mock_build_data';
import {mockLanesResponse} from '../common/test_helpers/mock_lane_data';
import {mockProjectListResponse, mockProjectResponse, mockProjectSummaryResponse} from '../common/test_helpers/mock_project_data';
import {mockRepositoryListResponse, mockRepositoryResponse} from '../common/test_helpers/mock_repository_data';
import {Build} from '../models/build';
import {BuildSummary} from '../models/build_summary';
import {Lane} from '../models/lane';
import {Project} from '../models/project';
import {ProjectSummary} from '../models/project_summary';
Expand Down Expand Up @@ -90,6 +91,23 @@ describe('DataService', () => {
});
});

describe('#rebuild', () => {
it('should return response mapped to Build Summary model', () => {
let buildSummary: BuildSummary;
dataService.rebuild('some-id', 3).subscribe((buildRespone) => {
buildSummary = buildRespone;
});

const rebuildRequest =
mockHttp.expectOne('/data/projects/some-id/build/3/rebuild');
expect(rebuildRequest.request.method).toBe('POST');
rebuildRequest.flush(mockBuildSummary_success);

expect(buildSummary.number).toBe(2);
expect(buildSummary.sha).toBe('asdfshzdggfdhdfh4');
});
});

describe('#getRepoLanes', () => {
it('should return response mapped to Lane model', () => {
let lanes: Lane[];
Expand Down Expand Up @@ -120,6 +138,7 @@ describe('DataService', () => {

const projectsRequest = mockHttp.expectOne('/data/projects');
expect(projectsRequest.request.body).toBe(COMMIT_TRIGGER_PROJECT_REQUEST);
expect(projectsRequest.request.method).toBe('POST');
projectsRequest.flush(mockProjectSummaryResponse);

expect(project.id).toBe('1');
Expand Down

0 comments on commit 83c8e86

Please sign in to comment.