From 0cbdf51e6a48db595a649680a1720437308fb27b Mon Sep 17 00:00:00 2001 From: Alex Harrison Date: Wed, 8 Feb 2012 23:01:02 +0100 Subject: [PATCH] #2847 Users can now toggle nsfw on and off --- app/controllers/profiles_controller.rb | 1 + spec/controllers/profiles_controller_spec.rb | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb index 89a657a37..0a28324ee 100644 --- a/app/controllers/profiles_controller.rb +++ b/app/controllers/profiles_controller.rb @@ -27,6 +27,7 @@ class ProfilesController < ApplicationController munge_tag_string @profile_attrs[:searchable] ||= false + @profile_attrs[:nsfw] ||= false if params[:photo_id] @profile_attrs[:photo] = Photo.where(:author_id => current_user.person.id, :id => params[:photo_id]).first diff --git a/spec/controllers/profiles_controller_spec.rb b/spec/controllers/profiles_controller_spec.rb index f4b52657d..e0f7ce730 100644 --- a/spec/controllers/profiles_controller_spec.rb +++ b/spec/controllers/profiles_controller_spec.rb @@ -42,6 +42,21 @@ describe ProfilesController do flash[:notice].should_not be_blank end + it "sets nsfw" do + @user.person(true).profile.nsfw.should == false + put :update, :profile => { :id => @user.person.id, :nsfw => "1" } + @user.person(true).profile.nsfw.should == true + end + + it "unsets nsfw" do + @user.person.profile.nsfw = true + @user.person.profile.save + + @user.person(true).profile.nsfw.should == true + put :update, :profile => { :id => @user.person.id } + @user.person(true).profile.nsfw.should == false + end + it 'sets tags' do params = { :id => @user.person.id, :tags => '#apples #oranges'}