Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request 42

  • Loading branch information...
commit a42d8ef7dd1efac9a207ee7e6c16d891ea1615d1 2 parents 6e8951b + 8090de8
@skanev authored
View
2  Gemfile
@@ -53,7 +53,7 @@ group :development do
end
group :test do
- gem 'cucumber-rails'
+ gem 'cucumber-rails', require: false
gem 'launchy'
gem 'shoulda-matchers'
gem 'capybara'
View
3  app/views/users/show.html.haml
@@ -1,6 +1,7 @@
#user-page
%h1= @user.name
- %p.faculty-number (№#{@user.faculty_number})
+ - if admin? or @user == current_user
+ %p.faculty-number (№#{@user.faculty_number})
= user_thumbnail @user
View
7 public/robots.txt
@@ -1,5 +1,6 @@
# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
#
-# To ban all spiders from the entire site uncomment the next two lines:
-# User-Agent: *
-# Disallow: /
+
+# Disallow indexing of the users' photos
+User-agent: *
+Disallow: /uploads/photos/
View
1  spec/spec_helper.rb
@@ -34,6 +34,7 @@
config.include Support::GeneralHelpers
config.include Support::ModelHelpers, type: :model
config.include Support::ControllerHelpers, type: :controller
+ config.include Support::ViewHelpers, type: :view
config.include EmailSpec::Helpers, type: :mailer
config.include EmailSpec::Matchers, type: :mailer
config.include CustomPaths, type: :mailer
View
7 spec/support/view_helpers.rb
@@ -0,0 +1,7 @@
+module Support
+ module ViewHelpers
+ def have_link_to(url)
+ have_selector "a[href='#{url}']"
+ end
+ end
+end
View
72 spec/views/users/show.html.haml_spec.rb
@@ -5,40 +5,90 @@
before do
view.stub admin?: false
- view.stub edit_profile_path: '/profile/edit'
-
assign :user, user
end
- context 'when a user is not logged in' do
+ context 'when a visitor is viewing a user profile' do
before do
view.stub logged_in?: false
view.stub current_user: nil
end
- it "doesn't show a link to the edit profile page" do
+ it "does not show a link to the edit profile page" do
render
- rendered.should_not have_selector("a[href='/profile/edit']")
+ rendered.should_not have_link_to edit_profile_path
+ end
+
+ it "does not show the faculty number" do
+ render
+ rendered.should_not have_content user.faculty_number
+ end
+
+ it "does not show the email" do
+ render
+ rendered.should_not have_content user.email
end
end
- context 'when a user is logged in' do
+ context 'when a user is viewing their own profile' do
before do
view.stub logged_in?: true
view.stub current_user: user
end
- it "shows a link to the edit profile page if viewing user's own profile" do
+ it "shows a link to the edit profile page" do
render
- rendered.should have_selector("a[href='/profile/edit']")
+ rendered.should have_link_to edit_profile_path
end
- it "doesn't show a link to the edit profile page if viewing someone else's profile" do
- assign :user, build_stubbed(:user)
+ it "shows their faculty number" do
+ render
+ rendered.should have_content user.faculty_number
+ end
+ it "does not show the email" do
render
+ rendered.should_not have_content user.email
+ end
+ end
+
+ context "when a user is viewing somebody else's profile" do
+ before do
+ view.stub logged_in?: true
+ view.stub current_user: build_stubbed(:user)
+ end
- rendered.should_not have_selector("a[href='/profile/edit']")
+ it "does not show a link to the edit profile page" do
+ render
+ rendered.should_not have_link_to edit_profile_path
+ end
+
+ it "does not show the faculty number" do
+ render
+ rendered.should_not have_content user.faculty_number
+ end
+
+ it "does not show the email" do
+ render
+ rendered.should_not have_content user.email
+ end
+ end
+
+ context 'when an admin is viewing a profile' do
+ before do
+ view.stub logged_in?: true
+ view.stub admin?: true
+ view.stub current_user: build_stubbed(:admin)
+ end
+
+ it "shows the faculty number" do
+ render
+ rendered.should have_content user.faculty_number
+ end
+
+ it "shows the email" do
+ render
+ rendered.should have_content user.email
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.