Commit 0f7d3f591cea40d922250260326892ed49275968

Authored by Dmitriy Zaporozhets
1 parent 120f50cf

Moving repositories spec to roles. Added missing spec for project

app/views/merge_requests/show/_mr_box.html.haml
1 .main_box 1 .main_box
2 .top_box_content 2 .top_box_content
3 %h4.box-title 3 %h4.box-title
4 - - if @merge_request.closed 4 + - if @merge_request.merged
  5 + .error.status_info
  6 + %i.icon-ok
  7 + Merged
  8 + - elsif @merge_request.closed
5 .error.status_info Closed 9 .error.status_info Closed
6 = gfm escape_once(@merge_request.title) 10 = gfm escape_once(@merge_request.title)
7 11
app/views/merge_requests/show/_mr_title.html.haml
@@ -6,11 +6,6 @@ @@ -6,11 +6,6 @@
6 %span.label_branch= @merge_request.target_branch 6 %span.label_branch= @merge_request.target_branch
7 7
8 %span.right 8 %span.right
9 - - if @merge_request.merged?  
10 - %span.btn.small.disabled.grouped.success  
11 - %strong  
12 - %i.icon-ok  
13 - = "MERGED"  
14 - if can?(current_user, :modify_merge_request, @merge_request) 9 - if can?(current_user, :modify_merge_request, @merge_request)
15 - if @merge_request.open? 10 - if @merge_request.open?
16 .left.btn-group 11 .left.btn-group
spec/models/project_spec.rb
@@ -129,6 +129,13 @@ describe Project do @@ -129,6 +129,13 @@ describe Project do
129 it { should respond_to(:execute_hooks) } 129 it { should respond_to(:execute_hooks) }
130 it { should respond_to(:post_receive_data) } 130 it { should respond_to(:post_receive_data) }
131 it { should respond_to(:trigger_post_receive) } 131 it { should respond_to(:trigger_post_receive) }
  132 +
  133 + # Namespaced Project Role
  134 + it { should respond_to(:transfer) }
  135 + it { should respond_to(:name_with_namespace) }
  136 + it { should respond_to(:namespace_owner) }
  137 + it { should respond_to(:chief) }
  138 + it { should respond_to(:path_with_namespace) }
132 end 139 end
133 140
134 describe 'modules' do 141 describe 'modules' do
@@ -136,6 +143,7 @@ describe Project do @@ -136,6 +143,7 @@ describe Project do
136 it { should include_module(PushObserver) } 143 it { should include_module(PushObserver) }
137 it { should include_module(Authority) } 144 it { should include_module(Authority) }
138 it { should include_module(Team) } 145 it { should include_module(Team) }
  146 + it { should include_module(NamespacedProject) }
