summaryrefslogtreecommitdiff
path: root/spec/controllers/groups/milestones_controller_spec.rb
blob: 6e4b5f78e334773ace89d943e7a5449cdb7c3df3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
require 'spec_helper'

describe Groups::MilestonesController do
  let(:group) { create(:group) }
  let(:project) { create(:empty_project, group: group) }
  let(:project2) { create(:empty_project, group: group) }
  let(:user)    { create(:user) }
  let(:title) { '肯定不是中文的问题' }

  before do
    sign_in(user)
    group.add_owner(user)
    project.team << [user, :master]
    controller.instance_variable_set(:@group, group)
  end

  describe "#create" do
    it "creates group milestone with Chinese title" do
      post :create,
           group_id: group.id,
           milestone: { project_ids: [project.id, project2.id], title: title }

      expect(response).to redirect_to(group_milestone_path(group, title.to_slug.to_s, title: title))
      expect(Milestone.where(title: title).count).to eq(2)
    end

    it "redirects to new when there are no project ids" do
      post :create, group_id: group.id, milestone: { title: title, project_ids: [""] }
      expect(response).to render_template :new
      expect(assigns(:milestone).errors).not_to be_nil
    end
  end
end