Merge pull request #787 from opf/fix/rewrite_my_controller_test_to_spec

Rewrote a test to a spec so it can be disabled by the profile_surveys
pull/799/head
meeee 11 years ago
commit 97f86d3f5d
  1. 8
      features/users/user_settings.feature
  2. 38
      spec/controllers/my_controller_spec.rb
  3. 9
      test/functional/my_controller_test.rb

@ -23,16 +23,16 @@ Feature: Update User Information
@javascript
Scenario: A user is able to change his mail address if the settings permit it
Given I am admin
And I go to the my account page
And I go to the my account page
And I fill in "user_mail" with "john@doe.com"
And I click on "Save"
And I submit the form by the "Save" button
Then I should see "Account was successfully updated."
@javascript
Scenario: A user is able to change his name if the settings permit it
Given I am admin
And I go to the my account page
And I go to the my account page
And I fill in "user_firstname" with "Jon"
And I fill in "user_lastname" with "Doe"
And I click on "Save"
And I submit the form by the "Save" button
Then I should see "Account was successfully updated."

@ -29,11 +29,12 @@
require 'spec_helper'
describe MyController, :type => :controller do
let(:user) { FactoryGirl.create(:user) }
before(:each) do
User.stub(:current).and_return(user)
end
describe 'password change' do
let(:user) { FactoryGirl.create(:user) }
before(:each) do
User.stub(:current).and_return(user)
end
describe :password do
before do
@ -96,4 +97,33 @@ describe MyController, :type => :controller do
end
end
end
describe "account" do
let(:custom_field) { FactoryGirl.create :text_user_custom_field }
before do
custom_field
as_logged_in_user user do
get :account
end
end
it "responds with success" do
expect(response).to be_success
end
it "renders the account template" do
expect(response).to render_template 'account'
end
it "assigns @user" do
expect(assigns(:user)).to eq(user)
end
context "with render_views" do
render_views
it "renders editable custom fields" do
expect(response.body).to have_content(custom_field.name)
end
end
end
end

@ -55,15 +55,6 @@ class MyControllerTest < ActionController::TestCase
assert_template 'page'
end
def test_my_account_should_show_editable_custom_fields
get :account
assert_response :success
assert_template 'account'
assert_equal User.find(2), assigns(:user)
assert_tag :input, :attributes => { :name => 'user[custom_field_values][4]'}
end
def test_my_account_should_not_show_non_editable_custom_fields
UserCustomField.find(4).update_attribute :editable, false

Loading…
Cancel
Save