Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
164 changes: 82 additions & 82 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,65 +1,65 @@
GEM
remote: https://rubygems.org/
specs:
actioncable (5.1.4)
actionpack (= 5.1.4)
actioncable (5.1.6)
actionpack (= 5.1.6)
nio4r (~> 2.0)
websocket-driver (~> 0.6.1)
actionmailer (5.1.4)
actionpack (= 5.1.4)
actionview (= 5.1.4)
activejob (= 5.1.4)
actionmailer (5.1.6)
actionpack (= 5.1.6)
actionview (= 5.1.6)
activejob (= 5.1.6)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.1.4)
actionview (= 5.1.4)
activesupport (= 5.1.4)
actionpack (5.1.6)
actionview (= 5.1.6)
activesupport (= 5.1.6)
rack (~> 2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.1.4)
activesupport (= 5.1.4)
actionview (5.1.6)
activesupport (= 5.1.6)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.1.4)
activesupport (= 5.1.4)
activejob (5.1.6)
activesupport (= 5.1.6)
globalid (>= 0.3.6)
activemodel (5.1.4)
activesupport (= 5.1.4)
activerecord (5.1.4)
activemodel (= 5.1.4)
activesupport (= 5.1.4)
activemodel (5.1.6)
activesupport (= 5.1.6)
activerecord (5.1.6)
activemodel (= 5.1.6)
activesupport (= 5.1.6)
arel (~> 8.0)
activesupport (5.1.4)
activesupport (5.1.6)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
arel (8.0.0)
bcrypt (3.1.11)
bcrypt (3.1.11-java)
bcrypt (3.1.11-x64-mingw32)
bcrypt (3.1.11-x86-mingw32)
bcrypt (3.1.12)
bcrypt (3.1.12-java)
bcrypt (3.1.12-x64-mingw32)
bcrypt (3.1.12-x86-mingw32)
bindex (0.5.0)
builder (3.2.3)
byebug (10.0.0)
capybara (2.17.0)
byebug (10.0.2)
capybara (2.18.0)
addressable
mini_mime (>= 0.1.3)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (>= 2.0, < 4.0)
carrierwave (1.2.2)
carrierwave (1.2.3)
activemodel (>= 4.0.0)
activesupport (>= 4.0.0)
mime-types (>= 1.16)
childprocess (0.8.0)
childprocess (0.9.0)
ffi (~> 1.0, >= 1.0.11)
coffee-rails (4.2.2)
coffee-script (>= 2.2.0)
Expand All @@ -70,29 +70,29 @@ GEM
coffee-script-source (1.12.2)
concurrent-ruby (1.0.5)
concurrent-ruby (1.0.5-java)
crass (1.0.3)
devise (4.4.1)
crass (1.0.4)
devise (4.4.3)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0, < 5.2)
railties (>= 4.1.0, < 6.0)
responders
warden (~> 1.2.3)
diff-lcs (1.3)
erubi (1.7.0)
erubi (1.7.1)
execjs (2.7.0)
factory_bot (4.8.2)
factory_bot (4.10.0)
activesupport (>= 3.0.0)
factory_bot_rails (4.8.2)
factory_bot (~> 4.8.2)
factory_bot_rails (4.10.0)
factory_bot (~> 4.10.0)
railties (>= 3.0.0)
ffaker (2.8.1)
ffi (1.9.18)
ffi (1.9.18-java)
ffi (1.9.18-x64-mingw32)
ffi (1.9.18-x86-mingw32)
ffaker (2.10.0)
ffi (1.9.25)
ffi (1.9.25-java)
ffi (1.9.25-x64-mingw32)
ffi (1.9.25-x86-mingw32)
globalid (0.4.1)
activesupport (>= 4.2.0)
i18n (0.9.3)
i18n (1.0.1)
concurrent-ruby (~> 1.0)
jbuilder (2.7.0)
activesupport (>= 4.2.0)
Expand All @@ -101,7 +101,7 @@ GEM
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
loofah (2.1.1)
loofah (2.2.2)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.0)
Expand All @@ -114,33 +114,33 @@ GEM
mini_portile2 (2.3.0)
minitest (5.11.3)
multi_json (1.13.1)
nio4r (2.2.0)
nio4r (2.2.0-java)
nokogiri (1.8.1)
nio4r (2.3.1)
nio4r (2.3.1-java)
nokogiri (1.8.4)
mini_portile2 (~> 2.3.0)
nokogiri (1.8.1-java)
nokogiri (1.8.1-x64-mingw32)
nokogiri (1.8.4-java)
nokogiri (1.8.4-x64-mingw32)
mini_portile2 (~> 2.3.0)
nokogiri (1.8.1-x86-mingw32)
nokogiri (1.8.4-x86-mingw32)
mini_portile2 (~> 2.3.0)
orm_adapter (0.5.0)
public_suffix (3.0.1)
puma (3.11.2)
puma (3.11.2-java)
rack (2.0.3)
rack-test (0.8.2)
public_suffix (3.0.2)
puma (3.12.0)
puma (3.12.0-java)
rack (2.0.5)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (5.1.4)
actioncable (= 5.1.4)
actionmailer (= 5.1.4)
actionpack (= 5.1.4)
actionview (= 5.1.4)
activejob (= 5.1.4)
activemodel (= 5.1.4)
activerecord (= 5.1.4)
activesupport (= 5.1.4)
rails (5.1.6)
actioncable (= 5.1.6)
actionmailer (= 5.1.6)
actionpack (= 5.1.6)
actionview (= 5.1.6)
activejob (= 5.1.6)
activemodel (= 5.1.6)
activerecord (= 5.1.6)
activesupport (= 5.1.6)
bundler (>= 1.3.0)
railties (= 5.1.4)
railties (= 5.1.6)
sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.2)
actionpack (~> 5.x, >= 5.0.1)
Expand All @@ -149,16 +149,16 @@ GEM
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
railties (5.1.4)
actionpack (= 5.1.4)
activesupport (= 5.1.4)
rails-html-sanitizer (1.0.4)
loofah (~> 2.2, >= 2.2.2)
railties (5.1.6)
actionpack (= 5.1.6)
activesupport (= 5.1.6)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (12.3.0)
rb-fsevent (0.10.2)
rake (12.3.1)
rb-fsevent (0.10.3)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
responders (2.4.0)
Expand All @@ -180,10 +180,10 @@ GEM
rspec-expectations (~> 3.7.0)
rspec-mocks (~> 3.7.0)
rspec-support (~> 3.7.0)
rspec-support (3.7.0)
rspec-support (3.7.1)
ruby_dep (1.5.0)
rubyzip (1.2.1)
sass (3.5.5)
sass (3.5.7)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
Expand All @@ -194,17 +194,17 @@ GEM
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
selenium-webdriver (3.8.0)
selenium-webdriver (3.14.0)
childprocess (~> 0.5)
rubyzip (~> 1.0)
rubyzip (~> 1.2)
shoulda-matchers (3.1.2)
activesupport (>= 4.0.0)
spring (2.0.2)
activesupport (>= 4.2)
spring-watcher-listen (2.0.1)
listen (>= 2.7, < 4.0)
spring (>= 1.2, < 3.0)
sprockets (3.7.1)
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.1)
Expand All @@ -219,18 +219,18 @@ GEM
thread_safe (0.3.6)
thread_safe (0.3.6-java)
tilt (2.0.8)
turbolinks (5.1.0)
turbolinks (5.1.1)
turbolinks-source (~> 5.1)
turbolinks-source (5.1.0)
tzinfo (1.2.4)
tzinfo (1.2.5)
thread_safe (~> 0.1)
tzinfo-data (1.2018.3)
tzinfo-data (1.2018.5)
tzinfo (>= 1.0.0)
uglifier (4.1.4)
uglifier (4.1.17)
execjs (>= 0.3.0, < 3)
warden (1.2.7)
rack (>= 1.0)
web-console (3.5.1)
web-console (3.6.2)
actionview (>= 5.0)
activemodel (>= 5.0)
bindex (>= 0.4.0)
Expand All @@ -240,7 +240,7 @@ GEM
websocket-driver (0.6.5-java)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.3)
xpath (3.0.0)
xpath (3.1.0)
nokogiri (~> 1.8)

