|
|
@ -1,13 +1,30 @@ |
|
|
|
require File.dirname(__FILE__) + '/../../spec_helper' |
|
|
|
require File.dirname(__FILE__) + '/../../spec_helper' |
|
|
|
|
|
|
|
|
|
|
|
describe 'rb_taskboards/show' do |
|
|
|
describe 'rb_taskboards/show' do |
|
|
|
let(:project) { stub_model(Project) } |
|
|
|
let(:user1) { FactoryGirl.create(:user) } |
|
|
|
let(:sprint) { stub_model(Sprint) } |
|
|
|
let(:user2) { FactoryGirl.create(:user) } |
|
|
|
let(:statuses) { [stub_model(IssueStatus, :name => 'Open'), |
|
|
|
let(:role_allowed) { FactoryGirl.create(:role, |
|
|
|
stub_model(IssueStatus, :name => 'In Progress'), |
|
|
|
:permissions => [:create_impediments, :create_tasks]) |
|
|
|
stub_model(IssueStatus, :name => 'Closed')] } |
|
|
|
} |
|
|
|
|
|
|
|
let(:role_forbidden) { FactoryGirl.create(:role) } |
|
|
|
|
|
|
|
#we need to create these as some view helpers access the database |
|
|
|
|
|
|
|
let(:statuses) { [FactoryGirl.create(:issue_status), |
|
|
|
|
|
|
|
FactoryGirl.create(:issue_status), |
|
|
|
|
|
|
|
FactoryGirl.create(:issue_status)] } |
|
|
|
|
|
|
|
|
|
|
|
let(:assignee) { stub_model(User, :firstname => 'Karl', :lastname => 'Gustav') } |
|
|
|
let(:project) do |
|
|
|
|
|
|
|
project = FactoryGirl.create(:project) |
|
|
|
|
|
|
|
project.members = [FactoryGirl.create(:member, :principal => user1,:project => project,:roles => [role_allowed]), |
|
|
|
|
|
|
|
FactoryGirl.create(:member, :principal => user2,:project => project,:roles => [role_forbidden])] |
|
|
|
|
|
|
|
project |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let(:story_a) { FactoryGirl.build_stubbed(:story, :status => statuses[0])} |
|
|
|
|
|
|
|
let(:story_b) { FactoryGirl.build_stubbed(:story, :status => statuses[1])} |
|
|
|
|
|
|
|
let(:story_c) { FactoryGirl.build_stubbed(:story, :status => statuses[2])} |
|
|
|
|
|
|
|
let(:stories) { [story_a, story_b, story_c] } |
|
|
|
|
|
|
|
let(:sprint) { FactoryGirl.build_stubbed(:sprint) } |
|
|
|
|
|
|
|
#let(:assignee) { user } |
|
|
|
|
|
|
|
|
|
|
|
before :each do |
|
|
|
before :each do |
|
|
|
view.extend RbCommonHelper |
|
|
|
view.extend RbCommonHelper |
|
|
@ -16,27 +33,12 @@ describe 'rb_taskboards/show' do |
|
|
|
assign(:project, project) |
|
|
|
assign(:project, project) |
|
|
|
assign(:sprint, sprint) |
|
|
|
assign(:sprint, sprint) |
|
|
|
assign(:statuses, statuses) |
|
|
|
assign(:statuses, statuses) |
|
|
|
assign(:all_issue_status, statuses) |
|
|
|
|
|
|
|
|
|
|
|
stories.each { |story| story.stub(:tasks).and_return([]) } |
|
|
|
|
|
|
|
sprint.should_receive(:stories).with(project).and_return(stories) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
describe 'story blocks' do |
|
|
|
describe 'story blocks' do |
|
|
|
let(:story_a) { story = |
|
|
|
|
|
|
|
stub_model(Story, :id => 1001, :subject => 'Story A', :status_id => statuses[0].id, :assigned_to => assignee) |
|
|
|
|
|
|
|
story.status = statuses[0] |
|
|
|
|
|
|
|
story } |
|
|
|
|
|
|
|
let(:story_b) { story = stub_model(Story, :id => 1002, :subject => 'Story B', :status_id => statuses[1].id, :assigned_to => assignee) |
|
|
|
|
|
|
|
story.status = statuses[1] |
|
|
|
|
|
|
|
story } |
|
|
|
|
|
|
|
let(:story_c) { story = stub_model(Story, :id => 1003, :subject => 'Story C', :status_id => statuses[2].id, :assigned_to => assignee) |
|
|
|
|
|
|
|
story.status = statuses[2] |
|
|
|
|
|
|
|
story } |
|
|
|
|
|
|
|
let(:stories) { [story_a, story_b, story_c] } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
|
|
|
stories.each { |story| story.stub(:tasks).and_return([]) } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sprint.should_receive(:stories).with(project).and_return(stories) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it 'contains the story id' do |
|
|
|
it 'contains the story id' do |
|
|
|
render |
|
|
|
render |
|
|
@ -78,4 +80,33 @@ describe 'rb_taskboards/show' do |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
describe 'create buttons' do |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it 'renders clickable + buttons with the right permissions' do |
|
|
|
|
|
|
|
User.current = user1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
render |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stories.each do |story| |
|
|
|
|
|
|
|
assert_select "tr.story_#{story.id} td.add_new" do |td| |
|
|
|
|
|
|
|
td.should have_content '+' |
|
|
|
|
|
|
|
td.should have_css '.clickable' |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it 'does not render a clickable + buttons without the right permissions' do |
|
|
|
|
|
|
|
User.current = user2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
render |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stories.each do |story| |
|
|
|
|
|
|
|
assert_select "tr.story_#{story.id} td.add_new" do |td| |
|
|
|
|
|
|
|
td.should_not have_content '+' |
|
|
|
|
|
|
|
td.should_not have_css '.clickable' |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|