LoginSignup
0

More than 5 years have passed since last update.

Rails Tutorial 第11章 問題発生からの解決の流れ11/8

Last updated at Posted at 2017-11-08

tutorial11章11.4まで完了したときに問題発生

1、テストでエラー

一つだけエラーがでる。
というのもassert_select div.paginateがみつからないという


yuyakuroiwa:~/workspace/sample_app (master) $ rails test
Running via Spring preloader in process 5513
Started with run options --seed 48155

 FAIL["test_index_as_admin_including_pagination_and_delete_links", UsersIndexTest, 1.5051524639129639]
 test_index_as_admin_including_pagination_and_delete_links#UsersIndexTest (1.51s)
        Expected at least 1 element matching "div.pagination", found 0..
        Expected 0 to be >= 1.
        test/integration/users_index_test.rb:14:in `block in <class:UsersIndexTest>'

  43/43: [================================] 100% Time: 00:00:02, Time: 00:00:02

Finished in 2.50721s
43 tests, 123 assertions, 1 failures, 0 errors, 0 skips

11.3.4の演習前まではgreenだったのになぜか。
git resetで11.3.3終了地点まで戻って再度同じ作業を繰り返していくと

演習問題のindexアクションをいじる項目後にエラー発生していることが判明


  def index
     @users = User.where(activated: true).paginate(page: params[:page])

  end

色々試したが理由がわからないので放置して最後まで進めてherokuにデプロイする為に

yuyakuroiwa:~/workspace/sample_app (master) $ git status
On branch master
Your branch is behind 'origin/master' by 2 commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   app/controllers/users_controller.rb
        modified:   app/models/user.rb
        modified:   config/environments/production.rb
        modified:   test/integration/users_signup_test.rb

no changes added to commit (use "git add" and/or "git commit -a")

ここで「branchが2つ動いてるよ」警告(resetでもどったため??)を見逃す。
そのままpushしようとすると

yuyakuroiwa:~/workspace/sample_app (master) $ git push heroku
To https://git.heroku.com/fathomless-wildwood-59704.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://git.heroku.com/fathomless-wildwood-59704.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
yuyakuroiwa:~/workspace/sample_app (master) $ git pull
Warning: Permanently added 'bitbucket.org,104.192.143.3' (RSA) to the list of known hosts.
Auto-merging test/integration/users_signup_test.rb
CONFLICT (content): Merge conflict in test/integration/users_signup_test.rb
Auto-merging app/models/user.rb
CONFLICT (content): Merge conflict in app/models/user.rb
Auto-merging app/controllers/users_controller.rb
CONFLICT (content): Merge conflict in app/controllers/users_controller.rb
Automatic merge failed; fix conflicts and then commit the result.
yuyakuroiwa:~/workspace/sample_app (master|MERGING) $ git commit -m "Add account activation(11.4) -2"
U       app/controllers/users_controller.rb
U       app/models/user.rb
U       test/integration/users_signup_test.rb
error: Committing is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.
yuyakuroiwa:~/workspace/sample_app (master|MERGING) $ git branch
  account-activation
  advanced-login
  basic-login
  filling-in-layout
* master
  modeling-users
  ruby
  sign-up
  static-page
  updating-users
yuyakuroiwa:~/workspace/sample_app (master|MERGING) $ git merge account-activation
error: Merging is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.
yuyakuroiwa:~/workspace/sample_app (master|MERGING) $ git checkout account-activation
app/controllers/users_controller.rb: needs merge
app/models/user.rb: needs merge
test/integration/users_signup_test.rb: needs merge
error: you need to resolve your current index first
yuyakuroiwa:~/workspace/sample_app (master|MERGING) $ git merge
error: Merging is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.
yuyakuroiwa:~/workspace/sample_app (master|MERGING) $ git pull
error: Pulling is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.

yuyakuroiwa:~/workspace/sample_app (master|MERGING) $ git branch
  account-activation
  advanced-login
  basic-login
  filling-in-layout
* master
  modeling-users
  ruby
  sign-up
  static-page
  updating-users
yuyakuroiwa:~/workspace/sample_app (master|MERGING) $ git status
On branch master
Your branch and 'origin/master' have diverged,
and have 2 and 2 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)

You have unmerged paths.
  (fix conflicts and run "git commit")
  (use "git merge --abort" to abort the merge)

Changes to be committed:

        modified:   app/controllers/account_activations_controller.rb
        modified:   app/views/users/index.html.erb
        modified:   test/integration/users_index_test.rb

Unmerged paths:
  (use "git add <file>..." to mark resolution)

        both modified:   app/controllers/users_controller.rb
        both modified:   app/models/user.rb
        both modified:   test/integration/users_signup_test.rb

yuyakuroiwa:~/workspace/sample_app (master|MERGING) $ git add .
yuyakuroiwa:~/workspace/sample_app (master|MERGING) $ git commit -a -m "Merge conflict"
[master 5ca01df] Merge conflict
yuyakuroiwa:~/workspace/sample_app (master) $ git status
On branch master
Your branch is ahead of 'origin/master' by 3 commits.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean

なんだかよくわからないまま、ダブったファイルがコンソールに示されたので見に行くとそれらが一つにまとまってでてきて、指示されるがままダブってる部分を削除、保存をおこなって、https://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q13172034403
上のアンサーのいうようにコンフリクトを解消。その後コミットして事なきを得たけど

・いつなんでコンフリクトがおきたのか
・結局なんで解決したのか

などまったくなにがおきたのか分からない。

あげくのはてに本番環境では新規登録後エラーが発生し、redだったテストはなにも直接さわっていないのにgreenになる

yuyakuroiwa:~/workspace/sample_app (master) $ rails test
Running via Spring preloader in process 6244
Started with run options --seed 8550

  43/43: [================================] 100% Time: 00:00:02, Time: 00:00:02

Finished in 2.27552s
43 tests, 123 assertions, 0 failures, 0 errors, 0 skips

2、本番環境のエラー

・開発環境では問題無くサーバーログに認可アドレスが表示されるので、herokuアドオンの設定がうまくいってない?
・エラー画面を更新するとメールアドレスがすでに使われているというエラーメッセージと一緒にsignup画面が再描画されるのでcreateアクションのデータベースに保存までのプロセスは行われている?

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0