139 end 147 end
140 148
141 it "should return valid url to repo" do 149 it "should return valid url to repo" do
@@ -153,18 +161,6 @@ describe Project do @@ -153,18 +161,6 @@ describe Project do
153 project.web_url.should == "#{Gitlab.config.url}/somewhere" 161 project.web_url.should == "#{Gitlab.config.url}/somewhere"
154 end 162 end
155 163
156 - describe :valid_repo? do  
157 - it "should be valid repo" do  
158 - project = create(:project)  
159 - project.valid_repo?.should be_true  
160 - end  
161 -  
162 - it "should be invalid repo" do  
163 - project = Project.new(name: "ok_name", path: "/INVALID_PATH/", path: "NEOK")  
164 - project.valid_repo?.should be_false  
165 - end  
166 - end  
167 -  
168 describe "last_activity methods" do 164 describe "last_activity methods" do
169 let(:project) { create(:project) } 165 let(:project) { create(:project) }
170 let(:last_event) { double(created_at: Time.now) } 166 let(:last_event) { double(created_at: Time.now) }
@@ -188,85 +184,6 @@ describe Project do @@ -188,85 +184,6 @@ describe Project do
188 end 184 end
189 end 185 end
190 186
191 - describe "fresh commits" do  
192 - let(:project) { create(:project) }  
193 -  
194 - it { project.fresh_commits(3).count.should == 3 }  
195 - it { project.fresh_commits.first.id.should == "bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a" }  
196 - it { project.fresh_commits.last.id.should == "f403da73f5e62794a0447aca879360494b08f678" }  
197 - end  
198 -  
199 - describe "commits_between" do  
200 - let(:project) { create(:project) }  
201 -  
202 - subject do  
203 - commits = project.commits_between("3a4b4fb4cde7809f033822a171b9feae19d41fff",  
204 - "8470d70da67355c9c009e4401746b1d5410af2e3")  
205 - commits.map { |c| c.id }  
206 - end  
207 -  
208 - it { should have(3).elements }  
209 - it { should include("f0f14c8eaba69ebddd766498a9d0b0e79becd633") }  
210 - it { should_not include("bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a") }  
211 - end  
212 -  
213 - describe "Git methods" do  
214 - let(:project) { create(:project) }  
215 -  
216 - describe :repo do  
217 - it "should return valid repo" do  
218 - project.repo.should be_kind_of(Grit::Repo)  
219 - end  
220 -  
221 - it "should return nil" do  
222 - lambda { Project.new(path: "invalid").repo }.should raise_error(Grit::NoSuchPathError)  
223 - end  
224 -  
225 - it "should return nil" do  
226 - lambda { Project.new.repo }.should raise_error(TypeError)  
227 - end  
228 - end  
229 -  
230 - describe :commit do  
231 - it "should return first head commit if without params" do  
232 - project.commit.id.should == project.repo.commits.first.id  
233 - end  
234 -  
235 - it "should return valid commit" do  
236 - project.commit(ValidCommit::ID).should be_valid_commit  
237 - end  
238 -  
239 - it "should return nil" do  
240 - project.commit("+123_4532530XYZ").should be_nil  
241 - end  
242 - end  
243 -  
244 - describe :tree do  
245 - before do  
246 - @commit = project.commit(ValidCommit::ID)  
247 - end  
248 -  
249 - it "should raise error w/o arguments" do  
250 - lambda { project.tree }.should raise_error  
251 - end  
252 -  
253 - it "should return root tree for commit" do  
254 - tree = project.tree(@commit)  
255 - tree.contents.size.should == ValidCommit::FILES_COUNT  
256 - tree.contents.map(&:name).should == ValidCommit::FILES  
257 - end  
258 -  
259 - it "should return root tree for commit with correct path" do  
260 - tree = project.tree(@commit, ValidCommit::C_FILE_PATH)  
261 - tree.contents.map(&:name).should == ValidCommit::C_FILES  
262 - end  
263 -  
264 - it "should return root tree for commit with incorrect path" do  
265 - project.tree(@commit, "invalid_path").should be_nil  
266 - end  
267 - end  
268 - end  
269 -  
270 describe :update_merge_requests do 187 describe :update_merge_requests do
271 let(:project) { create(:project) } 188 let(:project) { create(:project) }
272 189
spec/roles/repository_spec.rb
1 require 'spec_helper' 1 require 'spec_helper'
2 2
3 describe Project, "Repository" do 3 describe Project, "Repository" do
4 - let(:project) { build(:project) } 4 + let(:project) { create(:project) }
5 5
6 describe "#empty_repo?" do 6 describe "#empty_repo?" do
7 it "should return true if the repo doesn't exist" do 7 it "should return true if the repo doesn't exist" do
@@ -69,4 +69,91 @@ describe Project, "Repository" do @@ -69,4 +69,91 @@ describe Project, "Repository" do
69 project.root_ref?('stable').should be_false 69 project.root_ref?('stable').should be_false
70 end 70 end
71 end 71 end
  72 +
  73 + describe :repo do
  74 + it "should return valid repo" do
  75 + project.repo.should be_kind_of(Grit::Repo)
  76 + end
  77 +
  78 + it "should return nil" do
  79 + lambda { Project.new(path: "invalid").repo }.should raise_error(Grit::NoSuchPathError)
  80 + end
  81 +
  82 + it "should return nil" do
  83 + lambda { Project.new.repo }.should raise_error(TypeError)
  84 + end
  85 + end
  86 +
  87 + describe :commit do
  88 + it "should return first head commit if without params" do
  89 + project.commit.id.should == project.repo.commits.first.id
  90 + end
  91 +
  92 + it "should return valid commit" do
  93 + project.commit(ValidCommit::ID).should be_valid_commit
  94 + end
  95 +
  96 + it "should return nil" do
  97 + project.commit("+123_4532530XYZ").should be_nil
  98 + end
  99 + end
  100 +
  101 + describe :tree do
  102 + before do
  103 + @commit = project.commit(ValidCommit::ID)
  104 + end
  105 +
  106 + it "should raise error w/o arguments" do
  107 + lambda { project.tree }.should raise_error
  108 + end
  109 +
  110 + it "should return root tree for commit" do
  111 + tree = project.tree(@commit)
  112 + tree.contents.size.should == ValidCommit::FILES_COUNT
  113 + tree.contents.map(&:name).should == ValidCommit::FILES
  114 + end
  115 +
  116 + it "should return root tree for commit with correct path" do
  117 + tree = project.tree(@commit, ValidCommit::C_FILE_PATH)
  118 + tree.contents.map(&:name).should == ValidCommit::C_FILES
  119 + end
  120 +
  121 + it "should return root tree for commit with incorrect path" do
  122 + project.tree(@commit, "invalid_path").should be_nil
  123 + end
  124 + end
  125 +
  126 + describe "fresh commits" do
  127 + let(:project) { create(:project) }
  128 +
  129 + it { project.fresh_commits(3).count.should == 3 }
  130 + it { project.fresh_commits.first.id.should == "bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a" }
  131 + it { project.fresh_commits.last.id.should == "f403da73f5e62794a0447aca879360494b08f678" }
  132 + end
  133 +
  134 + describe "commits_between" do
  135 + let(:project) { create(:project) }
  136 +
  137 + subject do
  138 + commits = project.commits_between("3a4b4fb4cde7809f033822a171b9feae19d41fff",
  139 + "8470d70da67355c9c009e4401746b1d5410af2e3")
  140 + commits.map { |c| c.id }
  141 + end
  142 +
  143 + it { should have(3).elements }
  144 + it { should include("f0f14c8eaba69ebddd766498a9d0b0e79becd633") }
  145 + it { should_not include("bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a") }
  146 + end
  147 +
  148 + describe :valid_repo? do
  149 + it "should be valid repo" do
  150 + project = create(:project)
  151 + project.valid_repo?.should be_true
  152 + end
  153 +
  154 + it "should be invalid repo" do
  155 + project = Project.new(name: "ok_name", path: "/INVALID_PATH/", path: "NEOK")
  156 + project.valid_repo?.should be_false
  157 + end
  158 + end
72 end 159 end