Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
AO3-4862 Extending work controller test coverage #3165
Conversation
hatal175
added some commits
Nov 13, 2017
| @@ -3,7 +3,7 @@ | ||
| class WorksController < ApplicationController | ||
| # only registered users and NOT admin should be able to create new works | ||
| before_action :load_collection | ||
| - before_action :load_owner, only: [:index] | ||
| + before_action :load_owner, only: [:index, :show_multiple] |
| @@ -298,7 +298,7 @@ def create | ||
| @work.ip_address = request.remote_ip | ||
| # If Edit or Cancel is pressed, bail out and display relevant form | ||
| if params[:edit_button] | ||
| - render :new && return | ||
| + render :new and return |
| @@ -693,8 +687,8 @@ def post_draft | ||
| def show_multiple | ||
| @user = current_user | ||
| - if params[:pseud_id] | ||
| - @works = Work.joins(:pseuds).where(pseud_id: params[:pseud_id]) | ||
| + if @pseud |
| @@ -1011,21 +992,13 @@ def log_admin_activity | ||
| # what potential values `saved` has as used elsewhere (which is what is | ||
| # passed as `condition`) and thus the usual approach of condition=nil | ||
| # followed by a ||= cannot be reliably used. -@duckinator | ||
| - def preview_mode(page_name, condition = (@work.has_required_tags? && @work.invalid_tags.blank?)) | ||
| + def preview_mode(page_name, condition = (@work.invalid_tags.blank?)) |
houndci-bot
Nov 17, 2017
Unused method argument - page_name. If it's necessary, use _ or _page_name as an argument name to indicate that it won't be used.
Don't use parentheses around a method call.
| @@ -174,6 +174,42 @@ def call_with_params(params) | ||
| end | ||
| end | ||
| + describe "edit" do | ||
| + let(:user) { create(:user) } | ||
| + let(:work) { |
| + | ||
| + context "destroy" do | ||
| + let(:user) { create(:user) } | ||
| + let!(:work) { |
| - let(:update_work) { | ||
| + let!(:update_user) { create(:user) } | ||
| + let!(:update_chapter) { create(:chapter) } | ||
| + let!(:update_work) { |
| + end | ||
| + | ||
| + it "should show results" do | ||
| + get :collected, params: { user_id: collected_user.login, work_search: { query: "fandom_ids:#{collected_fandom.id}" }} |
| + it "should throw error when there are invalid tags and trying to preview" do | ||
| + allow_any_instance_of(Work).to receive(:invalid_tags).and_return([create(:unsorted_tag)]) | ||
| + | ||
| + expect {patch :update_tags, params: { id: work, preview_button: true } }.to raise_error UncaughtThrowError |
| @@ -134,6 +134,28 @@ | ||
| end | ||
| end | ||
| + context 'when work parameters are invalid' do | ||
| + let(:work_params) { |
| + context 'when work parameters are invalid' do | ||
| + let(:work_params) { | ||
| + { | ||
| + work: { |
houndci-bot
Nov 17, 2017
Use 2 spaces for indentation in a hash, relative to the start of the line where the left curly brace is.
| + let(:work_params) { | ||
| + { | ||
| + work: { | ||
| + summary: "a" * (ArchiveConfig.SUMMARY_MAX + 1), |
houndci-bot
Nov 17, 2017
Use 2 spaces for indentation in a hash, relative to the start of the line where the left curly brace is.
sarken
added
the
Awaiting review
label
Nov 17, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hatal175 commentedNov 17, 2017
Issue
https://otwarchive.atlassian.net/browse/AO3-4862
Purpose
This PR extends the test coverage for works controller.
I've also made a few changes for this purpose and I would really appreciate a review on them:
Testing
Run tests and see coverage improvement.
Credit
Tal Hayon
Please use he.