Skip to content

GitLab Next

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
GitLab
GitLab
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 35,012
    • Issues 35,012
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 1,272
    • Merge Requests 1,272
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Metrics
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • GitLab.org
  • GitLabGitLab
  • Issues
  • #16260

Closed
Open
Opened Oct 25, 2016 by Adam Niedzielski@adamniedzielskiContributor

Deprecate usage of assigns and render_template in our controller tests

Description

Rails 5 removes assigns and assert_template from its core and we have to include rails-controller-testing gem to migrate to Rails 5 (gitlab-foss!5555 (closed)). The motivations provided in http://blog.bigbinary.com/2016/04/19/changes-to-test-controllers-in-rails-5.html are following: (copy-paste)

Reasons for removing assigns and assert_template

The idea behind the removal of these methods is that instance variables and which template is rendered in a controller action are internals of a controller, and controller tests should not care about them.

According to Rails team, controller tests should be more concerned about what is the result of that controller action like what cookies are set, or what HTTP code is set rather than testing of the internals of the controller. So, these methods are removed from the core.

Proposal

Deprecate assigns and render_template in our controller specs. Include a section in https://docs.gitlab.com/ce/development/testing.html that asks people not to use them in new tests.

Status as of %13.8

$ git grep assigns -- {,ee/}spec/controllers | wc -l
442
$ git grep render_template -- {,ee/}spec/controllers | wc -l
251

Links / references

http://blog.bigbinary.com/2016/04/19/changes-to-test-controllers-in-rails-5.html

/cc @stanhu @dzaporozhets

Edited Jan 06, 2021 by Takuya Noguchi
Assignee
Assign to
Next 3-4 releases
Milestone
Next 3-4 releases
Assign milestone
Time tracking
None
Due date
None
Reference: gitlab-org/gitlab#16260