diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-01-18 20:21:13 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-01-18 20:21:13 +0200 |
commit | 6f05ea4f6e26e76edc0a6ad5d2eb4e5db676aea0 (patch) | |
tree | 19e8adf1f6e74a4636ef728bf06e4c01d94ae518 /spec | |
parent | 232d61d59808e6f0c731d135d728800c4b13ae27 (diff) | |
download | gitlab-ce-6f05ea4f6e26e76edc0a6ad5d2eb4e5db676aea0.tar.gz |
Improve CreateContext call. Fixed test
Diffstat (limited to 'spec')
-rw-r--r-- | spec/contexts/projects_create_context_spec.rb | 38 | ||||
-rw-r--r-- | spec/models/project_spec.rb | 30 |
2 files changed, 38 insertions, 30 deletions
diff --git a/spec/contexts/projects_create_context_spec.rb b/spec/contexts/projects_create_context_spec.rb new file mode 100644 index 00000000000..dd10dd3ede8 --- /dev/null +++ b/spec/contexts/projects_create_context_spec.rb @@ -0,0 +1,38 @@ +require 'spec_helper' + +describe Projects::CreateContext do + describe :create_by_user do + before do + @user = create :user + @opts = { + name: "GitLab" + } + end + + context 'user namespace' do + before do + @project = create_project(@user, @opts) + end + + it { @project.should be_valid } + it { @project.owner.should == @user } + it { @project.namespace.should == @user.namespace } + end + + context 'group namespace' do + before do + @group = create :group, owner: @user + @opts.merge!(namespace_id: @group.id) + @project = create_project(@user, @opts) + end + + it { @project.should be_valid } + it { @project.owner.should == @user } + it { @project.namespace.should == @group } + end + end + + def create_project(user, opts) + Projects::CreateContext.new(user, opts).execute + end +end diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 223b9d48c01..17bc988bf05 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -153,36 +153,6 @@ describe Project do end end - describe :create_by_user do - before do - @user = create :user - @opts = { - name: "GitLab" - } - end - - context 'user namespace' do - before do - @project = Project.create_by_user(@opts, @user) - end - - it { @project.should be_valid } - it { @project.owner.should == @user } - it { @project.namespace.should == @user.namespace } - end - - context 'user namespace' do - before do - @group = create :group, owner: @user - @opts.merge!(namespace_id: @group.id) - @project = Project.create_by_user(@opts, @user) - end - - it { @project.should be_valid } - it { @project.owner.should == @user } - it { @project.namespace.should == @group } - end - end describe :find_with_namespace do context 'with namespace' do |