PLATFORMS
Expand Down Expand Up @@ -276,4 +276,4 @@ DEPENDENCIES
web-console (>= 3.3.0)

BUNDLED WITH
1.16.1
1.16.3
38 changes: 26 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,39 @@

# README

This README would normally document whatever steps are necessary to get the
application up and running.
## Fork
請 Fork 到你的 GitHub 目錄下,再從自己的目錄 `git clone`。

Things you may want to cover:
## How to initialize

* Ruby version
下載要用到的套件
```
$ bundle install
```
載入預設提供的資料表
```
$ rails db:migrate
```

* System dependencies
## 更新 Fork 的程式碼

* Configuration
由於是先 fork 再 clone,一般的 pull origin 只會拉到自己的 github repo
如果 AC 專案有更新,想要同步到最新專案程式碼的話,你需要先把 AC 專案位置加入遠端清單,再執行 pull
```
git remote add upstream git@github.com:ALPHACamp/simple-twitter.git
git pull upstream master
```

* Database creation

* Database initialization
## 自動化測試

* How to run the test suite
和自動化測試有關的程式碼,都存放在 **/spec** 的專案目錄下,所有的 Model 和 Controller 文件都會有一個對應的 spec 檔案,使用 `rails generate model` 或 `rails generate controller` 指令時會自動覆寫到現有的 spec 檔案。

