summaryrefslogtreecommitdiff
path: root/spec/models
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-03-28 22:53:45 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-03-28 22:53:45 +0300
commit8ee0993fdf783ad12823ff817cd531df0bc363eb (patch)
tree83e7ecdc0f9779054dbd4d09bc820a0c3ab0b559 /spec/models
parentef32e01b4c365858582ba1c400bfba8b1558fd8d (diff)
downloadgitlab-ce-8ee0993fdf783ad12823ff817cd531df0bc363eb.tar.gz
Event & Wiki models specs
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/event_spec.rb44
-rw-r--r--spec/models/wiki_spec.rb31
2 files changed, 75 insertions, 0 deletions
diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb
index 50266fcf8ed..ee3bc40e354 100644
--- a/spec/models/event_spec.rb
+++ b/spec/models/event_spec.rb
@@ -20,6 +20,14 @@ describe Event do
it { should belong_to(:project) }
end
+ describe "Respond to" do
+ it { should respond_to(:author_name) }
+ it { should respond_to(:author_email) }
+ it { should respond_to(:issue_title) }
+ it { should respond_to(:merge_request_title) }
+ it { should respond_to(:commits) }
+ end
+
describe "Creation" do
before do
@event = Factory :event
@@ -29,4 +37,40 @@ describe Event do
@event.should be_valid
end
end
+
+ describe "Push event" do
+ before do
+ project = Factory :project
+ @user = project.owner
+
+ data = {
+ :before => "0000000000000000000000000000000000000000",
+ :after => "0220c11b9a3e6c69dc8fd35321254ca9a7b98f7e",
+ :ref => "refs/heads/master",
+ :user_id => @user.id,
+ :user_name => @user.name,
+ :repository => {
+ :name => project.name,
+ :url => "localhost/rubinius",
+ :description => "",
+ :homepage => "localhost/rubinius",
+ :private => true
+ }
+ }
+
+ @event = Event.create(
+ :project => project,
+ :action => Event::Pushed,
+ :data => data,
+ :author_id => @user.id
+ )
+ end
+
+ it { @event.push?.should be_true }
+ it { @event.allowed?.should be_true }
+ it { @event.new_branch?.should be_true }
+ it { @event.new_tag?.should be_false }
+ it { @event.branch_name.should == "master" }
+ it { @event.author.should == @user }
+ end
end
diff --git a/spec/models/wiki_spec.rb b/spec/models/wiki_spec.rb
new file mode 100644
index 00000000000..05dbc972350
--- /dev/null
+++ b/spec/models/wiki_spec.rb
@@ -0,0 +1,31 @@
+require 'spec_helper'
+
+describe Wiki do
+ describe "Associations" do
+ it { should belong_to(:project) }
+ it { should belong_to(:user) }
+ end
+
+ describe "Validation" do
+ it { should validate_presence_of(:title) }
+ it { should validate_presence_of(:content) }
+ it { should validate_presence_of(:user_id) }
+ end
+
+ it { Factory(:wiki).should be_valid }
+end
+# == Schema Information
+#
+# Table name: snippets
+#
+# id :integer not null, primary key
+# title :string(255)
+# content :text
+# author_id :integer not null
+# project_id :integer not null
+# created_at :datetime
+# updated_at :datetime
+# file_name :string(255)
+# expires_at :datetime
+#
+