質問編集履歴
2
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -76,8 +76,8 @@
|
|
76
76
|
{
|
77
77
|
id: recruit.id,
|
78
78
|
title: recruit.title,
|
79
|
-
e_st:
|
79
|
+
e_st: entry.present? ? entry.pluck(:status).first : "test",
|
80
|
-
r_st:
|
80
|
+
r_st: entry.present? && entry.pluck(:result) ? entry.pluck(:result).first : "pending",
|
81
81
|
}
|
82
82
|
end
|
83
83
|
end
|
1
補足
title
CHANGED
File without changes
|
body
CHANGED
@@ -83,6 +83,52 @@
|
|
83
83
|
end
|
84
84
|
|
85
85
|
```
|
86
|
+
|
87
|
+
spec
|
88
|
+
```ruby
|
89
|
+
require 'rails_helper'
|
90
|
+
|
91
|
+
RSpec.describe "User::Offer", type: :request do
|
92
|
+
describe "GET /user_offer" do
|
93
|
+
let!(:user) {create(:user)}
|
94
|
+
let!(:offer) { create(:offer_b) }
|
95
|
+
let!(:recruits) do
|
96
|
+
FactoryBot.create_list(:recruit, 3)
|
97
|
+
end
|
98
|
+
let!(:entry) {create(:entry)}
|
99
|
+
let(:res) { JSON.parse(response.body).deep_symbolize_keys }
|
100
|
+
context "正常系" do
|
101
|
+
it "詳細が有効" do
|
102
|
+
get '/api/user/offers/2'
|
103
|
+
pp JSON.parse(response.body)
|
104
|
+
expect(res).to eq(
|
105
|
+
{
|
106
|
+
:work => {
|
107
|
+
id: offer.id,
|
108
|
+
offer_name: "offer_name"
|
109
|
+
},
|
110
|
+
:recruits =>[
|
111
|
+
{
|
112
|
+
id: 1,
|
113
|
+
title: "title",
|
114
|
+
entry_status: "pending",
|
115
|
+
result_status: "pending"
|
116
|
+
},
|
117
|
+
{
|
118
|
+
id: 2,
|
119
|
+
title: "title",
|
120
|
+
e_st: "pending",
|
121
|
+
r_st: "pending"
|
122
|
+
}
|
123
|
+
],
|
124
|
+
errors: []
|
125
|
+
}
|
126
|
+
)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
```
|
86
132
|
こちらのdef recruit_as_json recruit, is_loginの中のe_st: recruit.entries.status,の書き方が悪いのだと思うのですが、どう直したらいいのかわからず困っています。
|
87
133
|
少しでもアドバイスなどいただければ助かります。
|
88
134
|
|