diff --git a/app/assets/javascripts/models/beta/story.js b/app/assets/javascripts/models/beta/story.js
index 5aeb64eca..152900b65 100644
--- a/app/assets/javascripts/models/beta/story.js
+++ b/app/assets/javascripts/models/beta/story.js
@@ -36,9 +36,7 @@ export const compareStartedAt = (a, b) => {
return compareValues(a.startedAt, b.startedAt);
};
-export const isUnestimatedFeature = story => {
- return (story.estimate === null || story.estimate === '') && story.storyType === storyTypes.FEATURE;
-};
+export const isUnestimatedFeature = story => !hasEstimate(story) && isFeature(story)
export const isFeature = story => {
return story.storyType === storyTypes.FEATURE;
@@ -82,7 +80,7 @@ export const releaseIsLate = (story) => {
}
export const possibleStatesFor = story =>
- isUnestimatedFeature(story) ? states : [states[0]];
+ isUnestimatedFeature(story._editing) ? [states[0]] : states;
export const types = ['feature', 'bug', 'release', 'chore'];
diff --git a/spec/javascripts/components/story/expanded_story/expanded_story_state_spec.js b/spec/javascripts/components/story/expanded_story/expanded_story_state_spec.js
index 0757c1f63..7bfcbdc43 100644
--- a/spec/javascripts/components/story/expanded_story/expanded_story_state_spec.js
+++ b/spec/javascripts/components/story/expanded_story/expanded_story_state_spec.js
@@ -1,7 +1,7 @@
import React from 'react';
import { shallow, mount } from 'enzyme';
import ExpandedStoryState from 'components/story/ExpandedStory/ExpandedStoryState';
-import { states } from '../../../../../app/assets/javascripts/models/beta/story';
+import { states, types } from '../../../../../app/assets/javascripts/models/beta/story';
import { storyTypes } from '../../../../../app/assets/javascripts/libs/beta/constants'
describe('', () => {
@@ -28,11 +28,53 @@ describe('', () => {
onEditSpy = sinon.spy();
})
- describe('when is estimated feature', () => {
+ const noFeatureTypes = types.filter(type => type !== storyTypes.FEATURE);
+
+ noFeatureTypes.forEach(noFeatureType => {
+ describe(`when is no ${noFeatureType}`, () => {
+ states.forEach(state => {
+ describe(`and state is ${state}`, () => {
+ const story = {
+ _editing: {
+ state,
+ estimate: 1,
+ storyType: noFeatureType,
+ }
+ };
+
+ let wrapper;
+
+ beforeEach(() => {
+ wrapper = shallow(
+
+ );
+ });
+
+ it('renders all states', () => {
+ expect(wrapper.find('option').length).toEqual(7);
+ });
+
+ it(`has to be ${state}`, () => {
+ expect(wrapper.find('select').prop('value')).toBe(state);
+ });
+ });
+ });
+ })
+ })
+
+ describe('when is unestimated feature', () => {
+ let onEditSpy;
+
+ beforeEach(() => {
+ onEditSpy = sinon.spy();
+ })
+
const story = {
- estimate: 1,
- storyType: storyTypes.BUG,
- _editing: { state: states[0] }
+ _editing: { state: states[0], estimate: null, storyType: storyTypes.FEATURE }
};
let wrapper;
@@ -44,8 +86,8 @@ describe('', () => {
disabled={false}
/>
);
- });
-
+ })
+
it('renders just one state', () => {
expect(wrapper.find('option').length).toEqual(1);
});
@@ -53,36 +95,7 @@ describe('', () => {
it('has to be unscheduled', () => {
expect(wrapper.find('select').prop('value')).toBe(states[0]);
});
- })
-
- describe('when is unestimated feature', () => {
- let onEditSpy;
-
- beforeEach(() => {
- onEditSpy = sinon.spy();
- })
-
- const story = {
- estimate: null,
- storyType: storyTypes.FEATURE,
- _editing: { state: states[0] }
- };
- let wrapper;
-
- beforeEach(() => {
- wrapper = shallow(
-
- );
- })
-
- it('renders all states', () => {
- expect(wrapper.find('option').length).toEqual(states.length);
});
- })
states.forEach(state => {
it(`sets select value as ${state}`, () => {
@@ -183,7 +196,7 @@ describe('', () => {
describe("to a number", () => {
it("doesn't disable state select when estimate is a number", () => {
- const story = { _editing: { estimate: !isNaN, storyType: 'feature', state: 'unstarted' } };
+ const story = { _editing: { estimate: 1, storyType: 'feature', state: 'unstarted' } };
const wrapper = shallow(
{
const invalidEstimates = [null, ''];
- const invalidStoryTypes = [storyTypes.FEATURE]
const validEstimates = [1,2,3]
- const validStoryTypes = [storyTypes.BUG, storyTypes.CHORE, storyTypes.RELEASE]
- invalidStoryTypes.forEach(invalidStoryType => {
- describe(`when storyType is ${invalidStoryType}`, () => {
+ const featureTypes = Story.types.filter(type => type === storyTypes.FEATURE)
+ const noFeatureTypes = Story.types.filter(type => type !== storyTypes.FEATURE)
+
+ featureTypes.forEach(featureType => {
+ describe(`when storyType is ${featureType}`, () => {
invalidEstimates.forEach(invalidEstimate => {
describe(`and estimate is "${invalidEstimate}"`, () => {
let story;
beforeEach(() => {
- story = { estimate: invalidEstimate, storyType: invalidStoryType}
+ story = { _editing: { estimate: invalidEstimate, storyType: featureType } }
});
- it('returns all states', () => {
- expect(Story.possibleStatesFor(story).length).toEqual(7);
+ it(`state has to be ${status.UNSCHEDULED}`, () => {
+ expect(Story.possibleStatesFor(story)[0]).toEqual(status.UNSCHEDULED);
})
- })
- validEstimates.forEach(validEstimate => {
- describe(`and estimate is ${validEstimate}`, () => {
- let story;
+ it('returns just one state', () => {
+ expect(Story.possibleStatesFor(story).length).toEqual(1);
+ })
+ })
+ })
- beforeEach(() => {
- story = { estimate: validEstimate, storyType: invalidStoryType }
- });
+ validEstimates.forEach(validEstimate => {
+ describe(`and estimate is ${validEstimate}`, () => {
+ let story;
- it(`state has to be ${status.UNSCHEDULED}`, () => {
- expect(Story.possibleStatesFor(story)[0]).toEqual(status.UNSCHEDULED);
- })
+ beforeEach(() => {
+ story = { _editing: { estimate: validEstimate, storyType: featureType } }
+ });
- it('return just one state', () => {
- expect(Story.possibleStatesFor(story).length).toEqual(1);
- })
+ it('return all states', () => {
+ expect(Story.possibleStatesFor(story).length).toEqual(7);
})
})
})
})
})
- validStoryTypes.forEach(validStoryType => {
- describe(`when storyType is ${validStoryType}`, () => {
+ noFeatureTypes.forEach(noFeatureType => {
+ describe(`when storyType is ${noFeatureType}`, () => {
invalidEstimates.forEach(invalidEstimate => {
describe(`and estimate is "${invalidEstimate}"`, () => {
let story;
beforeEach(() => {
- story = { estimate: invalidEstimate, storyType: validStoryType}
+ story = { _editing: { estimate: invalidEstimate, storyType: noFeatureType } }
});
it('returns all states', () => {
- expect(Story.possibleStatesFor(story).length).toEqual(1);
- })
-
- it(`state has to be ${status.UNSCHEDULED}`, () => {
- expect(Story.possibleStatesFor(story)[0]).toEqual(status.UNSCHEDULED);
+ expect(Story.possibleStatesFor(story).length).toEqual(7);
})
})
@@ -1058,15 +1055,11 @@ describe('Story model', function () {
let story;
beforeEach(() => {
- story = { estimate: validEstimate, storyType: validStoryType }
+ story = { _editing: { estimate: validEstimate, storyType: noFeatureType } }
});
it('returns all states', () => {
- expect(Story.possibleStatesFor(story).length).toEqual(1);
- })
-
- it(`state has to be ${status.UNSCHEDULED}`, () => {
- expect(Story.possibleStatesFor(story)[0]).toEqual(status.UNSCHEDULED);
+ expect(Story.possibleStatesFor(story).length).toEqual(7);
})
})
})