summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-01-28 00:26:18 -0800
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-01-28 00:26:18 -0800
commita184fcf368686f8224315c8afa6e5ec923e37c4b (patch)
treea76232580fb7777de8aba2611bb48a909db42479 /spec
parentb6454591ccaeced4c57562167be903308102a25d (diff)
parent251df827a5308d483a95242970569075ab655703 (diff)
downloadgitlab-ce-a184fcf368686f8224315c8afa6e5ec923e37c4b.tar.gz
Merge pull request #6178 from Popl7/add_group_avatars
added group avatars
Diffstat (limited to 'spec')
-rw-r--r--spec/helpers/application_helper_spec.rb17
-rw-r--r--spec/models/group_spec.rb15
2 files changed, 32 insertions, 0 deletions
diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb
index 3644410e46d..c58c83a2970 100644
--- a/spec/helpers/application_helper_spec.rb
+++ b/spec/helpers/application_helper_spec.rb
@@ -39,6 +39,23 @@ describe ApplicationHelper do
end
end
+ describe "group_icon" do
+ avatar_file_path = File.join(Rails.root, 'public', 'gitlab_logo.png')
+
+ it "should return an url for the avatar" do
+ group = create(:group)
+ group.avatar = File.open(avatar_file_path)
+ group.save!
+ group_icon(group.path).to_s.should == "/uploads/group/avatar/#{ group.id }/gitlab_logo.png"
+ end
+
+ it "should give default avatar_icon when no avatar is present" do
+ group = create(:group)
+ group.save!
+ group_icon(group.path).to_s.should == "/assets/no_group_avatar.png"
+ end
+ end
+
describe "avatar_icon" do
avatar_file_path = File.join(Rails.root, 'public', 'gitlab_logo.png')
diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb
index 12b84700eb1..686e43d8d10 100644
--- a/spec/models/group_spec.rb
+++ b/spec/models/group_spec.rb
@@ -54,4 +54,19 @@ describe Group do
group.users_groups.guests.map(&:user).should_not include(user)
end
end
+
+ describe :avatar_type do
+ let(:user) { create(:user) }
+ before { group.add_user(user, UsersGroup::MASTER) }
+
+ it "should be true if avatar is image" do
+ group.update_attribute(:avatar, 'uploads/avatar.png')
+ group.avatar_type.should be_true
+ end
+
+ it "should be false if avatar is html page" do
+ group.update_attribute(:avatar, 'uploads/avatar.html')
+ group.avatar_type.should == ["only images allowed"]
+ end
+ end
end