* Services (job queues, cache servers, search engines, etc.)
因此,請你不要使用 `rails generate model` 或 `rails generate controller` 指令。

* Deployment instructions
相對的,在你下載的專案中,已經準備好對應的 Model 和 Controller 檔案。

* ...
如果想在本地執行自動化測試,可以輸入指令
```
$ bundle exec rspec
```
2 changes: 1 addition & 1 deletion spec/factories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

factory :user_with_tweets do
transient do
tweets_count 5
tweets_count 1
end

after(:create) do |user, evaluator|
Expand Down
10 changes: 6 additions & 4 deletions spec/requests/admin/tweets_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
RSpec.describe 'Admin::Tweet', type: :request do
let(:user) { create(:user, email: FFaker::Internet.email, name: 'no_tweets') }
let(:user_with_tweets) { create(:user_with_tweets) }
let(:admin_user) { create(:user, email: FFaker::Internet.email, name: 'no_tweets', role: 'admin')}
let(:admin_user) { create(:user, email: FFaker::Internet.email, name: 'no_tweets_admin', role: 'admin')}

context 'go to admin root page' do
describe 'if normal user log in' do
Expand All @@ -18,20 +18,22 @@
user_with_tweets
get admin_root_path
expect(response).to have_http_status 200
expect(assigns(:tweets)).to eq Tweet.all
expect(assigns(:tweets).count).to eq 1
end

it 'can delete other users tweet' do
user.tweets.create(description: '123', created_at: 1.days.ago)
sign_in(admin_user)
user_with_tweets
get admin_root_path
expect(assigns(:tweets).count).to eq 5
expect(assigns(:tweets).count).to eq 2
expect(assigns(:tweets).first.user_id).to eq user_with_tweets.id

delete '/admin/tweets/1'
expect(response).to redirect_to(admin_root_path)
follow_redirect!

expect(assigns(:tweets).count).to eq 4
expect(assigns(:tweets).count).to eq 1
expect(response).to render_template(:index)
end
end
Expand Down
Loading